raise vwdw stacking tweak, drag handle for transitions, cleanup histogram plugin...
[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         UseWarnVersion *ver_warn = new UseWarnVersion(pwindow, x, y);
218         add_subwindow(ver_warn);
219         y += ver_warn->get_h() + ys5;
220         BD_WarnRoot *bdwr_warn = new BD_WarnRoot(pwindow, x, y);
221         add_subwindow(bdwr_warn);
222         y += bdwr_warn->get_h() + ys5;
223         UseWarnFileRef *warn_ref = new UseWarnFileRef(pwindow, x, y);
224         add_subwindow(warn_ref);
225         y += warn_ref->get_h() + ys5;
226
227         x = get_w() / 3 + xs30;
228         y = y1;
229         add_subwindow(title = new BC_Title(x, y, _("Flags:"), LARGEFONT,
230                 resources->text_default));
231         y += title->get_h() + ys10;
232         y1 = y;
233         AutocolorAssets *autocolor_assets = new AutocolorAssets(pwindow, x, y);
234         add_subwindow(autocolor_assets);
235         y += autocolor_assets->get_h() + ys5;
236         PerpetualSession *perpetual = new PerpetualSession(x, y, pwindow);
237         add_subwindow(perpetual);
238         y += perpetual->get_h() + ys5;
239         RectifyAudioToggle *rect_toggle = new RectifyAudioToggle(x, y, pwindow);
240         add_subwindow(rect_toggle);
241         y += rect_toggle->get_h() + ys5;
242         CtrlToggle *ctrl_toggle = new CtrlToggle(x, y, pwindow);
243         add_subwindow(ctrl_toggle);
244         y += ctrl_toggle->get_h() + ys5;
245         ForwardRenderDisplacement *displacement = new ForwardRenderDisplacement(pwindow, x, y);
246         add_subwindow(displacement);
247         y += displacement->get_h() + ys5;
248         UseTipWindow *tip_win = new UseTipWindow(pwindow, x, y);
249         add_subwindow(tip_win);
250         y += tip_win->get_h() + ys5;
251
252         x = 2*get_w() / 3 - xs30;
253         y = y1;
254         add_subwindow(thumbnails = new ViewThumbnails(x, y, pwindow));
255         y += thumbnails->get_h() + ys5;
256         PopupMenuBtnup *pop_win = new PopupMenuBtnup(pwindow, x, y);
257         add_subwindow(pop_win);
258         y += pop_win->get_h() + ys5;
259         GrabFocusPolicy *grab_input_focus = new GrabFocusPolicy(pwindow, x, y);
260         add_subwindow(grab_input_focus);
261         y += grab_input_focus->get_h() + ys5;
262         ActivateFocusPolicy *focus_activate = new ActivateFocusPolicy(pwindow, x, y);
263         add_subwindow(focus_activate);
264         y += focus_activate->get_h() + ys5;
265         DeactivateFocusPolicy *focus_deactivate = new DeactivateFocusPolicy(pwindow, x, y);
266         add_subwindow(focus_deactivate);
267         y += focus_deactivate->get_h() + ys5;
268         AutoRotate *auto_rotate = new AutoRotate(pwindow, x, y);
269         add_subwindow(auto_rotate);
270         y += auto_rotate->get_h() + ys5;
271 }
272
273 int AppearancePrefs::update(int new_value)
274 {
275         pwindow->thread->redraw_times = 1;
276         pwindow->thread->edl->session->time_format = new_value;
277         hms->update(new_value == TIME_HMS);
278         hmsf->update(new_value == TIME_HMSF);
279         timecode->update(new_value == TIME_TIMECODE);
280         samples->update(new_value == TIME_SAMPLES);
281         hex->update(new_value == TIME_SAMPLES_HEX);
282         frames->update(new_value == TIME_FRAMES);
283         feet->update(new_value == TIME_FEET_FRAMES);
284         seconds->update(new_value == TIME_SECONDS);
285         return 0;
286 }
287
288
289 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
290  : BC_Radial(x, y, value, TIME_HMS_TEXT)
291 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
292
293 int TimeFormatHMS::handle_event()
294 {
295         tfwindow->update(TIME_HMS);
296         return 1;
297 }
298
299 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
300  : BC_Radial(x, y, value, TIME_HMSF_TEXT)
301 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
302
303 int TimeFormatHMSF::handle_event()
304 {
305         tfwindow->update(TIME_HMSF);
306         return 1;
307 }
308
309 TimeFormatTimecode::TimeFormatTimecode(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
310  : BC_Radial(x, y, value, TIME_TIMECODE_TEXT)
311 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
312
313 int TimeFormatTimecode::handle_event()
314 {
315         tfwindow->update(TIME_TIMECODE);
316         return 1;
317 }
318
319 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
320  : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
321 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
322
323 int TimeFormatSamples::handle_event()
324 {
325         tfwindow->update(TIME_SAMPLES);
326         return 1;
327 }
328
329 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
330  : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
331 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
332
333 int TimeFormatFrames::handle_event()
334 {
335         tfwindow->update(TIME_FRAMES);
336         return 1;
337 }
338
339 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
340  : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
341 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
342
343 int TimeFormatHex::handle_event()
344 {
345         tfwindow->update(TIME_SAMPLES_HEX);
346         return 1;
347 }
348
349 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
350  : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
351 {
352         this->pwindow = pwindow;
353         this->tfwindow = tfwindow;
354 }
355
356 int TimeFormatSeconds::handle_event()
357 {
358         tfwindow->update(TIME_SECONDS);
359         return 1;
360 }
361
362 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
363  : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
364 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
365
366 int TimeFormatFeet::handle_event()
367 {
368         tfwindow->update(TIME_FEET_FRAMES);
369         return 1;
370 }
371
372 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
373  : BC_TextBox(x, y, xS(90), 1, string)
374 { this->pwindow = pwindow; }
375
376 int TimeFormatFeetSetting::handle_event()
377 {
378         pwindow->thread->edl->session->frames_per_foot = atof(get_text());
379         if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
380         return 0;
381 }
382
383
384 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
385  : BC_PopupMenu(x, y, xS(200), pwindow->thread->preferences->theme, 1)
386 {
387         this->pwindow = pwindow;
388 }
389 ViewTheme::~ViewTheme()
390 {
391 }
392
393 void ViewTheme::create_objects()
394 {
395         ArrayList<PluginServer*> themes;
396         MWindow::search_plugindb(0, 0, 0, 0, 1, themes);
397
398         for(int i = 0; i < themes.total; i++) {
399                 add_item(new ViewThemeItem(this, themes.values[i]->title));
400         }
401 }
402
403 int ViewTheme::handle_event()
404 {
405         return 1;
406 }
407
408 ViewThemeItem::ViewThemeItem(ViewTheme *popup, const char *text)
409  : BC_MenuItem(text)
410 {
411         this->popup = popup;
412 }
413
414 int ViewThemeItem::handle_event()
415 {
416         popup->set_text(get_text());
417         strcpy(popup->pwindow->thread->preferences->theme, get_text());
418         popup->handle_event();
419         return 1;
420 }
421
422
423 ViewPluginIcons::ViewPluginIcons(int x, int y, PreferencesWindow *pwindow)
424  : BC_PopupMenu(x, y, xS(200), pwindow->thread->preferences->plugin_icons, 1)
425 {
426         this->pwindow = pwindow;
427 }
428 ViewPluginIcons::~ViewPluginIcons()
429 {
430 }
431
432 void ViewPluginIcons::create_objects()
433 {
434         add_item(new ViewPluginIconItem(this, DEFAULT_PICON));
435         FileSystem fs;
436         const char *plugin_path = File::get_plugin_path();
437         char picon_path[BCTEXTLEN];
438         snprintf(picon_path,sizeof(picon_path)-1,"%s/picon", plugin_path);
439         if( fs.update(picon_path) ) return;
440         for( int i=0; i<fs.dir_list.total; ++i ) {
441                 char *fs_path = fs.dir_list[i]->path;
442                 if( !fs.is_dir(fs_path) ) continue;
443                 char *cp = strrchr(fs_path,'/');
444                 cp = !cp ? fs_path : cp+1;
445                 if( !strcmp(cp,DEFAULT_PICON) ) continue;
446                 add_item(new ViewPluginIconItem(this, cp));
447         }
448 }
449
450 int ViewPluginIcons::handle_event()
451 {
452         return 1;
453 }
454
455 ViewPluginIconItem::ViewPluginIconItem(ViewPluginIcons *popup, const char *text)
456  : BC_MenuItem(text)
457 {
458         this->popup = popup;
459 }
460
461 int ViewPluginIconItem::handle_event()
462 {
463         popup->set_text(get_text());
464         strcpy(popup->pwindow->thread->preferences->plugin_icons, get_text());
465         popup->handle_event();
466         return 1;
467 }
468
469 LayoutLocale::LayoutLocale(int x, int y, PreferencesWindow *pwindow)
470  : BC_PopupMenu(x, y, xS(200), pwindow->thread->preferences->locale, 1)
471 {
472         this->pwindow = pwindow;
473 }
474 LayoutLocale::~LayoutLocale()
475 {
476 }
477
478 const char *LayoutLocale::locale_list[] = { LOCALE_LIST, 0 };
479
480 void LayoutLocale::create_objects()
481 {
482         for( const char *tp, **lp=locale_list; (tp=*lp)!=0; ++lp )
483                 add_item(new LayoutLocaleItem(this, tp));
484 }
485
486 int LayoutLocale::handle_event()
487 {
488         return 1;
489 }
490
491 LayoutLocaleItem::LayoutLocaleItem(LayoutLocale *popup, const char *text)
492  : BC_MenuItem(text)
493 {
494         this->popup = popup;
495 }
496
497 int LayoutLocaleItem::handle_event()
498 {
499         popup->set_text(get_text());
500         strcpy(popup->pwindow->thread->preferences->locale, get_text());
501         popup->handle_event();
502         return 1;
503 }
504
505 ViewLayoutScale::ViewLayoutScale(PreferencesWindow *pwindow,
506                 AppearancePrefs *aprefs, int x, int y)
507  : BC_TumbleTextBox(aprefs,
508         pwindow->thread->preferences->layout_scale,
509         0.f, 10.f, x, y, xS(80), 2)
510 {
511         this->pwindow = pwindow;
512         this->aprefs = aprefs;
513         set_increment(0.1);
514 }
515
516 int ViewLayoutScale::handle_event()
517 {
518         float v = atof(get_text());
519         pwindow->thread->preferences->layout_scale = v;
520         return 1;
521 }
522
523
524 ViewThumbnails::ViewThumbnails(int x,
525         int y,
526         PreferencesWindow *pwindow)
527  : BC_CheckBox(x,
528         y,
529         pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
530 {
531         this->pwindow = pwindow;
532 }
533
534 int ViewThumbnails::handle_event()
535 {
536         pwindow->thread->preferences->use_thumbnails = get_value();
537         return 1;
538 }
539
540
541 ViewThumbnailSize::ViewThumbnailSize(PreferencesWindow *pwindow,
542                 AppearancePrefs *aprefs, int x, int y)
543  : BC_TumbleTextBox(aprefs,
544         pwindow->thread->preferences->awindow_picon_h,
545         16, 512, x, y, xS(80))
546
547 {
548         this->pwindow = pwindow;
549         this->aprefs = aprefs;
550 }
551
552 int ViewThumbnailSize::handle_event()
553 {
554         int v = atoi(get_text());
555         bclamp(v, 16,512);
556         pwindow->thread->preferences->awindow_picon_h = v;
557         return 1;
558 }
559
560 ViewViconSize::ViewViconSize(PreferencesWindow *pwindow,
561                 AppearancePrefs *aprefs, int x, int y)
562  : BC_TumbleTextBox(aprefs,
563         pwindow->thread->preferences->vicon_size,
564         16, 512, x, y, xS(80))
565
566 {
567         this->pwindow = pwindow;
568         this->aprefs = aprefs;
569 }
570
571 int ViewViconSize::handle_event()
572 {
573         int v = atoi(get_text());
574         bclamp(v, 16,512);
575         pwindow->thread->preferences->vicon_size = v;
576         return 1;
577 }
578
579 ViewViconColorMode::ViewViconColorMode(PreferencesWindow *pwindow, int x, int y)
580  : BC_PopupMenu(x, y, xS(100),
581         _(vicon_color_modes[pwindow->thread->preferences->vicon_color_mode]), 1)
582 {
583         this->pwindow = pwindow;
584 }
585 ViewViconColorMode::~ViewViconColorMode()
586 {
587 }
588
589 const char *ViewViconColorMode::vicon_color_modes[] = {
590         N_("Low"),
591         N_("Med"),
592         N_("High"),
593 };
594
595 void ViewViconColorMode::create_objects()
596 {
597         for( int id=0,nid=sizeof(vicon_color_modes)/sizeof(vicon_color_modes[0]); id<nid; ++id )
598                 add_item(new ViewViconColorModeItem(this, _(vicon_color_modes[id]), id));
599         handle_event();
600 }
601
602 int ViewViconColorMode::handle_event()
603 {
604         set_text(_(vicon_color_modes[pwindow->thread->preferences->vicon_color_mode]));
605         return 1;
606 }
607
608 ViewViconColorModeItem::ViewViconColorModeItem(ViewViconColorMode *popup, const char *text, int id)
609  : BC_MenuItem(text)
610 {
611         this->popup = popup;
612         this->id = id;
613 }
614
615 int ViewViconColorModeItem::handle_event()
616 {
617         popup->set_text(get_text());
618         popup->pwindow->thread->preferences->vicon_color_mode = id;
619         return popup->handle_event();
620 }
621
622
623 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
624  : BC_CheckBox(x,
625         y,
626         pwindow->thread->preferences->use_tipwindow,
627         _("Show tip of the day"))
628 {
629         this->pwindow = pwindow;
630 }
631 int UseTipWindow::handle_event()
632 {
633         pwindow->thread->preferences->use_tipwindow = get_value();
634         return 1;
635 }
636
637
638 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
639  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_indexes,
640         _("ffmpeg probe warns rebuild indexes"))
641 {
642         this->pwindow = pwindow;
643 }
644
645 int UseWarnIndecies::handle_event()
646 {
647         pwindow->thread->preferences->warn_indexes = get_value();
648         return 1;
649 }
650
651 UseWarnVersion::UseWarnVersion(PreferencesWindow *pwindow, int x, int y)
652  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_version,
653         _("EDL version warns if mismatched"))
654 {
655         this->pwindow = pwindow;
656 }
657
658 int UseWarnVersion::handle_event()
659 {
660         pwindow->thread->preferences->warn_version = get_value();
661         return 1;
662 }
663
664 BD_WarnRoot::BD_WarnRoot(PreferencesWindow *pwindow, int x, int y)
665  : BC_CheckBox(x, y, pwindow->thread->preferences->bd_warn_root,
666         _("Create Bluray warns if not root"))
667 {
668         this->pwindow = pwindow;
669 }
670
671 int BD_WarnRoot::handle_event()
672 {
673         pwindow->thread->preferences->bd_warn_root = get_value();
674         return 1;
675 }
676
677 UseWarnFileRef::UseWarnFileRef(PreferencesWindow *pwindow, int x, int y)
678  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_fileref,
679         _("Warn on creating file references"))
680 {
681         this->pwindow = pwindow;
682 }
683
684 int UseWarnFileRef::handle_event()
685 {
686         pwindow->thread->preferences->warn_fileref = get_value();
687         return 1;
688 }
689
690
691 PopupMenuBtnup::PopupMenuBtnup(PreferencesWindow *pwindow, int x, int y)
692  : BC_CheckBox(x, y, pwindow->thread->preferences->popupmenu_btnup,
693         _("Popups activate on button up"))
694 {
695         this->pwindow = pwindow;
696 }
697
698 int PopupMenuBtnup::handle_event()
699 {
700         pwindow->thread->preferences->popupmenu_btnup = get_value();
701         return 1;
702 }
703
704 GrabFocusPolicy::GrabFocusPolicy(PreferencesWindow *pwindow, int x, int y)
705  : BC_CheckBox(x, y, (pwindow->thread->preferences->grab_input_focus) != 0,
706         _("Set Input Focus when window entered"))
707 {
708         this->pwindow = pwindow;
709 }
710
711 int GrabFocusPolicy::handle_event()
712 {
713         pwindow->thread->preferences->grab_input_focus = get_value();
714         return 1;
715 }
716
717 ActivateFocusPolicy::ActivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
718  : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_ACTIVATE) != 0,
719         _("Click to activate text focus"))
720 {
721         this->pwindow = pwindow;
722 }
723
724 int ActivateFocusPolicy::handle_event()
725 {
726         if( get_value() )
727                 pwindow->thread->preferences->textbox_focus_policy |= CLICK_ACTIVATE;
728         else
729                 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_ACTIVATE;
730         return 1;
731 }
732
733 DeactivateFocusPolicy::DeactivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
734  : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_DEACTIVATE) != 0,
735         _("Click to deactivate text focus"))
736 {
737         this->pwindow = pwindow;
738 }
739
740 int DeactivateFocusPolicy::handle_event()
741 {
742         if( get_value() )
743                 pwindow->thread->preferences->textbox_focus_policy |= CLICK_DEACTIVATE;
744         else
745                 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_DEACTIVATE;
746         return 1;
747 }
748
749 AutoRotate::AutoRotate(PreferencesWindow *pwindow, int x, int y)
750  : BC_CheckBox(x, y, pwindow->thread->preferences->auto_rotate != 0,
751         _("Auto rotate ffmpeg media"))
752 {
753         this->pwindow = pwindow;
754 }
755
756 int AutoRotate::handle_event()
757 {
758         pwindow->thread->preferences->auto_rotate = get_value();
759         return 1;
760 }
761
762 ForwardRenderDisplacement::ForwardRenderDisplacement(PreferencesWindow *pwindow, int x, int y)
763  : BC_CheckBox(x, y, pwindow->thread->preferences->forward_render_displacement,
764         _("Always show next frame"))
765 {
766         this->pwindow = pwindow;
767 }
768
769 int ForwardRenderDisplacement::handle_event()
770 {
771         pwindow->thread->preferences->forward_render_displacement = get_value();
772         return 1;
773 }
774
775 AutocolorAssets::AutocolorAssets(PreferencesWindow *pwindow, int x, int y)
776  : BC_CheckBox(x, y, pwindow->thread->preferences->autocolor_assets,
777         _("Autocolor assets"))
778 {
779         this->pwindow = pwindow;
780 }
781
782 int AutocolorAssets::handle_event()
783 {
784         pwindow->thread->preferences->autocolor_assets = get_value();
785         return 1;
786 }
787
788 HighlightInverseColor::HighlightInverseColor(PreferencesWindow *pwindow, int x, int y, const char *hex)
789  : BC_TextBox(x, y, xS(80), 1, hex)
790 {
791         this->pwindow = pwindow;
792 }
793
794 int HighlightInverseColor::handle_event()
795 {
796         int inverse_color = strtoul(get_text(),0,16);
797         if( (inverse_color &= 0xffffff) == 0 ) {
798                 inverse_color = 0xffffff;
799                 char string[BCSTRLEN];
800                 sprintf(string,"%06x", inverse_color);
801                 update(string);
802         }
803         pwindow->thread->preferences->highlight_inverse = inverse_color;
804         return 1;
805 }
806
807
808 const char *YuvColorSpace::color_space[] = {
809         N_("BT601"), // COLOR_SPACE_BT601
810         N_("BT709"), // COLOR_SPACE_BT709
811         N_("BT2020"), // COLOR_SPACE_BT2020
812 };
813
814 YuvColorSpace::YuvColorSpace(int x, int y, PreferencesWindow *pwindow)
815  : BC_PopupMenu(x, y, xS(120),
816         _(color_space[pwindow->thread->preferences->yuv_color_space]), 1)
817 {
818         this->pwindow = pwindow;
819 }
820 YuvColorSpace::~YuvColorSpace()
821 {
822 }
823
824 void YuvColorSpace::create_objects()
825 {
826         for( int id=0,nid=sizeof(color_space)/sizeof(color_space[0]); id<nid; ++id )
827                 add_item(new YuvColorSpaceItem(this, _(color_space[id]), id));
828         handle_event();
829 }
830
831 int YuvColorSpace::handle_event()
832 {
833         set_text(_(color_space[pwindow->thread->preferences->yuv_color_space]));
834         return 1;
835 }
836
837 YuvColorSpaceItem::YuvColorSpaceItem(YuvColorSpace *popup, const char *text, int id)
838  : BC_MenuItem(text)
839 {
840         this->popup = popup;
841         this->id = id;
842 }
843
844 int YuvColorSpaceItem::handle_event()
845 {
846         popup->set_text(get_text());
847         popup->pwindow->thread->preferences->yuv_color_space = id;
848         return popup->handle_event();
849 }
850
851
852 const char *YuvColorRange::color_range[] = {
853         N_("JPEG"), // COLOR_RANGE_JPEG
854         N_("MPEG"), // COLOR_RANGE_MPEG
855 };
856
857 YuvColorRange::YuvColorRange(int x, int y, PreferencesWindow *pwindow)
858  : BC_PopupMenu(x, y, xS(100),
859         _(color_range[pwindow->thread->preferences->yuv_color_range]), 1)
860 {
861         this->pwindow = pwindow;
862 }
863 YuvColorRange::~YuvColorRange()
864 {
865 }
866
867 void YuvColorRange::create_objects()
868 {
869         for( int id=0,nid=sizeof(color_range)/sizeof(color_range[0]); id<nid; ++id )
870                 add_item(new YuvColorRangeItem(this, _(color_range[id]), id));
871         handle_event();
872 }
873
874 int YuvColorRange::handle_event()
875 {
876         set_text(color_range[pwindow->thread->preferences->yuv_color_range]);
877         return 1;
878 }
879
880 YuvColorRangeItem::YuvColorRangeItem(YuvColorRange *popup, const char *text, int id)
881  : BC_MenuItem(text)
882 {
883         this->popup = popup;
884         this->id = id;
885 }
886
887 int YuvColorRangeItem::handle_event()
888 {
889         popup->set_text(get_text());
890         popup->pwindow->thread->preferences->yuv_color_range = id;
891         return popup->handle_event();
892 }
893
894 PerpetualSession::PerpetualSession(int x, int y, PreferencesWindow *pwindow)
895  : BC_CheckBox(x, y,
896         pwindow->thread->preferences->perpetual_session, _("Perpetual session"))
897 {
898         this->pwindow = pwindow;
899 }
900
901 int PerpetualSession::handle_event()
902 {
903         pwindow->thread->preferences->perpetual_session = get_value();
904         return 1;
905 }
906
907 CtrlToggle::CtrlToggle(int x, int y, PreferencesWindow *pwindow)
908  : BC_CheckBox(x, y,
909         pwindow->thread->preferences->ctrl_toggle, _("Clears before toggle"))
910 {
911         this->pwindow = pwindow;
912 }
913
914 int CtrlToggle::handle_event()
915 {
916         pwindow->thread->preferences->ctrl_toggle = get_value();
917         return 1;
918 }
919
920 RectifyAudioToggle::RectifyAudioToggle(int x, int y, PreferencesWindow *pwindow)
921  : BC_CheckBox(x, y,
922         pwindow->thread->preferences->rectify_audio, _("Timeline Rectify Audio"))
923 {
924         this->pwindow = pwindow;
925 }
926
927 int RectifyAudioToggle::handle_event()
928 {
929         pwindow->thread->preferences->rectify_audio = get_value();
930         return 1;
931 }
932
933 Composer_BG_Color::Composer_BG_Color(PreferencesWindow *pwindow,
934                 int x, int y, int w, int h, int color)
935  : ColorBoxButton(_("Composer BG color"), x, y, w, h, color, -1, 1)
936 {
937         this->pwindow = pwindow;
938 }
939
940 Composer_BG_Color::~Composer_BG_Color()
941 {
942 }
943
944 void Composer_BG_Color::handle_done_event(int result)
945 {
946         if( result ) {
947                 pwindow->lock_window("Composer_BG_Color::handle_done_event");
948                 update_gui(orig_color, orig_alpha);
949                 pwindow->unlock_window();
950                 handle_new_color(orig_color, orig_alpha);
951         }
952 }
953
954 int Composer_BG_Color::handle_new_color(int color, int alpha)
955 {
956         pwindow->thread->edl->session->cwindow_clear_color = color;
957         return 1;
958 }
959