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