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