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