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