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 int xs4 = xS(4), xs5 = xS(5), xs10 = xS(10), xs30 = xS(30);
65 int ys5 = yS(5), ys10 = yS(10), ys20 = yS(20), ys30 = yS(30), ys35 = yS(35);
66 BC_Resources *resources = BC_WindowBase::get_resources();
67 int margin = mwindow->theme->widget_border;
68 char string[BCTEXTLEN];
69 int x0 = mwindow->theme->preferencesoptions_x;
70 int y0 = mwindow->theme->preferencesoptions_y;
73 add_subwindow(new BC_Title(x, y, _("Editing:"), LARGEFONT,
74 resources->text_default));
77 int x2 = get_w()/2, y2 = y;
80 add_subwindow(title = new BC_Title(x, y, _("Keyframe reticle:")));
81 y += title->get_h() + ys5;
82 keyframe_reticle = new KeyframeReticle(pwindow, this, x, y,
83 &pwindow->thread->preferences->keyframe_reticle);
84 add_subwindow(keyframe_reticle);
85 keyframe_reticle->create_objects();
88 add_subwindow(title = new BC_Title(x, y, _("Snapshot path:")));
89 y += title->get_h() + ys5;
90 add_subwindow(snapshot_path = new SnapshotPathText(pwindow, this, x, y, get_w()-x-xs30));
93 add_subwindow(title = new BC_Title(x, y, _("Clicking on edit boundaries does what:")));
94 y += title->get_h() + ys10;
95 add_subwindow(new BC_Title(x, y, _("Button 1:")));
98 ViewBehaviourText *text;
99 add_subwindow(text = new ViewBehaviourText(x1, y - ys5,
100 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]),
102 &(pwindow->thread->edl->session->edit_handle_mode[0])));
103 text->create_objects();
105 add_subwindow(new BC_Title(x, y, _("Button 2:")));
106 add_subwindow(text = new ViewBehaviourText(x1,
108 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]),
110 &(pwindow->thread->edl->session->edit_handle_mode[1])));
111 text->create_objects();
113 add_subwindow(new BC_Title(x, y, _("Button 3:")));
114 add_subwindow(text = new ViewBehaviourText(x1, y - ys5,
115 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]),
117 &(pwindow->thread->edl->session->edit_handle_mode[2])));
118 text->create_objects();
119 y += text->get_h() + ys30;
122 add_subwindow(new BC_Bar(xs5, y, get_w() - xs10));
124 add_subwindow(new BC_Title(x, y, _("Operation:"), LARGEFONT,
125 resources->text_default));
130 AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y);
131 add_subwindow(android_remote);
132 y += android_remote->get_h() + ys10;
133 add_subwindow(title = new BC_Title(x2, y, _("Port:")));
134 int x3 = x2 + title->get_w() + margin;
135 AndroidPort *android_port = new AndroidPort(pwindow, x3, y);
136 add_subwindow(android_port);
137 y += title->get_h() + ys10;
138 add_subwindow(title = new BC_Title(x2, y, _("PIN:")));
139 AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y);
140 add_subwindow(android_pin);
141 y += title->get_h() + ys20;
143 ShBtnPrefs *shbtn_prefs = new ShBtnPrefs(pwindow, this, x2, y);
144 add_subwindow(shbtn_prefs);
145 y += shbtn_prefs->get_h() + ys20;
147 add_subwindow(reload_plugins = new PrefsReloadPlugins(pwindow, this, x2, y));
148 y += reload_plugins->get_h() + ys10;
150 add_subwindow(title = new BC_Title(x2, y, _("Default LV2_PATH:")));
151 y += title->get_h() + ys10;
152 PrefsLV2PathText *lv2_path_text = new PrefsLV2PathText(pwindow, this, x2, y, get_w()-x2-xs30);
153 add_subwindow(lv2_path_text);
157 x = x0; y = y1 + ys35;
158 add_subwindow(file_probes = new PrefsFileProbes(pwindow, this, x, y));
161 PrefsTrapSigSEGV *trap_segv = new PrefsTrapSigSEGV(this, x, y);
162 add_subwindow(trap_segv);
163 x1 = x + trap_segv->get_w() + xs10;
164 add_subwindow(new BC_Title(x1, y, _("(must be root)"), MEDIUMFONT, RED));
167 PrefsTrapSigINTR *trap_intr = new PrefsTrapSigINTR(this, x, y);
168 add_subwindow(trap_intr);
169 add_subwindow(new BC_Title(x1, y, _("(must be root)"), MEDIUMFONT, RED));
172 yuv420p_dvdlace = new PrefsYUV420P_DVDlace(pwindow, this, x, y);
173 add_subwindow(yuv420p_dvdlace);
176 add_subwindow(title = new BC_Title(x1=x, y + ys5, _("Min DB for meter:")));
177 x1 += title->get_w() + xs4;
178 sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
179 add_subwindow(min_db = new MeterMinDB(pwindow, string, x1, y));
180 x1 += min_db->get_w() + xs4;
181 add_subwindow(title = new BC_Title(x1, y + ys5, _("Max:")));
182 x1 += title->get_w() + xs4;
183 sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
184 add_subwindow(max_db = new MeterMaxDB(pwindow, string, x1, y));
187 StillImageUseDuration *use_stduration = new StillImageUseDuration(pwindow,
188 pwindow->thread->edl->session->si_useduration, x, y);
189 add_subwindow(use_stduration);
190 x1 = x + use_stduration->get_w() + xs10;
191 StillImageDuration *stduration = new StillImageDuration(pwindow, x1, y);
192 add_subwindow(stduration);
193 x1 += stduration->get_w() + xs10;
194 add_subwindow(new BC_Title(x1, y, _("Seconds")));
197 PrefsAutostartLV2UI *autostart_lv2ui = new PrefsAutostartLV2UI(x, y,pwindow);
198 add_subwindow(autostart_lv2ui);
199 y += autostart_lv2ui->get_h() + ys10;
203 add_subwindow(new BC_Bar(xs5, y, get_w() - xs10));
206 add_subwindow(new BC_Title(x, y, _("Index files:"), LARGEFONT, resources->text_default));
209 add_subwindow(new BC_Title(x, y + ys5,
210 _("Index files go here:"), MEDIUMFONT, resources->text_default));
212 add_subwindow(ipathtext = new IndexPathText(x1, y, pwindow,
213 pwindow->thread->preferences->index_directory));
214 x1 += ipathtext->get_w();
215 add_subwindow(ipath = new BrowseButton(mwindow->theme, this, ipathtext, x1, y,
216 pwindow->thread->preferences->index_directory,
217 _("Index Path"), _("Select the directory for index files"), 1));
220 add_subwindow(new BC_Title(x, y + ys5, _("Size of index file in KB:"),
221 MEDIUMFONT, resources->text_default));
222 sprintf(string, "%jd", pwindow->thread->preferences->index_size/1024);
223 add_subwindow(isize = new IndexSize(x + xS(230), y, pwindow, string));
224 add_subwindow(new ScanCommercials(pwindow, xS(400),y));
227 add_subwindow(new BC_Title(x, y + ys5, _("Number of index files to keep:"),
228 MEDIUMFONT, resources->text_default));
229 sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
230 add_subwindow(icount = new IndexCount(x + xS(230), y, pwindow, string));
231 add_subwindow(del_indexes = new DeleteAllIndexes(mwindow, pwindow, xS(400), y,
232 _("Delete existing indexes"), "[*.idx][*.toc][*.mkr]"));
234 add_subwindow(ffmpeg_marker_files = new IndexFFMPEGMarkerFiles(this, x, y));
235 add_subwindow(del_clipngs = new DeleteAllIndexes(mwindow, pwindow, xS(400), y,
236 _("Delete clip thumbnails"), "clip_*.png"));
239 const char* InterfacePrefs::behavior_to_text(int mode)
242 case MOVE_RIPPLE: return _(MOVE_RIPPLE_TITLE);
243 case MOVE_ROLL: return _(MOVE_ROLL_TITLE);
244 case MOVE_SLIP: return _(MOVE_SLIP_TITLE);
245 case MOVE_SLIDE: return _(MOVE_SLIDE_TITLE);
246 case MOVE_EDGE: return _(MOVE_EDGE_TITLE);
247 case MOVE_EDITS_DISABLED: return _(MOVE_EDITS_DISABLED_TITLE);
252 IndexPathText::IndexPathText(int x, int y, PreferencesWindow *pwindow, char *text)
253 : BC_TextBox(x, y, xS(240), 1, text)
255 this->pwindow = pwindow;
258 IndexPathText::~IndexPathText() {}
260 int IndexPathText::handle_event()
262 strcpy(pwindow->thread->preferences->index_directory, get_text());
269 IndexSize::IndexSize(int x, int y, PreferencesWindow *pwindow, char *text)
270 : BC_TextBox(x, y, xS(100), 1, text)
272 this->pwindow = pwindow;
275 int IndexSize::handle_event()
279 result = atol(get_text()) * 1024;
280 if( result < 65536 ) result = 65536;
281 //if(result < 500000) result = 500000;
282 pwindow->thread->preferences->index_size = result;
288 IndexCount::IndexCount(int x, int y, PreferencesWindow *pwindow, char *text)
289 : BC_TextBox(x, y, 100, 1, text)
291 this->pwindow = pwindow;
294 int IndexCount::handle_event()
298 result = atol(get_text());
299 if(result < 1) result = 1;
300 pwindow->thread->preferences->index_count = result;
306 IndexFFMPEGMarkerFiles::IndexFFMPEGMarkerFiles(InterfacePrefs *iface_prefs, int x, int y)
308 iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes,
309 _("build ffmpeg marker indexes"))
311 this->iface_prefs = iface_prefs;
313 IndexFFMPEGMarkerFiles::~IndexFFMPEGMarkerFiles()
317 int IndexFFMPEGMarkerFiles::handle_event()
319 iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes = get_value();
324 ViewBehaviourText::ViewBehaviourText(int x, int y, const char *text, PreferencesWindow *pwindow,
326 : BC_PopupMenu(x, y, xS(250), text)
328 this->output = output;
331 ViewBehaviourText::~ViewBehaviourText()
335 int ViewBehaviourText::handle_event()
340 void ViewBehaviourText::create_objects()
342 for( int mode=0; mode<=EDIT_HANDLE_MODES; ++mode )
343 add_item(new ViewBehaviourItem(this,
344 InterfacePrefs::behavior_to_text(mode), mode));
348 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup,
349 const char *text, int behaviour)
353 this->behaviour = behaviour;
356 ViewBehaviourItem::~ViewBehaviourItem()
360 int ViewBehaviourItem::handle_event()
362 popup->set_text(get_text());
363 *(popup->output) = behaviour;
368 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
369 : BC_TextBox(x, y, xS(50), 1, text)
371 this->pwindow = pwindow;
374 int MeterMinDB::handle_event()
376 pwindow->thread->redraw_meters = 1;
377 pwindow->thread->edl->session->min_meter_db = atol(get_text());
382 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
383 : BC_TextBox(x, y, xS(50), 1, text)
385 this->pwindow = pwindow;
388 int MeterMaxDB::handle_event()
390 pwindow->thread->redraw_meters = 1;
391 pwindow->thread->edl->session->max_meter_db = atol(get_text());
396 ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y)
399 pwindow->thread->preferences->scan_commercials,
400 _("Scan for commercials during toc build"))
402 this->pwindow = pwindow;
404 int ScanCommercials::handle_event()
406 pwindow->thread->preferences->scan_commercials = get_value();
411 AndroidRemote::AndroidRemote(PreferencesWindow *pwindow, int x, int y)
413 pwindow->thread->preferences->android_remote,
414 _("Android Remote Control"))
416 this->pwindow = pwindow;
418 int AndroidRemote::handle_event()
420 pwindow->thread->preferences->android_remote = get_value();
424 AndroidPIN::AndroidPIN(PreferencesWindow *pwindow, int x, int y)
425 : BC_TextBox(x, y, xS(240), 1, pwindow->thread->preferences->android_pin)
427 this->pwindow = pwindow;
430 int AndroidPIN::handle_event()
432 char *txt = pwindow->thread->preferences->android_pin;
433 int len = sizeof(pwindow->thread->preferences->android_pin);
434 strncpy(txt, get_text(), len);
439 AndroidPort::AndroidPort(PreferencesWindow *pwindow, int x, int y)
440 : BC_TextBox(x, y, xS(72), 1, pwindow->thread->preferences->android_port)
442 this->pwindow = pwindow;
445 int AndroidPort::handle_event()
447 unsigned short port = atoi(get_text());
448 if( port < 1024 ) port = 1024;
449 pwindow->thread->preferences->android_port = port;
451 sprintf(str,"%u",port);
456 int InterfacePrefs::start_shbtn_dialog()
459 shbtn_dialog = new ShBtnEditDialog(pwindow);
460 shbtn_dialog->start();
464 ShBtnPrefs::ShBtnPrefs(PreferencesWindow *pwindow, InterfacePrefs *iface_prefs, int x, int y)
465 : BC_GenericButton(x, y, _("Shell Commands"))
467 this->pwindow = pwindow;
468 this->iface_prefs = iface_prefs;
469 set_tooltip(_("Main Menu Shell Commands"));
472 int ShBtnPrefs::handle_event()
474 return iface_prefs->start_shbtn_dialog();
478 StillImageUseDuration::StillImageUseDuration(PreferencesWindow *pwindow, int value, int x, int y)
479 : BC_CheckBox(x, y, value, _("Import images with a duration of"))
481 this->pwindow = pwindow;
484 int StillImageUseDuration::handle_event()
486 pwindow->thread->edl->session->si_useduration = get_value();
490 StillImageDuration::StillImageDuration(PreferencesWindow *pwindow, int x, int y)
491 : BC_TextBox(x, y, xS(70), 1, pwindow->thread->edl->session->si_duration)
493 this->pwindow = pwindow;
495 int StillImageDuration::handle_event()
497 pwindow->thread->edl->session->si_duration = atof(get_text());
502 HairlineItem::HairlineItem(KeyframeReticle *popup, int hairline)
503 : BC_MenuItem(popup->hairline_to_string(hairline))
506 this->hairline = hairline;
509 HairlineItem::~HairlineItem()
513 int HairlineItem::handle_event()
515 popup->pwindow->thread->redraw_overlays = 1;
516 popup->set_text(get_text());
517 *(popup->output) = hairline;
522 KeyframeReticle::KeyframeReticle(PreferencesWindow *pwindow,
523 InterfacePrefs *iface_prefs, int x, int y, int *output)
524 : BC_PopupMenu(x, y, xS(220), hairline_to_string(*output))
526 this->pwindow = pwindow;
527 this->iface_prefs = iface_prefs;
528 this->output = output;
531 KeyframeReticle::~KeyframeReticle()
535 const char *KeyframeReticle::hairline_to_string(int type)
538 case HAIRLINE_NEVER: return _("Never");
539 case HAIRLINE_DRAGGING: return _("Dragging");
540 case HAIRLINE_ALWAYS: return _("Always");
545 void KeyframeReticle::create_objects()
547 add_item(new HairlineItem(this, HAIRLINE_NEVER));
548 add_item(new HairlineItem(this, HAIRLINE_DRAGGING));
549 add_item(new HairlineItem(this, HAIRLINE_ALWAYS));
552 PrefsTrapSigSEGV::PrefsTrapSigSEGV(InterfacePrefs *subwindow, int x, int y)
554 subwindow->pwindow->thread->preferences->trap_sigsegv,
557 this->subwindow = subwindow;
559 PrefsTrapSigSEGV::~PrefsTrapSigSEGV()
562 int PrefsTrapSigSEGV::handle_event()
564 subwindow->pwindow->thread->preferences->trap_sigsegv = get_value();
568 PrefsTrapSigINTR::PrefsTrapSigINTR(InterfacePrefs *subwindow, int x, int y)
570 subwindow->pwindow->thread->preferences->trap_sigintr,
573 this->subwindow = subwindow;
575 PrefsTrapSigINTR::~PrefsTrapSigINTR()
578 int PrefsTrapSigINTR::handle_event()
580 subwindow->pwindow->thread->preferences->trap_sigintr = get_value();
585 void InterfacePrefs::start_probe_dialog()
587 if( !file_probe_dialog )
588 file_probe_dialog = new FileProbeDialog(pwindow);
589 file_probe_dialog->start();
592 PrefsFileProbes::PrefsFileProbes(PreferencesWindow *pwindow,
593 InterfacePrefs *subwindow, int x, int y)
594 : BC_GenericButton(x, y, _("Probe Order"))
596 this->pwindow = pwindow;
597 this->subwindow = subwindow;
598 set_tooltip(_("File Open Probe Ordering"));
601 int PrefsFileProbes::handle_event()
603 subwindow->start_probe_dialog();
608 PrefsYUV420P_DVDlace::PrefsYUV420P_DVDlace(PreferencesWindow *pwindow,
609 InterfacePrefs *subwindow, int x, int y)
610 : BC_CheckBox(x, y, pwindow->thread->preferences->dvd_yuv420p_interlace,
611 _("Use yuv420p dvd interlace format"))
613 this->pwindow = pwindow;
614 this->subwindow = subwindow;
617 int PrefsYUV420P_DVDlace::handle_event()
619 pwindow->thread->preferences->dvd_yuv420p_interlace = get_value();
624 SnapshotPathText::SnapshotPathText(PreferencesWindow *pwindow,
625 InterfacePrefs *subwindow, int x, int y, int w)
626 : BC_TextBox(x, y, w, 1, pwindow->thread->preferences->snapshot_path)
628 this->pwindow = pwindow;
629 this->subwindow = subwindow;
632 SnapshotPathText::~SnapshotPathText()
636 int SnapshotPathText::handle_event()
638 strcpy(pwindow->thread->preferences->snapshot_path, get_text());
642 PrefsAutostartLV2UI::PrefsAutostartLV2UI(int x, int y, PreferencesWindow *pwindow)
644 pwindow->thread->preferences->autostart_lv2ui, _("Auto start lv2 gui"))
646 this->pwindow = pwindow;
648 int PrefsAutostartLV2UI::handle_event()
650 pwindow->thread->preferences->autostart_lv2ui = get_value();
654 PrefsReloadPlugins::PrefsReloadPlugins(PreferencesWindow *pwindow,
655 InterfacePrefs *iface_prefs, int x, int y)
656 : BC_GenericButton(x, y, _("Reload plugin index"))
658 this->pwindow = pwindow;
659 this->iface_prefs = iface_prefs;
662 int PrefsReloadPlugins::handle_event()
664 pwindow->thread->reload_plugins = 1;
665 text_color(get_resources()->button_highlighted);
670 PrefsLV2PathText::PrefsLV2PathText(PreferencesWindow *pwindow,
671 InterfacePrefs *subwindow, int x, int y, int w)
672 : BC_TextBox(x, y, w, 1, pwindow->thread->preferences->lv2_path)
674 this->pwindow = pwindow;
675 this->subwindow = subwindow;
678 PrefsLV2PathText::~PrefsLV2PathText()
682 int PrefsLV2PathText::handle_event()
684 strcpy(pwindow->thread->preferences->lv2_path, get_text());