4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "appearanceprefs.h"
23 #include "deleteallindexes.h"
25 #include "edlsession.h"
27 #include "filesystem.h"
30 #include "preferences.h"
31 #include "preferencesthread.h"
32 #include "shbtnprefs.h"
36 AppearancePrefs::AppearancePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
37 : PreferencesDialog(mwindow, pwindow)
49 AppearancePrefs::~AppearancePrefs()
58 delete thumbnail_size;
62 void AppearancePrefs::create_objects()
64 BC_Resources *resources = BC_WindowBase::get_resources();
65 int margin = mwindow->theme->widget_border;
66 char string[BCTEXTLEN];
67 int x0 = mwindow->theme->preferencesoptions_x;
68 int y0 = mwindow->theme->preferencesoptions_y;
69 int x = x0, y = y0, x1 = x + 100;
71 add_subwindow(new BC_Title(x, y, _("Layout:"), LARGEFONT,
72 resources->text_default));
77 add_subwindow(new BC_Title(x, y, _("Theme:")));
78 add_subwindow(theme = new ViewTheme(x1, y, pwindow));
79 theme->create_objects();
80 y += theme->get_h() + 5;
83 ViewPluginIcons *plugin_icons;
84 add_subwindow(new BC_Title(x, y, _("Plugin Icons:")));
85 add_subwindow(plugin_icons = new ViewPluginIcons(x1, y, pwindow));
86 plugin_icons->create_objects();
87 y += plugin_icons->get_h() + 15;
90 int x2 = x1 + 160, y2 = y;
92 add_subwindow(new BC_Title(x1, y, _("View thumbnail size:")));
93 thumbnail_size = new ViewThumbnailSize(pwindow, this, x2, y);
94 thumbnail_size->create_objects();
95 y += thumbnail_size->get_h() + 5;
96 add_subwindow(new BC_Title(x1, y, _("Vicon memory size:")));
97 vicon_size = new ViewViconSize(pwindow, this, x2, y);
98 vicon_size->create_objects();
99 y += vicon_size->get_h() + 5;
100 add_subwindow(new BC_Title(x1, y, _("Vicon color mode:")));
101 add_subwindow(vicon_color_mode = new ViewViconColorMode(pwindow, x2, y));
102 vicon_color_mode->create_objects();
103 y += vicon_color_mode->get_h() + 5;
107 add_subwindow(new BC_Bar(5, y, get_w() - 10));
110 add_subwindow(new BC_Title(x, y, _("Time Format:"), LARGEFONT,
111 resources->text_default));
113 add_subwindow(new BC_Title(x1, y, _("Flags:"), LARGEFONT,
114 resources->text_default));
116 y += get_text_height(LARGEFONT) + 5;
120 add_subwindow(hms = new TimeFormatHMS(pwindow, this,
121 pwindow->thread->edl->session->time_format == TIME_HMS,
124 add_subwindow(hmsf = new TimeFormatHMSF(pwindow, this,
125 pwindow->thread->edl->session->time_format == TIME_HMSF,
128 add_subwindow(samples = new TimeFormatSamples(pwindow, this,
129 pwindow->thread->edl->session->time_format == TIME_SAMPLES,
132 add_subwindow(hex = new TimeFormatHex(pwindow, this,
133 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX,
136 add_subwindow(frames = new TimeFormatFrames(pwindow, this,
137 pwindow->thread->edl->session->time_format == TIME_FRAMES,
140 add_subwindow(feet = new TimeFormatFeet(pwindow, this,
141 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES,
143 x += feet->get_w() + 15;
145 add_subwindow(title = new BC_Title(x, y, _("Frames per foot:")));
146 x += title->get_w() + margin;
147 sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
148 add_subwindow(new TimeFormatFeetSetting(pwindow,
152 add_subwindow(seconds = new TimeFormatSeconds(pwindow, this,
153 pwindow->thread->edl->session->time_format == TIME_SECONDS,
157 add_subwindow(new BC_Bar(5, y, get_w()/2 - 30));
160 add_subwindow(new BC_Title(x, y, _("Color:"), LARGEFONT,
161 resources->text_default));
163 add_subwindow(title = new BC_Title(x, y, _("Highlighting Inversion color:")));
164 x += title->get_w() + margin;
165 char hex_color[BCSTRLEN];
166 sprintf(hex_color, "%06x", preferences->highlight_inverse);
167 add_subwindow(new HighlightInverseColor(pwindow, x, y, hex_color));
171 add_subwindow(title = new BC_Title(x, y, _("YUV color space:")));
172 x += title->get_w() + margin;
173 add_subwindow(yuv_color_space = new YuvColorSpace(x, y, pwindow));
174 yuv_color_space->create_objects();
175 y += yuv_color_space->get_h() + 5;
178 add_subwindow(title = new BC_Title(x, y, _("YUV color range:")));
179 x += title->get_w() + margin;
180 add_subwindow(yuv_color_range = new YuvColorRange(x, y, pwindow));
181 yuv_color_range->create_objects();
182 y += yuv_color_range->get_h() + 5;
184 UseTipWindow *tip_win = new UseTipWindow(pwindow, x1, y1);
185 add_subwindow(tip_win);
186 y1 += tip_win->get_h() + 5;
187 AutocolorAssets *autocolor_assets = new AutocolorAssets(pwindow, x1, y1);
188 add_subwindow(autocolor_assets);
189 y1 += autocolor_assets->get_h() + 5;
190 UseWarnIndecies *idx_win = new UseWarnIndecies(pwindow, x1, y1);
191 add_subwindow(idx_win);
192 y1 += idx_win->get_h() + 5;
193 UseWarnVersion *ver_win = new UseWarnVersion(pwindow, x1, y1);
194 add_subwindow(ver_win);
195 y1 += ver_win->get_h() + 5;
196 BD_WarnRoot *bdwr_win = new BD_WarnRoot(pwindow, x1, y1);
197 add_subwindow(bdwr_win);
198 y1 += bdwr_win->get_h() + 5;
199 PopupMenuBtnup *pop_win = new PopupMenuBtnup(pwindow, x1, y1);
200 add_subwindow(pop_win);
201 y1 += pop_win->get_h() + 5;
202 GrabFocusPolicy *grab_input_focus = new GrabFocusPolicy(pwindow, x1, y1);
203 add_subwindow(grab_input_focus);
204 y1 += grab_input_focus->get_h() + 5;
205 ActivateFocusPolicy *focus_activate = new ActivateFocusPolicy(pwindow, x1, y1);
206 add_subwindow(focus_activate);
207 y1 += focus_activate->get_h() + 5;
208 DeactivateFocusPolicy *focus_deactivate = new DeactivateFocusPolicy(pwindow, x1, y1);
209 add_subwindow(focus_deactivate);
210 y1 += focus_deactivate->get_h() + 5;
211 ForwardRenderDisplacement *displacement = new ForwardRenderDisplacement(pwindow, x1, y1);
212 add_subwindow(displacement);
213 y1 += displacement->get_h() + 5;
214 add_subwindow(thumbnails = new ViewThumbnails(x1, y1, pwindow));
215 y1 += thumbnails->get_h() + 5;
216 PerpetualSession *perpetual = new PerpetualSession(x1, y1, pwindow);
217 add_subwindow(perpetual);
218 y1 += perpetual->get_h() + 5;
222 int AppearancePrefs::update(int new_value)
224 pwindow->thread->redraw_times = 1;
225 pwindow->thread->edl->session->time_format = new_value;
226 hms->update(new_value == TIME_HMS);
227 hmsf->update(new_value == TIME_HMSF);
228 samples->update(new_value == TIME_SAMPLES);
229 hex->update(new_value == TIME_SAMPLES_HEX);
230 frames->update(new_value == TIME_FRAMES);
231 feet->update(new_value == TIME_FEET_FRAMES);
232 seconds->update(new_value == TIME_SECONDS);
237 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
238 : BC_Radial(x, y, value, TIME_HMS_TEXT)
239 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
241 int TimeFormatHMS::handle_event()
243 tfwindow->update(TIME_HMS);
247 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
248 : BC_Radial(x, y, value, TIME_HMSF_TEXT)
249 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
251 int TimeFormatHMSF::handle_event()
253 tfwindow->update(TIME_HMSF);
257 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
258 : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
259 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
261 int TimeFormatSamples::handle_event()
263 tfwindow->update(TIME_SAMPLES);
267 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
268 : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
269 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
271 int TimeFormatFrames::handle_event()
273 tfwindow->update(TIME_FRAMES);
277 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
278 : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
279 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
281 int TimeFormatHex::handle_event()
283 tfwindow->update(TIME_SAMPLES_HEX);
287 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
288 : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
290 this->pwindow = pwindow;
291 this->tfwindow = tfwindow;
294 int TimeFormatSeconds::handle_event()
296 tfwindow->update(TIME_SECONDS);
300 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
301 : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
302 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
304 int TimeFormatFeet::handle_event()
306 tfwindow->update(TIME_FEET_FRAMES);
310 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
311 : BC_TextBox(x, y, 90, 1, string)
312 { this->pwindow = pwindow; }
314 int TimeFormatFeetSetting::handle_event()
316 pwindow->thread->edl->session->frames_per_foot = atof(get_text());
317 if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
322 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
323 : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
325 this->pwindow = pwindow;
327 ViewTheme::~ViewTheme()
331 void ViewTheme::create_objects()
333 ArrayList<PluginServer*> themes;
334 MWindow::search_plugindb(0, 0, 0, 0, 1, themes);
336 for(int i = 0; i < themes.total; i++) {
337 add_item(new ViewThemeItem(this, themes.values[i]->title));
341 int ViewTheme::handle_event()
346 ViewThemeItem::ViewThemeItem(ViewTheme *popup, const char *text)
352 int ViewThemeItem::handle_event()
354 popup->set_text(get_text());
355 strcpy(popup->pwindow->thread->preferences->theme, get_text());
356 popup->handle_event();
361 ViewPluginIcons::ViewPluginIcons(int x, int y, PreferencesWindow *pwindow)
362 : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->plugin_icons, 1)
364 this->pwindow = pwindow;
366 ViewPluginIcons::~ViewPluginIcons()
370 void ViewPluginIcons::create_objects()
372 add_item(new ViewPluginIconItem(this, DEFAULT_PICON));
374 const char *plugin_path = File::get_plugin_path();
375 char picon_path[BCTEXTLEN];
376 snprintf(picon_path,sizeof(picon_path)-1,"%s/picon", plugin_path);
377 if( fs.update(picon_path) ) return;
378 for( int i=0; i<fs.dir_list.total; ++i ) {
379 char *fs_path = fs.dir_list[i]->path;
380 if( !fs.is_dir(fs_path) ) continue;
381 char *cp = strrchr(fs_path,'/');
382 cp = !cp ? fs_path : cp+1;
383 if( !strcmp(cp,DEFAULT_PICON) ) continue;
384 add_item(new ViewPluginIconItem(this, cp));
388 int ViewPluginIcons::handle_event()
393 ViewPluginIconItem::ViewPluginIconItem(ViewPluginIcons *popup, const char *text)
399 int ViewPluginIconItem::handle_event()
401 popup->set_text(get_text());
402 strcpy(popup->pwindow->thread->preferences->plugin_icons, get_text());
403 popup->handle_event();
408 ViewThumbnails::ViewThumbnails(int x,
410 PreferencesWindow *pwindow)
413 pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
415 this->pwindow = pwindow;
418 int ViewThumbnails::handle_event()
420 pwindow->thread->preferences->use_thumbnails = get_value();
425 ViewThumbnailSize::ViewThumbnailSize(PreferencesWindow *pwindow,
426 AppearancePrefs *aprefs, int x, int y)
427 : BC_TumbleTextBox(aprefs,
428 pwindow->thread->preferences->awindow_picon_h,
432 this->pwindow = pwindow;
433 this->aprefs = aprefs;
436 int ViewThumbnailSize::handle_event()
438 int v = atoi(get_text());
440 pwindow->thread->preferences->awindow_picon_h = v;
444 ViewViconSize::ViewViconSize(PreferencesWindow *pwindow,
445 AppearancePrefs *aprefs, int x, int y)
446 : BC_TumbleTextBox(aprefs,
447 pwindow->thread->preferences->vicon_size,
451 this->pwindow = pwindow;
452 this->aprefs = aprefs;
455 int ViewViconSize::handle_event()
457 int v = atoi(get_text());
459 pwindow->thread->preferences->vicon_size = v;
463 ViewViconColorMode::ViewViconColorMode(PreferencesWindow *pwindow, int x, int y)
464 : BC_PopupMenu(x, y, 100,
465 _(vicon_color_modes[pwindow->thread->preferences->vicon_color_mode]), 1)
467 this->pwindow = pwindow;
469 ViewViconColorMode::~ViewViconColorMode()
473 const char *ViewViconColorMode::vicon_color_modes[] = {
479 void ViewViconColorMode::create_objects()
481 for( int id=0,nid=sizeof(vicon_color_modes)/sizeof(vicon_color_modes[0]); id<nid; ++id )
482 add_item(new ViewViconColorModeItem(this, _(vicon_color_modes[id]), id));
486 int ViewViconColorMode::handle_event()
488 set_text(_(vicon_color_modes[pwindow->thread->preferences->vicon_color_mode]));
492 ViewViconColorModeItem::ViewViconColorModeItem(ViewViconColorMode *popup, const char *text, int id)
499 int ViewViconColorModeItem::handle_event()
501 popup->set_text(get_text());
502 popup->pwindow->thread->preferences->vicon_color_mode = id;
503 return popup->handle_event();
507 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
510 pwindow->thread->preferences->use_tipwindow,
511 _("Show tip of the day"))
513 this->pwindow = pwindow;
515 int UseTipWindow::handle_event()
517 pwindow->thread->preferences->use_tipwindow = get_value();
522 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
523 : BC_CheckBox(x, y, pwindow->thread->preferences->warn_indexes,
524 _("ffmpeg probe warns rebuild indexes"))
526 this->pwindow = pwindow;
529 int UseWarnIndecies::handle_event()
531 pwindow->thread->preferences->warn_indexes = get_value();
535 UseWarnVersion::UseWarnVersion(PreferencesWindow *pwindow, int x, int y)
536 : BC_CheckBox(x, y, pwindow->thread->preferences->warn_version,
537 _("EDL version warns if mismatched"))
539 this->pwindow = pwindow;
542 int UseWarnVersion::handle_event()
544 pwindow->thread->preferences->warn_version = get_value();
548 BD_WarnRoot::BD_WarnRoot(PreferencesWindow *pwindow, int x, int y)
549 : BC_CheckBox(x, y, pwindow->thread->preferences->bd_warn_root,
550 _("Create Bluray warns if not root"))
552 this->pwindow = pwindow;
555 int BD_WarnRoot::handle_event()
557 pwindow->thread->preferences->bd_warn_root = get_value();
561 PopupMenuBtnup::PopupMenuBtnup(PreferencesWindow *pwindow, int x, int y)
562 : BC_CheckBox(x, y, pwindow->thread->preferences->popupmenu_btnup,
563 _("Popups activate on button up"))
565 this->pwindow = pwindow;
568 int PopupMenuBtnup::handle_event()
570 pwindow->thread->preferences->popupmenu_btnup = get_value();
574 GrabFocusPolicy::GrabFocusPolicy(PreferencesWindow *pwindow, int x, int y)
575 : BC_CheckBox(x, y, (pwindow->thread->preferences->grab_input_focus) != 0,
576 _("Set Input Focus when window entered"))
578 this->pwindow = pwindow;
581 int GrabFocusPolicy::handle_event()
583 pwindow->thread->preferences->grab_input_focus = get_value();
587 ActivateFocusPolicy::ActivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
588 : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_ACTIVATE) != 0,
589 _("Click to activate text focus"))
591 this->pwindow = pwindow;
594 int ActivateFocusPolicy::handle_event()
597 pwindow->thread->preferences->textbox_focus_policy |= CLICK_ACTIVATE;
599 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_ACTIVATE;
603 DeactivateFocusPolicy::DeactivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
604 : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_DEACTIVATE) != 0,
605 _("Click to deactivate text focus"))
607 this->pwindow = pwindow;
610 int DeactivateFocusPolicy::handle_event()
613 pwindow->thread->preferences->textbox_focus_policy |= CLICK_DEACTIVATE;
615 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_DEACTIVATE;
619 ForwardRenderDisplacement::ForwardRenderDisplacement(PreferencesWindow *pwindow, int x, int y)
620 : BC_CheckBox(x, y, pwindow->thread->preferences->forward_render_displacement,
621 _("Always show next frame"))
623 this->pwindow = pwindow;
626 int ForwardRenderDisplacement::handle_event()
628 pwindow->thread->preferences->forward_render_displacement = get_value();
632 AutocolorAssets::AutocolorAssets(PreferencesWindow *pwindow, int x, int y)
633 : BC_CheckBox(x, y, pwindow->thread->preferences->autocolor_assets,
634 _("Autocolor assets"))
636 this->pwindow = pwindow;
639 int AutocolorAssets::handle_event()
641 pwindow->thread->preferences->autocolor_assets = get_value();
645 HighlightInverseColor::HighlightInverseColor(PreferencesWindow *pwindow, int x, int y, const char *hex)
646 : BC_TextBox(x, y, 80, 1, hex)
648 this->pwindow = pwindow;
651 int HighlightInverseColor::handle_event()
653 int inverse_color = strtoul(get_text(),0,16);
654 if( (inverse_color &= 0xffffff) == 0 ) {
655 inverse_color = 0xffffff;
656 char string[BCSTRLEN];
657 sprintf(string,"%06x", inverse_color);
660 pwindow->thread->preferences->highlight_inverse = inverse_color;
665 const char *YuvColorSpace::color_space[] = {
671 YuvColorSpace::YuvColorSpace(int x, int y, PreferencesWindow *pwindow)
672 : BC_PopupMenu(x, y, 100,
673 _(color_space[pwindow->thread->preferences->yuv_color_space]), 1)
675 this->pwindow = pwindow;
677 YuvColorSpace::~YuvColorSpace()
681 void YuvColorSpace::create_objects()
683 for( int id=0,nid=sizeof(color_space)/sizeof(color_space[0]); id<nid; ++id )
684 add_item(new YuvColorSpaceItem(this, _(color_space[id]), id));
688 int YuvColorSpace::handle_event()
690 set_text(_(color_space[pwindow->thread->preferences->yuv_color_space]));
694 YuvColorSpaceItem::YuvColorSpaceItem(YuvColorSpace *popup, const char *text, int id)
701 int YuvColorSpaceItem::handle_event()
703 popup->set_text(get_text());
704 popup->pwindow->thread->preferences->yuv_color_space = id;
705 return popup->handle_event();
709 const char *YuvColorRange::color_range[] = {
714 YuvColorRange::YuvColorRange(int x, int y, PreferencesWindow *pwindow)
715 : BC_PopupMenu(x, y, 100,
716 _(color_range[pwindow->thread->preferences->yuv_color_range]), 1)
718 this->pwindow = pwindow;
720 YuvColorRange::~YuvColorRange()
724 void YuvColorRange::create_objects()
726 for( int id=0,nid=sizeof(color_range)/sizeof(color_range[0]); id<nid; ++id )
727 add_item(new YuvColorRangeItem(this, _(color_range[id]), id));
731 int YuvColorRange::handle_event()
733 set_text(color_range[pwindow->thread->preferences->yuv_color_range]);
737 YuvColorRangeItem::YuvColorRangeItem(YuvColorRange *popup, const char *text, int id)
744 int YuvColorRangeItem::handle_event()
746 popup->set_text(get_text());
747 popup->pwindow->thread->preferences->yuv_color_range = id;
748 return popup->handle_event();
751 PerpetualSession::PerpetualSession(int x, int y, PreferencesWindow *pwindow)
753 pwindow->thread->preferences->perpetual_session, _("Perpetual session"))
755 this->pwindow = pwindow;
758 int PerpetualSession::handle_event()
760 pwindow->thread->preferences->perpetual_session = get_value();