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), 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;
134 add_subwindow(title = new BC_Title(x3, y, _("Port:")));
135 x3 += title->get_w() + margin;
136 AndroidPort *android_port = new AndroidPort(pwindow, x3, y);
137 add_subwindow(android_port);
138 x3 += android_port->get_w() + 2*margin;
139 add_subwindow(title = new BC_Title(x3, y, _("PIN:")));
140 x3 += title->get_w() + margin;
141 AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y);
142 add_subwindow(android_pin);
143 y += android_port->get_h() + 3*margin;
145 ShBtnPrefs *shbtn_prefs = new ShBtnPrefs(pwindow, this, x2, y);
146 add_subwindow(shbtn_prefs);
147 x3 = x2 + shbtn_prefs->get_w() + 2*margin;
148 add_subwindow(reload_plugins = new PrefsReloadPlugins(pwindow, this, x3, y));
149 y += reload_plugins->get_h() + 3*margin;
151 add_subwindow(title = new BC_Title(x2, y, _("Nested Proxy Path:")));
152 y += title->get_h() + ys10;
153 PrefsNestedProxyPath *nested_proxy_path = new PrefsNestedProxyPath(pwindow, this,
154 x2, y, get_w()-x2-xs30);
155 add_subwindow(nested_proxy_path);
158 add_subwindow(title = new BC_Title(x2, y, _("Default LV2_PATH:")));
159 y += title->get_h() + ys10;
160 PrefsLV2PathText *lv2_path_text = new PrefsLV2PathText(pwindow, this,
161 x2, y, get_w()-x2-xs30);
162 add_subwindow(lv2_path_text);
166 x = x0; y = y1 + ys35;
167 add_subwindow(file_probes = new PrefsFileProbes(pwindow, this, x, y));
170 PrefsTrapSigSEGV *trap_segv = new PrefsTrapSigSEGV(this, x, y);
171 add_subwindow(trap_segv);
172 x1 = x + trap_segv->get_w() + xs10;
173 add_subwindow(new BC_Title(x1, y, _("(must be root)"), MEDIUMFONT, RED));
176 PrefsTrapSigINTR *trap_intr = new PrefsTrapSigINTR(this, x, y);
177 add_subwindow(trap_intr);
178 add_subwindow(new BC_Title(x1, y, _("(must be root)"), MEDIUMFONT, RED));
181 yuv420p_dvdlace = new PrefsYUV420P_DVDlace(pwindow, this, x, y);
182 add_subwindow(yuv420p_dvdlace);
185 add_subwindow(title = new BC_Title(x1=x, y + ys5, _("Min DB for meter:")));
186 x1 += title->get_w() + xs4;
187 sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
188 add_subwindow(min_db = new MeterMinDB(pwindow, string, x1, y));
189 x1 += min_db->get_w() + xs4;
190 add_subwindow(title = new BC_Title(x1, y + ys5, _("Max:")));
191 x1 += title->get_w() + xs4;
192 sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
193 add_subwindow(max_db = new MeterMaxDB(pwindow, string, x1, y));
196 StillImageUseDuration *use_stduration = new StillImageUseDuration(pwindow,
197 pwindow->thread->edl->session->si_useduration, x, y);
198 add_subwindow(use_stduration);
199 x1 = x + use_stduration->get_w() + xs10;
200 StillImageDuration *stduration = new StillImageDuration(pwindow, x1, y);
201 add_subwindow(stduration);
202 x1 += stduration->get_w() + xs10;
203 add_subwindow(new BC_Title(x1, y, _("Seconds")));
206 PrefsAutostartLV2UI *autostart_lv2ui = new PrefsAutostartLV2UI(x, y,pwindow);
207 add_subwindow(autostart_lv2ui);
208 y += autostart_lv2ui->get_h() + ys10;
212 add_subwindow(new BC_Bar(xs5, y, get_w() - xs10));
215 add_subwindow(new BC_Title(x, y, _("Index files:"), LARGEFONT, resources->text_default));
218 add_subwindow(new BC_Title(x, y + ys5,
219 _("Index files go here:"), MEDIUMFONT, resources->text_default));
221 add_subwindow(ipathtext = new IndexPathText(x1, y, pwindow,
222 pwindow->thread->preferences->index_directory));
223 x1 += ipathtext->get_w();
224 add_subwindow(ipath = new BrowseButton(mwindow->theme, this, ipathtext, x1, y,
225 pwindow->thread->preferences->index_directory,
226 _("Index Path"), _("Select the directory for index files"), 1));
229 add_subwindow(new BC_Title(x, y + ys5, _("Size of index file in KB:"),
230 MEDIUMFONT, resources->text_default));
231 sprintf(string, "%jd", pwindow->thread->preferences->index_size/1024);
232 add_subwindow(isize = new IndexSize(x + xS(230), y, pwindow, string));
233 add_subwindow(new ScanCommercials(pwindow, xS(400),y));
236 add_subwindow(new BC_Title(x, y + ys5, _("Number of index files to keep:"),
237 MEDIUMFONT, resources->text_default));
238 sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
239 add_subwindow(icount = new IndexCount(x + xS(230), y, pwindow, string));
240 add_subwindow(del_indexes = new DeleteAllIndexes(mwindow, pwindow, xS(400), y,
241 _("Delete existing indexes"), "[*.idx][*.toc][*.mkr]"));
243 add_subwindow(ffmpeg_marker_files = new IndexFFMPEGMarkerFiles(this, x, y));
244 add_subwindow(del_clipngs = new DeleteAllIndexes(mwindow, pwindow, xS(400), y,
245 _("Delete clip thumbnails"), "clip_*.png"));
248 const char* InterfacePrefs::behavior_to_text(int mode)
251 case MOVE_RIPPLE: return _(MOVE_RIPPLE_TITLE);
252 case MOVE_ROLL: return _(MOVE_ROLL_TITLE);
253 case MOVE_SLIP: return _(MOVE_SLIP_TITLE);
254 case MOVE_SLIDE: return _(MOVE_SLIDE_TITLE);
255 case MOVE_EDGE: return _(MOVE_EDGE_TITLE);
256 case MOVE_EDITS_DISABLED: return _(MOVE_EDITS_DISABLED_TITLE);
261 IndexPathText::IndexPathText(int x, int y, PreferencesWindow *pwindow, char *text)
262 : BC_TextBox(x, y, xS(240), 1, text)
264 this->pwindow = pwindow;
267 IndexPathText::~IndexPathText() {}
269 int IndexPathText::handle_event()
271 strcpy(pwindow->thread->preferences->index_directory, get_text());
278 IndexSize::IndexSize(int x, int y, PreferencesWindow *pwindow, char *text)
279 : BC_TextBox(x, y, xS(100), 1, text)
281 this->pwindow = pwindow;
284 int IndexSize::handle_event()
288 result = atol(get_text()) * 1024;
289 if( result < 65536 ) result = 65536;
290 //if(result < 500000) result = 500000;
291 pwindow->thread->preferences->index_size = result;
297 IndexCount::IndexCount(int x, int y, PreferencesWindow *pwindow, char *text)
298 : BC_TextBox(x, y, 100, 1, text)
300 this->pwindow = pwindow;
303 int IndexCount::handle_event()
307 result = atol(get_text());
308 if(result < 1) result = 1;
309 pwindow->thread->preferences->index_count = result;
315 IndexFFMPEGMarkerFiles::IndexFFMPEGMarkerFiles(InterfacePrefs *iface_prefs, int x, int y)
317 iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes,
318 _("build ffmpeg marker indexes"))
320 this->iface_prefs = iface_prefs;
322 IndexFFMPEGMarkerFiles::~IndexFFMPEGMarkerFiles()
326 int IndexFFMPEGMarkerFiles::handle_event()
328 iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes = get_value();
333 ViewBehaviourText::ViewBehaviourText(int x, int y, const char *text, PreferencesWindow *pwindow,
335 : BC_PopupMenu(x, y, xS(250), text)
337 this->output = output;
340 ViewBehaviourText::~ViewBehaviourText()
344 int ViewBehaviourText::handle_event()
349 void ViewBehaviourText::create_objects()
351 for( int mode=0; mode<=EDIT_HANDLE_MODES; ++mode )
352 add_item(new ViewBehaviourItem(this,
353 InterfacePrefs::behavior_to_text(mode), mode));
357 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup,
358 const char *text, int behaviour)
362 this->behaviour = behaviour;
365 ViewBehaviourItem::~ViewBehaviourItem()
369 int ViewBehaviourItem::handle_event()
371 popup->set_text(get_text());
372 *(popup->output) = behaviour;
377 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
378 : BC_TextBox(x, y, xS(50), 1, text)
380 this->pwindow = pwindow;
383 int MeterMinDB::handle_event()
385 pwindow->thread->redraw_meters = 1;
386 pwindow->thread->edl->session->min_meter_db = atol(get_text());
391 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
392 : BC_TextBox(x, y, xS(50), 1, text)
394 this->pwindow = pwindow;
397 int MeterMaxDB::handle_event()
399 pwindow->thread->redraw_meters = 1;
400 pwindow->thread->edl->session->max_meter_db = atol(get_text());
405 ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y)
408 pwindow->thread->preferences->scan_commercials,
409 _("Scan for commercials during toc build"))
411 this->pwindow = pwindow;
413 int ScanCommercials::handle_event()
415 pwindow->thread->preferences->scan_commercials = get_value();
420 AndroidRemote::AndroidRemote(PreferencesWindow *pwindow, int x, int y)
422 pwindow->thread->preferences->android_remote,
423 _("Android Remote Control"))
425 this->pwindow = pwindow;
427 int AndroidRemote::handle_event()
429 pwindow->thread->preferences->android_remote = get_value();
433 AndroidPIN::AndroidPIN(PreferencesWindow *pwindow, int x, int y)
434 : BC_TextBox(x, y, xS(180), 1, pwindow->thread->preferences->android_pin)
436 this->pwindow = pwindow;
439 int AndroidPIN::handle_event()
441 char *txt = pwindow->thread->preferences->android_pin;
442 int len = sizeof(pwindow->thread->preferences->android_pin);
443 strncpy(txt, get_text(), len);
448 AndroidPort::AndroidPort(PreferencesWindow *pwindow, int x, int y)
449 : BC_TextBox(x, y, xS(72), 1, pwindow->thread->preferences->android_port)
451 this->pwindow = pwindow;
454 int AndroidPort::handle_event()
456 unsigned short port = atoi(get_text());
457 if( port < 1024 ) port = 1024;
458 pwindow->thread->preferences->android_port = port;
460 sprintf(str,"%u",port);
465 int InterfacePrefs::start_shbtn_dialog()
468 shbtn_dialog = new ShBtnEditDialog(pwindow);
469 shbtn_dialog->start();
473 ShBtnPrefs::ShBtnPrefs(PreferencesWindow *pwindow, InterfacePrefs *iface_prefs, int x, int y)
474 : BC_GenericButton(x, y, _("Shell Commands"))
476 this->pwindow = pwindow;
477 this->iface_prefs = iface_prefs;
478 set_tooltip(_("Main Menu Shell Commands"));
481 int ShBtnPrefs::handle_event()
483 return iface_prefs->start_shbtn_dialog();
487 StillImageUseDuration::StillImageUseDuration(PreferencesWindow *pwindow, int value, int x, int y)
488 : BC_CheckBox(x, y, value, _("Import images with a duration of"))
490 this->pwindow = pwindow;
493 int StillImageUseDuration::handle_event()
495 pwindow->thread->edl->session->si_useduration = get_value();
499 StillImageDuration::StillImageDuration(PreferencesWindow *pwindow, int x, int y)
500 : BC_TextBox(x, y, xS(70), 1, pwindow->thread->edl->session->si_duration)
502 this->pwindow = pwindow;
504 int StillImageDuration::handle_event()
506 pwindow->thread->edl->session->si_duration = atof(get_text());
511 HairlineItem::HairlineItem(KeyframeReticle *popup, int hairline)
512 : BC_MenuItem(popup->hairline_to_string(hairline))
515 this->hairline = hairline;
518 HairlineItem::~HairlineItem()
522 int HairlineItem::handle_event()
524 popup->pwindow->thread->redraw_overlays = 1;
525 popup->set_text(get_text());
526 *(popup->output) = hairline;
531 KeyframeReticle::KeyframeReticle(PreferencesWindow *pwindow,
532 InterfacePrefs *iface_prefs, int x, int y, int *output)
533 : BC_PopupMenu(x, y, xS(220), hairline_to_string(*output))
535 this->pwindow = pwindow;
536 this->iface_prefs = iface_prefs;
537 this->output = output;
540 KeyframeReticle::~KeyframeReticle()
544 const char *KeyframeReticle::hairline_to_string(int type)
547 case HAIRLINE_NEVER: return _("Never");
548 case HAIRLINE_DRAGGING: return _("Dragging");
549 case HAIRLINE_ALWAYS: return _("Always");
554 void KeyframeReticle::create_objects()
556 add_item(new HairlineItem(this, HAIRLINE_NEVER));
557 add_item(new HairlineItem(this, HAIRLINE_DRAGGING));
558 add_item(new HairlineItem(this, HAIRLINE_ALWAYS));
561 PrefsTrapSigSEGV::PrefsTrapSigSEGV(InterfacePrefs *subwindow, int x, int y)
563 subwindow->pwindow->thread->preferences->trap_sigsegv,
566 this->subwindow = subwindow;
568 PrefsTrapSigSEGV::~PrefsTrapSigSEGV()
571 int PrefsTrapSigSEGV::handle_event()
573 subwindow->pwindow->thread->preferences->trap_sigsegv = get_value();
577 PrefsTrapSigINTR::PrefsTrapSigINTR(InterfacePrefs *subwindow, int x, int y)
579 subwindow->pwindow->thread->preferences->trap_sigintr,
582 this->subwindow = subwindow;
584 PrefsTrapSigINTR::~PrefsTrapSigINTR()
587 int PrefsTrapSigINTR::handle_event()
589 subwindow->pwindow->thread->preferences->trap_sigintr = get_value();
594 void InterfacePrefs::start_probe_dialog()
596 if( !file_probe_dialog )
597 file_probe_dialog = new FileProbeDialog(pwindow);
598 file_probe_dialog->start();
601 PrefsFileProbes::PrefsFileProbes(PreferencesWindow *pwindow,
602 InterfacePrefs *subwindow, int x, int y)
603 : BC_GenericButton(x, y, _("Probe Order"))
605 this->pwindow = pwindow;
606 this->subwindow = subwindow;
607 set_tooltip(_("File Open Probe Ordering"));
610 int PrefsFileProbes::handle_event()
612 subwindow->start_probe_dialog();
617 PrefsYUV420P_DVDlace::PrefsYUV420P_DVDlace(PreferencesWindow *pwindow,
618 InterfacePrefs *subwindow, int x, int y)
619 : BC_CheckBox(x, y, pwindow->thread->preferences->dvd_yuv420p_interlace,
620 _("Use yuv420p dvd interlace format"))
622 this->pwindow = pwindow;
623 this->subwindow = subwindow;
626 int PrefsYUV420P_DVDlace::handle_event()
628 pwindow->thread->preferences->dvd_yuv420p_interlace = get_value();
633 SnapshotPathText::SnapshotPathText(PreferencesWindow *pwindow,
634 InterfacePrefs *subwindow, int x, int y, int w)
635 : BC_TextBox(x, y, w, 1, pwindow->thread->preferences->snapshot_path)
637 this->pwindow = pwindow;
638 this->subwindow = subwindow;
641 SnapshotPathText::~SnapshotPathText()
645 int SnapshotPathText::handle_event()
647 strcpy(pwindow->thread->preferences->snapshot_path, get_text());
651 PrefsAutostartLV2UI::PrefsAutostartLV2UI(int x, int y, PreferencesWindow *pwindow)
653 pwindow->thread->preferences->autostart_lv2ui, _("Auto start lv2 gui"))
655 this->pwindow = pwindow;
657 int PrefsAutostartLV2UI::handle_event()
659 pwindow->thread->preferences->autostart_lv2ui = get_value();
663 PrefsReloadPlugins::PrefsReloadPlugins(PreferencesWindow *pwindow,
664 InterfacePrefs *iface_prefs, int x, int y)
665 : BC_GenericButton(x, y, _("Reload plugin index"))
667 this->pwindow = pwindow;
668 this->iface_prefs = iface_prefs;
671 int PrefsReloadPlugins::handle_event()
673 pwindow->thread->reload_plugins = 1;
674 text_color(get_resources()->button_highlighted);
679 PrefsLV2PathText::PrefsLV2PathText(PreferencesWindow *pwindow,
680 InterfacePrefs *subwindow, int x, int y, int w)
681 : BC_TextBox(x, y, w, 1, pwindow->thread->preferences->lv2_path)
683 this->pwindow = pwindow;
684 this->subwindow = subwindow;
687 PrefsLV2PathText::~PrefsLV2PathText()
691 int PrefsLV2PathText::handle_event()
693 strcpy(pwindow->thread->preferences->lv2_path, get_text());
697 PrefsNestedProxyPath::PrefsNestedProxyPath(PreferencesWindow *pwindow,
698 InterfacePrefs *subwindow, int x, int y, int w)
699 : BC_TextBox(x, y, w, 1, pwindow->thread->preferences->nested_proxy_path)
701 this->pwindow = pwindow;
702 this->subwindow = subwindow;
705 PrefsNestedProxyPath::~PrefsNestedProxyPath()
709 int PrefsNestedProxyPath::handle_event()
711 strcpy(pwindow->thread->preferences->nested_proxy_path, get_text());