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 #define MOVE_ALL_EDITS_TITLE N_("Drag all following edits")
37 #define MOVE_ONE_EDIT_TITLE N_("Drag only one edit")
38 #define MOVE_NO_EDITS_TITLE N_("Drag source only")
39 #define MOVE_EDITS_DISABLED_TITLE N_("No effect")
42 AppearancePrefs::AppearancePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
43 : PreferencesDialog(mwindow, pwindow)
54 AppearancePrefs::~AppearancePrefs()
66 void AppearancePrefs::create_objects()
68 BC_Resources *resources = BC_WindowBase::get_resources();
69 int margin = mwindow->theme->widget_border;
70 char string[BCTEXTLEN];
71 int x0 = mwindow->theme->preferencesoptions_x;
72 int y0 = mwindow->theme->preferencesoptions_y;
73 int x = x0, y = y0, x1 = x + 100;
75 add_subwindow(new BC_Title(x, y, _("Layout:"), LARGEFONT,
76 resources->text_default));
80 add_subwindow(new BC_Title(x, y, _("Theme:")));
81 add_subwindow(theme = new ViewTheme(x1, y, pwindow));
82 theme->create_objects();
83 y += theme->get_h() + 5;
86 ViewPluginIcons *plugin_icons;
87 add_subwindow(new BC_Title(x, y, _("Plugin Icons:")));
88 add_subwindow(plugin_icons = new ViewPluginIcons(x1, y, pwindow));
89 plugin_icons->create_objects();
90 y += plugin_icons->get_h() + 5;
93 add_subwindow(new BC_Bar(5, y, get_w() - 10));
96 add_subwindow(new BC_Title(x, y, _("Time Format:"), LARGEFONT,
97 resources->text_default));
100 add_subwindow(new BC_Title(x1, y, _("Flags:"), LARGEFONT,
101 resources->text_default));
103 y += get_text_height(LARGEFONT) + 5;
107 add_subwindow(hms = new TimeFormatHMS(pwindow, this,
108 pwindow->thread->edl->session->time_format == TIME_HMS,
111 add_subwindow(hmsf = new TimeFormatHMSF(pwindow, this,
112 pwindow->thread->edl->session->time_format == TIME_HMSF,
115 add_subwindow(samples = new TimeFormatSamples(pwindow, this,
116 pwindow->thread->edl->session->time_format == TIME_SAMPLES,
119 add_subwindow(hex = new TimeFormatHex(pwindow, this,
120 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX,
123 add_subwindow(frames = new TimeFormatFrames(pwindow, this,
124 pwindow->thread->edl->session->time_format == TIME_FRAMES,
127 add_subwindow(feet = new TimeFormatFeet(pwindow, this,
128 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES,
130 x += feet->get_w() + 15;
132 add_subwindow(title = new BC_Title(x, y, _("Frames per foot:")));
133 x += title->get_w() + margin;
134 sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
135 add_subwindow(new TimeFormatFeetSetting(pwindow,
139 add_subwindow(seconds = new TimeFormatSeconds(pwindow, this,
140 pwindow->thread->edl->session->time_format == TIME_SECONDS,
144 add_subwindow(title = new BC_Title(x, y, _("Highlighting Inversion color:")));
145 x += title->get_w() + margin;
146 char hex_color[BCSTRLEN];
147 sprintf(hex_color, "%06x", preferences->highlight_inverse);
148 add_subwindow(new HighlightInverseColor(pwindow, x, y, hex_color));
151 UseTipWindow *tip_win = new UseTipWindow(pwindow, x1, y1);
152 add_subwindow(tip_win);
153 y1 += tip_win->get_h() + 5;
154 UseWarnIndecies *idx_win = new UseWarnIndecies(pwindow, x1, y1);
155 add_subwindow(idx_win);
156 y1 += idx_win->get_h() + 5;
157 UseWarnVersion *ver_win = new UseWarnVersion(pwindow, x1, y1);
158 add_subwindow(ver_win);
159 y1 += ver_win->get_h() + 5;
160 BD_WarnRoot *bdwr_win = new BD_WarnRoot(pwindow, x1, y1);
161 add_subwindow(bdwr_win);
162 y1 += bdwr_win->get_h() + 5;
163 PopupMenuBtnup *pop_win = new PopupMenuBtnup(pwindow, x1, y1);
164 add_subwindow(pop_win);
165 y1 += pop_win->get_h() + 5;
166 GrabFocusPolicy *grab_input_focus = new GrabFocusPolicy(pwindow, x1, y1);
167 add_subwindow(grab_input_focus);
168 y1 += grab_input_focus->get_h() + 5;
169 ActivateFocusPolicy *focus_activate = new ActivateFocusPolicy(pwindow, x1, y1);
170 add_subwindow(focus_activate);
171 y1 += focus_activate->get_h() + 5;
172 DeactivateFocusPolicy *focus_deactivate = new DeactivateFocusPolicy(pwindow, x1, y1);
173 add_subwindow(focus_deactivate);
174 y1 += focus_deactivate->get_h() + 5;
175 ForwardRenderDisplacement *displacement = new ForwardRenderDisplacement(pwindow, x1, y1);
176 add_subwindow(displacement);
177 y1 += displacement->get_h() + 5;
178 add_subwindow(thumbnails = new ViewThumbnails(x1, y1, pwindow));
182 int AppearancePrefs::update(int new_value)
184 pwindow->thread->redraw_times = 1;
185 pwindow->thread->edl->session->time_format = new_value;
186 hms->update(new_value == TIME_HMS);
187 hmsf->update(new_value == TIME_HMSF);
188 samples->update(new_value == TIME_SAMPLES);
189 hex->update(new_value == TIME_SAMPLES_HEX);
190 frames->update(new_value == TIME_FRAMES);
191 feet->update(new_value == TIME_FEET_FRAMES);
192 seconds->update(new_value == TIME_SECONDS);
197 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
198 : BC_Radial(x, y, value, TIME_HMS_TEXT)
199 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
201 int TimeFormatHMS::handle_event()
203 tfwindow->update(TIME_HMS);
207 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
208 : BC_Radial(x, y, value, TIME_HMSF_TEXT)
209 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
211 int TimeFormatHMSF::handle_event()
213 tfwindow->update(TIME_HMSF);
217 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
218 : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
219 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
221 int TimeFormatSamples::handle_event()
223 tfwindow->update(TIME_SAMPLES);
227 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
228 : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
229 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
231 int TimeFormatFrames::handle_event()
233 tfwindow->update(TIME_FRAMES);
237 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
238 : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
239 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
241 int TimeFormatHex::handle_event()
243 tfwindow->update(TIME_SAMPLES_HEX);
247 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
248 : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
250 this->pwindow = pwindow;
251 this->tfwindow = tfwindow;
254 int TimeFormatSeconds::handle_event()
256 tfwindow->update(TIME_SECONDS);
260 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
261 : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
262 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
264 int TimeFormatFeet::handle_event()
266 tfwindow->update(TIME_FEET_FRAMES);
270 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
271 : BC_TextBox(x, y, 90, 1, string)
272 { this->pwindow = pwindow; }
274 int TimeFormatFeetSetting::handle_event()
276 pwindow->thread->edl->session->frames_per_foot = atof(get_text());
277 if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
282 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
283 : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
285 this->pwindow = pwindow;
287 ViewTheme::~ViewTheme()
291 void ViewTheme::create_objects()
293 ArrayList<PluginServer*> themes;
294 MWindow::search_plugindb(0, 0, 0, 0, 1, themes);
296 for(int i = 0; i < themes.total; i++) {
297 add_item(new ViewThemeItem(this, themes.values[i]->title));
301 int ViewTheme::handle_event()
306 ViewThemeItem::ViewThemeItem(ViewTheme *popup, const char *text)
312 int ViewThemeItem::handle_event()
314 popup->set_text(get_text());
315 strcpy(popup->pwindow->thread->preferences->theme, get_text());
316 popup->handle_event();
321 ViewPluginIcons::ViewPluginIcons(int x, int y, PreferencesWindow *pwindow)
322 : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->plugin_icons, 1)
324 this->pwindow = pwindow;
326 ViewPluginIcons::~ViewPluginIcons()
330 void ViewPluginIcons::create_objects()
332 add_item(new ViewPluginIconItem(this, DEFAULT_PICON));
334 const char *plugin_path = File::get_plugin_path();
335 if( fs.update(plugin_path) ) return;
336 for( int i=0; i<fs.dir_list.total; ++i ) {
337 char *fs_path = fs.dir_list[i]->path;
338 if( !fs.is_dir(fs_path) ) continue;
339 char *cp = strrchr(fs_path,'/');
340 cp = !cp ? fs_path : cp+1;
341 if( strncmp("picon_", cp, 6) ) continue;
342 if( !strcmp(cp += 6,DEFAULT_PICON) ) continue;
343 add_item(new ViewPluginIconItem(this, cp));
347 int ViewPluginIcons::handle_event()
352 ViewPluginIconItem::ViewPluginIconItem(ViewPluginIcons *popup, const char *text)
358 int ViewPluginIconItem::handle_event()
360 popup->set_text(get_text());
361 strcpy(popup->pwindow->thread->preferences->plugin_icons, get_text());
362 popup->handle_event();
367 ViewThumbnails::ViewThumbnails(int x,
369 PreferencesWindow *pwindow)
372 pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
374 this->pwindow = pwindow;
377 int ViewThumbnails::handle_event()
379 pwindow->thread->preferences->use_thumbnails = get_value();
385 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
388 pwindow->thread->preferences->use_tipwindow,
389 _("Show tip of the day"))
391 this->pwindow = pwindow;
393 int UseTipWindow::handle_event()
395 pwindow->thread->preferences->use_tipwindow = get_value();
400 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
401 : BC_CheckBox(x, y, pwindow->thread->preferences->warn_indexes,
402 _("ffmpeg probe warns rebuild indexes"))
404 this->pwindow = pwindow;
407 int UseWarnIndecies::handle_event()
409 pwindow->thread->preferences->warn_indexes = get_value();
413 UseWarnVersion::UseWarnVersion(PreferencesWindow *pwindow, int x, int y)
414 : BC_CheckBox(x, y, pwindow->thread->preferences->warn_version,
415 _("EDL version warns if mismatched"))
417 this->pwindow = pwindow;
420 int UseWarnVersion::handle_event()
422 pwindow->thread->preferences->warn_version = get_value();
426 BD_WarnRoot::BD_WarnRoot(PreferencesWindow *pwindow, int x, int y)
427 : BC_CheckBox(x, y, pwindow->thread->preferences->bd_warn_root,
428 _("Create Bluray warns if not root"))
430 this->pwindow = pwindow;
433 int BD_WarnRoot::handle_event()
435 pwindow->thread->preferences->bd_warn_root = get_value();
439 PopupMenuBtnup::PopupMenuBtnup(PreferencesWindow *pwindow, int x, int y)
440 : BC_CheckBox(x, y, pwindow->thread->preferences->popupmenu_btnup,
441 _("Popups activate on button up"))
443 this->pwindow = pwindow;
446 int PopupMenuBtnup::handle_event()
448 pwindow->thread->preferences->popupmenu_btnup = get_value();
452 GrabFocusPolicy::GrabFocusPolicy(PreferencesWindow *pwindow, int x, int y)
453 : BC_CheckBox(x, y, (pwindow->thread->preferences->grab_input_focus) != 0,
454 _("Set Input Focus when window entered"))
456 this->pwindow = pwindow;
459 int GrabFocusPolicy::handle_event()
461 pwindow->thread->preferences->grab_input_focus = get_value();
465 ActivateFocusPolicy::ActivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
466 : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_ACTIVATE) != 0,
467 _("Click to activate text focus"))
469 this->pwindow = pwindow;
472 int ActivateFocusPolicy::handle_event()
475 pwindow->thread->preferences->textbox_focus_policy |= CLICK_ACTIVATE;
477 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_ACTIVATE;
481 DeactivateFocusPolicy::DeactivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
482 : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_DEACTIVATE) != 0,
483 _("Click to deactivate text focus"))
485 this->pwindow = pwindow;
488 int DeactivateFocusPolicy::handle_event()
491 pwindow->thread->preferences->textbox_focus_policy |= CLICK_DEACTIVATE;
493 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_DEACTIVATE;
497 ForwardRenderDisplacement::ForwardRenderDisplacement(PreferencesWindow *pwindow, int x, int y)
498 : BC_CheckBox(x, y, pwindow->thread->preferences->forward_render_displacement,
499 _("Always show next frame"))
501 this->pwindow = pwindow;
504 int ForwardRenderDisplacement::handle_event()
506 pwindow->thread->preferences->forward_render_displacement = get_value();
510 HighlightInverseColor::HighlightInverseColor(PreferencesWindow *pwindow, int x, int y, const char *hex)
511 : BC_TextBox(x, y, 80, 1, hex)
513 this->pwindow = pwindow;
516 int HighlightInverseColor::handle_event()
518 int inverse_color = strtoul(get_text(),0,16);
519 if( (inverse_color &= 0xffffff) == 0 ) {
520 inverse_color = 0xffffff;
521 char string[BCSTRLEN];
522 sprintf(string,"%06x", inverse_color);
525 pwindow->thread->preferences->highlight_inverse = inverse_color;