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