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