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