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 UseTipWindow *tip_win = new UseTipWindow(pwindow, x1, y1);
145 add_subwindow(tip_win);
146 y1 += tip_win->get_h() + 5;
147 UseWarnIndecies *idx_win = new UseWarnIndecies(pwindow, x1, y1);
148 add_subwindow(idx_win);
149 y1 += idx_win->get_h() + 5;
150 UseWarnVersion *ver_win = new UseWarnVersion(pwindow, x1, y1);
151 add_subwindow(ver_win);
152 y1 += ver_win->get_h() + 5;
153 BD_WarnRoot *bdwr_win = new BD_WarnRoot(pwindow, x1, y1);
154 add_subwindow(bdwr_win);
155 y1 += bdwr_win->get_h() + 5;
156 PopupMenuBtnup *pop_win = new PopupMenuBtnup(pwindow, x1, y1);
157 add_subwindow(pop_win);
158 y1 += pop_win->get_h() + 5;
159 ActivateFocusPolicy *focus_activate = new ActivateFocusPolicy(pwindow, x1, y1);
160 add_subwindow(focus_activate);
161 y1 += focus_activate->get_h() + 5;
162 DeactivateFocusPolicy *focus_deactivate = new DeactivateFocusPolicy(pwindow, x1, y1);
163 add_subwindow(focus_deactivate);
164 y1 += focus_deactivate->get_h() + 5;
165 add_subwindow(thumbnails = new ViewThumbnails(x1, y1, pwindow));
169 int AppearancePrefs::update(int new_value)
171 pwindow->thread->redraw_times = 1;
172 pwindow->thread->edl->session->time_format = new_value;
173 hms->update(new_value == TIME_HMS);
174 hmsf->update(new_value == TIME_HMSF);
175 samples->update(new_value == TIME_SAMPLES);
176 hex->update(new_value == TIME_SAMPLES_HEX);
177 frames->update(new_value == TIME_FRAMES);
178 feet->update(new_value == TIME_FEET_FRAMES);
179 seconds->update(new_value == TIME_SECONDS);
184 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
185 : BC_Radial(x, y, value, TIME_HMS_TEXT)
186 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
188 int TimeFormatHMS::handle_event()
190 tfwindow->update(TIME_HMS);
194 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
195 : BC_Radial(x, y, value, TIME_HMSF_TEXT)
196 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
198 int TimeFormatHMSF::handle_event()
200 tfwindow->update(TIME_HMSF);
204 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
205 : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
206 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
208 int TimeFormatSamples::handle_event()
210 tfwindow->update(TIME_SAMPLES);
214 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
215 : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
216 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
218 int TimeFormatFrames::handle_event()
220 tfwindow->update(TIME_FRAMES);
224 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
225 : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
226 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
228 int TimeFormatHex::handle_event()
230 tfwindow->update(TIME_SAMPLES_HEX);
234 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
235 : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
237 this->pwindow = pwindow;
238 this->tfwindow = tfwindow;
241 int TimeFormatSeconds::handle_event()
243 tfwindow->update(TIME_SECONDS);
247 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
248 : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
249 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
251 int TimeFormatFeet::handle_event()
253 tfwindow->update(TIME_FEET_FRAMES);
257 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
258 : BC_TextBox(x, y, 90, 1, string)
259 { this->pwindow = pwindow; }
261 int TimeFormatFeetSetting::handle_event()
263 pwindow->thread->edl->session->frames_per_foot = atof(get_text());
264 if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
269 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
270 : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
272 this->pwindow = pwindow;
274 ViewTheme::~ViewTheme()
278 void ViewTheme::create_objects()
280 ArrayList<PluginServer*> themes;
281 MWindow::search_plugindb(0, 0, 0, 0, 1, themes);
283 for(int i = 0; i < themes.total; i++) {
284 add_item(new ViewThemeItem(this, themes.values[i]->title));
288 int ViewTheme::handle_event()
293 ViewThemeItem::ViewThemeItem(ViewTheme *popup, const char *text)
299 int ViewThemeItem::handle_event()
301 popup->set_text(get_text());
302 strcpy(popup->pwindow->thread->preferences->theme, get_text());
303 popup->handle_event();
308 ViewPluginIcons::ViewPluginIcons(int x, int y, PreferencesWindow *pwindow)
309 : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->plugin_icons, 1)
311 this->pwindow = pwindow;
313 ViewPluginIcons::~ViewPluginIcons()
317 void ViewPluginIcons::create_objects()
319 add_item(new ViewPluginIconItem(this, DEFAULT_PICON));
321 const char *plugin_path = File::get_plugin_path();
322 if( fs.update(plugin_path) ) return;
323 for( int i=0; i<fs.dir_list.total; ++i ) {
324 char *fs_path = fs.dir_list[i]->path;
325 if( !fs.is_dir(fs_path) ) continue;
326 char *cp = strrchr(fs_path,'/');
327 cp = !cp ? fs_path : cp+1;
328 if( strncmp("picon_", cp, 6) ) continue;
329 if( !strcmp(cp += 6,DEFAULT_PICON) ) continue;
330 add_item(new ViewPluginIconItem(this, cp));
334 int ViewPluginIcons::handle_event()
339 ViewPluginIconItem::ViewPluginIconItem(ViewPluginIcons *popup, const char *text)
345 int ViewPluginIconItem::handle_event()
347 popup->set_text(get_text());
348 strcpy(popup->pwindow->thread->preferences->plugin_icons, get_text());
349 popup->handle_event();
354 ViewThumbnails::ViewThumbnails(int x,
356 PreferencesWindow *pwindow)
359 pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
361 this->pwindow = pwindow;
364 int ViewThumbnails::handle_event()
366 pwindow->thread->preferences->use_thumbnails = get_value();
372 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
375 pwindow->thread->preferences->use_tipwindow,
376 _("Show tip of the day"))
378 this->pwindow = pwindow;
380 int UseTipWindow::handle_event()
382 pwindow->thread->preferences->use_tipwindow = get_value();
387 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
388 : BC_CheckBox(x, y, pwindow->thread->preferences->warn_indexes,
389 _("ffmpeg probe warns rebuild indexes"))
391 this->pwindow = pwindow;
394 int UseWarnIndecies::handle_event()
396 pwindow->thread->preferences->warn_indexes = get_value();
400 UseWarnVersion::UseWarnVersion(PreferencesWindow *pwindow, int x, int y)
401 : BC_CheckBox(x, y, pwindow->thread->preferences->warn_version,
402 _("EDL version warns if mismatched"))
404 this->pwindow = pwindow;
407 int UseWarnVersion::handle_event()
409 pwindow->thread->preferences->warn_version = get_value();
413 BD_WarnRoot::BD_WarnRoot(PreferencesWindow *pwindow, int x, int y)
414 : BC_CheckBox(x, y, pwindow->thread->preferences->bd_warn_root,
415 _("Create Bluray warns if not root"))
417 this->pwindow = pwindow;
420 int BD_WarnRoot::handle_event()
422 pwindow->thread->preferences->bd_warn_root = get_value();
426 PopupMenuBtnup::PopupMenuBtnup(PreferencesWindow *pwindow, int x, int y)
427 : BC_CheckBox(x, y, pwindow->thread->preferences->popupmenu_btnup,
428 _("Popups activate on button up"))
430 this->pwindow = pwindow;
433 int PopupMenuBtnup::handle_event()
435 pwindow->thread->preferences->popupmenu_btnup = get_value();
439 ActivateFocusPolicy::ActivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
440 : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_ACTIVATE) != 0,
441 _("Click to activate text focus"))
443 this->pwindow = pwindow;
446 int ActivateFocusPolicy::handle_event()
449 pwindow->thread->preferences->textbox_focus_policy |= CLICK_ACTIVATE;
451 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_ACTIVATE;
455 DeactivateFocusPolicy::DeactivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
456 : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_DEACTIVATE) != 0,
457 _("Click to deactivate text focus"))
459 this->pwindow = pwindow;
462 int DeactivateFocusPolicy::handle_event()
465 pwindow->thread->preferences->textbox_focus_policy |= CLICK_DEACTIVATE;
467 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_DEACTIVATE;