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