4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #include "deleteallindexes.h"
24 #include "edlsession.h"
26 #include "filesystem.h"
29 #include "preferences.h"
30 #include "preferencesthread.h"
31 #include "probeprefs.h"
32 #include "interfaceprefs.h"
33 #include "shbtnprefs.h"
36 #define MOVE_RIPPLE_TITLE N_("All Edits (ripple)")
37 #define MOVE_ROLL_TITLE N_("One Edit (roll)")
38 #define MOVE_SLIP_TITLE N_("Src Only (slip)")
39 #define MOVE_SLIDE_TITLE N_("Move Edit (slide)")
40 #define MOVE_EDGE_TITLE N_("Drag Edge (edge)")
41 #define MOVE_EDITS_DISABLED_TITLE N_("No effect")
44 InterfacePrefs::InterfacePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
45 : PreferencesDialog(mwindow, pwindow)
50 file_probe_dialog = 0;
53 InterfacePrefs::~InterfacePrefs()
58 delete file_probe_dialog;
62 void InterfacePrefs::create_objects()
64 BC_Resources *resources = BC_WindowBase::get_resources();
65 int margin = mwindow->theme->widget_border;
66 char string[BCTEXTLEN];
67 int x0 = mwindow->theme->preferencesoptions_x;
68 int y0 = mwindow->theme->preferencesoptions_y;
71 add_subwindow(new BC_Title(x, y, _("Editing:"), LARGEFONT,
72 resources->text_default));
75 int x2 = get_w()/2, y2 = y;
78 add_subwindow(title = new BC_Title(x, y, _("Keyframe reticle:")));
79 y += title->get_h() + 5;
80 keyframe_reticle = new KeyframeReticle(pwindow, this, x, y,
81 &pwindow->thread->preferences->keyframe_reticle);
82 add_subwindow(keyframe_reticle);
83 keyframe_reticle->create_objects();
86 add_subwindow(title = new BC_Title(x, y, _("Snapshot path:")));
87 y += title->get_h() + 5;
88 add_subwindow(snapshot_path = new SnapshotPathText(pwindow, this, x, y, get_w()-x-30));
91 add_subwindow(title = new BC_Title(x, y, _("Clicking on edit boundaries does what:")));
92 y += title->get_h() + 10;
93 add_subwindow(new BC_Title(x, y, _("Button 1:")));
96 ViewBehaviourText *text;
97 add_subwindow(text = new ViewBehaviourText(x1, y - 5,
98 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]),
100 &(pwindow->thread->edl->session->edit_handle_mode[0])));
101 text->create_objects();
103 add_subwindow(new BC_Title(x, y, _("Button 2:")));
104 add_subwindow(text = new ViewBehaviourText(x1,
106 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]),
108 &(pwindow->thread->edl->session->edit_handle_mode[1])));
109 text->create_objects();
111 add_subwindow(new BC_Title(x, y, _("Button 3:")));
112 add_subwindow(text = new ViewBehaviourText(x1, y - 5,
113 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]),
115 &(pwindow->thread->edl->session->edit_handle_mode[2])));
116 text->create_objects();
117 y += text->get_h() + 30;
120 add_subwindow(new BC_Bar(5, y, get_w() - 10));
122 add_subwindow(new BC_Title(x, y, _("Operation:"), LARGEFONT,
123 resources->text_default));
128 AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y);
129 add_subwindow(android_remote);
130 y += android_remote->get_h() + 10;
131 add_subwindow(title = new BC_Title(x2, y, _("Port:")));
132 int x3 = x2 + title->get_w() + margin;
133 AndroidPort *android_port = new AndroidPort(pwindow, x3, y);
134 add_subwindow(android_port);
135 y += title->get_h() + 10;
136 add_subwindow(title = new BC_Title(x2, y, _("PIN:")));
137 AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y);
138 add_subwindow(android_pin);
139 y += title->get_h() + 20;
141 ShBtnPrefs *shbtn_prefs = new ShBtnPrefs(pwindow, this, x2, y);
142 add_subwindow(shbtn_prefs);
143 y += shbtn_prefs->get_h() + 20;
145 add_subwindow(reload_plugins = new PrefsReloadPlugins(pwindow, this, x2, y));
146 y += reload_plugins->get_h() + 10;
148 add_subwindow(title = new BC_Title(x2, y, _("Default LV2_PATH:")));
149 y += title->get_h() + 10;
150 PrefsLV2PathText *lv2_path_text = new PrefsLV2PathText(pwindow, this, x2, y, get_w()-x2-30);
151 add_subwindow(lv2_path_text);
156 add_subwindow(file_probes = new PrefsFileProbes(pwindow, this, x, y));
159 PrefsTrapSigSEGV *trap_segv = new PrefsTrapSigSEGV(this, x, y);
160 add_subwindow(trap_segv);
161 x1 = x + trap_segv->get_w() + 10;
162 add_subwindow(new BC_Title(x1, y, _("(must be root)"), MEDIUMFONT, RED));
165 PrefsTrapSigINTR *trap_intr = new PrefsTrapSigINTR(this, x, y);
166 add_subwindow(trap_intr);
167 add_subwindow(new BC_Title(x1, y, _("(must be root)"), MEDIUMFONT, RED));
170 yuv420p_dvdlace = new PrefsYUV420P_DVDlace(pwindow, this, x, y);
171 add_subwindow(yuv420p_dvdlace);
174 add_subwindow(title = new BC_Title(x1=x, y + 5, _("Min DB for meter:")));
175 x1 += title->get_w() + 4;
176 sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
177 add_subwindow(min_db = new MeterMinDB(pwindow, string, x1, y));
178 x1 += min_db->get_w() + 4;
179 add_subwindow(title = new BC_Title(x1, y + 5, _("Max:")));
180 x1 += title->get_w() + 4;
181 sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
182 add_subwindow(max_db = new MeterMaxDB(pwindow, string, x1, y));
185 StillImageUseDuration *use_stduration = new StillImageUseDuration(pwindow,
186 pwindow->thread->edl->session->si_useduration, x, y);
187 add_subwindow(use_stduration);
188 x1 = x + use_stduration->get_w() + 10;
189 StillImageDuration *stduration = new StillImageDuration(pwindow, x1, y);
190 add_subwindow(stduration);
191 x1 += stduration->get_w() + 10;
192 add_subwindow(new BC_Title(x1, y, _("Seconds")));
195 PrefsAutostartLV2UI *autostart_lv2ui = new PrefsAutostartLV2UI(x, y,pwindow);
196 add_subwindow(autostart_lv2ui);
197 y += autostart_lv2ui->get_h() + 10;
201 add_subwindow(new BC_Bar(5, y, get_w() - 10));
204 add_subwindow(new BC_Title(x, y, _("Index files:"), LARGEFONT, resources->text_default));
207 add_subwindow(new BC_Title(x, y + 5,
208 _("Index files go here:"), MEDIUMFONT, resources->text_default));
210 add_subwindow(ipathtext = new IndexPathText(x1, y, pwindow,
211 pwindow->thread->preferences->index_directory));
212 x1 += ipathtext->get_w();
213 add_subwindow(ipath = new BrowseButton(mwindow->theme, this, ipathtext, x1, y,
214 pwindow->thread->preferences->index_directory,
215 _("Index Path"), _("Select the directory for index files"), 1));
218 add_subwindow(new BC_Title(x, y + 5, _("Size of index file:"),
219 MEDIUMFONT, resources->text_default));
220 sprintf(string, "%jd", pwindow->thread->preferences->index_size);
221 add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
222 add_subwindow(new ScanCommercials(pwindow, 400,y));
225 add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"),
226 MEDIUMFONT, resources->text_default));
227 sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
228 add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
229 add_subwindow(del_indexes = new DeleteAllIndexes(mwindow, pwindow, 400, y,
230 _("Delete existing indexes"), "[*.idx][*.toc][*.mkr]"));
232 add_subwindow(ffmpeg_marker_files = new IndexFFMPEGMarkerFiles(this, x, y));
233 add_subwindow(del_clipngs = new DeleteAllIndexes(mwindow, pwindow, 400, y,
234 _("Delete clip thumbnails"), "clip_*.png"));
237 const char* InterfacePrefs::behavior_to_text(int mode)
240 case MOVE_RIPPLE: return _(MOVE_RIPPLE_TITLE);
241 case MOVE_ROLL: return _(MOVE_ROLL_TITLE);
242 case MOVE_SLIP: return _(MOVE_SLIP_TITLE);
243 case MOVE_SLIDE: return _(MOVE_SLIDE_TITLE);
244 case MOVE_EDGE: return _(MOVE_EDGE_TITLE);
245 case MOVE_EDITS_DISABLED: return _(MOVE_EDITS_DISABLED_TITLE);
250 IndexPathText::IndexPathText(int x, int y, PreferencesWindow *pwindow, char *text)
251 : BC_TextBox(x, y, 240, 1, text)
253 this->pwindow = pwindow;
256 IndexPathText::~IndexPathText() {}
258 int IndexPathText::handle_event()
260 strcpy(pwindow->thread->preferences->index_directory, get_text());
267 IndexSize::IndexSize(int x, int y, PreferencesWindow *pwindow, char *text)
268 : BC_TextBox(x, y, 100, 1, text)
270 this->pwindow = pwindow;
273 int IndexSize::handle_event()
277 result = atol(get_text());
278 if(result < 64000) result = 64000;
279 //if(result < 500000) result = 500000;
280 pwindow->thread->preferences->index_size = result;
286 IndexCount::IndexCount(int x, int y, PreferencesWindow *pwindow, char *text)
287 : BC_TextBox(x, y, 100, 1, text)
289 this->pwindow = pwindow;
292 int IndexCount::handle_event()
296 result = atol(get_text());
297 if(result < 1) result = 1;
298 pwindow->thread->preferences->index_count = result;
304 IndexFFMPEGMarkerFiles::IndexFFMPEGMarkerFiles(InterfacePrefs *iface_prefs, int x, int y)
306 iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes,
307 _("build ffmpeg marker indexes"))
309 this->iface_prefs = iface_prefs;
311 IndexFFMPEGMarkerFiles::~IndexFFMPEGMarkerFiles()
315 int IndexFFMPEGMarkerFiles::handle_event()
317 iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes = get_value();
322 ViewBehaviourText::ViewBehaviourText(int x, int y, const char *text, PreferencesWindow *pwindow,
324 : BC_PopupMenu(x, y, 250, text)
326 this->output = output;
329 ViewBehaviourText::~ViewBehaviourText()
333 int ViewBehaviourText::handle_event()
338 void ViewBehaviourText::create_objects()
340 for( int mode=0; mode<=EDIT_HANDLE_MODES; ++mode )
341 add_item(new ViewBehaviourItem(this,
342 InterfacePrefs::behavior_to_text(mode), mode));
346 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup,
347 const char *text, int behaviour)
351 this->behaviour = behaviour;
354 ViewBehaviourItem::~ViewBehaviourItem()
358 int ViewBehaviourItem::handle_event()
360 popup->set_text(get_text());
361 *(popup->output) = behaviour;
366 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
367 : BC_TextBox(x, y, 50, 1, text)
369 this->pwindow = pwindow;
372 int MeterMinDB::handle_event()
374 pwindow->thread->redraw_meters = 1;
375 pwindow->thread->edl->session->min_meter_db = atol(get_text());
380 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
381 : BC_TextBox(x, y, 50, 1, text)
383 this->pwindow = pwindow;
386 int MeterMaxDB::handle_event()
388 pwindow->thread->redraw_meters = 1;
389 pwindow->thread->edl->session->max_meter_db = atol(get_text());
394 ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y)
397 pwindow->thread->preferences->scan_commercials,
398 _("Scan for commercials during toc build"))
400 this->pwindow = pwindow;
402 int ScanCommercials::handle_event()
404 pwindow->thread->preferences->scan_commercials = get_value();
409 AndroidRemote::AndroidRemote(PreferencesWindow *pwindow, int x, int y)
411 pwindow->thread->preferences->android_remote,
412 _("Android Remote Control"))
414 this->pwindow = pwindow;
416 int AndroidRemote::handle_event()
418 pwindow->thread->preferences->android_remote = get_value();
422 AndroidPIN::AndroidPIN(PreferencesWindow *pwindow, int x, int y)
423 : BC_TextBox(x, y, 240, 1, pwindow->thread->preferences->android_pin)
425 this->pwindow = pwindow;
428 int AndroidPIN::handle_event()
430 char *txt = pwindow->thread->preferences->android_pin;
431 int len = sizeof(pwindow->thread->preferences->android_pin);
432 strncpy(txt, get_text(), len);
437 AndroidPort::AndroidPort(PreferencesWindow *pwindow, int x, int y)
438 : BC_TextBox(x, y, 72, 1, pwindow->thread->preferences->android_port)
440 this->pwindow = pwindow;
443 int AndroidPort::handle_event()
445 unsigned short port = atoi(get_text());
446 if( port < 1024 ) port = 1024;
447 pwindow->thread->preferences->android_port = port;
449 sprintf(str,"%u",port);
454 int InterfacePrefs::start_shbtn_dialog()
457 shbtn_dialog = new ShBtnEditDialog(pwindow);
458 shbtn_dialog->start();
462 ShBtnPrefs::ShBtnPrefs(PreferencesWindow *pwindow, InterfacePrefs *iface_prefs, int x, int y)
463 : BC_GenericButton(x, y, _("Shell Commands"))
465 this->pwindow = pwindow;
466 this->iface_prefs = iface_prefs;
467 set_tooltip(_("Main Menu Shell Commands"));
470 int ShBtnPrefs::handle_event()
472 return iface_prefs->start_shbtn_dialog();
476 StillImageUseDuration::StillImageUseDuration(PreferencesWindow *pwindow, int value, int x, int y)
477 : BC_CheckBox(x, y, value, _("Import images with a duration of"))
479 this->pwindow = pwindow;
482 int StillImageUseDuration::handle_event()
484 pwindow->thread->edl->session->si_useduration = get_value();
488 StillImageDuration::StillImageDuration(PreferencesWindow *pwindow, int x, int y)
489 : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->si_duration)
491 this->pwindow = pwindow;
493 int StillImageDuration::handle_event()
495 pwindow->thread->edl->session->si_duration = atof(get_text());
500 HairlineItem::HairlineItem(KeyframeReticle *popup, int hairline)
501 : BC_MenuItem(popup->hairline_to_string(hairline))
504 this->hairline = hairline;
507 HairlineItem::~HairlineItem()
511 int HairlineItem::handle_event()
513 popup->pwindow->thread->redraw_overlays = 1;
514 popup->set_text(get_text());
515 *(popup->output) = hairline;
520 KeyframeReticle::KeyframeReticle(PreferencesWindow *pwindow,
521 InterfacePrefs *iface_prefs, int x, int y, int *output)
522 : BC_PopupMenu(x, y, 220, hairline_to_string(*output))
524 this->pwindow = pwindow;
525 this->iface_prefs = iface_prefs;
526 this->output = output;
529 KeyframeReticle::~KeyframeReticle()
533 const char *KeyframeReticle::hairline_to_string(int type)
536 case HAIRLINE_NEVER: return _("Never");
537 case HAIRLINE_DRAGGING: return _("Dragging");
538 case HAIRLINE_ALWAYS: return _("Always");
543 void KeyframeReticle::create_objects()
545 add_item(new HairlineItem(this, HAIRLINE_NEVER));
546 add_item(new HairlineItem(this, HAIRLINE_DRAGGING));
547 add_item(new HairlineItem(this, HAIRLINE_ALWAYS));
550 PrefsTrapSigSEGV::PrefsTrapSigSEGV(InterfacePrefs *subwindow, int x, int y)
552 subwindow->pwindow->thread->preferences->trap_sigsegv,
555 this->subwindow = subwindow;
557 PrefsTrapSigSEGV::~PrefsTrapSigSEGV()
560 int PrefsTrapSigSEGV::handle_event()
562 subwindow->pwindow->thread->preferences->trap_sigsegv = get_value();
566 PrefsTrapSigINTR::PrefsTrapSigINTR(InterfacePrefs *subwindow, int x, int y)
568 subwindow->pwindow->thread->preferences->trap_sigintr,
571 this->subwindow = subwindow;
573 PrefsTrapSigINTR::~PrefsTrapSigINTR()
576 int PrefsTrapSigINTR::handle_event()
578 subwindow->pwindow->thread->preferences->trap_sigintr = get_value();
583 void InterfacePrefs::start_probe_dialog()
585 if( !file_probe_dialog )
586 file_probe_dialog = new FileProbeDialog(pwindow);
587 file_probe_dialog->start();
590 PrefsFileProbes::PrefsFileProbes(PreferencesWindow *pwindow,
591 InterfacePrefs *subwindow, int x, int y)
592 : BC_GenericButton(x, y, _("Probe Order"))
594 this->pwindow = pwindow;
595 this->subwindow = subwindow;
596 set_tooltip(_("File Open Probe Ordering"));
599 int PrefsFileProbes::handle_event()
601 subwindow->start_probe_dialog();
606 PrefsYUV420P_DVDlace::PrefsYUV420P_DVDlace(PreferencesWindow *pwindow,
607 InterfacePrefs *subwindow, int x, int y)
608 : BC_CheckBox(x, y, pwindow->thread->preferences->dvd_yuv420p_interlace,
609 _("Use yuv420p dvd interlace format"))
611 this->pwindow = pwindow;
612 this->subwindow = subwindow;
615 int PrefsYUV420P_DVDlace::handle_event()
617 pwindow->thread->preferences->dvd_yuv420p_interlace = get_value();
622 SnapshotPathText::SnapshotPathText(PreferencesWindow *pwindow,
623 InterfacePrefs *subwindow, int x, int y, int w)
624 : BC_TextBox(x, y, w, 1, pwindow->thread->preferences->snapshot_path)
626 this->pwindow = pwindow;
627 this->subwindow = subwindow;
630 SnapshotPathText::~SnapshotPathText()
634 int SnapshotPathText::handle_event()
636 strcpy(pwindow->thread->preferences->snapshot_path, get_text());
640 PrefsAutostartLV2UI::PrefsAutostartLV2UI(int x, int y, PreferencesWindow *pwindow)
642 pwindow->thread->preferences->autostart_lv2ui, _("Auto start lv2 gui"))
644 this->pwindow = pwindow;
646 int PrefsAutostartLV2UI::handle_event()
648 pwindow->thread->preferences->autostart_lv2ui = get_value();
652 PrefsReloadPlugins::PrefsReloadPlugins(PreferencesWindow *pwindow,
653 InterfacePrefs *iface_prefs, int x, int y)
654 : BC_GenericButton(x, y, _("Reload plugin index"))
656 this->pwindow = pwindow;
657 this->iface_prefs = iface_prefs;
660 int PrefsReloadPlugins::handle_event()
662 pwindow->thread->reload_plugins = 1;
663 text_color(get_resources()->button_highlighted);
668 PrefsLV2PathText::PrefsLV2PathText(PreferencesWindow *pwindow,
669 InterfacePrefs *subwindow, int x, int y, int w)
670 : BC_TextBox(x, y, w, 1, pwindow->thread->preferences->lv2_path)
672 this->pwindow = pwindow;
673 this->subwindow = subwindow;
676 PrefsLV2PathText::~PrefsLV2PathText()
680 int PrefsLV2PathText::handle_event()
682 strcpy(pwindow->thread->preferences->lv2_path, get_text());