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