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