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