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