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 ForwardRenderDisplacement *displacement = new ForwardRenderDisplacement(pwindow, x1, y1);
166 add_subwindow(displacement);
167 y1 += displacement->get_h() + 5;
168 add_subwindow(thumbnails = new ViewThumbnails(x1, y1, pwindow));
172 int AppearancePrefs::update(int new_value)
174 pwindow->thread->redraw_times = 1;
175 pwindow->thread->edl->session->time_format = new_value;
176 hms->update(new_value == TIME_HMS);
177 hmsf->update(new_value == TIME_HMSF);
178 samples->update(new_value == TIME_SAMPLES);
179 hex->update(new_value == TIME_SAMPLES_HEX);
180 frames->update(new_value == TIME_FRAMES);
181 feet->update(new_value == TIME_FEET_FRAMES);
182 seconds->update(new_value == TIME_SECONDS);
187 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
188 : BC_Radial(x, y, value, TIME_HMS_TEXT)
189 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
191 int TimeFormatHMS::handle_event()
193 tfwindow->update(TIME_HMS);
197 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
198 : BC_Radial(x, y, value, TIME_HMSF_TEXT)
199 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
201 int TimeFormatHMSF::handle_event()
203 tfwindow->update(TIME_HMSF);
207 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
208 : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
209 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
211 int TimeFormatSamples::handle_event()
213 tfwindow->update(TIME_SAMPLES);
217 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
218 : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
219 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
221 int TimeFormatFrames::handle_event()
223 tfwindow->update(TIME_FRAMES);
227 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
228 : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
229 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
231 int TimeFormatHex::handle_event()
233 tfwindow->update(TIME_SAMPLES_HEX);
237 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
238 : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
240 this->pwindow = pwindow;
241 this->tfwindow = tfwindow;
244 int TimeFormatSeconds::handle_event()
246 tfwindow->update(TIME_SECONDS);
250 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
251 : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
252 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
254 int TimeFormatFeet::handle_event()
256 tfwindow->update(TIME_FEET_FRAMES);
260 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
261 : BC_TextBox(x, y, 90, 1, string)
262 { this->pwindow = pwindow; }
264 int TimeFormatFeetSetting::handle_event()
266 pwindow->thread->edl->session->frames_per_foot = atof(get_text());
267 if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
272 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
273 : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
275 this->pwindow = pwindow;
277 ViewTheme::~ViewTheme()
281 void ViewTheme::create_objects()
283 ArrayList<PluginServer*> themes;
284 MWindow::search_plugindb(0, 0, 0, 0, 1, themes);
286 for(int i = 0; i < themes.total; i++) {
287 add_item(new ViewThemeItem(this, themes.values[i]->title));
291 int ViewTheme::handle_event()
296 ViewThemeItem::ViewThemeItem(ViewTheme *popup, const char *text)
302 int ViewThemeItem::handle_event()
304 popup->set_text(get_text());
305 strcpy(popup->pwindow->thread->preferences->theme, get_text());
306 popup->handle_event();
311 ViewPluginIcons::ViewPluginIcons(int x, int y, PreferencesWindow *pwindow)
312 : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->plugin_icons, 1)
314 this->pwindow = pwindow;
316 ViewPluginIcons::~ViewPluginIcons()
320 void ViewPluginIcons::create_objects()
322 add_item(new ViewPluginIconItem(this, DEFAULT_PICON));
324 const char *plugin_path = File::get_plugin_path();
325 if( fs.update(plugin_path) ) return;
326 for( int i=0; i<fs.dir_list.total; ++i ) {
327 char *fs_path = fs.dir_list[i]->path;
328 if( !fs.is_dir(fs_path) ) continue;
329 char *cp = strrchr(fs_path,'/');
330 cp = !cp ? fs_path : cp+1;
331 if( strncmp("picon_", cp, 6) ) continue;
332 if( !strcmp(cp += 6,DEFAULT_PICON) ) continue;
333 add_item(new ViewPluginIconItem(this, cp));
337 int ViewPluginIcons::handle_event()
342 ViewPluginIconItem::ViewPluginIconItem(ViewPluginIcons *popup, const char *text)
348 int ViewPluginIconItem::handle_event()
350 popup->set_text(get_text());
351 strcpy(popup->pwindow->thread->preferences->plugin_icons, get_text());
352 popup->handle_event();
357 ViewThumbnails::ViewThumbnails(int x,
359 PreferencesWindow *pwindow)
362 pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
364 this->pwindow = pwindow;
367 int ViewThumbnails::handle_event()
369 pwindow->thread->preferences->use_thumbnails = get_value();
375 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
378 pwindow->thread->preferences->use_tipwindow,
379 _("Show tip of the day"))
381 this->pwindow = pwindow;
383 int UseTipWindow::handle_event()
385 pwindow->thread->preferences->use_tipwindow = get_value();
390 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
391 : BC_CheckBox(x, y, pwindow->thread->preferences->warn_indexes,
392 _("ffmpeg probe warns rebuild indexes"))
394 this->pwindow = pwindow;
397 int UseWarnIndecies::handle_event()
399 pwindow->thread->preferences->warn_indexes = get_value();
403 UseWarnVersion::UseWarnVersion(PreferencesWindow *pwindow, int x, int y)
404 : BC_CheckBox(x, y, pwindow->thread->preferences->warn_version,
405 _("EDL version warns if mismatched"))
407 this->pwindow = pwindow;
410 int UseWarnVersion::handle_event()
412 pwindow->thread->preferences->warn_version = get_value();
416 BD_WarnRoot::BD_WarnRoot(PreferencesWindow *pwindow, int x, int y)
417 : BC_CheckBox(x, y, pwindow->thread->preferences->bd_warn_root,
418 _("Create Bluray warns if not root"))
420 this->pwindow = pwindow;
423 int BD_WarnRoot::handle_event()
425 pwindow->thread->preferences->bd_warn_root = get_value();
429 PopupMenuBtnup::PopupMenuBtnup(PreferencesWindow *pwindow, int x, int y)
430 : BC_CheckBox(x, y, pwindow->thread->preferences->popupmenu_btnup,
431 _("Popups activate on button up"))
433 this->pwindow = pwindow;
436 int PopupMenuBtnup::handle_event()
438 pwindow->thread->preferences->popupmenu_btnup = get_value();
442 ActivateFocusPolicy::ActivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
443 : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_ACTIVATE) != 0,
444 _("Click to activate text focus"))
446 this->pwindow = pwindow;
449 int ActivateFocusPolicy::handle_event()
452 pwindow->thread->preferences->textbox_focus_policy |= CLICK_ACTIVATE;
454 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_ACTIVATE;
458 DeactivateFocusPolicy::DeactivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
459 : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_DEACTIVATE) != 0,
460 _("Click to deactivate text focus"))
462 this->pwindow = pwindow;
465 int DeactivateFocusPolicy::handle_event()
468 pwindow->thread->preferences->textbox_focus_policy |= CLICK_DEACTIVATE;
470 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_DEACTIVATE;
474 ForwardRenderDisplacement::ForwardRenderDisplacement(PreferencesWindow *pwindow, int x, int y)
475 : BC_CheckBox(x, y, pwindow->thread->preferences->forward_render_displacement,
476 _("Forward render enable displacement"))
478 this->pwindow = pwindow;
481 int ForwardRenderDisplacement::handle_event()
483 pwindow->thread->preferences->forward_render_displacement = get_value();