c80ee26bef23c2a00ff0557087ca65fdbdc33700
[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         add_subwindow(cwdw_bg_color = new Composer_BG_Color(pwindow,
188                 x2, y, xS(80), yS(24), clr_color));
189         draw_3d_border(x2-2,y-2, xS(80)+4,xS(24)+4, 1);
190         cwdw_bg_color->create_objects();
191         x2 += cwdw_bg_color->get_w();
192         y += ys35;
193
194         add_subwindow(title = new BC_Title(x1, y, _("YUV color space:")));
195         x = x2 - xS(120);
196         add_subwindow(yuv_color_space = new YuvColorSpace(x, y, pwindow));
197         yuv_color_space->create_objects();
198         y += yuv_color_space->get_h() + ys5;
199
200         add_subwindow(title = new BC_Title(x1, y, _("YUV color range:")));
201         x = x2 - xS(100);
202         add_subwindow(yuv_color_range = new YuvColorRange(x, y, pwindow));
203         yuv_color_range->create_objects();
204         y += yuv_color_range->get_h() + ys35;
205         if( y2 < y ) y2 = y;
206
207         add_subwindow(new BC_Bar(x0, y2, get_w()-x0 - xs30));
208         y += ys35;
209
210         x = x0;  y1 = y;
211         add_subwindow(title = new BC_Title(x, y, _("Warnings:"), LARGEFONT,
212                 resources->text_default));
213         y += title->get_h() + ys10;
214         UseWarnIndecies *idx_warn = new UseWarnIndecies(pwindow, x, y);
215         add_subwindow(idx_warn);
216         y += idx_warn->get_h() + ys5;
217         BD_WarnRoot *bdwr_warn = new BD_WarnRoot(pwindow, x, y);
218         add_subwindow(bdwr_warn);
219         y += bdwr_warn->get_h() + ys5;
220         UseWarnFileRef *warn_ref = new UseWarnFileRef(pwindow, x, y);
221         add_subwindow(warn_ref);
222         y += warn_ref->get_h() + ys5;
223         
224         add_subwindow(new BC_Bar(x0, y, warn_ref->get_w()-x0 - xs30));
225         y += ys15;
226
227         add_subwindow(title = new BC_Title(x, y, _("Dangerous:"), LARGEFONT,
228                 resources->text_default));
229         y += title->get_h() + ys10;
230
231         
232         UseUnsafeGUI *unsafe_gui = new UseUnsafeGUI(pwindow, x, y);
233         add_subwindow(unsafe_gui);
234         y += unsafe_gui->get_h() + ys5;
235         OngoingBackups *ongoing_backups = new OngoingBackups(pwindow, x, y);
236         add_subwindow(ongoing_backups);
237         y += ongoing_backups->get_h() + ys5;
238
239         x = get_w() / 3 + xs30;
240         y = y1;
241         add_subwindow(title = new BC_Title(x, y, _("Flags:"), LARGEFONT,
242                 resources->text_default));
243         y += title->get_h() + ys10;
244         y1 = y;
245         AutocolorAssets *autocolor_assets = new AutocolorAssets(pwindow, x, y);
246         add_subwindow(autocolor_assets);
247         y += autocolor_assets->get_h() + ys5;
248         PerpetualSession *perpetual = new PerpetualSession(x, y, pwindow);
249         add_subwindow(perpetual);
250         y += perpetual->get_h() + ys5;
251         RectifyAudioToggle *rect_toggle = new RectifyAudioToggle(x, y, pwindow);
252         add_subwindow(rect_toggle);
253         y += rect_toggle->get_h() + ys5;
254         CtrlToggle *ctrl_toggle = new CtrlToggle(x, y, pwindow);
255         add_subwindow(ctrl_toggle);
256         y += ctrl_toggle->get_h() + ys5;
257         ForwardRenderDisplacement *displacement = new ForwardRenderDisplacement(pwindow, x, y);
258         add_subwindow(displacement);
259         y += displacement->get_h() + ys5;
260         UseTipWindow *tip_win = new UseTipWindow(pwindow, x, y);
261         add_subwindow(tip_win);
262         y += tip_win->get_h() + ys5;
263
264         x = 2*get_w() / 3 - xs30;
265         y = y1;
266         add_subwindow(thumbnails = new ViewThumbnails(x, y, pwindow));
267         y += thumbnails->get_h() + ys5;
268         PopupMenuBtnup *pop_win = new PopupMenuBtnup(pwindow, x, y);
269         add_subwindow(pop_win);
270         y += pop_win->get_h() + ys5;
271         GrabFocusPolicy *grab_input_focus = new GrabFocusPolicy(pwindow, x, y);
272         add_subwindow(grab_input_focus);
273         y += grab_input_focus->get_h() + ys5;
274         ActivateFocusPolicy *focus_activate = new ActivateFocusPolicy(pwindow, x, y);
275         add_subwindow(focus_activate);
276         y += focus_activate->get_h() + ys5;
277         DeactivateFocusPolicy *focus_deactivate = new DeactivateFocusPolicy(pwindow, x, y);
278         add_subwindow(focus_deactivate);
279         y += focus_deactivate->get_h() + ys5;
280         AutoRotate *auto_rotate = new AutoRotate(pwindow, x, y);
281         add_subwindow(auto_rotate);
282         y += auto_rotate->get_h() + ys5;
283 }
284
285 int AppearancePrefs::update(int new_value)
286 {
287         pwindow->thread->redraw_times = 1;
288         pwindow->thread->edl->session->time_format = new_value;
289         hms->update(new_value == TIME_HMS);
290         hmsf->update(new_value == TIME_HMSF);
291         timecode->update(new_value == TIME_TIMECODE);
292         samples->update(new_value == TIME_SAMPLES);
293         hex->update(new_value == TIME_SAMPLES_HEX);
294         frames->update(new_value == TIME_FRAMES);
295         feet->update(new_value == TIME_FEET_FRAMES);
296         seconds->update(new_value == TIME_SECONDS);
297         return 0;
298 }
299
300
301 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
302  : BC_Radial(x, y, value, TIME_HMS_TEXT)
303 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
304
305 int TimeFormatHMS::handle_event()
306 {
307         tfwindow->update(TIME_HMS);
308         return 1;
309 }
310
311 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
312  : BC_Radial(x, y, value, TIME_HMSF_TEXT)
313 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
314
315 int TimeFormatHMSF::handle_event()
316 {
317         tfwindow->update(TIME_HMSF);
318         return 1;
319 }
320
321 TimeFormatTimecode::TimeFormatTimecode(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
322  : BC_Radial(x, y, value, TIME_TIMECODE_TEXT)
323 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
324
325 int TimeFormatTimecode::handle_event()
326 {
327         tfwindow->update(TIME_TIMECODE);
328         return 1;
329 }
330
331 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
332  : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
333 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
334
335 int TimeFormatSamples::handle_event()
336 {
337         tfwindow->update(TIME_SAMPLES);
338         return 1;
339 }
340
341 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
342  : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
343 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
344
345 int TimeFormatFrames::handle_event()
346 {
347         tfwindow->update(TIME_FRAMES);
348         return 1;
349 }
350
351 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
352  : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
353 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
354
355 int TimeFormatHex::handle_event()
356 {
357         tfwindow->update(TIME_SAMPLES_HEX);
358         return 1;
359 }
360
361 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
362  : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
363 {
364         this->pwindow = pwindow;
365         this->tfwindow = tfwindow;
366 }
367
368 int TimeFormatSeconds::handle_event()
369 {
370         tfwindow->update(TIME_SECONDS);
371         return 1;
372 }
373
374 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, AppearancePrefs *tfwindow, int value, int x, int y)
375  : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
376 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
377
378 int TimeFormatFeet::handle_event()
379 {
380         tfwindow->update(TIME_FEET_FRAMES);
381         return 1;
382 }
383
384 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
385  : BC_TextBox(x, y, xS(90), 1, string)
386 { this->pwindow = pwindow; }
387
388 int TimeFormatFeetSetting::handle_event()
389 {
390         pwindow->thread->edl->session->frames_per_foot = atof(get_text());
391         if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
392         return 0;
393 }
394
395
396 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
397  : BC_PopupMenu(x, y, xS(200), pwindow->thread->preferences->theme, 1)
398 {
399         this->pwindow = pwindow;
400 }
401 ViewTheme::~ViewTheme()
402 {
403 }
404
405 void ViewTheme::create_objects()
406 {
407         ArrayList<PluginServer*> themes;
408         MWindow::search_plugindb(0, 0, 0, 0, 1, themes);
409
410         for(int i = 0; i < themes.total; i++) {
411                 add_item(new ViewThemeItem(this, themes.values[i]->title));
412         }
413 }
414
415 int ViewTheme::handle_event()
416 {
417         return 1;
418 }
419
420 ViewThemeItem::ViewThemeItem(ViewTheme *popup, const char *text)
421  : BC_MenuItem(text)
422 {
423         this->popup = popup;
424 }
425
426 int ViewThemeItem::handle_event()
427 {
428         popup->set_text(get_text());
429         strcpy(popup->pwindow->thread->preferences->theme, get_text());
430         popup->handle_event();
431         return 1;
432 }
433
434
435 ViewPluginIcons::ViewPluginIcons(int x, int y, PreferencesWindow *pwindow)
436  : BC_PopupMenu(x, y, xS(200), pwindow->thread->preferences->plugin_icons, 1)
437 {
438         this->pwindow = pwindow;
439 }
440 ViewPluginIcons::~ViewPluginIcons()
441 {
442 }
443
444 void ViewPluginIcons::create_objects()
445 {
446         add_item(new ViewPluginIconItem(this, DEFAULT_PICON));
447         FileSystem fs;
448         const char *plugin_path = File::get_plugin_path();
449         char picon_path[BCTEXTLEN];
450         snprintf(picon_path,sizeof(picon_path)-1,"%s/picon", plugin_path);
451         if( fs.update(picon_path) ) return;
452         for( int i=0; i<fs.dir_list.total; ++i ) {
453                 char *fs_path = fs.dir_list[i]->path;
454                 if( !fs.is_dir(fs_path) ) continue;
455                 char *cp = strrchr(fs_path,'/');
456                 cp = !cp ? fs_path : cp+1;
457                 if( !strcmp(cp,DEFAULT_PICON) ) continue;
458                 add_item(new ViewPluginIconItem(this, cp));
459         }
460 }
461
462 int ViewPluginIcons::handle_event()
463 {
464         return 1;
465 }
466
467 ViewPluginIconItem::ViewPluginIconItem(ViewPluginIcons *popup, const char *text)
468  : BC_MenuItem(text)
469 {
470         this->popup = popup;
471 }
472
473 int ViewPluginIconItem::handle_event()
474 {
475         popup->set_text(get_text());
476         strcpy(popup->pwindow->thread->preferences->plugin_icons, get_text());
477         popup->handle_event();
478         return 1;
479 }
480
481 LayoutLocale::LayoutLocale(int x, int y, PreferencesWindow *pwindow)
482  : BC_PopupMenu(x, y, xS(200), pwindow->thread->preferences->locale, 1)
483 {
484         this->pwindow = pwindow;
485 }
486 LayoutLocale::~LayoutLocale()
487 {
488 }
489
490 const char *LayoutLocale::locale_list[] = { LOCALE_LIST, 0 };
491
492 void LayoutLocale::create_objects()
493 {
494         for( const char *tp, **lp=locale_list; (tp=*lp)!=0; ++lp )
495                 add_item(new LayoutLocaleItem(this, tp));
496 }
497
498 int LayoutLocale::handle_event()
499 {
500         return 1;
501 }
502
503 LayoutLocaleItem::LayoutLocaleItem(LayoutLocale *popup, const char *text)
504  : BC_MenuItem(text)
505 {
506         this->popup = popup;
507 }
508
509 int LayoutLocaleItem::handle_event()
510 {
511         popup->set_text(get_text());
512         strcpy(popup->pwindow->thread->preferences->locale, get_text());
513         popup->handle_event();
514         return 1;
515 }
516
517 ViewLayoutScale::ViewLayoutScale(PreferencesWindow *pwindow,
518                 AppearancePrefs *aprefs, int x, int y)
519  : BC_TumbleTextBox(aprefs,
520         pwindow->thread->preferences->layout_scale,
521         0.f, 10.f, x, y, xS(80), 2)
522 {
523         this->pwindow = pwindow;
524         this->aprefs = aprefs;
525         set_increment(0.1);
526 }
527
528 int ViewLayoutScale::handle_event()
529 {
530         float v = atof(get_text());
531         pwindow->thread->preferences->layout_scale = v;
532         return 1;
533 }
534
535
536 ViewThumbnails::ViewThumbnails(int x,
537         int y,
538         PreferencesWindow *pwindow)
539  : BC_CheckBox(x,
540         y,
541         pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
542 {
543         this->pwindow = pwindow;
544 }
545
546 int ViewThumbnails::handle_event()
547 {
548         pwindow->thread->preferences->use_thumbnails = get_value();
549         return 1;
550 }
551
552
553 ViewThumbnailSize::ViewThumbnailSize(PreferencesWindow *pwindow,
554                 AppearancePrefs *aprefs, int x, int y)
555  : BC_TumbleTextBox(aprefs,
556         pwindow->thread->preferences->awindow_picon_h,
557         16, 512, x, y, xS(80))
558
559 {
560         this->pwindow = pwindow;
561         this->aprefs = aprefs;
562 }
563
564 int ViewThumbnailSize::handle_event()
565 {
566         int v = atoi(get_text());
567         bclamp(v, 16,512);
568         pwindow->thread->preferences->awindow_picon_h = v;
569         return 1;
570 }
571
572 ViewViconSize::ViewViconSize(PreferencesWindow *pwindow,
573                 AppearancePrefs *aprefs, int x, int y)
574  : BC_TumbleTextBox(aprefs,
575         pwindow->thread->preferences->vicon_size,
576         16, 512, x, y, xS(80))
577
578 {
579         this->pwindow = pwindow;
580         this->aprefs = aprefs;
581 }
582
583 int ViewViconSize::handle_event()
584 {
585         int v = atoi(get_text());
586         bclamp(v, 16,512);
587         pwindow->thread->preferences->vicon_size = v;
588         return 1;
589 }
590
591 ViewViconColorMode::ViewViconColorMode(PreferencesWindow *pwindow, int x, int y)
592  : BC_PopupMenu(x, y, xS(100),
593         _(vicon_color_modes[pwindow->thread->preferences->vicon_color_mode]), 1)
594 {
595         this->pwindow = pwindow;
596 }
597 ViewViconColorMode::~ViewViconColorMode()
598 {
599 }
600
601 const char *ViewViconColorMode::vicon_color_modes[] = {
602         N_("Low"),
603         N_("Med"),
604         N_("High"),
605 };
606
607 void ViewViconColorMode::create_objects()
608 {
609         for( int id=0,nid=sizeof(vicon_color_modes)/sizeof(vicon_color_modes[0]); id<nid; ++id )
610                 add_item(new ViewViconColorModeItem(this, _(vicon_color_modes[id]), id));
611         handle_event();
612 }
613
614 int ViewViconColorMode::handle_event()
615 {
616         set_text(_(vicon_color_modes[pwindow->thread->preferences->vicon_color_mode]));
617         return 1;
618 }
619
620 ViewViconColorModeItem::ViewViconColorModeItem(ViewViconColorMode *popup, const char *text, int id)
621  : BC_MenuItem(text)
622 {
623         this->popup = popup;
624         this->id = id;
625 }
626
627 int ViewViconColorModeItem::handle_event()
628 {
629         popup->set_text(get_text());
630         popup->pwindow->thread->preferences->vicon_color_mode = id;
631         return popup->handle_event();
632 }
633
634
635 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
636  : BC_CheckBox(x,
637         y,
638         pwindow->thread->preferences->use_tipwindow,
639         _("Show tip of the day"))
640 {
641         this->pwindow = pwindow;
642 }
643 int UseTipWindow::handle_event()
644 {
645         pwindow->thread->preferences->use_tipwindow = get_value();
646         return 1;
647 }
648
649
650 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
651  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_indexes,
652         _("ffmpeg probe warns rebuild indexes"))
653 {
654         this->pwindow = pwindow;
655 }
656
657 int UseWarnIndecies::handle_event()
658 {
659         pwindow->thread->preferences->warn_indexes = get_value();
660         return 1;
661 }
662
663 UseUnsafeGUI::UseUnsafeGUI(PreferencesWindow *pwindow, int x, int y)
664  : BC_CheckBox(x, y, pwindow->thread->preferences->unsafe_gui,
665         _("Unsafe GUI in batchrender"))
666 {
667         this->pwindow = pwindow;
668         set_tooltip(_("Save to EDL path option becomes available and will overwrite EDL on disk. \n Warn if jobs/session mismatch option is available but can be unchecked."));
669 }
670
671 int UseUnsafeGUI::handle_event()
672 {
673         pwindow->thread->preferences->unsafe_gui = get_value();
674         return 1;
675 }
676
677 OngoingBackups::OngoingBackups(PreferencesWindow *pwindow, int x, int y)
678  : BC_CheckBox(x, y, pwindow->thread->preferences->ongoing_backups,
679         _("Autosave continuous backups"))
680 {
681         this->pwindow = pwindow;
682         set_tooltip(_("When you stop Cinelerra, all but the newest 50 will be deleted but you risk \n running out of disk space if you do a lot of work without restarting."));
683 }
684
685 int OngoingBackups::handle_event()
686 {
687         pwindow->thread->preferences->ongoing_backups = get_value();
688         return 1;
689 }
690
691 BD_WarnRoot::BD_WarnRoot(PreferencesWindow *pwindow, int x, int y)
692  : BC_CheckBox(x, y, pwindow->thread->preferences->bd_warn_root,
693         _("Create Bluray warns if not root"))
694 {
695         this->pwindow = pwindow;
696 }
697
698 int BD_WarnRoot::handle_event()
699 {
700         pwindow->thread->preferences->bd_warn_root = get_value();
701         return 1;
702 }
703
704 UseWarnFileRef::UseWarnFileRef(PreferencesWindow *pwindow, int x, int y)
705  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_fileref,
706         _("Warn on creating file references"))
707 {
708         this->pwindow = pwindow;
709 }
710
711 int UseWarnFileRef::handle_event()
712 {
713         pwindow->thread->preferences->warn_fileref = get_value();
714         return 1;
715 }
716
717
718 PopupMenuBtnup::PopupMenuBtnup(PreferencesWindow *pwindow, int x, int y)
719  : BC_CheckBox(x, y, pwindow->thread->preferences->popupmenu_btnup,
720         _("Popups activate on button up"))
721 {
722         this->pwindow = pwindow;
723 }
724
725 int PopupMenuBtnup::handle_event()
726 {
727         pwindow->thread->preferences->popupmenu_btnup = get_value();
728         return 1;
729 }
730
731 GrabFocusPolicy::GrabFocusPolicy(PreferencesWindow *pwindow, int x, int y)
732  : BC_CheckBox(x, y, (pwindow->thread->preferences->grab_input_focus) != 0,
733         _("Set Input Focus when window entered"))
734 {
735         this->pwindow = pwindow;
736 }
737
738 int GrabFocusPolicy::handle_event()
739 {
740         pwindow->thread->preferences->grab_input_focus = get_value();
741         return 1;
742 }
743
744 ActivateFocusPolicy::ActivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
745  : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_ACTIVATE) != 0,
746         _("Click to activate text focus"))
747 {
748         this->pwindow = pwindow;
749 }
750
751 int ActivateFocusPolicy::handle_event()
752 {
753         if( get_value() )
754                 pwindow->thread->preferences->textbox_focus_policy |= CLICK_ACTIVATE;
755         else
756                 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_ACTIVATE;
757         return 1;
758 }
759
760 DeactivateFocusPolicy::DeactivateFocusPolicy(PreferencesWindow *pwindow, int x, int y)
761  : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_DEACTIVATE) != 0,
762         _("Click to deactivate text focus"))
763 {
764         this->pwindow = pwindow;
765 }
766
767 int DeactivateFocusPolicy::handle_event()
768 {
769         if( get_value() )
770                 pwindow->thread->preferences->textbox_focus_policy |= CLICK_DEACTIVATE;
771         else
772                 pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_DEACTIVATE;
773         return 1;
774 }
775
776 AutoRotate::AutoRotate(PreferencesWindow *pwindow, int x, int y)
777  : BC_CheckBox(x, y, pwindow->thread->preferences->auto_rotate != 0,
778         _("Auto rotate ffmpeg media"))
779 {
780         this->pwindow = pwindow;
781         set_tooltip(_("Automatically rotates media if legal rotation metadata in file."));
782 }
783
784 int AutoRotate::handle_event()
785 {
786         pwindow->thread->preferences->auto_rotate = get_value();
787         return 1;
788 }
789
790 ForwardRenderDisplacement::ForwardRenderDisplacement(PreferencesWindow *pwindow, int x, int y)
791  : BC_CheckBox(x, y, pwindow->thread->preferences->forward_render_displacement,
792         _("Always show next frame"))
793 {
794         this->pwindow = pwindow;
795 }
796
797 int ForwardRenderDisplacement::handle_event()
798 {
799         pwindow->thread->preferences->forward_render_displacement = get_value();
800         return 1;
801 }
802
803 AutocolorAssets::AutocolorAssets(PreferencesWindow *pwindow, int x, int y)
804  : BC_CheckBox(x, y, pwindow->thread->preferences->autocolor_assets,
805         _("Autocolor assets"))
806 {
807         this->pwindow = pwindow;
808         set_tooltip(_("Displays automatically generated color overlay for the \n edits on the timeline that belong to the same media file."));
809 }
810
811 int AutocolorAssets::handle_event()
812 {
813         pwindow->thread->preferences->autocolor_assets = get_value();
814         return 1;
815 }
816
817 HighlightInverseColor::HighlightInverseColor(PreferencesWindow *pwindow, int x, int y, const char *hex)
818  : BC_TextBox(x, y, xS(80), 1, hex)
819 {
820         this->pwindow = pwindow;
821 }
822
823 int HighlightInverseColor::handle_event()
824 {
825         int inverse_color = strtoul(get_text(),0,16);
826         if( (inverse_color &= 0xffffff) == 0 ) {
827                 inverse_color = 0xffffff;
828                 char string[BCSTRLEN];
829                 sprintf(string,"%06x", inverse_color);
830                 update(string);
831         }
832         pwindow->thread->preferences->highlight_inverse = inverse_color;
833         return 1;
834 }
835
836
837 const char *YuvColorSpace::color_space[] = {
838         N_("BT601"), // COLOR_SPACE_BT601
839         N_("BT709"), // COLOR_SPACE_BT709
840         N_("BT2020"), // COLOR_SPACE_BT2020
841 };
842
843 YuvColorSpace::YuvColorSpace(int x, int y, PreferencesWindow *pwindow)
844  : BC_PopupMenu(x, y, xS(120),
845         _(color_space[pwindow->thread->preferences->yuv_color_space]), 1)
846 {
847         this->pwindow = pwindow;
848 }
849 YuvColorSpace::~YuvColorSpace()
850 {
851 }
852
853 void YuvColorSpace::create_objects()
854 {
855         for( int id=0,nid=sizeof(color_space)/sizeof(color_space[0]); id<nid; ++id )
856                 add_item(new YuvColorSpaceItem(this, _(color_space[id]), id));
857         handle_event();
858 }
859
860 int YuvColorSpace::handle_event()
861 {
862         set_text(_(color_space[pwindow->thread->preferences->yuv_color_space]));
863         return 1;
864 }
865
866 YuvColorSpaceItem::YuvColorSpaceItem(YuvColorSpace *popup, const char *text, int id)
867  : BC_MenuItem(text)
868 {
869         this->popup = popup;
870         this->id = id;
871 }
872
873 int YuvColorSpaceItem::handle_event()
874 {
875         popup->set_text(get_text());
876         popup->pwindow->thread->preferences->yuv_color_space = id;
877         return popup->handle_event();
878 }
879
880
881 const char *YuvColorRange::color_range[] = {
882         N_("JPEG"), // COLOR_RANGE_JPEG
883         N_("MPEG"), // COLOR_RANGE_MPEG
884 };
885
886 YuvColorRange::YuvColorRange(int x, int y, PreferencesWindow *pwindow)
887  : BC_PopupMenu(x, y, xS(100),
888         _(color_range[pwindow->thread->preferences->yuv_color_range]), 1)
889 {
890         this->pwindow = pwindow;
891 }
892 YuvColorRange::~YuvColorRange()
893 {
894 }
895
896 void YuvColorRange::create_objects()
897 {
898         for( int id=0,nid=sizeof(color_range)/sizeof(color_range[0]); id<nid; ++id )
899                 add_item(new YuvColorRangeItem(this, _(color_range[id]), id));
900         handle_event();
901 }
902
903 int YuvColorRange::handle_event()
904 {
905         set_text(color_range[pwindow->thread->preferences->yuv_color_range]);
906         return 1;
907 }
908
909 YuvColorRangeItem::YuvColorRangeItem(YuvColorRange *popup, const char *text, int id)
910  : BC_MenuItem(text)
911 {
912         this->popup = popup;
913         this->id = id;
914 }
915
916 int YuvColorRangeItem::handle_event()
917 {
918         popup->set_text(get_text());
919         popup->pwindow->thread->preferences->yuv_color_range = id;
920         return popup->handle_event();
921 }
922
923 PerpetualSession::PerpetualSession(int x, int y, PreferencesWindow *pwindow)
924  : BC_CheckBox(x, y,
925         pwindow->thread->preferences->perpetual_session, _("Perpetual session"))
926 {
927         this->pwindow = pwindow;
928         set_tooltip(_("Resume previous session on startup with undo/redo stack saved between sessions. \n On startup, previous project is loaded as if there was no stoppage."));
929 }
930
931 int PerpetualSession::handle_event()
932 {
933         pwindow->thread->preferences->perpetual_session = get_value();
934         return 1;
935 }
936
937 CtrlToggle::CtrlToggle(int x, int y, PreferencesWindow *pwindow)
938  : BC_CheckBox(x, y,
939         pwindow->thread->preferences->ctrl_toggle, _("Clears before toggle"))
940 {
941         this->pwindow = pwindow;
942         set_tooltip(_("Drag and Drop editing - when using LMB on edit,\n clears all selected edits except this one."));
943 }
944
945 int CtrlToggle::handle_event()
946 {
947         pwindow->thread->preferences->ctrl_toggle = get_value();
948         return 1;
949 }
950
951 RectifyAudioToggle::RectifyAudioToggle(int x, int y, PreferencesWindow *pwindow)
952  : BC_CheckBox(x, y,
953         pwindow->thread->preferences->rectify_audio, _("Timeline Rectify Audio"))
954 {
955         this->pwindow = pwindow;
956         set_tooltip(_("Displays rectified audio showing only positive half of the waveform \n resulting in waveform stretched more over the height of the track."));
957 }
958
959 int RectifyAudioToggle::handle_event()
960 {
961         pwindow->thread->preferences->rectify_audio = get_value();
962         return 1;
963 }
964
965 Composer_BG_Color::Composer_BG_Color(PreferencesWindow *pwindow,
966                 int x, int y, int w, int h, int color)
967  : ColorBoxButton(_("Composer BG color"), x, y, w, h, color, -1, 1)
968 {
969         this->pwindow = pwindow;
970 }
971
972 Composer_BG_Color::~Composer_BG_Color()
973 {
974 }
975
976 void Composer_BG_Color::handle_done_event(int result)
977 {
978         if( result ) {
979                 pwindow->lock_window("Composer_BG_Color::handle_done_event");
980                 update_gui(orig_color, orig_alpha);
981                 pwindow->unlock_window();
982                 handle_new_color(orig_color, orig_alpha);
983         }
984 }
985
986 int Composer_BG_Color::handle_new_color(int color, int alpha)
987 {
988         pwindow->thread->edl->session->cwindow_clear_color = color;
989         return 1;
990 }
991