textbox/suggestion fixups, update to lossless, canvas scaling
[goodguy/history.git] / cinelerra-5.1 / cinelerra / interfaceprefs.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 "deleteallindexes.h"
23 #include "edl.h"
24 #include "edlsession.h"
25 #include "language.h"
26 #include "mwindow.h"
27 #include "preferences.h"
28 #include "preferencesthread.h"
29 #include "interfaceprefs.h"
30 #include "shbtnprefs.h"
31 #include "theme.h"
32
33 #if 0
34 N_("Drag all following edits")
35 N_("Drag only one edit")
36 N_("Drag source only")
37 N_("No effect")
38 #endif
39
40 #define MOVE_ALL_EDITS_TITLE "Drag all following edits"
41 #define MOVE_ONE_EDIT_TITLE "Drag only one edit"
42 #define MOVE_NO_EDITS_TITLE "Drag source only"
43 #define MOVE_EDITS_DISABLED_TITLE "No effect"
44
45 InterfacePrefs::InterfacePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
46  : PreferencesDialog(mwindow, pwindow)
47 {
48         hms = 0;
49         hmsf = 0;
50         samples = 0;
51         frames = 0;
52         hex = 0;
53         feet = 0;
54         min_db = 0;
55         max_db = 0;
56 //      vu_db = 0;
57 //      vu_int = 0;
58         thumbnails = 0;
59         shbtn_dialog = 0;
60 }
61
62 InterfacePrefs::~InterfacePrefs()
63 {
64         delete hms;
65         delete hmsf;
66         delete samples;
67         delete frames;
68         delete hex;
69         delete feet;
70         delete min_db;
71         delete max_db;
72 //      delete vu_db;
73 //      delete vu_int;
74         delete thumbnails;
75         delete shbtn_dialog;
76 }
77
78
79 void InterfacePrefs::create_objects()
80 {
81         int x, y;
82         BC_Resources *resources = BC_WindowBase::get_resources();
83         int margin = mwindow->theme->widget_border;
84         char string[BCTEXTLEN];
85         x = mwindow->theme->preferencesoptions_x;
86         y = mwindow->theme->preferencesoptions_y;
87
88         add_subwindow(new BC_Title(x, y, _("Time Format"), LARGEFONT,
89                 resources->text_default));
90         int x1 = get_w()/2;
91         add_subwindow(new BC_Title(x1, y, _("Flags"), LARGEFONT,
92                 resources->text_default));
93
94         y += get_text_height(LARGEFONT) + 5;
95         int y1 = y;
96
97         add_subwindow(hms = new TimeFormatHMS(pwindow, this,
98                 pwindow->thread->edl->session->time_format == TIME_HMS,
99                 x, y));
100         y += 20;
101         add_subwindow(hmsf = new TimeFormatHMSF(pwindow, this,
102                 pwindow->thread->edl->session->time_format == TIME_HMSF,
103                 x, y));
104         y += 20;
105         add_subwindow(samples = new TimeFormatSamples(pwindow, this,
106                 pwindow->thread->edl->session->time_format == TIME_SAMPLES,
107                 x, y));
108         y += 20;
109         add_subwindow(hex = new TimeFormatHex(pwindow, this,
110                 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX,
111                 x, y));
112         y += 20;
113         add_subwindow(frames = new TimeFormatFrames(pwindow, this,
114                 pwindow->thread->edl->session->time_format == TIME_FRAMES,
115                 x, y));
116         y += 20;
117         int x0 = x;
118         add_subwindow(feet = new TimeFormatFeet(pwindow, this,
119                 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES,
120                 x0, y));
121         x0 += feet->get_w() + 15;
122         BC_Title *title;
123         add_subwindow(title = new BC_Title(x0, y, _("Frames per foot:")));
124         x0 += title->get_w() + margin;
125         sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
126         add_subwindow(new TimeFormatFeetSetting(pwindow,
127                 x0, y - 5,      string));
128         y += 20;
129         add_subwindow(seconds = new TimeFormatSeconds(pwindow, this,
130                 pwindow->thread->edl->session->time_format == TIME_SECONDS,
131                 x, y));
132         y += 35;
133
134         UseTipWindow *tip_win = new UseTipWindow(pwindow, x1, y1);
135         add_subwindow(tip_win);
136         y1 += tip_win->get_h() + 5;
137         UseWarnIndecies *idx_win = new UseWarnIndecies(pwindow, x1, y1);
138         add_subwindow(idx_win);
139         y1 += idx_win->get_h() + 5;
140         UseWarnVersion *ver_win = new UseWarnVersion(pwindow, x1, y1);
141         add_subwindow(ver_win);
142         y1 += ver_win->get_h() + 5;
143         BD_WarnRoot *bdwr_win = new BD_WarnRoot(pwindow, x1, y1);
144         add_subwindow(bdwr_win);
145         y1 += bdwr_win->get_h() + 5;
146         PopupMenuBtnup *pop_win = new PopupMenuBtnup(pwindow, x1, y1);
147         add_subwindow(pop_win);
148         y1 += pop_win->get_h() + 25;
149
150         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
151         y += 5;
152
153         add_subwindow(new BC_Title(x, y, _("Index files"), LARGEFONT, resources->text_default));
154
155
156         y += 25;
157         add_subwindow(new BC_Title(x, y + 5,
158                 _("Index files go here:"), MEDIUMFONT, resources->text_default));
159         add_subwindow(ipathtext = new IndexPathText(x + 230, y,
160                 pwindow,
161                 pwindow->thread->preferences->index_directory));
162         add_subwindow(ipath = new BrowseButton(mwindow->theme, this, ipathtext,
163                 x + 230 + ipathtext->get_w(), y,
164                 pwindow->thread->preferences->index_directory,
165                 _("Index Path"),
166                 _("Select the directory for index files"),
167                 1));
168
169         y += 30;
170         add_subwindow(new BC_Title(x, y + 5,
171                 _("Size of index file:"),
172                 MEDIUMFONT,
173                 resources->text_default));
174         sprintf(string, "%jd", pwindow->thread->preferences->index_size);
175         add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
176         add_subwindow(new ScanCommercials(pwindow, 350,y));
177         y += 30;
178         add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"), MEDIUMFONT, resources->text_default));
179         sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
180         add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
181         add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 350, y));
182
183
184
185
186
187         y += 35;
188         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
189         y += 5;
190
191         add_subwindow(new BC_Title(x, y, _("Editing"), LARGEFONT, resources->text_default));
192
193         y1 = y + 5;
194         y += 35;
195         add_subwindow(title = new BC_Title(x, y, _("Keyframe reticle:")));
196         x1 = x + title->get_w() + 10;
197         keyframe_reticle = new KeyframeReticle(x1, y, &pwindow->thread->preferences->keyframe_reticle);
198         add_subwindow(keyframe_reticle);
199         keyframe_reticle->create_objects();
200
201         int x2 = x + 400, y2 = y;
202         add_subwindow(thumbnails = new ViewThumbnails(x2, y1, pwindow));
203         AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y2);
204         add_subwindow(android_remote);
205         y2 += android_remote->get_h() + 10;
206         add_subwindow(title = new BC_Title(x2, y2, _("Port:")));
207         int x3 = x2 + title->get_w() + margin;
208         AndroidPort *android_port = new AndroidPort(pwindow, x3, y2);
209         add_subwindow(android_port);
210         y2 += title->get_h() + 10;
211         add_subwindow(title = new BC_Title(x2, y2, _("PIN:")));
212         AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y2);
213         add_subwindow(android_pin);
214
215         y2 += title->get_h() + 30;
216         ShBtnPrefs *shbtn_prefs = new ShBtnPrefs(pwindow, this, x2, y2);
217         add_subwindow(shbtn_prefs);
218
219         y2 += shbtn_prefs->get_h() + 30;
220         StillImageUseDuration *use_stduration = new StillImageUseDuration(pwindow,
221                 pwindow->thread->edl->session->si_useduration, x2, y2);
222         add_subwindow(use_stduration);
223         int tw = 0, th = 0;
224         BC_CheckBox::calculate_extents(this, &tw, &th, 0, 0);
225         x2 += tw + 3;
226         y2 += use_stduration->get_h() + 3;
227         StillImageDuration *stduration = new StillImageDuration(pwindow, x2, y2);
228         add_subwindow(stduration);
229         x2 += stduration->get_w() + 10;
230         y2 += 3;
231         add_subwindow(new BC_Title(x2, y2, _("Seconds")));
232
233         y += 35;
234         add_subwindow(new BC_Title(x, y, _("Clicking on edit boundaries does what:")));
235         y += 25;
236         add_subwindow(new BC_Title(x, y, _("Button 1:")));
237
238         ViewBehaviourText *text;
239         add_subwindow(text = new ViewBehaviourText(80, y - 5,
240                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]),
241                         pwindow,
242                         &(pwindow->thread->edl->session->edit_handle_mode[0])));
243         text->create_objects();
244         y += 30;
245         add_subwindow(new BC_Title(x, y, _("Button 2:")));
246         add_subwindow(text = new ViewBehaviourText(80,
247                 y - 5,
248                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]),
249                         pwindow,
250                         &(pwindow->thread->edl->session->edit_handle_mode[1])));
251         text->create_objects();
252         y += 30;
253         add_subwindow(new BC_Title(x, y, _("Button 3:")));
254         add_subwindow(text = new ViewBehaviourText(80,
255                 y - 5,
256                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]),
257                         pwindow,
258                         &(pwindow->thread->edl->session->edit_handle_mode[2])));
259         text->create_objects();
260
261         y += 40;
262         x1 = x;
263         add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
264         x += title->get_w() + 10;
265         sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
266         add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
267
268         x += min_db->get_w() + 10;
269         add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
270         x += title->get_w() + 10;
271         sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
272         add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
273
274         x = x1;
275         y += 30;
276         ViewTheme *theme;
277         add_subwindow(new BC_Title(x, y, _("Theme:")));
278         x += 60;
279         add_subwindow(theme = new ViewTheme(x, y, pwindow));
280         theme->create_objects();
281
282 }
283
284 const char* InterfacePrefs::behavior_to_text(int mode)
285 {
286         switch(mode)
287         {
288                 case MOVE_ALL_EDITS:
289                         return _(MOVE_ALL_EDITS_TITLE);
290                         break;
291                 case MOVE_ONE_EDIT:
292                         return _(MOVE_ONE_EDIT_TITLE);
293                         break;
294                 case MOVE_NO_EDITS:
295                         return _(MOVE_NO_EDITS_TITLE);
296                         break;
297                 case MOVE_EDITS_DISABLED:
298                         return _(MOVE_EDITS_DISABLED_TITLE);
299                         break;
300                 default:
301                         return "";
302                         break;
303         }
304 }
305
306 int InterfacePrefs::update(int new_value)
307 {
308         pwindow->thread->redraw_times = 1;
309         pwindow->thread->edl->session->time_format = new_value;
310         hms->update(new_value == TIME_HMS);
311         hmsf->update(new_value == TIME_HMSF);
312         samples->update(new_value == TIME_SAMPLES);
313         hex->update(new_value == TIME_SAMPLES_HEX);
314         frames->update(new_value == TIME_FRAMES);
315         feet->update(new_value == TIME_FEET_FRAMES);
316         seconds->update(new_value == TIME_SECONDS);
317         return 0;
318 }
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334 IndexPathText::IndexPathText(int x,
335         int y,
336         PreferencesWindow *pwindow,
337         char *text)
338  : BC_TextBox(x, y, 240, 1, text)
339 {
340         this->pwindow = pwindow;
341 }
342
343 IndexPathText::~IndexPathText() {}
344
345 int IndexPathText::handle_event()
346 {
347         strcpy(pwindow->thread->preferences->index_directory, get_text());
348         return 1;
349 }
350
351
352
353
354 IndexSize::IndexSize(int x,
355         int y,
356         PreferencesWindow *pwindow,
357         char *text)
358  : BC_TextBox(x, y, 100, 1, text)
359 {
360         this->pwindow = pwindow;
361 }
362
363 int IndexSize::handle_event()
364 {
365         long result;
366
367         result = atol(get_text());
368         if(result < 64000) result = 64000;
369         //if(result < 500000) result = 500000;
370         pwindow->thread->preferences->index_size = result;
371         return 0;
372 }
373
374
375
376 IndexCount::IndexCount(int x,
377         int y,
378         PreferencesWindow *pwindow,
379         char *text)
380  : BC_TextBox(x, y, 100, 1, text)
381 {
382         this->pwindow = pwindow;
383 }
384
385 int IndexCount::handle_event()
386 {
387         long result;
388
389         result = atol(get_text());
390         if(result < 1) result = 1;
391         pwindow->thread->preferences->index_count = result;
392         return 0;
393 }
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
410  : BC_Radial(x, y, value, TIME_HMS_TEXT)
411 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
412
413 int TimeFormatHMS::handle_event()
414 {
415         tfwindow->update(TIME_HMS);
416         return 1;
417 }
418
419 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
420  : BC_Radial(x, y, value, TIME_HMSF_TEXT)
421 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
422
423 int TimeFormatHMSF::handle_event()
424 {
425         tfwindow->update(TIME_HMSF);
426         return 1;
427 }
428
429 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
430  : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
431 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
432
433 int TimeFormatSamples::handle_event()
434 {
435         tfwindow->update(TIME_SAMPLES);
436         return 1;
437 }
438
439 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
440  : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
441 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
442
443 int TimeFormatFrames::handle_event()
444 {
445         tfwindow->update(TIME_FRAMES);
446         return 1;
447 }
448
449 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
450  : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
451 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
452
453 int TimeFormatHex::handle_event()
454 {
455         tfwindow->update(TIME_SAMPLES_HEX);
456         return 1;
457 }
458
459 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
460  : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
461 {
462         this->pwindow = pwindow;
463         this->tfwindow = tfwindow;
464 }
465
466 int TimeFormatSeconds::handle_event()
467 {
468         tfwindow->update(TIME_SECONDS);
469         return 1;
470 }
471
472 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
473  : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
474 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
475
476 int TimeFormatFeet::handle_event()
477 {
478         tfwindow->update(TIME_FEET_FRAMES);
479         return 1;
480 }
481
482 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
483  : BC_TextBox(x, y, 90, 1, string)
484 { this->pwindow = pwindow; }
485
486 int TimeFormatFeetSetting::handle_event()
487 {
488         pwindow->thread->edl->session->frames_per_foot = atof(get_text());
489         if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
490         return 0;
491 }
492
493
494
495
496 ViewBehaviourText::ViewBehaviourText(int x,
497         int y,
498         const char *text,
499         PreferencesWindow *pwindow,
500         int *output)
501  : BC_PopupMenu(x, y, 200, text)
502 {
503         this->output = output;
504 }
505
506 ViewBehaviourText::~ViewBehaviourText()
507 {
508 }
509
510 int ViewBehaviourText::handle_event()
511 {
512         return 0;
513 }
514
515 void ViewBehaviourText::create_objects()
516 {
517 // Video4linux versions are automatically detected
518         add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
519         add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
520         add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
521         add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
522 }
523
524
525 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
526  : BC_MenuItem(text)
527 {
528         this->popup = popup;
529         this->behaviour = behaviour;
530 }
531
532 ViewBehaviourItem::~ViewBehaviourItem()
533 {
534 }
535
536 int ViewBehaviourItem::handle_event()
537 {
538         popup->set_text(get_text());
539         *(popup->output) = behaviour;
540         return 1;
541 }
542
543
544
545
546 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
547  : BC_TextBox(x, y, 50, 1, text)
548 {
549         this->pwindow = pwindow;
550 }
551
552 int MeterMinDB::handle_event()
553 {
554         pwindow->thread->redraw_meters = 1;
555         pwindow->thread->edl->session->min_meter_db = atol(get_text());
556         return 0;
557 }
558
559
560
561
562 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
563  : BC_TextBox(x, y, 50, 1, text)
564 {
565         this->pwindow = pwindow;
566 }
567
568 int MeterMaxDB::handle_event()
569 {
570         pwindow->thread->redraw_meters = 1;
571         pwindow->thread->edl->session->max_meter_db = atol(get_text());
572         return 0;
573 }
574
575
576
577
578
579 MeterVUDB::MeterVUDB(PreferencesWindow *pwindow, char *text, int y)
580  : BC_Radial(145, y, pwindow->thread->edl->session->meter_format == METER_DB, text)
581 {
582         this->pwindow = pwindow;
583 }
584
585 int MeterVUDB::handle_event()
586 {
587         pwindow->thread->redraw_meters = 1;
588 //      vu_int->update(0);
589         pwindow->thread->edl->session->meter_format = METER_DB;
590         return 1;
591 }
592
593 MeterVUInt::MeterVUInt(PreferencesWindow *pwindow, char *text, int y)
594  : BC_Radial(205, y, pwindow->thread->edl->session->meter_format == METER_INT, text)
595 {
596         this->pwindow = pwindow;
597 }
598
599 int MeterVUInt::handle_event()
600 {
601         pwindow->thread->redraw_meters = 1;
602         vu_db->update(0);
603         pwindow->thread->edl->session->meter_format = METER_INT;
604         return 1;
605 }
606
607
608
609
610 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
611  : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
612 {
613         this->pwindow = pwindow;
614 }
615 ViewTheme::~ViewTheme()
616 {
617 }
618
619 void ViewTheme::create_objects()
620 {
621         ArrayList<PluginServer*> themes;
622         MWindow::search_plugindb(0,
623                 0,
624                 0,
625                 0,
626                 1,
627                 themes);
628
629         for(int i = 0; i < themes.total; i++)
630         {
631                 add_item(new ViewThemeItem(this, themes.values[i]->title));
632         }
633 }
634
635 int ViewTheme::handle_event()
636 {
637         return 1;
638 }
639
640
641
642
643
644 ViewThemeItem::ViewThemeItem(ViewTheme *popup, char *text)
645  : BC_MenuItem(text)
646 {
647         this->popup = popup;
648 }
649
650 int ViewThemeItem::handle_event()
651 {
652         popup->set_text(get_text());
653         strcpy(popup->pwindow->thread->preferences->theme, get_text());
654         popup->handle_event();
655         return 1;
656 }
657
658 ViewThumbnails::ViewThumbnails(int x,
659         int y,
660         PreferencesWindow *pwindow)
661  : BC_CheckBox(x,
662         y,
663         pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
664 {
665         this->pwindow = pwindow;
666 }
667
668 int ViewThumbnails::handle_event()
669 {
670         pwindow->thread->preferences->use_thumbnails = get_value();
671         return 1;
672 }
673
674
675
676 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
677  : BC_CheckBox(x,
678         y,
679         pwindow->thread->preferences->use_tipwindow,
680         _("Show tip of the day"))
681 {
682         this->pwindow = pwindow;
683 }
684 int UseTipWindow::handle_event()
685 {
686         pwindow->thread->preferences->use_tipwindow = get_value();
687         return 1;
688 }
689
690
691 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
692  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_indexes,
693         _("ffmpeg probe warns rebuild indexes"))
694 {
695         this->pwindow = pwindow;
696 }
697
698 int UseWarnIndecies::handle_event()
699 {
700         pwindow->thread->preferences->warn_indexes = get_value();
701         return 1;
702 }
703
704 UseWarnVersion::UseWarnVersion(PreferencesWindow *pwindow, int x, int y)
705  : BC_CheckBox(x, y, pwindow->thread->preferences->warn_version,
706         _("EDL version warns if mismatched"))
707 {
708         this->pwindow = pwindow;
709 }
710
711 int UseWarnVersion::handle_event()
712 {
713         pwindow->thread->preferences->warn_version = get_value();
714         return 1;
715 }
716
717 BD_WarnRoot::BD_WarnRoot(PreferencesWindow *pwindow, int x, int y)
718  : BC_CheckBox(x, y, pwindow->thread->preferences->bd_warn_root,
719         _("Create Bluray warns if not root"))
720 {
721         this->pwindow = pwindow;
722 }
723
724 int BD_WarnRoot::handle_event()
725 {
726         pwindow->thread->preferences->bd_warn_root = get_value();
727         return 1;
728 }
729
730 PopupMenuBtnup::PopupMenuBtnup(PreferencesWindow *pwindow, int x, int y)
731  : BC_CheckBox(x, y, pwindow->thread->preferences->popupmenu_btnup,
732         _("Popups activate on button up"))
733 {
734         this->pwindow = pwindow;
735 }
736
737 int PopupMenuBtnup::handle_event()
738 {
739         pwindow->thread->preferences->popupmenu_btnup = get_value();
740         return 1;
741 }
742
743
744 ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y)
745  : BC_CheckBox(x,
746         y,
747         pwindow->thread->preferences->scan_commercials,
748         _("Scan for commercials during toc build"))
749 {
750         this->pwindow = pwindow;
751 }
752 int ScanCommercials::handle_event()
753 {
754         pwindow->thread->preferences->scan_commercials = get_value();
755         return 1;
756 }
757
758
759 AndroidRemote::AndroidRemote(PreferencesWindow *pwindow, int x, int y)
760  : BC_CheckBox(x, y,
761         pwindow->thread->preferences->android_remote,
762         _("Android Remote Control"))
763 {
764         this->pwindow = pwindow;
765 }
766 int AndroidRemote::handle_event()
767 {
768         pwindow->thread->preferences->android_remote = get_value();
769         return 1;
770 }
771
772 AndroidPIN::AndroidPIN(PreferencesWindow *pwindow, int x, int y)
773  : BC_TextBox(x, y, 240, 1, pwindow->thread->preferences->android_pin)
774 {
775         this->pwindow = pwindow;
776 }
777
778 int AndroidPIN::handle_event()
779 {
780         char *txt = pwindow->thread->preferences->android_pin;
781         int len = sizeof(pwindow->thread->preferences->android_pin);
782         strncpy(txt, get_text(), len);
783         return 1;
784 }
785
786
787 AndroidPort::AndroidPort(PreferencesWindow *pwindow, int x, int y)
788  : BC_TextBox(x, y, 72, 1, pwindow->thread->preferences->android_port)
789 {
790         this->pwindow = pwindow;
791 }
792
793 int AndroidPort::handle_event()
794 {
795         unsigned short port = atoi(get_text());
796         if( port < 1024 ) port = 1024;
797         pwindow->thread->preferences->android_port = port;
798         char str[BCSTRLEN];
799         sprintf(str,"%u",port);
800         update(str);
801         return 1;
802 }
803
804 int InterfacePrefs::start_shbtn_dialog()
805 {
806         if( !shbtn_dialog )
807                 shbtn_dialog = new ShBtnEditDialog(pwindow);
808         shbtn_dialog->start();
809         return 1;
810 }
811
812 ShBtnPrefs::ShBtnPrefs(PreferencesWindow *pwindow, InterfacePrefs *iface_prefs, int x, int y)
813  : BC_GenericButton(x, y, _("Shell Commands"))
814 {
815         this->pwindow = pwindow;
816         this->iface_prefs = iface_prefs;
817         set_tooltip(_("Main Menu Shell Commands"));
818 }
819
820 int ShBtnPrefs::handle_event()
821 {
822         return iface_prefs->start_shbtn_dialog();
823 }
824
825
826 StillImageUseDuration::StillImageUseDuration(PreferencesWindow *pwindow, int value, int x, int y)
827  : BC_CheckBox(x, y, value, _("Import images with a duration of"))
828 {
829         this->pwindow = pwindow;
830 }
831
832 int StillImageUseDuration::handle_event()
833 {
834         pwindow->thread->edl->session->si_useduration = get_value();
835         return 1;
836 }
837
838 StillImageDuration::StillImageDuration(PreferencesWindow *pwindow, int x, int y)
839  : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->si_duration)
840 {
841         this->pwindow = pwindow;
842 }
843 int StillImageDuration::handle_event()
844 {
845         pwindow->thread->edl->session->si_duration = atof(get_text());
846         return 1;
847 }
848
849
850 HairlineItem::HairlineItem(KeyframeReticle *popup, int hairline)
851  : BC_MenuItem(popup->hairline_to_string(hairline))
852 {
853         this->popup = popup;
854         this->hairline = hairline;
855 }
856
857 HairlineItem::~HairlineItem()
858 {
859 }
860
861 int HairlineItem::handle_event()
862 {
863         popup->set_text(get_text());
864         *(popup->output) = hairline;
865         return 1;
866 }
867
868
869 KeyframeReticle::KeyframeReticle(int x, int y, int *output)
870  : BC_PopupMenu(x, y, 175, hairline_to_string(*output))
871 {
872         this->output = output;
873 }
874
875 KeyframeReticle::~KeyframeReticle()
876 {
877 }
878
879 const char *KeyframeReticle::hairline_to_string(int type)
880 {
881         switch( type ) {
882         case HAIRLINE_NEVER:    return _("Never");
883         case HAIRLINE_DRAGGING: return _("Dragging");
884         case HAIRLINE_ALWAYS:   return _("Always");
885         }
886         return _("Unknown");
887 }
888
889 void KeyframeReticle::create_objects()
890 {
891         add_item(new HairlineItem(this, HAIRLINE_NEVER));
892         add_item(new HairlineItem(this, HAIRLINE_DRAGGING));
893         add_item(new HairlineItem(this, HAIRLINE_ALWAYS));
894 }
895