upgrade bld_prep.sh debian libpng, add rectify timeline audio pref, rework maskgui...
[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 quality:")));
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         RectifyAudioToggle *rect_toggle = new RectifyAudioToggle(x1, y1, pwindow);
223         add_subwindow(rect_toggle);
224         y1 += rect_toggle->get_h() + 5;
225         if( y < y1 ) y = y1;
226 }
227
228 int AppearancePrefs::update(int new_value)
229 {
230         pwindow->thread->redraw_times = 1;
231         pwindow->thread->edl->session->time_format = new_value;
232         hms->update(new_value == TIME_HMS);
233         hmsf->update(new_value == TIME_HMSF);
234         samples->update(new_value == TIME_SAMPLES);
235         hex->update(new_value == TIME_SAMPLES_HEX);
236         frames->update(new_value == TIME_FRAMES);
237         feet->update(new_value == TIME_FEET_FRAMES);
238         seconds->update(new_value == TIME_SECONDS);
239         return 0;
240 }
241
242
243 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
244  : BC_Radial(x, y, value, TIME_HMS_TEXT)
245 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
246
247 int TimeFormatHMS::handle_event()
248 {
249         tfwindow->update(TIME_HMS);
250         return 1;
251 }
252
253 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
254  : BC_Radial(x, y, value, TIME_HMSF_TEXT)
255 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
256
257 int TimeFormatHMSF::handle_event()
258 {
259         tfwindow->update(TIME_HMSF);
260         return 1;
261 }
262
263 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
264  : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
265 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
266
267 int TimeFormatSamples::handle_event()
268 {
269         tfwindow->update(TIME_SAMPLES);
270         return 1;
271 }
272
273 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
274  : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
275 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
276
277 int TimeFormatFrames::handle_event()
278 {
279         tfwindow->update(TIME_FRAMES);
280         return 1;
281 }
282
283 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
284  : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
285 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
286
287 int TimeFormatHex::handle_event()
288 {
289         tfwindow->update(TIME_SAMPLES_HEX);
290         return 1;
291 }
292
293 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
294  : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
295 {
296         this->pwindow = pwindow;
297         this->tfwindow = tfwindow;
298 }
299
300 int TimeFormatSeconds::handle_event()
301 {
302         tfwindow->update(TIME_SECONDS);
303         return 1;
304 }
305
306 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
307  : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
308 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
309
310 int TimeFormatFeet::handle_event()
311 {
312         tfwindow->update(TIME_FEET_FRAMES);
313         return 1;
314 }
315
316 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
317  : BC_TextBox(x, y, 90, 1, string)
318 { this->pwindow = pwindow; }
319
320 int TimeFormatFeetSetting::handle_event()
321 {
322         pwindow->thread->edl->session->frames_per_foot = atof(get_text());
323         if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
324         return 0;
325 }
326
327
328 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
329  : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
330 {
331         this->pwindow = pwindow;
332 }
333 ViewTheme::~ViewTheme()
334 {
335 }
336
337 void ViewTheme::create_objects()
338 {
339         ArrayList<PluginServer*> themes;
340         MWindow::search_plugindb(0, 0, 0, 0, 1, themes);
341
342         for(int i = 0; i < themes.total; i++) {
343                 add_item(new ViewThemeItem(this, themes.values[i]->title));
344         }
345 }
346
347 int ViewTheme::handle_event()
348 {
349         return 1;
350 }
351
352 ViewThemeItem::ViewThemeItem(ViewTheme *popup, const char *text)
353  : BC_MenuItem(text)
354 {
355         this->popup = popup;
356 }
357
358 int ViewThemeItem::handle_event()
359 {
360         popup->set_text(get_text());
361         strcpy(popup->pwindow->thread->preferences->theme, get_text());
362         popup->handle_event();
363         return 1;
364 }
365
366
367 ViewPluginIcons::ViewPluginIcons(int x, int y, PreferencesWindow *pwindow)
368  : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->plugin_icons, 1)
369 {
370         this->pwindow = pwindow;
371 }
372 ViewPluginIcons::~ViewPluginIcons()
373 {
374 }
375
376 void ViewPluginIcons::create_objects()
377 {
378         add_item(new ViewPluginIconItem(this, DEFAULT_PICON));
379         FileSystem fs;
380         const char *plugin_path = File::get_plugin_path();
381         char picon_path[BCTEXTLEN];
382         snprintf(picon_path,sizeof(picon_path)-1,"%s/picon", plugin_path);
383         if( fs.update(picon_path) ) return;
384         for( int i=0; i<fs.dir_list.total; ++i ) {
385                 char *fs_path = fs.dir_list[i]->path;
386                 if( !fs.is_dir(fs_path) ) continue;
387                 char *cp = strrchr(fs_path,'/');
388                 cp = !cp ? fs_path : cp+1;
389                 if( !strcmp(cp,DEFAULT_PICON) ) continue;
390                 add_item(new ViewPluginIconItem(this, cp));
391         }
392 }
393
394 int ViewPluginIcons::handle_event()
395 {
396         return 1;
397 }
398
399 ViewPluginIconItem::ViewPluginIconItem(ViewPluginIcons *popup, const char *text)
400  : BC_MenuItem(text)
401 {
402         this->popup = popup;
403 }
404
405 int ViewPluginIconItem::handle_event()
406 {
407         popup->set_text(get_text());
408         strcpy(popup->pwindow->thread->preferences->plugin_icons, get_text());
409         popup->handle_event();
410         return 1;
411 }
412
413
414 ViewThumbnails::ViewThumbnails(int x,
415         int y,
416         PreferencesWindow *pwindow)
417  : BC_CheckBox(x,
418         y,
419         pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
420 {
421         this->pwindow = pwindow;
422 }
423
424 int ViewThumbnails::handle_event()
425 {
426         pwindow->thread->preferences->use_thumbnails = get_value();
427         return 1;
428 }
429
430
431 ViewThumbnailSize::ViewThumbnailSize(PreferencesWindow *pwindow,
432                 AppearancePrefs *aprefs, int x, int y)
433  : BC_TumbleTextBox(aprefs,
434         pwindow->thread->preferences->awindow_picon_h,
435         16, 512, x, y, 80)
436
437 {
438         this->pwindow = pwindow;
439         this->aprefs = aprefs;
440 }
441
442 int ViewThumbnailSize::handle_event()
443 {
444         int v = atoi(get_text());
445         bclamp(v, 16,512);
446         pwindow->thread->preferences->awindow_picon_h = v;
447         return 1;
448 }
449
450 ViewViconSize::ViewViconSize(PreferencesWindow *pwindow,
451                 AppearancePrefs *aprefs, int x, int y)
452  : BC_TumbleTextBox(aprefs,
453         pwindow->thread->preferences->vicon_size,
454         16, 512, x, y, 80)
455
456 {
457         this->pwindow = pwindow;
458         this->aprefs = aprefs;
459 }
460
461 int ViewViconSize::handle_event()
462 {
463         int v = atoi(get_text());
464         bclamp(v, 16,512);
465         pwindow->thread->preferences->vicon_size = v;
466         return 1;
467 }
468
469 ViewViconColorMode::ViewViconColorMode(PreferencesWindow *pwindow, int x, int y)
470  : BC_PopupMenu(x, y, 100,
471         _(vicon_color_modes[pwindow->thread->preferences->vicon_color_mode]), 1)
472 {
473         this->pwindow = pwindow;
474 }
475 ViewViconColorMode::~ViewViconColorMode()
476 {
477 }
478
479 const char *ViewViconColorMode::vicon_color_modes[] = {
480         N_("Low"),
481         N_("Med"),
482         N_("High"),
483 };
484
485 void ViewViconColorMode::create_objects()
486 {
487         for( int id=0,nid=sizeof(vicon_color_modes)/sizeof(vicon_color_modes[0]); id<nid; ++id )
488                 add_item(new ViewViconColorModeItem(this, _(vicon_color_modes[id]), id));
489         handle_event();
490 }
491
492 int ViewViconColorMode::handle_event()
493 {
494         set_text(_(vicon_color_modes[pwindow->thread->preferences->vicon_color_mode]));
495         return 1;
496 }
497
498 ViewViconColorModeItem::ViewViconColorModeItem(ViewViconColorMode *popup, const char *text, int id)
499  : BC_MenuItem(text)
500 {
501         this->popup = popup;
502         this->id = id;
503 }
504
505 int ViewViconColorModeItem::handle_event()
506 {
507         popup->set_text(get_text());
508         popup->pwindow->thread->preferences->vicon_color_mode = id;
509         return popup->handle_event();
510 }
511
512
513 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
514  : BC_CheckBox(x,
515         y,
516         pwindow->thread->preferences->use_tipwindow,
517         _("Show tip of the day"))
518 {
519         this->pwindow = pwindow;
520 }
521 int UseTipWindow::handle_event()
522 {
523         pwindow->thread->preferences->use_tipwindow = get_value();
524         return 1;
525 }
526
527
528 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
529  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_indexes,
530         _("ffmpeg probe warns rebuild indexes"))
531 {
532         this->pwindow = pwindow;
533 }
534
535 int UseWarnIndecies::handle_event()
536 {
537         pwindow->thread->preferences->warn_indexes = get_value();
538         return 1;
539 }
540
541 UseWarnVersion::UseWarnVersion(PreferencesWindow *pwindow, int x, int y)
542  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_version,
543         _("EDL version warns if mismatched"))
544 {
545         this->pwindow = pwindow;
546 }
547
548 int UseWarnVersion::handle_event()
549 {
550         pwindow->thread->preferences->warn_version = get_value();
551         return 1;
552 }
553
554 BD_WarnRoot::BD_WarnRoot(PreferencesWindow *pwindow, int x, int y)
555  : BC_CheckBox(x, y, pwindow->thread->preferences->bd_warn_root,
556         _("Create Bluray warns if not root"))
557 {
558         this->pwindow = pwindow;
559 }
560
561 int BD_WarnRoot::handle_event()
562 {
563         pwindow->thread->preferences->bd_warn_root = get_value();
564         return 1;
565 }
566
567 PopupMenuBtnup::PopupMenuBtnup(PreferencesWindow *pwindow, int x, int y)
568  : BC_CheckBox(x, y, pwindow->thread->preferences->popupmenu_btnup,
569         _("Popups activate on button up"))
570 {
571         this->pwindow = pwindow;
572 }
573
574 int PopupMenuBtnup::handle_event()
575 {
576         pwindow->thread->preferences->popupmenu_btnup = get_value();
577         return 1;
578 }
579
580 GrabFocusPolicy::GrabFocusPolicy(PreferencesWindow *pwindow, int x, int y)
581  : BC_CheckBox(x, y, (pwindow->thread->preferences->grab_input_focus) != 0,
582         _("Set Input Focus when window entered"))
583 {
584         this->pwindow = pwindow;
585 }
586
587 int GrabFocusPolicy::handle_event()
588 {
589         pwindow->thread->preferences->grab_input_focus = get_value();
590         return 1;
591 }
592
593 ActivateFocusPolicy::ActivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
594  : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_ACTIVATE) != 0,
595         _("Click to activate text focus"))
596 {
597         this->pwindow = pwindow;
598 }
599
600 int ActivateFocusPolicy::handle_event()
601 {
602         if( get_value() )
603                 pwindow->thread->preferences->textbox_focus_policy |= CLICK_ACTIVATE;
604         else
605                 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_ACTIVATE;
606         return 1;
607 }
608
609 DeactivateFocusPolicy::DeactivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
610  : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_DEACTIVATE) != 0,
611         _("Click to deactivate text focus"))
612 {
613         this->pwindow = pwindow;
614 }
615
616 int DeactivateFocusPolicy::handle_event()
617 {
618         if( get_value() )
619                 pwindow->thread->preferences->textbox_focus_policy |= CLICK_DEACTIVATE;
620         else
621                 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_DEACTIVATE;
622         return 1;
623 }
624
625 ForwardRenderDisplacement::ForwardRenderDisplacement(PreferencesWindow *pwindow, int x, int y)
626  : BC_CheckBox(x, y, pwindow->thread->preferences->forward_render_displacement,
627         _("Always show next frame"))
628 {
629         this->pwindow = pwindow;
630 }
631
632 int ForwardRenderDisplacement::handle_event()
633 {
634         pwindow->thread->preferences->forward_render_displacement = get_value();
635         return 1;
636 }
637
638 AutocolorAssets::AutocolorAssets(PreferencesWindow *pwindow, int x, int y)
639  : BC_CheckBox(x, y, pwindow->thread->preferences->autocolor_assets,
640         _("Autocolor assets"))
641 {
642         this->pwindow = pwindow;
643 }
644
645 int AutocolorAssets::handle_event()
646 {
647         pwindow->thread->preferences->autocolor_assets = get_value();
648         return 1;
649 }
650
651 HighlightInverseColor::HighlightInverseColor(PreferencesWindow *pwindow, int x, int y, const char *hex)
652  : BC_TextBox(x, y, 80, 1, hex)
653 {
654         this->pwindow = pwindow;
655 }
656
657 int HighlightInverseColor::handle_event()
658 {
659         int inverse_color = strtoul(get_text(),0,16);
660         if( (inverse_color &= 0xffffff) == 0 ) {
661                 inverse_color = 0xffffff;
662                 char string[BCSTRLEN];
663                 sprintf(string,"%06x", inverse_color);
664                 update(string);
665         }
666         pwindow->thread->preferences->highlight_inverse = inverse_color;
667         return 1;
668 }
669
670
671 const char *YuvColorSpace::color_space[] = {
672         N_("BT601"),
673         N_("BT709"),
674         N_("BT2020"),
675 };
676
677 YuvColorSpace::YuvColorSpace(int x, int y, PreferencesWindow *pwindow)
678  : BC_PopupMenu(x, y, 100,
679         _(color_space[pwindow->thread->preferences->yuv_color_space]), 1)
680 {
681         this->pwindow = pwindow;
682 }
683 YuvColorSpace::~YuvColorSpace()
684 {
685 }
686
687 void YuvColorSpace::create_objects()
688 {
689         for( int id=0,nid=sizeof(color_space)/sizeof(color_space[0]); id<nid; ++id )
690                 add_item(new YuvColorSpaceItem(this, _(color_space[id]), id));
691         handle_event();
692 }
693
694 int YuvColorSpace::handle_event()
695 {
696         set_text(_(color_space[pwindow->thread->preferences->yuv_color_space]));
697         return 1;
698 }
699
700 YuvColorSpaceItem::YuvColorSpaceItem(YuvColorSpace *popup, const char *text, int id)
701  : BC_MenuItem(text)
702 {
703         this->popup = popup;
704         this->id = id;
705 }
706
707 int YuvColorSpaceItem::handle_event()
708 {
709         popup->set_text(get_text());
710         popup->pwindow->thread->preferences->yuv_color_space = id;
711         return popup->handle_event();
712 }
713
714
715 const char *YuvColorRange::color_range[] = {
716         N_("JPEG"),
717         N_("MPEG"),
718 };
719
720 YuvColorRange::YuvColorRange(int x, int y, PreferencesWindow *pwindow)
721  : BC_PopupMenu(x, y, 100,
722         _(color_range[pwindow->thread->preferences->yuv_color_range]), 1)
723 {
724         this->pwindow = pwindow;
725 }
726 YuvColorRange::~YuvColorRange()
727 {
728 }
729
730 void YuvColorRange::create_objects()
731 {
732         for( int id=0,nid=sizeof(color_range)/sizeof(color_range[0]); id<nid; ++id )
733                 add_item(new YuvColorRangeItem(this, _(color_range[id]), id));
734         handle_event();
735 }
736
737 int YuvColorRange::handle_event()
738 {
739         set_text(color_range[pwindow->thread->preferences->yuv_color_range]);
740         return 1;
741 }
742
743 YuvColorRangeItem::YuvColorRangeItem(YuvColorRange *popup, const char *text, int id)
744  : BC_MenuItem(text)
745 {
746         this->popup = popup;
747         this->id = id;
748 }
749
750 int YuvColorRangeItem::handle_event()
751 {
752         popup->set_text(get_text());
753         popup->pwindow->thread->preferences->yuv_color_range = id;
754         return popup->handle_event();
755 }
756
757 PerpetualSession::PerpetualSession(int x, int y, PreferencesWindow *pwindow)
758  : BC_CheckBox(x, y,
759         pwindow->thread->preferences->perpetual_session, _("Perpetual session"))
760 {
761         this->pwindow = pwindow;
762 }
763
764 int PerpetualSession::handle_event()
765 {
766         pwindow->thread->preferences->perpetual_session = get_value();
767         return 1;
768 }
769
770 CtrlToggle::CtrlToggle(int x, int y, PreferencesWindow *pwindow)
771  : BC_CheckBox(x, y,
772         pwindow->thread->preferences->ctrl_toggle, _("Clears before toggle"))
773 {
774         this->pwindow = pwindow;
775 }
776
777 int CtrlToggle::handle_event()
778 {
779         pwindow->thread->preferences->ctrl_toggle = get_value();
780         return 1;
781 }
782
783 RectifyAudioToggle::RectifyAudioToggle(int x, int y, PreferencesWindow *pwindow)
784  : BC_CheckBox(x, y,
785         pwindow->thread->preferences->rectify_audio, _("Timeline Rectify Audio"))
786 {
787         this->pwindow = pwindow;
788 }
789
790 int RectifyAudioToggle::handle_event()
791 {
792         pwindow->thread->preferences->rectify_audio = get_value();
793         return 1;
794 }
795