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