31729d576569edf7126b65acfa93ddd52096e75d
[goodguy/cinelerra.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 AppearancePrefs::AppearancePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
37  : PreferencesDialog(mwindow, pwindow)
38 {
39         hms = 0;
40         hmsf = 0;
41         timecode = 0;
42         samples = 0;
43         frames = 0;
44         hex = 0;
45         feet = 0;
46         layout_scale = 0;
47         thumbnails = 0;
48         thumbnail_size = 0;
49         vicon_size = 0;
50 }
51
52 AppearancePrefs::~AppearancePrefs()
53 {
54         delete hms;
55         delete hmsf;
56         delete timecode;
57         delete samples;
58         delete frames;
59         delete hex;
60         delete feet;
61         delete layout_scale;
62         delete thumbnails;
63         delete thumbnail_size;
64         delete vicon_size;
65 }
66
67
68 void AppearancePrefs::create_objects()
69 {
70         int xs5 = xS(5), xs10 = xS(10), xs30 = xS(30);
71         int ys5 = yS(5), ys10 = yS(10), ys15 = yS(15);
72         int ys20 = yS(20), ys35 = yS(35);
73         BC_Resources *resources = BC_WindowBase::get_resources();
74         int margin = mwindow->theme->widget_border;
75         char string[BCTEXTLEN];
76         int x0 = mwindow->theme->preferencesoptions_x;
77         int y0 = mwindow->theme->preferencesoptions_y;
78         int x = x0, y = y0, x1 = x + xS(100);
79
80         BC_Title *title;
81         add_subwindow(title = new BC_Title(x, y, _("Layout:"), LARGEFONT,
82                 resources->text_default));
83         y += title->get_h() + ys10;
84         int y1 = y;
85
86         ViewTheme *theme;
87         add_subwindow(new BC_Title(x, y, _("Theme:")));
88         add_subwindow(theme = new ViewTheme(x1, y, pwindow));
89         theme->create_objects();
90         y += theme->get_h() + ys5;
91
92         x = x0;
93         ViewPluginIcons *plugin_icons;
94         add_subwindow(new BC_Title(x, y, _("Plugin Icons:")));
95         add_subwindow(plugin_icons = new ViewPluginIcons(x1, y, pwindow));
96         plugin_icons->create_objects();
97         y += plugin_icons->get_h() + ys10;
98         add_subwindow(new BC_Title(x, y, _("Language:")));
99         LayoutLocale *layout_locale;
100         add_subwindow(layout_locale = new LayoutLocale(x1, y, pwindow));
101         layout_locale->create_objects();
102         y += layout_locale->get_h() + ys15;
103         x1 = get_w()/2;
104
105         int x2 = x1 + xS(160), y2 = y;
106         y = y1;
107
108         add_subwindow(new BC_Title(x1, y, _("Layout Scale:")));
109         layout_scale = new ViewLayoutScale(pwindow, this, x2, y);
110         layout_scale->create_objects();
111         y += layout_scale->get_h() + ys5;
112         add_subwindow(new BC_Title(x1, y, _("View thumbnail size:")));
113         thumbnail_size = new ViewThumbnailSize(pwindow, this, x2, y);
114         thumbnail_size->create_objects();
115         y += thumbnail_size->get_h() + ys5;
116         add_subwindow(new BC_Title(x1, y, _("Vicon quality:")));
117         vicon_size = new ViewViconSize(pwindow, this, x2, y);
118         vicon_size->create_objects();
119         y += vicon_size->get_h() + ys5;
120         add_subwindow(new BC_Title(x1, y, _("Vicon color mode:")));
121         add_subwindow(vicon_color_mode = new ViewViconColorMode(pwindow, x2, y));
122         vicon_color_mode->create_objects();
123         y += vicon_color_mode->get_h() + ys5;
124         y = bmax(y, y2);        
125         y += ys10;
126         add_subwindow(new BC_Bar(xs5, y, get_w() - xs10));
127         y += ys15;
128
129         y1 = y;
130         add_subwindow(title = new BC_Title(x, y, _("Time Format:"), LARGEFONT,
131                 resources->text_default));
132         y += title->get_h() + ys10;
133         add_subwindow(hms = new TimeFormatHMS(pwindow, this,
134                 pwindow->thread->edl->session->time_format == TIME_HMS,
135                 x, y));
136         y += ys20;
137         add_subwindow(hmsf = new TimeFormatHMSF(pwindow, this,
138                 pwindow->thread->edl->session->time_format == TIME_HMSF,
139                 x, y));
140         y += ys20;
141         add_subwindow(timecode = new TimeFormatTimecode(pwindow, this,
142                 pwindow->thread->edl->session->time_format == TIME_TIMECODE,
143                 x, y));
144         y += ys20;
145         add_subwindow(samples = new TimeFormatSamples(pwindow, this,
146                 pwindow->thread->edl->session->time_format == TIME_SAMPLES,
147                 x, y));
148         y += ys20;
149         add_subwindow(hex = new TimeFormatHex(pwindow, this,
150                 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX,
151                 x, y));
152         y += ys20;
153         add_subwindow(frames = new TimeFormatFrames(pwindow, this,
154                 pwindow->thread->edl->session->time_format == TIME_FRAMES,
155                 x, y));
156         y += ys20;
157         add_subwindow(feet = new TimeFormatFeet(pwindow, this,
158                 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES,
159                 x, y));
160         x += feet->get_w() + xS(15);
161         add_subwindow(title = new BC_Title(x, y, _("Frames per foot:")));
162         x += title->get_w() + margin;
163         sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
164         add_subwindow(new TimeFormatFeetSetting(pwindow,
165                 x, y - ys5,     string));
166         x = x0;
167         y += ys20;
168         add_subwindow(seconds = new TimeFormatSeconds(pwindow, this,
169                 pwindow->thread->edl->session->time_format == TIME_SECONDS,
170                 x, y));
171         y += ys35;
172         y2 = y;
173         
174         x = x1;  y = y1;
175         add_subwindow(new BC_Title(x, y, _("Color:"), LARGEFONT,
176                 resources->text_default));
177         y += ys35;
178         add_subwindow(title = new BC_Title(x, y, _("Highlighting Inversion color:")));
179         x += title->get_w() + margin;
180         char hex_color[BCSTRLEN];
181         sprintf(hex_color, "%06x", preferences->highlight_inverse);
182         add_subwindow(new HighlightInverseColor(pwindow, x, y, hex_color));
183         x2 = x;  x = x1;
184         y += ys35;
185         add_subwindow(title = new BC_Title(x, y, _("Composer BG Color:")));
186         int clr_color = pwindow->thread->edl->session->cwindow_clear_color;
187         add_subwindow(cwdw_bg_color = new Composer_BG_Color(pwindow,
188                 x2, y, xS(80), yS(24), clr_color));
189         draw_3d_border(x2-2,y-2, xS(80)+4,xS(24)+4, 1);
190         cwdw_bg_color->create_objects();
191         x2 += cwdw_bg_color->get_w();
192         y += ys35;
193
194         add_subwindow(title = new BC_Title(x1, y, _("YUV color space:")));
195         x = x2 - xS(120);
196         add_subwindow(yuv_color_space = new YuvColorSpace(x, y, pwindow));
197         yuv_color_space->create_objects();
198         y += yuv_color_space->get_h() + ys5;
199
200         add_subwindow(title = new BC_Title(x1, y, _("YUV color range:")));
201         x = x2 - xS(100);
202         add_subwindow(yuv_color_range = new YuvColorRange(x, y, pwindow));
203         yuv_color_range->create_objects();
204         y += yuv_color_range->get_h() + ys35;
205         if( y2 < y ) y2 = y;
206
207         add_subwindow(new BC_Bar(x0, y2, get_w()-x0 - xs30));
208         y += ys35;
209
210         x = x0;  y1 = y;
211         add_subwindow(title = new BC_Title(x, y, _("Warnings:"), LARGEFONT,
212                 resources->text_default));
213         y += title->get_h() + ys10;
214         UseWarnIndecies *idx_warn = new UseWarnIndecies(pwindow, x, y);
215         add_subwindow(idx_warn);
216         y += idx_warn->get_h() + ys5;
217         BD_WarnRoot *bdwr_warn = new BD_WarnRoot(pwindow, x, y);
218         add_subwindow(bdwr_warn);
219         y += bdwr_warn->get_h() + ys5;
220         UseWarnFileRef *warn_ref = new UseWarnFileRef(pwindow, x, y);
221         add_subwindow(warn_ref);
222         y += warn_ref->get_h() + ys5;
223         
224         add_subwindow(new BC_Bar(x0, y, warn_ref->get_w()-x0 - xs30));
225         y += ys15;
226
227         add_subwindow(title = new BC_Title(x, y, _("Dangerous:"), LARGEFONT,
228                 resources->text_default));
229         y += title->get_h() + ys10;
230
231         
232         UseUnsafeGUI *unsafe_gui = new UseUnsafeGUI(pwindow, x, y);
233         add_subwindow(unsafe_gui);
234         y += unsafe_gui->get_h() + ys5;
235
236
237         x = get_w() / 3 + xs30;
238         y = y1;
239         add_subwindow(title = new BC_Title(x, y, _("Flags:"), LARGEFONT,
240                 resources->text_default));
241         y += title->get_h() + ys10;
242         y1 = y;
243         AutocolorAssets *autocolor_assets = new AutocolorAssets(pwindow, x, y);
244         add_subwindow(autocolor_assets);
245         y += autocolor_assets->get_h() + ys5;
246         PerpetualSession *perpetual = new PerpetualSession(x, y, pwindow);
247         add_subwindow(perpetual);
248         y += perpetual->get_h() + ys5;
249         RectifyAudioToggle *rect_toggle = new RectifyAudioToggle(x, y, pwindow);
250         add_subwindow(rect_toggle);
251         y += rect_toggle->get_h() + ys5;
252         CtrlToggle *ctrl_toggle = new CtrlToggle(x, y, pwindow);
253         add_subwindow(ctrl_toggle);
254         y += ctrl_toggle->get_h() + ys5;
255         ForwardRenderDisplacement *displacement = new ForwardRenderDisplacement(pwindow, x, y);
256         add_subwindow(displacement);
257         y += displacement->get_h() + ys5;
258         UseTipWindow *tip_win = new UseTipWindow(pwindow, x, y);
259         add_subwindow(tip_win);
260         y += tip_win->get_h() + ys5;
261
262         x = 2*get_w() / 3 - xs30;
263         y = y1;
264         add_subwindow(thumbnails = new ViewThumbnails(x, y, pwindow));
265         y += thumbnails->get_h() + ys5;
266         PopupMenuBtnup *pop_win = new PopupMenuBtnup(pwindow, x, y);
267         add_subwindow(pop_win);
268         y += pop_win->get_h() + ys5;
269         GrabFocusPolicy *grab_input_focus = new GrabFocusPolicy(pwindow, x, y);
270         add_subwindow(grab_input_focus);
271         y += grab_input_focus->get_h() + ys5;
272         ActivateFocusPolicy *focus_activate = new ActivateFocusPolicy(pwindow, x, y);
273         add_subwindow(focus_activate);
274         y += focus_activate->get_h() + ys5;
275         DeactivateFocusPolicy *focus_deactivate = new DeactivateFocusPolicy(pwindow, x, y);
276         add_subwindow(focus_deactivate);
277         y += focus_deactivate->get_h() + ys5;
278         AutoRotate *auto_rotate = new AutoRotate(pwindow, x, y);
279         add_subwindow(auto_rotate);
280         y += auto_rotate->get_h() + ys5;
281 }
282
283 int AppearancePrefs::update(int new_value)
284 {
285         pwindow->thread->redraw_times = 1;
286         pwindow->thread->edl->session->time_format = new_value;
287         hms->update(new_value == TIME_HMS);
288         hmsf->update(new_value == TIME_HMSF);
289         timecode->update(new_value == TIME_TIMECODE);
290         samples->update(new_value == TIME_SAMPLES);
291         hex->update(new_value == TIME_SAMPLES_HEX);
292         frames->update(new_value == TIME_FRAMES);
293         feet->update(new_value == TIME_FEET_FRAMES);
294         seconds->update(new_value == TIME_SECONDS);
295         return 0;
296 }
297
298
299 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
300  : BC_Radial(x, y, value, TIME_HMS_TEXT)
301 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
302
303 int TimeFormatHMS::handle_event()
304 {
305         tfwindow->update(TIME_HMS);
306         return 1;
307 }
308
309 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
310  : BC_Radial(x, y, value, TIME_HMSF_TEXT)
311 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
312
313 int TimeFormatHMSF::handle_event()
314 {
315         tfwindow->update(TIME_HMSF);
316         return 1;
317 }
318
319 TimeFormatTimecode::TimeFormatTimecode(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
320  : BC_Radial(x, y, value, TIME_TIMECODE_TEXT)
321 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
322
323 int TimeFormatTimecode::handle_event()
324 {
325         tfwindow->update(TIME_TIMECODE);
326         return 1;
327 }
328
329 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
330  : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
331 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
332
333 int TimeFormatSamples::handle_event()
334 {
335         tfwindow->update(TIME_SAMPLES);
336         return 1;
337 }
338
339 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
340  : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
341 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
342
343 int TimeFormatFrames::handle_event()
344 {
345         tfwindow->update(TIME_FRAMES);
346         return 1;
347 }
348
349 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
350  : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
351 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
352
353 int TimeFormatHex::handle_event()
354 {
355         tfwindow->update(TIME_SAMPLES_HEX);
356         return 1;
357 }
358
359 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
360  : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
361 {
362         this->pwindow = pwindow;
363         this->tfwindow = tfwindow;
364 }
365
366 int TimeFormatSeconds::handle_event()
367 {
368         tfwindow->update(TIME_SECONDS);
369         return 1;
370 }
371
372 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
373  : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
374 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
375
376 int TimeFormatFeet::handle_event()
377 {
378         tfwindow->update(TIME_FEET_FRAMES);
379         return 1;
380 }
381
382 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
383  : BC_TextBox(x, y, xS(90), 1, string)
384 { this->pwindow = pwindow; }
385
386 int TimeFormatFeetSetting::handle_event()
387 {
388         pwindow->thread->edl->session->frames_per_foot = atof(get_text());
389         if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
390         return 0;
391 }
392
393
394 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
395  : BC_PopupMenu(x, y, xS(200), pwindow->thread->preferences->theme, 1)
396 {
397         this->pwindow = pwindow;
398 }
399 ViewTheme::~ViewTheme()
400 {
401 }
402
403 void ViewTheme::create_objects()
404 {
405         ArrayList<PluginServer*> themes;
406         MWindow::search_plugindb(0, 0, 0, 0, 1, themes);
407
408         for(int i = 0; i < themes.total; i++) {
409                 add_item(new ViewThemeItem(this, themes.values[i]->title));
410         }
411 }
412
413 int ViewTheme::handle_event()
414 {
415         return 1;
416 }
417
418 ViewThemeItem::ViewThemeItem(ViewTheme *popup, const char *text)
419  : BC_MenuItem(text)
420 {
421         this->popup = popup;
422 }
423
424 int ViewThemeItem::handle_event()
425 {
426         popup->set_text(get_text());
427         strcpy(popup->pwindow->thread->preferences->theme, get_text());
428         popup->handle_event();
429         return 1;
430 }
431
432
433 ViewPluginIcons::ViewPluginIcons(int x, int y, PreferencesWindow *pwindow)
434  : BC_PopupMenu(x, y, xS(200), pwindow->thread->preferences->plugin_icons, 1)
435 {
436         this->pwindow = pwindow;
437 }
438 ViewPluginIcons::~ViewPluginIcons()
439 {
440 }
441
442 void ViewPluginIcons::create_objects()
443 {
444         add_item(new ViewPluginIconItem(this, DEFAULT_PICON));
445         FileSystem fs;
446         const char *plugin_path = File::get_plugin_path();
447         char picon_path[BCTEXTLEN];
448         snprintf(picon_path,sizeof(picon_path)-1,"%s/picon", plugin_path);
449         if( fs.update(picon_path) ) return;
450         for( int i=0; i<fs.dir_list.total; ++i ) {
451                 char *fs_path = fs.dir_list[i]->path;
452                 if( !fs.is_dir(fs_path) ) continue;
453                 char *cp = strrchr(fs_path,'/');
454                 cp = !cp ? fs_path : cp+1;
455                 if( !strcmp(cp,DEFAULT_PICON) ) continue;
456                 add_item(new ViewPluginIconItem(this, cp));
457         }
458 }
459
460 int ViewPluginIcons::handle_event()
461 {
462         return 1;
463 }
464
465 ViewPluginIconItem::ViewPluginIconItem(ViewPluginIcons *popup, const char *text)
466  : BC_MenuItem(text)
467 {
468         this->popup = popup;
469 }
470
471 int ViewPluginIconItem::handle_event()
472 {
473         popup->set_text(get_text());
474         strcpy(popup->pwindow->thread->preferences->plugin_icons, get_text());
475         popup->handle_event();
476         return 1;
477 }
478
479 LayoutLocale::LayoutLocale(int x, int y, PreferencesWindow *pwindow)
480  : BC_PopupMenu(x, y, xS(200), pwindow->thread->preferences->locale, 1)
481 {
482         this->pwindow = pwindow;
483 }
484 LayoutLocale::~LayoutLocale()
485 {
486 }
487
488 const char *LayoutLocale::locale_list[] = { LOCALE_LIST, 0 };
489
490 void LayoutLocale::create_objects()
491 {
492         for( const char *tp, **lp=locale_list; (tp=*lp)!=0; ++lp )
493                 add_item(new LayoutLocaleItem(this, tp));
494 }
495
496 int LayoutLocale::handle_event()
497 {
498         return 1;
499 }
500
501 LayoutLocaleItem::LayoutLocaleItem(LayoutLocale *popup, const char *text)
502  : BC_MenuItem(text)
503 {
504         this->popup = popup;
505 }
506
507 int LayoutLocaleItem::handle_event()
508 {
509         popup->set_text(get_text());
510         strcpy(popup->pwindow->thread->preferences->locale, get_text());
511         popup->handle_event();
512         return 1;
513 }
514
515 ViewLayoutScale::ViewLayoutScale(PreferencesWindow *pwindow,
516                 AppearancePrefs *aprefs, int x, int y)
517  : BC_TumbleTextBox(aprefs,
518         pwindow->thread->preferences->layout_scale,
519         0.f, 10.f, x, y, xS(80), 2)
520 {
521         this->pwindow = pwindow;
522         this->aprefs = aprefs;
523         set_increment(0.1);
524 }
525
526 int ViewLayoutScale::handle_event()
527 {
528         float v = atof(get_text());
529         pwindow->thread->preferences->layout_scale = v;
530         return 1;
531 }
532
533
534 ViewThumbnails::ViewThumbnails(int x,
535         int y,
536         PreferencesWindow *pwindow)
537  : BC_CheckBox(x,
538         y,
539         pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
540 {
541         this->pwindow = pwindow;
542 }
543
544 int ViewThumbnails::handle_event()
545 {
546         pwindow->thread->preferences->use_thumbnails = get_value();
547         return 1;
548 }
549
550
551 ViewThumbnailSize::ViewThumbnailSize(PreferencesWindow *pwindow,
552                 AppearancePrefs *aprefs, int x, int y)
553  : BC_TumbleTextBox(aprefs,
554         pwindow->thread->preferences->awindow_picon_h,
555         16, 512, x, y, xS(80))
556
557 {
558         this->pwindow = pwindow;
559         this->aprefs = aprefs;
560 }
561
562 int ViewThumbnailSize::handle_event()
563 {
564         int v = atoi(get_text());
565         bclamp(v, 16,512);
566         pwindow->thread->preferences->awindow_picon_h = v;
567         return 1;
568 }
569
570 ViewViconSize::ViewViconSize(PreferencesWindow *pwindow,
571                 AppearancePrefs *aprefs, int x, int y)
572  : BC_TumbleTextBox(aprefs,
573         pwindow->thread->preferences->vicon_size,
574         16, 512, x, y, xS(80))
575
576 {
577         this->pwindow = pwindow;
578         this->aprefs = aprefs;
579 }
580
581 int ViewViconSize::handle_event()
582 {
583         int v = atoi(get_text());
584         bclamp(v, 16,512);
585         pwindow->thread->preferences->vicon_size = v;
586         return 1;
587 }
588
589 ViewViconColorMode::ViewViconColorMode(PreferencesWindow *pwindow, int x, int y)
590  : BC_PopupMenu(x, y, xS(100),
591         _(vicon_color_modes[pwindow->thread->preferences->vicon_color_mode]), 1)
592 {
593         this->pwindow = pwindow;
594 }
595 ViewViconColorMode::~ViewViconColorMode()
596 {
597 }
598
599 const char *ViewViconColorMode::vicon_color_modes[] = {
600         N_("Low"),
601         N_("Med"),
602         N_("High"),
603 };
604
605 void ViewViconColorMode::create_objects()
606 {
607         for( int id=0,nid=sizeof(vicon_color_modes)/sizeof(vicon_color_modes[0]); id<nid; ++id )
608                 add_item(new ViewViconColorModeItem(this, _(vicon_color_modes[id]), id));
609         handle_event();
610 }
611
612 int ViewViconColorMode::handle_event()
613 {
614         set_text(_(vicon_color_modes[pwindow->thread->preferences->vicon_color_mode]));
615         return 1;
616 }
617
618 ViewViconColorModeItem::ViewViconColorModeItem(ViewViconColorMode *popup, const char *text, int id)
619  : BC_MenuItem(text)
620 {
621         this->popup = popup;
622         this->id = id;
623 }
624
625 int ViewViconColorModeItem::handle_event()
626 {
627         popup->set_text(get_text());
628         popup->pwindow->thread->preferences->vicon_color_mode = id;
629         return popup->handle_event();
630 }
631
632
633 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
634  : BC_CheckBox(x,
635         y,
636         pwindow->thread->preferences->use_tipwindow,
637         _("Show tip of the day"))
638 {
639         this->pwindow = pwindow;
640 }
641 int UseTipWindow::handle_event()
642 {
643         pwindow->thread->preferences->use_tipwindow = get_value();
644         return 1;
645 }
646
647
648 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
649  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_indexes,
650         _("ffmpeg probe warns rebuild indexes"))
651 {
652         this->pwindow = pwindow;
653 }
654
655 int UseWarnIndecies::handle_event()
656 {
657         pwindow->thread->preferences->warn_indexes = get_value();
658         return 1;
659 }
660
661 UseUnsafeGUI::UseUnsafeGUI(PreferencesWindow *pwindow, int x, int y)
662  : BC_CheckBox(x, y, pwindow->thread->preferences->unsafe_gui,
663         _("Unsafe GUI in batchrender"))
664 {
665         this->pwindow = pwindow;
666 }
667
668 int UseUnsafeGUI::handle_event()
669 {
670         pwindow->thread->preferences->unsafe_gui = get_value();
671         return 1;
672 }
673
674 BD_WarnRoot::BD_WarnRoot(PreferencesWindow *pwindow, int x, int y)
675  : BC_CheckBox(x, y, pwindow->thread->preferences->bd_warn_root,
676         _("Create Bluray warns if not root"))
677 {
678         this->pwindow = pwindow;
679 }
680
681 int BD_WarnRoot::handle_event()
682 {
683         pwindow->thread->preferences->bd_warn_root = get_value();
684         return 1;
685 }
686
687 UseWarnFileRef::UseWarnFileRef(PreferencesWindow *pwindow, int x, int y)
688  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_fileref,
689         _("Warn on creating file references"))
690 {
691         this->pwindow = pwindow;
692 }
693
694 int UseWarnFileRef::handle_event()
695 {
696         pwindow->thread->preferences->warn_fileref = get_value();
697         return 1;
698 }
699
700
701 PopupMenuBtnup::PopupMenuBtnup(PreferencesWindow *pwindow, int x, int y)
702  : BC_CheckBox(x, y, pwindow->thread->preferences->popupmenu_btnup,
703         _("Popups activate on button up"))
704 {
705         this->pwindow = pwindow;
706 }
707
708 int PopupMenuBtnup::handle_event()
709 {
710         pwindow->thread->preferences->popupmenu_btnup = get_value();
711         return 1;
712 }
713
714 GrabFocusPolicy::GrabFocusPolicy(PreferencesWindow *pwindow, int x, int y)
715  : BC_CheckBox(x, y, (pwindow->thread->preferences->grab_input_focus) != 0,
716         _("Set Input Focus when window entered"))
717 {
718         this->pwindow = pwindow;
719 }
720
721 int GrabFocusPolicy::handle_event()
722 {
723         pwindow->thread->preferences->grab_input_focus = get_value();
724         return 1;
725 }
726
727 ActivateFocusPolicy::ActivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
728  : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_ACTIVATE) != 0,
729         _("Click to activate text focus"))
730 {
731         this->pwindow = pwindow;
732 }
733
734 int ActivateFocusPolicy::handle_event()
735 {
736         if( get_value() )
737                 pwindow->thread->preferences->textbox_focus_policy |= CLICK_ACTIVATE;
738         else
739                 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_ACTIVATE;
740         return 1;
741 }
742
743 DeactivateFocusPolicy::DeactivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
744  : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_DEACTIVATE) != 0,
745         _("Click to deactivate text focus"))
746 {
747         this->pwindow = pwindow;
748 }
749
750 int DeactivateFocusPolicy::handle_event()
751 {
752         if( get_value() )
753                 pwindow->thread->preferences->textbox_focus_policy |= CLICK_DEACTIVATE;
754         else
755                 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_DEACTIVATE;
756         return 1;
757 }
758
759 AutoRotate::AutoRotate(PreferencesWindow *pwindow, int x, int y)
760  : BC_CheckBox(x, y, pwindow->thread->preferences->auto_rotate != 0,
761         _("Auto rotate ffmpeg media"))
762 {
763         this->pwindow = pwindow;
764         set_tooltip(_("Automatically rotates media if legal rotation metadata included."));
765 }
766
767 int AutoRotate::handle_event()
768 {
769         pwindow->thread->preferences->auto_rotate = get_value();
770         return 1;
771 }
772
773 ForwardRenderDisplacement::ForwardRenderDisplacement(PreferencesWindow *pwindow, int x, int y)
774  : BC_CheckBox(x, y, pwindow->thread->preferences->forward_render_displacement,
775         _("Always show next frame"))
776 {
777         this->pwindow = pwindow;
778 }
779
780 int ForwardRenderDisplacement::handle_event()
781 {
782         pwindow->thread->preferences->forward_render_displacement = get_value();
783         return 1;
784 }
785
786 AutocolorAssets::AutocolorAssets(PreferencesWindow *pwindow, int x, int y)
787  : BC_CheckBox(x, y, pwindow->thread->preferences->autocolor_assets,
788         _("Autocolor assets"))
789 {
790         this->pwindow = pwindow;
791         set_tooltip(_("Displays automatically generated color overlay for the \n edits on the timeline that belong to the same media file."));
792 }
793
794 int AutocolorAssets::handle_event()
795 {
796         pwindow->thread->preferences->autocolor_assets = get_value();
797         return 1;
798 }
799
800 HighlightInverseColor::HighlightInverseColor(PreferencesWindow *pwindow, int x, int y, const char *hex)
801  : BC_TextBox(x, y, xS(80), 1, hex)
802 {
803         this->pwindow = pwindow;
804 }
805
806 int HighlightInverseColor::handle_event()
807 {
808         int inverse_color = strtoul(get_text(),0,16);
809         if( (inverse_color &= 0xffffff) == 0 ) {
810                 inverse_color = 0xffffff;
811                 char string[BCSTRLEN];
812                 sprintf(string,"%06x", inverse_color);
813                 update(string);
814         }
815         pwindow->thread->preferences->highlight_inverse = inverse_color;
816         return 1;
817 }
818
819
820 const char *YuvColorSpace::color_space[] = {
821         N_("BT601"), // COLOR_SPACE_BT601
822         N_("BT709"), // COLOR_SPACE_BT709
823         N_("BT2020"), // COLOR_SPACE_BT2020
824 };
825
826 YuvColorSpace::YuvColorSpace(int x, int y, PreferencesWindow *pwindow)
827  : BC_PopupMenu(x, y, xS(120),
828         _(color_space[pwindow->thread->preferences->yuv_color_space]), 1)
829 {
830         this->pwindow = pwindow;
831 }
832 YuvColorSpace::~YuvColorSpace()
833 {
834 }
835
836 void YuvColorSpace::create_objects()
837 {
838         for( int id=0,nid=sizeof(color_space)/sizeof(color_space[0]); id<nid; ++id )
839                 add_item(new YuvColorSpaceItem(this, _(color_space[id]), id));
840         handle_event();
841 }
842
843 int YuvColorSpace::handle_event()
844 {
845         set_text(_(color_space[pwindow->thread->preferences->yuv_color_space]));
846         return 1;
847 }
848
849 YuvColorSpaceItem::YuvColorSpaceItem(YuvColorSpace *popup, const char *text, int id)
850  : BC_MenuItem(text)
851 {
852         this->popup = popup;
853         this->id = id;
854 }
855
856 int YuvColorSpaceItem::handle_event()
857 {
858         popup->set_text(get_text());
859         popup->pwindow->thread->preferences->yuv_color_space = id;
860         return popup->handle_event();
861 }
862
863
864 const char *YuvColorRange::color_range[] = {
865         N_("JPEG"), // COLOR_RANGE_JPEG
866         N_("MPEG"), // COLOR_RANGE_MPEG
867 };
868
869 YuvColorRange::YuvColorRange(int x, int y, PreferencesWindow *pwindow)
870  : BC_PopupMenu(x, y, xS(100),
871         _(color_range[pwindow->thread->preferences->yuv_color_range]), 1)
872 {
873         this->pwindow = pwindow;
874 }
875 YuvColorRange::~YuvColorRange()
876 {
877 }
878
879 void YuvColorRange::create_objects()
880 {
881         for( int id=0,nid=sizeof(color_range)/sizeof(color_range[0]); id<nid; ++id )
882                 add_item(new YuvColorRangeItem(this, _(color_range[id]), id));
883         handle_event();
884 }
885
886 int YuvColorRange::handle_event()
887 {
888         set_text(color_range[pwindow->thread->preferences->yuv_color_range]);
889         return 1;
890 }
891
892 YuvColorRangeItem::YuvColorRangeItem(YuvColorRange *popup, const char *text, int id)
893  : BC_MenuItem(text)
894 {
895         this->popup = popup;
896         this->id = id;
897 }
898
899 int YuvColorRangeItem::handle_event()
900 {
901         popup->set_text(get_text());
902         popup->pwindow->thread->preferences->yuv_color_range = id;
903         return popup->handle_event();
904 }
905
906 PerpetualSession::PerpetualSession(int x, int y, PreferencesWindow *pwindow)
907  : BC_CheckBox(x, y,
908         pwindow->thread->preferences->perpetual_session, _("Perpetual session"))
909 {
910         this->pwindow = pwindow;
911         set_tooltip(_("Resume previous session on startup with undo/redo stack saved between sessions. \n On startup, previous project is loaded as if there was no stoppage."));
912 }
913
914 int PerpetualSession::handle_event()
915 {
916         pwindow->thread->preferences->perpetual_session = get_value();
917         return 1;
918 }
919
920 CtrlToggle::CtrlToggle(int x, int y, PreferencesWindow *pwindow)
921  : BC_CheckBox(x, y,
922         pwindow->thread->preferences->ctrl_toggle, _("Clears before toggle"))
923 {
924         this->pwindow = pwindow;
925         set_tooltip(_("Drag and Drop editing - when using LMB on edit,\n clears all selected edits except this one."));
926 }
927
928 int CtrlToggle::handle_event()
929 {
930         pwindow->thread->preferences->ctrl_toggle = get_value();
931         return 1;
932 }
933
934 RectifyAudioToggle::RectifyAudioToggle(int x, int y, PreferencesWindow *pwindow)
935  : BC_CheckBox(x, y,
936         pwindow->thread->preferences->rectify_audio, _("Timeline Rectify Audio"))
937 {
938         this->pwindow = pwindow;
939         set_tooltip(_("Displays rectified audio showing only positive half of the waveform \n resulting in waveform stretched more over the height of the track."));
940 }
941
942 int RectifyAudioToggle::handle_event()
943 {
944         pwindow->thread->preferences->rectify_audio = get_value();
945         return 1;
946 }
947
948 Composer_BG_Color::Composer_BG_Color(PreferencesWindow *pwindow,
949                 int x, int y, int w, int h, int color)
950  : ColorBoxButton(_("Composer BG color"), x, y, w, h, color, -1, 1)
951 {
952         this->pwindow = pwindow;
953 }
954
955 Composer_BG_Color::~Composer_BG_Color()
956 {
957 }
958
959 void Composer_BG_Color::handle_done_event(int result)
960 {
961         if( result ) {
962                 pwindow->lock_window("Composer_BG_Color::handle_done_event");
963                 update_gui(orig_color, orig_alpha);
964                 pwindow->unlock_window();
965                 handle_new_color(orig_color, orig_alpha);
966         }
967 }
968
969 int Composer_BG_Color::handle_new_color(int color, int alpha)
970 {
971         pwindow->thread->edl->session->cwindow_clear_color = color;
972         return 1;
973 }
974