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