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