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, x2 = x + 160;
71 add_subwindow(new BC_Title(x, y, _("Layout:"), LARGEFONT,
72 resources->text_default));
76 add_subwindow(new BC_Title(x, y, _("Theme:")));
77 add_subwindow(theme = new ViewTheme(x1, y, pwindow));
78 theme->create_objects();
79 y += theme->get_h() + 5;
82 ViewPluginIcons *plugin_icons;
83 add_subwindow(new BC_Title(x, y, _("Plugin Icons:")));
84 add_subwindow(plugin_icons = new ViewPluginIcons(x1, y, pwindow));
85 plugin_icons->create_objects();
86 y += plugin_icons->get_h() + 15;
88 add_subwindow(new BC_Title(x, y, _("View Thumbnail size:")));
89 thumbnail_size = new ViewThumbnailSize(pwindow, this, x2, y);
90 thumbnail_size->create_objects();
91 y += thumbnail_size->get_h() + 5;
94 add_subwindow(new BC_Bar(5, y, get_w() - 10));
97 add_subwindow(new BC_Title(x, y, _("Time Format:"), LARGEFONT,
98 resources->text_default));
101 add_subwindow(new BC_Title(x1, y, _("Flags:"), LARGEFONT,
102 resources->text_default));
104 y += get_text_height(LARGEFONT) + 5;
108 add_subwindow(hms = new TimeFormatHMS(pwindow, this,
109 pwindow->thread->edl->session->time_format == TIME_HMS,
112 add_subwindow(hmsf = new TimeFormatHMSF(pwindow, this,
113 pwindow->thread->edl->session->time_format == TIME_HMSF,
116 add_subwindow(samples = new TimeFormatSamples(pwindow, this,
117 pwindow->thread->edl->session->time_format == TIME_SAMPLES,
120 add_subwindow(hex = new TimeFormatHex(pwindow, this,
121 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX,
124 add_subwindow(frames = new TimeFormatFrames(pwindow, this,
125 pwindow->thread->edl->session->time_format == TIME_FRAMES,
128 add_subwindow(feet = new TimeFormatFeet(pwindow, this,
129 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES,
131 x += feet->get_w() + 15;
133 add_subwindow(title = new BC_Title(x, y, _("Frames per foot:")));
134 x += title->get_w() + margin;
135 sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
136 add_subwindow(new TimeFormatFeetSetting(pwindow,
140 add_subwindow(seconds = new TimeFormatSeconds(pwindow, this,
141 pwindow->thread->edl->session->time_format == TIME_SECONDS,
145 add_subwindow(new BC_Bar(5, y, get_w()/2 - 30));
148 add_subwindow(new BC_Title(x, y, _("Color:"), LARGEFONT,
149 resources->text_default));
151 add_subwindow(title = new BC_Title(x, y, _("Highlighting Inversion color:")));
152 x += title->get_w() + margin;
153 char hex_color[BCSTRLEN];
154 sprintf(hex_color, "%06x", preferences->highlight_inverse);
155 add_subwindow(new HighlightInverseColor(pwindow, x, y, hex_color));
159 add_subwindow(title = new BC_Title(x, y, _("YUV color space:")));
160 x += title->get_w() + margin;
161 add_subwindow(yuv_color_space = new YuvColorSpace(x, y, pwindow));
162 yuv_color_space->create_objects();
163 y += yuv_color_space->get_h() + 5;
166 add_subwindow(title = new BC_Title(x, y, _("YUV color range:")));
167 x += title->get_w() + margin;
168 add_subwindow(yuv_color_range = new YuvColorRange(x, y, pwindow));
169 yuv_color_range->create_objects();
170 y += yuv_color_range->get_h() + 5;
172 UseTipWindow *tip_win = new UseTipWindow(pwindow, x1, y1);
173 add_subwindow(tip_win);
174 y1 += tip_win->get_h() + 5;
175 UseWarnIndecies *idx_win = new UseWarnIndecies(pwindow, x1, y1);
176 add_subwindow(idx_win);
177 y1 += idx_win->get_h() + 5;
178 UseWarnVersion *ver_win = new UseWarnVersion(pwindow, x1, y1);
179 add_subwindow(ver_win);
180 y1 += ver_win->get_h() + 5;
181 BD_WarnRoot *bdwr_win = new BD_WarnRoot(pwindow, x1, y1);
182 add_subwindow(bdwr_win);
183 y1 += bdwr_win->get_h() + 5;
184 PopupMenuBtnup *pop_win = new PopupMenuBtnup(pwindow, x1, y1);
185 add_subwindow(pop_win);
186 y1 += pop_win->get_h() + 5;
187 GrabFocusPolicy *grab_input_focus = new GrabFocusPolicy(pwindow, x1, y1);
188 add_subwindow(grab_input_focus);
189 y1 += grab_input_focus->get_h() + 5;
190 ActivateFocusPolicy *focus_activate = new ActivateFocusPolicy(pwindow, x1, y1);
191 add_subwindow(focus_activate);
192 y1 += focus_activate->get_h() + 5;
193 DeactivateFocusPolicy *focus_deactivate = new DeactivateFocusPolicy(pwindow, x1, y1);
194 add_subwindow(focus_deactivate);
195 y1 += focus_deactivate->get_h() + 5;
196 ForwardRenderDisplacement *displacement = new ForwardRenderDisplacement(pwindow, x1, y1);
197 add_subwindow(displacement);
198 y1 += displacement->get_h() + 5;
199 add_subwindow(thumbnails = new ViewThumbnails(x1, y1, pwindow));
200 y1 += thumbnails->get_h() + 5;
201 PerpetualSession *perpetual = new PerpetualSession(x1, y1, pwindow);
202 add_subwindow(perpetual);
203 y1 += perpetual->get_h() + 5;
207 int AppearancePrefs::update(int new_value)
209 pwindow->thread->redraw_times = 1;
210 pwindow->thread->edl->session->time_format = new_value;
211 hms->update(new_value == TIME_HMS);
212 hmsf->update(new_value == TIME_HMSF);
213 samples->update(new_value == TIME_SAMPLES);
214 hex->update(new_value == TIME_SAMPLES_HEX);
215 frames->update(new_value == TIME_FRAMES);
216 feet->update(new_value == TIME_FEET_FRAMES);
217 seconds->update(new_value == TIME_SECONDS);
222 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
223 : BC_Radial(x, y, value, TIME_HMS_TEXT)
224 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
226 int TimeFormatHMS::handle_event()
228 tfwindow->update(TIME_HMS);
232 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
233 : BC_Radial(x, y, value, TIME_HMSF_TEXT)
234 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
236 int TimeFormatHMSF::handle_event()
238 tfwindow->update(TIME_HMSF);
242 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
243 : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
244 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
246 int TimeFormatSamples::handle_event()
248 tfwindow->update(TIME_SAMPLES);
252 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
253 : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
254 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
256 int TimeFormatFrames::handle_event()
258 tfwindow->update(TIME_FRAMES);
262 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
263 : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
264 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
266 int TimeFormatHex::handle_event()
268 tfwindow->update(TIME_SAMPLES_HEX);
272 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
273 : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
275 this->pwindow = pwindow;
276 this->tfwindow = tfwindow;
279 int TimeFormatSeconds::handle_event()
281 tfwindow->update(TIME_SECONDS);
285 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
286 : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
287 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
289 int TimeFormatFeet::handle_event()
291 tfwindow->update(TIME_FEET_FRAMES);
295 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
296 : BC_TextBox(x, y, 90, 1, string)
297 { this->pwindow = pwindow; }
299 int TimeFormatFeetSetting::handle_event()
301 pwindow->thread->edl->session->frames_per_foot = atof(get_text());
302 if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
307 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
308 : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
310 this->pwindow = pwindow;
312 ViewTheme::~ViewTheme()
316 void ViewTheme::create_objects()
318 ArrayList<PluginServer*> themes;
319 MWindow::search_plugindb(0, 0, 0, 0, 1, themes);
321 for(int i = 0; i < themes.total; i++) {
322 add_item(new ViewThemeItem(this, themes.values[i]->title));
326 int ViewTheme::handle_event()
331 ViewThemeItem::ViewThemeItem(ViewTheme *popup, const char *text)
337 int ViewThemeItem::handle_event()
339 popup->set_text(get_text());
340 strcpy(popup->pwindow->thread->preferences->theme, get_text());
341 popup->handle_event();
346 ViewPluginIcons::ViewPluginIcons(int x, int y, PreferencesWindow *pwindow)
347 : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->plugin_icons, 1)
349 this->pwindow = pwindow;
351 ViewPluginIcons::~ViewPluginIcons()
355 void ViewPluginIcons::create_objects()
357 add_item(new ViewPluginIconItem(this, DEFAULT_PICON));
359 const char *plugin_path = File::get_plugin_path();
360 char picon_path[BCTEXTLEN];
361 snprintf(picon_path,sizeof(picon_path)-1,"%s/picon", plugin_path);
362 if( fs.update(picon_path) ) return;
363 for( int i=0; i<fs.dir_list.total; ++i ) {
364 char *fs_path = fs.dir_list[i]->path;
365 if( !fs.is_dir(fs_path) ) continue;
366 char *cp = strrchr(fs_path,'/');
367 cp = !cp ? fs_path : cp+1;
368 if( !strcmp(cp,DEFAULT_PICON) ) continue;
369 add_item(new ViewPluginIconItem(this, cp));
373 int ViewPluginIcons::handle_event()
378 ViewPluginIconItem::ViewPluginIconItem(ViewPluginIcons *popup, const char *text)
384 int ViewPluginIconItem::handle_event()
386 popup->set_text(get_text());
387 strcpy(popup->pwindow->thread->preferences->plugin_icons, get_text());
388 popup->handle_event();
393 ViewThumbnails::ViewThumbnails(int x,
395 PreferencesWindow *pwindow)
398 pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
400 this->pwindow = pwindow;
403 int ViewThumbnails::handle_event()
405 pwindow->thread->preferences->use_thumbnails = get_value();
410 ViewThumbnailSize::ViewThumbnailSize(PreferencesWindow *pwindow,
411 AppearancePrefs *aprefs, int x, int y)
412 : BC_TumbleTextBox(aprefs,
413 pwindow->thread->preferences->awindow_picon_h,
417 this->pwindow = pwindow;
418 this->aprefs = aprefs;
421 int ViewThumbnailSize::handle_event()
423 int v = atoi(get_text());
425 pwindow->thread->preferences->awindow_picon_h = v;
430 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
433 pwindow->thread->preferences->use_tipwindow,
434 _("Show tip of the day"))
436 this->pwindow = pwindow;
438 int UseTipWindow::handle_event()
440 pwindow->thread->preferences->use_tipwindow = get_value();
445 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
446 : BC_CheckBox(x, y, pwindow->thread->preferences->warn_indexes,
447 _("ffmpeg probe warns rebuild indexes"))
449 this->pwindow = pwindow;
452 int UseWarnIndecies::handle_event()
454 pwindow->thread->preferences->warn_indexes = get_value();
458 UseWarnVersion::UseWarnVersion(PreferencesWindow *pwindow, int x, int y)
459 : BC_CheckBox(x, y, pwindow->thread->preferences->warn_version,
460 _("EDL version warns if mismatched"))
462 this->pwindow = pwindow;
465 int UseWarnVersion::handle_event()
467 pwindow->thread->preferences->warn_version = get_value();
471 BD_WarnRoot::BD_WarnRoot(PreferencesWindow *pwindow, int x, int y)
472 : BC_CheckBox(x, y, pwindow->thread->preferences->bd_warn_root,
473 _("Create Bluray warns if not root"))
475 this->pwindow = pwindow;
478 int BD_WarnRoot::handle_event()
480 pwindow->thread->preferences->bd_warn_root = get_value();
484 PopupMenuBtnup::PopupMenuBtnup(PreferencesWindow *pwindow, int x, int y)
485 : BC_CheckBox(x, y, pwindow->thread->preferences->popupmenu_btnup,
486 _("Popups activate on button up"))
488 this->pwindow = pwindow;
491 int PopupMenuBtnup::handle_event()
493 pwindow->thread->preferences->popupmenu_btnup = get_value();
497 GrabFocusPolicy::GrabFocusPolicy(PreferencesWindow *pwindow, int x, int y)
498 : BC_CheckBox(x, y, (pwindow->thread->preferences->grab_input_focus) != 0,
499 _("Set Input Focus when window entered"))
501 this->pwindow = pwindow;
504 int GrabFocusPolicy::handle_event()
506 pwindow->thread->preferences->grab_input_focus = get_value();
510 ActivateFocusPolicy::ActivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
511 : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_ACTIVATE) != 0,
512 _("Click to activate text focus"))
514 this->pwindow = pwindow;
517 int ActivateFocusPolicy::handle_event()
520 pwindow->thread->preferences->textbox_focus_policy |= CLICK_ACTIVATE;
522 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_ACTIVATE;
526 DeactivateFocusPolicy::DeactivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
527 : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_DEACTIVATE) != 0,
528 _("Click to deactivate text focus"))
530 this->pwindow = pwindow;
533 int DeactivateFocusPolicy::handle_event()
536 pwindow->thread->preferences->textbox_focus_policy |= CLICK_DEACTIVATE;
538 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_DEACTIVATE;
542 ForwardRenderDisplacement::ForwardRenderDisplacement(PreferencesWindow *pwindow, int x, int y)
543 : BC_CheckBox(x, y, pwindow->thread->preferences->forward_render_displacement,
544 _("Always show next frame"))
546 this->pwindow = pwindow;
549 int ForwardRenderDisplacement::handle_event()
551 pwindow->thread->preferences->forward_render_displacement = get_value();
555 HighlightInverseColor::HighlightInverseColor(PreferencesWindow *pwindow, int x, int y, const char *hex)
556 : BC_TextBox(x, y, 80, 1, hex)
558 this->pwindow = pwindow;
561 int HighlightInverseColor::handle_event()
563 int inverse_color = strtoul(get_text(),0,16);
564 if( (inverse_color &= 0xffffff) == 0 ) {
565 inverse_color = 0xffffff;
566 char string[BCSTRLEN];
567 sprintf(string,"%06x", inverse_color);
570 pwindow->thread->preferences->highlight_inverse = inverse_color;
575 const char *YuvColorSpace::color_space[] = {
581 YuvColorSpace::YuvColorSpace(int x, int y, PreferencesWindow *pwindow)
582 : BC_PopupMenu(x, y, 100,
583 _(color_space[pwindow->thread->preferences->yuv_color_space]), 1)
585 this->pwindow = pwindow;
587 YuvColorSpace::~YuvColorSpace()
591 void YuvColorSpace::create_objects()
593 for( int id=0,nid=sizeof(color_space)/sizeof(color_space[0]); id<nid; ++id )
594 add_item(new YuvColorSpaceItem(this, _(color_space[id]), id));
598 int YuvColorSpace::handle_event()
600 set_text(color_space[pwindow->thread->preferences->yuv_color_space]);
604 YuvColorSpaceItem::YuvColorSpaceItem(YuvColorSpace *popup, const char *text, int id)
611 int YuvColorSpaceItem::handle_event()
613 popup->set_text(get_text());
614 popup->pwindow->thread->preferences->yuv_color_space = id;
615 return popup->handle_event();
619 const char *YuvColorRange::color_range[] = {
624 YuvColorRange::YuvColorRange(int x, int y, PreferencesWindow *pwindow)
625 : BC_PopupMenu(x, y, 100,
626 _(color_range[pwindow->thread->preferences->yuv_color_range]), 1)
628 this->pwindow = pwindow;
630 YuvColorRange::~YuvColorRange()
634 void YuvColorRange::create_objects()
636 for( int id=0,nid=sizeof(color_range)/sizeof(color_range[0]); id<nid; ++id )
637 add_item(new YuvColorRangeItem(this, _(color_range[id]), id));
641 int YuvColorRange::handle_event()
643 set_text(color_range[pwindow->thread->preferences->yuv_color_range]);
647 YuvColorRangeItem::YuvColorRangeItem(YuvColorRange *popup, const char *text, int id)
654 int YuvColorRangeItem::handle_event()
656 popup->set_text(get_text());
657 popup->pwindow->thread->preferences->yuv_color_range = id;
658 return popup->handle_event();
661 PerpetualSession::PerpetualSession(int x, int y, PreferencesWindow *pwindow)
663 pwindow->thread->preferences->perpetual_session, _("Perpetual session"))
665 this->pwindow = pwindow;
668 int PerpetualSession::handle_event()
670 pwindow->thread->preferences->perpetual_session = get_value();