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