fred (fwd render enb displ) play pref. info text tweak
[goodguy/history.git] / cinelerra-5.1 / cinelerra / appearanceprefs.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include "appearanceprefs.h"
23 #include "deleteallindexes.h"
24 #include "edl.h"
25 #include "edlsession.h"
26 #include "file.h"
27 #include "filesystem.h"
28 #include "language.h"
29 #include "mwindow.h"
30 #include "preferences.h"
31 #include "preferencesthread.h"
32 #include "shbtnprefs.h"
33 #include "theme.h"
34
35
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")
40
41
42 AppearancePrefs::AppearancePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
43  : PreferencesDialog(mwindow, pwindow)
44 {
45         hms = 0;
46         hmsf = 0;
47         samples = 0;
48         frames = 0;
49         hex = 0;
50         feet = 0;
51         thumbnails = 0;
52 }
53
54 AppearancePrefs::~AppearancePrefs()
55 {
56         delete hms;
57         delete hmsf;
58         delete samples;
59         delete frames;
60         delete hex;
61         delete feet;
62         delete thumbnails;
63 }
64
65
66 void AppearancePrefs::create_objects()
67 {
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;
74
75         add_subwindow(new BC_Title(x, y, _("Layout:"), LARGEFONT,
76                 resources->text_default));
77         y += 35;
78
79         ViewTheme *theme;
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;
84
85         x = x0;
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;
91
92         y += 10;
93         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
94         y += 15;
95
96         add_subwindow(new BC_Title(x, y, _("Time Format:"), LARGEFONT,
97                 resources->text_default));
98
99         x1 = get_w()/2;
100         add_subwindow(new BC_Title(x1, y, _("Flags:"), LARGEFONT,
101                 resources->text_default));
102
103         y += get_text_height(LARGEFONT) + 5;
104         y += 10;
105         int y1 = y;
106
107         add_subwindow(hms = new TimeFormatHMS(pwindow, this,
108                 pwindow->thread->edl->session->time_format == TIME_HMS,
109                 x, y));
110         y += 20;
111         add_subwindow(hmsf = new TimeFormatHMSF(pwindow, this,
112                 pwindow->thread->edl->session->time_format == TIME_HMSF,
113                 x, y));
114         y += 20;
115         add_subwindow(samples = new TimeFormatSamples(pwindow, this,
116                 pwindow->thread->edl->session->time_format == TIME_SAMPLES,
117                 x, y));
118         y += 20;
119         add_subwindow(hex = new TimeFormatHex(pwindow, this,
120                 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX,
121                 x, y));
122         y += 20;
123         add_subwindow(frames = new TimeFormatFrames(pwindow, this,
124                 pwindow->thread->edl->session->time_format == TIME_FRAMES,
125                 x, y));
126         y += 20;
127         add_subwindow(feet = new TimeFormatFeet(pwindow, this,
128                 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES,
129                 x, y));
130         x += feet->get_w() + 15;
131         BC_Title *title;
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,
136                 x, y - 5,       string));
137         x = x0;
138         y += 20;
139         add_subwindow(seconds = new TimeFormatSeconds(pwindow, this,
140                 pwindow->thread->edl->session->time_format == TIME_SECONDS,
141                 x, y));
142         y += 35;
143
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));
169         if( y < y1 ) y = y1;
170 }
171
172 int AppearancePrefs::update(int new_value)
173 {
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);
183         return 0;
184 }
185
186
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; }
190
191 int TimeFormatHMS::handle_event()
192 {
193         tfwindow->update(TIME_HMS);
194         return 1;
195 }
196
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; }
200
201 int TimeFormatHMSF::handle_event()
202 {
203         tfwindow->update(TIME_HMSF);
204         return 1;
205 }
206
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; }
210
211 int TimeFormatSamples::handle_event()
212 {
213         tfwindow->update(TIME_SAMPLES);
214         return 1;
215 }
216
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; }
220
221 int TimeFormatFrames::handle_event()
222 {
223         tfwindow->update(TIME_FRAMES);
224         return 1;
225 }
226
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; }
230
231 int TimeFormatHex::handle_event()
232 {
233         tfwindow->update(TIME_SAMPLES_HEX);
234         return 1;
235 }
236
237 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
238  : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
239 {
240         this->pwindow = pwindow;
241         this->tfwindow = tfwindow;
242 }
243
244 int TimeFormatSeconds::handle_event()
245 {
246         tfwindow->update(TIME_SECONDS);
247         return 1;
248 }
249
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; }
253
254 int TimeFormatFeet::handle_event()
255 {
256         tfwindow->update(TIME_FEET_FRAMES);
257         return 1;
258 }
259
260 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
261  : BC_TextBox(x, y, 90, 1, string)
262 { this->pwindow = pwindow; }
263
264 int TimeFormatFeetSetting::handle_event()
265 {
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;
268         return 0;
269 }
270
271
272 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
273  : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
274 {
275         this->pwindow = pwindow;
276 }
277 ViewTheme::~ViewTheme()
278 {
279 }
280
281 void ViewTheme::create_objects()
282 {
283         ArrayList<PluginServer*> themes;
284         MWindow::search_plugindb(0, 0, 0, 0, 1, themes);
285
286         for(int i = 0; i < themes.total; i++) {
287                 add_item(new ViewThemeItem(this, themes.values[i]->title));
288         }
289 }
290
291 int ViewTheme::handle_event()
292 {
293         return 1;
294 }
295
296 ViewThemeItem::ViewThemeItem(ViewTheme *popup, const char *text)
297  : BC_MenuItem(text)
298 {
299         this->popup = popup;
300 }
301
302 int ViewThemeItem::handle_event()
303 {
304         popup->set_text(get_text());
305         strcpy(popup->pwindow->thread->preferences->theme, get_text());
306         popup->handle_event();
307         return 1;
308 }
309
310
311 ViewPluginIcons::ViewPluginIcons(int x, int y, PreferencesWindow *pwindow)
312  : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->plugin_icons, 1)
313 {
314         this->pwindow = pwindow;
315 }
316 ViewPluginIcons::~ViewPluginIcons()
317 {
318 }
319
320 void ViewPluginIcons::create_objects()
321 {
322         add_item(new ViewPluginIconItem(this, DEFAULT_PICON));
323         FileSystem fs;
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));
334         }
335 }
336
337 int ViewPluginIcons::handle_event()
338 {
339         return 1;
340 }
341
342 ViewPluginIconItem::ViewPluginIconItem(ViewPluginIcons *popup, const char *text)
343  : BC_MenuItem(text)
344 {
345         this->popup = popup;
346 }
347
348 int ViewPluginIconItem::handle_event()
349 {
350         popup->set_text(get_text());
351         strcpy(popup->pwindow->thread->preferences->plugin_icons, get_text());
352         popup->handle_event();
353         return 1;
354 }
355
356
357 ViewThumbnails::ViewThumbnails(int x,
358         int y,
359         PreferencesWindow *pwindow)
360  : BC_CheckBox(x,
361         y,
362         pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
363 {
364         this->pwindow = pwindow;
365 }
366
367 int ViewThumbnails::handle_event()
368 {
369         pwindow->thread->preferences->use_thumbnails = get_value();
370         return 1;
371 }
372
373
374
375 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
376  : BC_CheckBox(x,
377         y,
378         pwindow->thread->preferences->use_tipwindow,
379         _("Show tip of the day"))
380 {
381         this->pwindow = pwindow;
382 }
383 int UseTipWindow::handle_event()
384 {
385         pwindow->thread->preferences->use_tipwindow = get_value();
386         return 1;
387 }
388
389
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"))
393 {
394         this->pwindow = pwindow;
395 }
396
397 int UseWarnIndecies::handle_event()
398 {
399         pwindow->thread->preferences->warn_indexes = get_value();
400         return 1;
401 }
402
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"))
406 {
407         this->pwindow = pwindow;
408 }
409
410 int UseWarnVersion::handle_event()
411 {
412         pwindow->thread->preferences->warn_version = get_value();
413         return 1;
414 }
415
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"))
419 {
420         this->pwindow = pwindow;
421 }
422
423 int BD_WarnRoot::handle_event()
424 {
425         pwindow->thread->preferences->bd_warn_root = get_value();
426         return 1;
427 }
428
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"))
432 {
433         this->pwindow = pwindow;
434 }
435
436 int PopupMenuBtnup::handle_event()
437 {
438         pwindow->thread->preferences->popupmenu_btnup = get_value();
439         return 1;
440 }
441
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"))
445 {
446         this->pwindow = pwindow;
447 }
448
449 int ActivateFocusPolicy::handle_event()
450 {
451         if( get_value() )
452                 pwindow->thread->preferences->textbox_focus_policy |= CLICK_ACTIVATE;
453         else
454                 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_ACTIVATE;
455         return 1;
456 }
457
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"))
461 {
462         this->pwindow = pwindow;
463 }
464
465 int DeactivateFocusPolicy::handle_event()
466 {
467         if( get_value() )
468                 pwindow->thread->preferences->textbox_focus_policy |= CLICK_DEACTIVATE;
469         else
470                 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_DEACTIVATE;
471         return 1;
472 }
473
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"))
477 {
478         this->pwindow = pwindow;
479 }
480
481 int ForwardRenderDisplacement::handle_event()
482 {
483         pwindow->thread->preferences->forward_render_displacement = get_value();
484         return 1;
485 }
486