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