apply contrib scale plugin rework
[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         timecode = 0;
42         samples = 0;
43         frames = 0;
44         hex = 0;
45         feet = 0;
46         layout_scale = 0;
47         thumbnails = 0;
48         thumbnail_size = 0;
49         vicon_size = 0;
50 }
51
52 AppearancePrefs::~AppearancePrefs()
53 {
54         delete hms;
55         delete hmsf;
56         delete timecode;
57         delete samples;
58         delete frames;
59         delete hex;
60         delete feet;
61         delete layout_scale;
62         delete thumbnails;
63         delete thumbnail_size;
64         delete vicon_size;
65 }
66
67
68 void AppearancePrefs::create_objects()
69 {
70         int xs5 = xS(5), xs10 = xS(10), xs30 = xS(30);
71         int ys5 = yS(5), ys10 = yS(10), ys15 = yS(15);
72         int ys20 = yS(20), ys35 = yS(35);
73         BC_Resources *resources = BC_WindowBase::get_resources();
74         int margin = mwindow->theme->widget_border;
75         char string[BCTEXTLEN];
76         int x0 = mwindow->theme->preferencesoptions_x;
77         int y0 = mwindow->theme->preferencesoptions_y;
78         int x = x0, y = y0, x1 = x + xS(100);
79
80         BC_Title *title;
81         add_subwindow(title = new BC_Title(x, y, _("Layout:"), LARGEFONT,
82                 resources->text_default));
83         y += title->get_h() + ys10;
84         int y1 = y;
85
86         ViewTheme *theme;
87         add_subwindow(new BC_Title(x, y, _("Theme:")));
88         add_subwindow(theme = new ViewTheme(x1, y, pwindow));
89         theme->create_objects();
90         y += theme->get_h() + ys5;
91
92         x = x0;
93         ViewPluginIcons *plugin_icons;
94         add_subwindow(new BC_Title(x, y, _("Plugin Icons:")));
95         add_subwindow(plugin_icons = new ViewPluginIcons(x1, y, pwindow));
96         plugin_icons->create_objects();
97         y += plugin_icons->get_h() + ys10;
98         add_subwindow(new BC_Title(x, y, _("Language:")));
99         LayoutLocale *layout_locale;
100         add_subwindow(layout_locale = new LayoutLocale(x1, y, pwindow));
101         layout_locale->create_objects();
102         y += layout_locale->get_h() + ys15;
103         x1 = get_w()/2;
104
105         int x2 = x1 + xS(160), y2 = y;
106         y = y1;
107
108         add_subwindow(new BC_Title(x1, y, _("Layout Scale:")));
109         layout_scale = new ViewLayoutScale(pwindow, this, x2, y);
110         layout_scale->create_objects();
111         y += layout_scale->get_h() + ys5;
112         add_subwindow(new BC_Title(x1, y, _("View thumbnail size:")));
113         thumbnail_size = new ViewThumbnailSize(pwindow, this, x2, y);
114         thumbnail_size->create_objects();
115         y += thumbnail_size->get_h() + ys5;
116         add_subwindow(new BC_Title(x1, y, _("Vicon quality:")));
117         vicon_size = new ViewViconSize(pwindow, this, x2, y);
118         vicon_size->create_objects();
119         y += vicon_size->get_h() + ys5;
120         add_subwindow(new BC_Title(x1, y, _("Vicon color mode:")));
121         add_subwindow(vicon_color_mode = new ViewViconColorMode(pwindow, x2, y));
122         vicon_color_mode->create_objects();
123         y += vicon_color_mode->get_h() + ys5;
124         y = bmax(y, y2);        
125         y += ys10;
126         add_subwindow(new BC_Bar(xs5, y, get_w() - xs10));
127         y += ys15;
128
129         y1 = y;
130         add_subwindow(title = new BC_Title(x, y, _("Time Format:"), LARGEFONT,
131                 resources->text_default));
132         y += title->get_h() + ys10;
133         add_subwindow(hms = new TimeFormatHMS(pwindow, this,
134                 pwindow->thread->edl->session->time_format == TIME_HMS,
135                 x, y));
136         y += ys20;
137         add_subwindow(hmsf = new TimeFormatHMSF(pwindow, this,
138                 pwindow->thread->edl->session->time_format == TIME_HMSF,
139                 x, y));
140         y += ys20;
141         add_subwindow(timecode = new TimeFormatTimecode(pwindow, this,
142                 pwindow->thread->edl->session->time_format == TIME_TIMECODE,
143                 x, y));
144         y += ys20;
145         add_subwindow(samples = new TimeFormatSamples(pwindow, this,
146                 pwindow->thread->edl->session->time_format == TIME_SAMPLES,
147                 x, y));
148         y += ys20;
149         add_subwindow(hex = new TimeFormatHex(pwindow, this,
150                 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX,
151                 x, y));
152         y += ys20;
153         add_subwindow(frames = new TimeFormatFrames(pwindow, this,
154                 pwindow->thread->edl->session->time_format == TIME_FRAMES,
155                 x, y));
156         y += ys20;
157         add_subwindow(feet = new TimeFormatFeet(pwindow, this,
158                 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES,
159                 x, y));
160         x += feet->get_w() + xS(15);
161         add_subwindow(title = new BC_Title(x, y, _("Frames per foot:")));
162         x += title->get_w() + margin;
163         sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
164         add_subwindow(new TimeFormatFeetSetting(pwindow,
165                 x, y - ys5,     string));
166         x = x0;
167         y += ys20;
168         add_subwindow(seconds = new TimeFormatSeconds(pwindow, this,
169                 pwindow->thread->edl->session->time_format == TIME_SECONDS,
170                 x, y));
171         y += ys35;
172         y2 = y;
173         
174         x = x1;  y = y1;
175         add_subwindow(new BC_Title(x, y, _("Color:"), LARGEFONT,
176                 resources->text_default));
177         y += ys35;
178         add_subwindow(title = new BC_Title(x, y, _("Highlighting Inversion color:")));
179         x += title->get_w() + margin;
180         char hex_color[BCSTRLEN];
181         sprintf(hex_color, "%06x", preferences->highlight_inverse);
182         add_subwindow(new HighlightInverseColor(pwindow, x, y, hex_color));
183         x2 = x;  x = x1;
184         y += ys35;
185         add_subwindow(title = new BC_Title(x, y, _("Composer BG Color:")));
186         int clr_color = pwindow->thread->edl->session->cwindow_clear_color;
187         int clr_alpha = pwindow->thread->edl->session->cwindow_clear_alpha;
188         add_subwindow(cwdw_bg_color = new Composer_BG_Color(pwindow,
189                 x2, y, xS(80), yS(24), clr_color, clr_alpha));
190         draw_3d_border(x2-2,y-2, xS(80)+4,xS(24)+4, 1);
191         cwdw_bg_color->create_objects();
192         x2 += cwdw_bg_color->get_w();
193         y += ys35;
194
195         add_subwindow(title = new BC_Title(x1, y, _("YUV color space:")));
196         x = x2 - xS(120);
197         add_subwindow(yuv_color_space = new YuvColorSpace(x, y, pwindow));
198         yuv_color_space->create_objects();
199         y += yuv_color_space->get_h() + ys5;
200
201         add_subwindow(title = new BC_Title(x1, y, _("YUV color range:")));
202         x = x2 - xS(100);
203         add_subwindow(yuv_color_range = new YuvColorRange(x, y, pwindow));
204         yuv_color_range->create_objects();
205         y += yuv_color_range->get_h() + ys35;
206         if( y2 < y ) y2 = y;
207
208         add_subwindow(new BC_Bar(x0, y2, get_w()-x0 - xs30));
209         y += ys15;
210
211         x = x0;  y1 = y;
212         add_subwindow(title = new BC_Title(x, y, _("Warnings:"), LARGEFONT,
213                 resources->text_default));
214         y += title->get_h() + ys10;
215         UseWarnIndecies *idx_warn = new UseWarnIndecies(pwindow, x, y);
216         add_subwindow(idx_warn);
217         y += idx_warn->get_h() + ys5;
218         UseWarnVersion *ver_warn = new UseWarnVersion(pwindow, x, y);
219         add_subwindow(ver_warn);
220         y += ver_warn->get_h() + ys5;
221         BD_WarnRoot *bdwr_warn = new BD_WarnRoot(pwindow, x, y);
222         add_subwindow(bdwr_warn);
223         y += bdwr_warn->get_h() + ys5;
224         UseWarnFileRef *warn_ref = new UseWarnFileRef(pwindow, x, y);
225         add_subwindow(warn_ref);
226         y += warn_ref->get_h() + ys5;
227
228         x = get_w() / 3 + xs30;
229         y = y1;
230         add_subwindow(title = new BC_Title(x, y, _("Flags:"), LARGEFONT,
231                 resources->text_default));
232         y += title->get_h() + ys10;
233         y1 = y;
234         AutocolorAssets *autocolor_assets = new AutocolorAssets(pwindow, x, y);
235         add_subwindow(autocolor_assets);
236         y += autocolor_assets->get_h() + ys5;
237         PerpetualSession *perpetual = new PerpetualSession(x, y, pwindow);
238         add_subwindow(perpetual);
239         y += perpetual->get_h() + ys5;
240         RectifyAudioToggle *rect_toggle = new RectifyAudioToggle(x, y, pwindow);
241         add_subwindow(rect_toggle);
242         y += rect_toggle->get_h() + ys5;
243         CtrlToggle *ctrl_toggle = new CtrlToggle(x, y, pwindow);
244         add_subwindow(ctrl_toggle);
245         y += ctrl_toggle->get_h() + ys5;
246         ForwardRenderDisplacement *displacement = new ForwardRenderDisplacement(pwindow, x, y);
247         add_subwindow(displacement);
248         y += displacement->get_h() + ys5;
249         UseTipWindow *tip_win = new UseTipWindow(pwindow, x, y);
250         add_subwindow(tip_win);
251         y += tip_win->get_h() + ys5;
252
253         x = 2*get_w() / 3 - xs30;
254         y = y1;
255         add_subwindow(thumbnails = new ViewThumbnails(x, y, pwindow));
256         y += thumbnails->get_h() + ys5;
257         PopupMenuBtnup *pop_win = new PopupMenuBtnup(pwindow, x, y);
258         add_subwindow(pop_win);
259         y += pop_win->get_h() + ys5;
260         GrabFocusPolicy *grab_input_focus = new GrabFocusPolicy(pwindow, x, y);
261         add_subwindow(grab_input_focus);
262         y += grab_input_focus->get_h() + ys5;
263         ActivateFocusPolicy *focus_activate = new ActivateFocusPolicy(pwindow, x, y);
264         add_subwindow(focus_activate);
265         y += focus_activate->get_h() + ys5;
266         DeactivateFocusPolicy *focus_deactivate = new DeactivateFocusPolicy(pwindow, x, y);
267         add_subwindow(focus_deactivate);
268         y += focus_deactivate->get_h() + ys5;
269         AutoRotate *auto_rotate = new AutoRotate(pwindow, x, y);
270         add_subwindow(auto_rotate);
271         y += auto_rotate->get_h() + ys5;
272 }
273
274 int AppearancePrefs::update(int new_value)
275 {
276         pwindow->thread->redraw_times = 1;
277         pwindow->thread->edl->session->time_format = new_value;
278         hms->update(new_value == TIME_HMS);
279         hmsf->update(new_value == TIME_HMSF);
280         timecode->update(new_value == TIME_TIMECODE);
281         samples->update(new_value == TIME_SAMPLES);
282         hex->update(new_value == TIME_SAMPLES_HEX);
283         frames->update(new_value == TIME_FRAMES);
284         feet->update(new_value == TIME_FEET_FRAMES);
285         seconds->update(new_value == TIME_SECONDS);
286         return 0;
287 }
288
289
290 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
291  : BC_Radial(x, y, value, TIME_HMS_TEXT)
292 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
293
294 int TimeFormatHMS::handle_event()
295 {
296         tfwindow->update(TIME_HMS);
297         return 1;
298 }
299
300 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
301  : BC_Radial(x, y, value, TIME_HMSF_TEXT)
302 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
303
304 int TimeFormatHMSF::handle_event()
305 {
306         tfwindow->update(TIME_HMSF);
307         return 1;
308 }
309
310 TimeFormatTimecode::TimeFormatTimecode(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
311  : BC_Radial(x, y, value, TIME_TIMECODE_TEXT)
312 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
313
314 int TimeFormatTimecode::handle_event()
315 {
316         tfwindow->update(TIME_TIMECODE);
317         return 1;
318 }
319
320 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
321  : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
322 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
323
324 int TimeFormatSamples::handle_event()
325 {
326         tfwindow->update(TIME_SAMPLES);
327         return 1;
328 }
329
330 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
331  : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
332 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
333
334 int TimeFormatFrames::handle_event()
335 {
336         tfwindow->update(TIME_FRAMES);
337         return 1;
338 }
339
340 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
341  : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
342 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
343
344 int TimeFormatHex::handle_event()
345 {
346         tfwindow->update(TIME_SAMPLES_HEX);
347         return 1;
348 }
349
350 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
351  : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
352 {
353         this->pwindow = pwindow;
354         this->tfwindow = tfwindow;
355 }
356
357 int TimeFormatSeconds::handle_event()
358 {
359         tfwindow->update(TIME_SECONDS);
360         return 1;
361 }
362
363 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
364  : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
365 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
366
367 int TimeFormatFeet::handle_event()
368 {
369         tfwindow->update(TIME_FEET_FRAMES);
370         return 1;
371 }
372
373 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
374  : BC_TextBox(x, y, xS(90), 1, string)
375 { this->pwindow = pwindow; }
376
377 int TimeFormatFeetSetting::handle_event()
378 {
379         pwindow->thread->edl->session->frames_per_foot = atof(get_text());
380         if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
381         return 0;
382 }
383
384
385 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
386  : BC_PopupMenu(x, y, xS(200), pwindow->thread->preferences->theme, 1)
387 {
388         this->pwindow = pwindow;
389 }
390 ViewTheme::~ViewTheme()
391 {
392 }
393
394 void ViewTheme::create_objects()
395 {
396         ArrayList<PluginServer*> themes;
397         MWindow::search_plugindb(0, 0, 0, 0, 1, themes);
398
399         for(int i = 0; i < themes.total; i++) {
400                 add_item(new ViewThemeItem(this, themes.values[i]->title));
401         }
402 }
403
404 int ViewTheme::handle_event()
405 {
406         return 1;
407 }
408
409 ViewThemeItem::ViewThemeItem(ViewTheme *popup, const char *text)
410  : BC_MenuItem(text)
411 {
412         this->popup = popup;
413 }
414
415 int ViewThemeItem::handle_event()
416 {
417         popup->set_text(get_text());
418         strcpy(popup->pwindow->thread->preferences->theme, get_text());
419         popup->handle_event();
420         return 1;
421 }
422
423
424 ViewPluginIcons::ViewPluginIcons(int x, int y, PreferencesWindow *pwindow)
425  : BC_PopupMenu(x, y, xS(200), pwindow->thread->preferences->plugin_icons, 1)
426 {
427         this->pwindow = pwindow;
428 }
429 ViewPluginIcons::~ViewPluginIcons()
430 {
431 }
432
433 void ViewPluginIcons::create_objects()
434 {
435         add_item(new ViewPluginIconItem(this, DEFAULT_PICON));
436         FileSystem fs;
437         const char *plugin_path = File::get_plugin_path();
438         char picon_path[BCTEXTLEN];
439         snprintf(picon_path,sizeof(picon_path)-1,"%s/picon", plugin_path);
440         if( fs.update(picon_path) ) return;
441         for( int i=0; i<fs.dir_list.total; ++i ) {
442                 char *fs_path = fs.dir_list[i]->path;
443                 if( !fs.is_dir(fs_path) ) continue;
444                 char *cp = strrchr(fs_path,'/');
445                 cp = !cp ? fs_path : cp+1;
446                 if( !strcmp(cp,DEFAULT_PICON) ) continue;
447                 add_item(new ViewPluginIconItem(this, cp));
448         }
449 }
450
451 int ViewPluginIcons::handle_event()
452 {
453         return 1;
454 }
455
456 ViewPluginIconItem::ViewPluginIconItem(ViewPluginIcons *popup, const char *text)
457  : BC_MenuItem(text)
458 {
459         this->popup = popup;
460 }
461
462 int ViewPluginIconItem::handle_event()
463 {
464         popup->set_text(get_text());
465         strcpy(popup->pwindow->thread->preferences->plugin_icons, get_text());
466         popup->handle_event();
467         return 1;
468 }
469
470 LayoutLocale::LayoutLocale(int x, int y, PreferencesWindow *pwindow)
471  : BC_PopupMenu(x, y, xS(200), pwindow->thread->preferences->locale, 1)
472 {
473         this->pwindow = pwindow;
474 }
475 LayoutLocale::~LayoutLocale()
476 {
477 }
478
479 const char *LayoutLocale::locale_list[] = { LOCALE_LIST, 0 };
480
481 void LayoutLocale::create_objects()
482 {
483         for( const char *tp, **lp=locale_list; (tp=*lp)!=0; ++lp )
484                 add_item(new LayoutLocaleItem(this, tp));
485 }
486
487 int LayoutLocale::handle_event()
488 {
489         return 1;
490 }
491
492 LayoutLocaleItem::LayoutLocaleItem(LayoutLocale *popup, const char *text)
493  : BC_MenuItem(text)
494 {
495         this->popup = popup;
496 }
497
498 int LayoutLocaleItem::handle_event()
499 {
500         popup->set_text(get_text());
501         strcpy(popup->pwindow->thread->preferences->locale, get_text());
502         popup->handle_event();
503         return 1;
504 }
505
506 ViewLayoutScale::ViewLayoutScale(PreferencesWindow *pwindow,
507                 AppearancePrefs *aprefs, int x, int y)
508  : BC_TumbleTextBox(aprefs,
509         pwindow->thread->preferences->layout_scale,
510         0.f, 10.f, x, y, xS(80), 2)
511 {
512         this->pwindow = pwindow;
513         this->aprefs = aprefs;
514         set_increment(0.1);
515 }
516
517 int ViewLayoutScale::handle_event()
518 {
519         float v = atof(get_text());
520         pwindow->thread->preferences->layout_scale = v;
521         return 1;
522 }
523
524
525 ViewThumbnails::ViewThumbnails(int x,
526         int y,
527         PreferencesWindow *pwindow)
528  : BC_CheckBox(x,
529         y,
530         pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
531 {
532         this->pwindow = pwindow;
533 }
534
535 int ViewThumbnails::handle_event()
536 {
537         pwindow->thread->preferences->use_thumbnails = get_value();
538         return 1;
539 }
540
541
542 ViewThumbnailSize::ViewThumbnailSize(PreferencesWindow *pwindow,
543                 AppearancePrefs *aprefs, int x, int y)
544  : BC_TumbleTextBox(aprefs,
545         pwindow->thread->preferences->awindow_picon_h,
546         16, 512, x, y, xS(80))
547
548 {
549         this->pwindow = pwindow;
550         this->aprefs = aprefs;
551 }
552
553 int ViewThumbnailSize::handle_event()
554 {
555         int v = atoi(get_text());
556         bclamp(v, 16,512);
557         pwindow->thread->preferences->awindow_picon_h = v;
558         return 1;
559 }
560
561 ViewViconSize::ViewViconSize(PreferencesWindow *pwindow,
562                 AppearancePrefs *aprefs, int x, int y)
563  : BC_TumbleTextBox(aprefs,
564         pwindow->thread->preferences->vicon_size,
565         16, 512, x, y, xS(80))
566
567 {
568         this->pwindow = pwindow;
569         this->aprefs = aprefs;
570 }
571
572 int ViewViconSize::handle_event()
573 {
574         int v = atoi(get_text());
575         bclamp(v, 16,512);
576         pwindow->thread->preferences->vicon_size = v;
577         return 1;
578 }
579
580 ViewViconColorMode::ViewViconColorMode(PreferencesWindow *pwindow, int x, int y)
581  : BC_PopupMenu(x, y, xS(100),
582         _(vicon_color_modes[pwindow->thread->preferences->vicon_color_mode]), 1)
583 {
584         this->pwindow = pwindow;
585 }
586 ViewViconColorMode::~ViewViconColorMode()
587 {
588 }
589
590 const char *ViewViconColorMode::vicon_color_modes[] = {
591         N_("Low"),
592         N_("Med"),
593         N_("High"),
594 };
595
596 void ViewViconColorMode::create_objects()
597 {
598         for( int id=0,nid=sizeof(vicon_color_modes)/sizeof(vicon_color_modes[0]); id<nid; ++id )
599                 add_item(new ViewViconColorModeItem(this, _(vicon_color_modes[id]), id));
600         handle_event();
601 }
602
603 int ViewViconColorMode::handle_event()
604 {
605         set_text(_(vicon_color_modes[pwindow->thread->preferences->vicon_color_mode]));
606         return 1;
607 }
608
609 ViewViconColorModeItem::ViewViconColorModeItem(ViewViconColorMode *popup, const char *text, int id)
610  : BC_MenuItem(text)
611 {
612         this->popup = popup;
613         this->id = id;
614 }
615
616 int ViewViconColorModeItem::handle_event()
617 {
618         popup->set_text(get_text());
619         popup->pwindow->thread->preferences->vicon_color_mode = id;
620         return popup->handle_event();
621 }
622
623
624 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
625  : BC_CheckBox(x,
626         y,
627         pwindow->thread->preferences->use_tipwindow,
628         _("Show tip of the day"))
629 {
630         this->pwindow = pwindow;
631 }
632 int UseTipWindow::handle_event()
633 {
634         pwindow->thread->preferences->use_tipwindow = get_value();
635         return 1;
636 }
637
638
639 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
640  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_indexes,
641         _("ffmpeg probe warns rebuild indexes"))
642 {
643         this->pwindow = pwindow;
644 }
645
646 int UseWarnIndecies::handle_event()
647 {
648         pwindow->thread->preferences->warn_indexes = get_value();
649         return 1;
650 }
651
652 UseWarnVersion::UseWarnVersion(PreferencesWindow *pwindow, int x, int y)
653  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_version,
654         _("EDL version warns if mismatched"))
655 {
656         this->pwindow = pwindow;
657 }
658
659 int UseWarnVersion::handle_event()
660 {
661         pwindow->thread->preferences->warn_version = get_value();
662         return 1;
663 }
664
665 BD_WarnRoot::BD_WarnRoot(PreferencesWindow *pwindow, int x, int y)
666  : BC_CheckBox(x, y, pwindow->thread->preferences->bd_warn_root,
667         _("Create Bluray warns if not root"))
668 {
669         this->pwindow = pwindow;
670 }
671
672 int BD_WarnRoot::handle_event()
673 {
674         pwindow->thread->preferences->bd_warn_root = get_value();
675         return 1;
676 }
677
678 UseWarnFileRef::UseWarnFileRef(PreferencesWindow *pwindow, int x, int y)
679  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_fileref,
680         _("Warn on creating file references"))
681 {
682         this->pwindow = pwindow;
683 }
684
685 int UseWarnFileRef::handle_event()
686 {
687         pwindow->thread->preferences->warn_fileref = get_value();
688         return 1;
689 }
690
691
692 PopupMenuBtnup::PopupMenuBtnup(PreferencesWindow *pwindow, int x, int y)
693  : BC_CheckBox(x, y, pwindow->thread->preferences->popupmenu_btnup,
694         _("Popups activate on button up"))
695 {
696         this->pwindow = pwindow;
697 }
698
699 int PopupMenuBtnup::handle_event()
700 {
701         pwindow->thread->preferences->popupmenu_btnup = get_value();
702         return 1;
703 }
704
705 GrabFocusPolicy::GrabFocusPolicy(PreferencesWindow *pwindow, int x, int y)
706  : BC_CheckBox(x, y, (pwindow->thread->preferences->grab_input_focus) != 0,
707         _("Set Input Focus when window entered"))
708 {
709         this->pwindow = pwindow;
710 }
711
712 int GrabFocusPolicy::handle_event()
713 {
714         pwindow->thread->preferences->grab_input_focus = get_value();
715         return 1;
716 }
717
718 ActivateFocusPolicy::ActivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
719  : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_ACTIVATE) != 0,
720         _("Click to activate text focus"))
721 {
722         this->pwindow = pwindow;
723 }
724
725 int ActivateFocusPolicy::handle_event()
726 {
727         if( get_value() )
728                 pwindow->thread->preferences->textbox_focus_policy |= CLICK_ACTIVATE;
729         else
730                 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_ACTIVATE;
731         return 1;
732 }
733
734 DeactivateFocusPolicy::DeactivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
735  : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_DEACTIVATE) != 0,
736         _("Click to deactivate text focus"))
737 {
738         this->pwindow = pwindow;
739 }
740
741 int DeactivateFocusPolicy::handle_event()
742 {
743         if( get_value() )
744                 pwindow->thread->preferences->textbox_focus_policy |= CLICK_DEACTIVATE;
745         else
746                 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_DEACTIVATE;
747         return 1;
748 }
749
750 AutoRotate::AutoRotate(PreferencesWindow *pwindow, int x, int y)
751  : BC_CheckBox(x, y, pwindow->thread->preferences->auto_rotate != 0,
752         _("Auto rotate ffmpeg media"))
753 {
754         this->pwindow = pwindow;
755 }
756
757 int AutoRotate::handle_event()
758 {
759         pwindow->thread->preferences->auto_rotate = get_value();
760         return 1;
761 }
762
763 ForwardRenderDisplacement::ForwardRenderDisplacement(PreferencesWindow *pwindow, int x, int y)
764  : BC_CheckBox(x, y, pwindow->thread->preferences->forward_render_displacement,
765         _("Always show next frame"))
766 {
767         this->pwindow = pwindow;
768 }
769
770 int ForwardRenderDisplacement::handle_event()
771 {
772         pwindow->thread->preferences->forward_render_displacement = get_value();
773         return 1;
774 }
775
776 AutocolorAssets::AutocolorAssets(PreferencesWindow *pwindow, int x, int y)
777  : BC_CheckBox(x, y, pwindow->thread->preferences->autocolor_assets,
778         _("Autocolor assets"))
779 {
780         this->pwindow = pwindow;
781 }
782
783 int AutocolorAssets::handle_event()
784 {
785         pwindow->thread->preferences->autocolor_assets = get_value();
786         return 1;
787 }
788
789 HighlightInverseColor::HighlightInverseColor(PreferencesWindow *pwindow, int x, int y, const char *hex)
790  : BC_TextBox(x, y, xS(80), 1, hex)
791 {
792         this->pwindow = pwindow;
793 }
794
795 int HighlightInverseColor::handle_event()
796 {
797         int inverse_color = strtoul(get_text(),0,16);
798         if( (inverse_color &= 0xffffff) == 0 ) {
799                 inverse_color = 0xffffff;
800                 char string[BCSTRLEN];
801                 sprintf(string,"%06x", inverse_color);
802                 update(string);
803         }
804         pwindow->thread->preferences->highlight_inverse = inverse_color;
805         return 1;
806 }
807
808
809 const char *YuvColorSpace::color_space[] = {
810         N_("BT601"), // COLOR_SPACE_BT601
811         N_("BT709"), // COLOR_SPACE_BT709
812         N_("BT2020"), // COLOR_SPACE_BT2020
813 };
814
815 YuvColorSpace::YuvColorSpace(int x, int y, PreferencesWindow *pwindow)
816  : BC_PopupMenu(x, y, xS(120),
817         _(color_space[pwindow->thread->preferences->yuv_color_space]), 1)
818 {
819         this->pwindow = pwindow;
820 }
821 YuvColorSpace::~YuvColorSpace()
822 {
823 }
824
825 void YuvColorSpace::create_objects()
826 {
827         for( int id=0,nid=sizeof(color_space)/sizeof(color_space[0]); id<nid; ++id )
828                 add_item(new YuvColorSpaceItem(this, _(color_space[id]), id));
829         handle_event();
830 }
831
832 int YuvColorSpace::handle_event()
833 {
834         set_text(_(color_space[pwindow->thread->preferences->yuv_color_space]));
835         return 1;
836 }
837
838 YuvColorSpaceItem::YuvColorSpaceItem(YuvColorSpace *popup, const char *text, int id)
839  : BC_MenuItem(text)
840 {
841         this->popup = popup;
842         this->id = id;
843 }
844
845 int YuvColorSpaceItem::handle_event()
846 {
847         popup->set_text(get_text());
848         popup->pwindow->thread->preferences->yuv_color_space = id;
849         return popup->handle_event();
850 }
851
852
853 const char *YuvColorRange::color_range[] = {
854         N_("JPEG"), // COLOR_RANGE_JPEG
855         N_("MPEG"), // COLOR_RANGE_MPEG
856 };
857
858 YuvColorRange::YuvColorRange(int x, int y, PreferencesWindow *pwindow)
859  : BC_PopupMenu(x, y, xS(100),
860         _(color_range[pwindow->thread->preferences->yuv_color_range]), 1)
861 {
862         this->pwindow = pwindow;
863 }
864 YuvColorRange::~YuvColorRange()
865 {
866 }
867
868 void YuvColorRange::create_objects()
869 {
870         for( int id=0,nid=sizeof(color_range)/sizeof(color_range[0]); id<nid; ++id )
871                 add_item(new YuvColorRangeItem(this, _(color_range[id]), id));
872         handle_event();
873 }
874
875 int YuvColorRange::handle_event()
876 {
877         set_text(color_range[pwindow->thread->preferences->yuv_color_range]);
878         return 1;
879 }
880
881 YuvColorRangeItem::YuvColorRangeItem(YuvColorRange *popup, const char *text, int id)
882  : BC_MenuItem(text)
883 {
884         this->popup = popup;
885         this->id = id;
886 }
887
888 int YuvColorRangeItem::handle_event()
889 {
890         popup->set_text(get_text());
891         popup->pwindow->thread->preferences->yuv_color_range = id;
892         return popup->handle_event();
893 }
894
895 PerpetualSession::PerpetualSession(int x, int y, PreferencesWindow *pwindow)
896  : BC_CheckBox(x, y,
897         pwindow->thread->preferences->perpetual_session, _("Perpetual session"))
898 {
899         this->pwindow = pwindow;
900 }
901
902 int PerpetualSession::handle_event()
903 {
904         pwindow->thread->preferences->perpetual_session = get_value();
905         return 1;
906 }
907
908 CtrlToggle::CtrlToggle(int x, int y, PreferencesWindow *pwindow)
909  : BC_CheckBox(x, y,
910         pwindow->thread->preferences->ctrl_toggle, _("Clears before toggle"))
911 {
912         this->pwindow = pwindow;
913 }
914
915 int CtrlToggle::handle_event()
916 {
917         pwindow->thread->preferences->ctrl_toggle = get_value();
918         return 1;
919 }
920
921 RectifyAudioToggle::RectifyAudioToggle(int x, int y, PreferencesWindow *pwindow)
922  : BC_CheckBox(x, y,
923         pwindow->thread->preferences->rectify_audio, _("Timeline Rectify Audio"))
924 {
925         this->pwindow = pwindow;
926 }
927
928 int RectifyAudioToggle::handle_event()
929 {
930         pwindow->thread->preferences->rectify_audio = get_value();
931         return 1;
932 }
933
934 Composer_BG_Color::Composer_BG_Color(PreferencesWindow *pwindow,
935                 int x, int y, int w, int h, int color, int alpha)
936  : ColorBoxButton(_("Composer BG color"), x, y, w, h, color, alpha, 1)
937 {
938         this->pwindow = pwindow;
939 }
940
941 Composer_BG_Color::~Composer_BG_Color()
942 {
943 }
944
945 void Composer_BG_Color::handle_done_event(int result)
946 {
947         if( result ) {
948                 pwindow->lock_window("Composer_BG_Color::handle_done_event");
949                 update_gui(orig_color, orig_alpha);
950                 pwindow->unlock_window();
951                 handle_new_color(orig_color, orig_alpha);
952         }
953 }
954
955 int Composer_BG_Color::handle_new_color(int color, int alpha)
956 {
957         pwindow->thread->edl->session->cwindow_clear_color = color;
958         pwindow->thread->edl->session->cwindow_clear_alpha = alpha;
959         return 1;
960 }
961