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"
37 N_("Drag all following edits")
38 N_("Drag only one edit")
39 N_("Drag source only")
43 #define MOVE_ALL_EDITS_TITLE N_("Drag all following edits")
44 #define MOVE_ONE_EDIT_TITLE N_("Drag only one edit")
45 #define MOVE_NO_EDITS_TITLE N_("Drag source only")
46 #define MOVE_EDITS_DISABLED_TITLE N_("No effect")
48 InterfacePrefs::InterfacePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
49 : PreferencesDialog(mwindow, pwindow)
54 file_probe_dialog = 0;
57 InterfacePrefs::~InterfacePrefs()
62 delete file_probe_dialog;
66 void InterfacePrefs::create_objects()
68 BC_Resources *resources = BC_WindowBase::get_resources();
69 int margin = mwindow->theme->widget_border;
70 char string[BCTEXTLEN];
71 int x0 = mwindow->theme->preferencesoptions_x;
72 int y0 = mwindow->theme->preferencesoptions_y;
75 add_subwindow(new BC_Title(x, y, _("Editing:"), LARGEFONT,
76 resources->text_default));
79 int x2 = get_w()/2, y2 = y;
82 add_subwindow(title = new BC_Title(x, y, _("Keyframe reticle:")));
83 y += title->get_h() + 5;
84 keyframe_reticle = new KeyframeReticle(pwindow, this, x, y,
85 &pwindow->thread->preferences->keyframe_reticle);
86 add_subwindow(keyframe_reticle);
87 keyframe_reticle->create_objects();
90 add_subwindow(title = new BC_Title(x, y, _("Snapshot path:")));
91 y += title->get_h() + 5;
92 add_subwindow(snapshot_path = new SnapshotPathText(pwindow, this, x, y, get_w()-x-30));
95 add_subwindow(new BC_Title(x, y, _("Clicking on edit boundaries does what:")));
97 add_subwindow(new BC_Title(x, y, _("Button 1:")));
100 ViewBehaviourText *text;
101 add_subwindow(text = new ViewBehaviourText(x1, y - 5,
102 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]),
104 &(pwindow->thread->edl->session->edit_handle_mode[0])));
105 text->create_objects();
107 add_subwindow(new BC_Title(x, y, _("Button 2:")));
108 add_subwindow(text = new ViewBehaviourText(x1,
110 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]),
112 &(pwindow->thread->edl->session->edit_handle_mode[1])));
113 text->create_objects();
115 add_subwindow(new BC_Title(x, y, _("Button 3:")));
116 add_subwindow(text = new ViewBehaviourText(x1, y - 5,
117 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]),
119 &(pwindow->thread->edl->session->edit_handle_mode[2])));
120 text->create_objects();
121 y += text->get_h() + 30;
124 add_subwindow(new BC_Bar(5, y, get_w() - 10));
126 add_subwindow(new BC_Title(x, y, _("Operation:"), LARGEFONT,
127 resources->text_default));
131 AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y);
132 add_subwindow(android_remote);
133 y += android_remote->get_h() + 10;
134 add_subwindow(title = new BC_Title(x2, y, _("Port:")));
135 int x3 = x2 + title->get_w() + margin;
136 AndroidPort *android_port = new AndroidPort(pwindow, x3, y);
137 add_subwindow(android_port);
138 y += title->get_h() + 10;
139 add_subwindow(title = new BC_Title(x2, y, _("PIN:")));
140 AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y);
141 add_subwindow(android_pin);
142 y += title->get_h() + 30;
144 ShBtnPrefs *shbtn_prefs = new ShBtnPrefs(pwindow, this, x2, y);
145 add_subwindow(shbtn_prefs);
146 y += shbtn_prefs->get_h() + 30;
150 add_subwindow(file_probes = new PrefsFileProbes(pwindow, this, x, y));
153 PrefsTrapSigSEGV *trap_segv = new PrefsTrapSigSEGV(this, x, y);
154 add_subwindow(trap_segv);
155 x1 = x + trap_segv->get_w() + 10;
156 add_subwindow(new BC_Title(x1, y, _("(must be root)"), MEDIUMFONT, RED));
159 PrefsTrapSigINTR *trap_intr = new PrefsTrapSigINTR(this, x, y);
160 add_subwindow(trap_intr);
161 add_subwindow(new BC_Title(x1, y, _("(must be root)"), MEDIUMFONT, RED));
164 yuv420p_dvdlace = new PrefsYUV420P_DVDlace(pwindow, this, x, y);
165 add_subwindow(yuv420p_dvdlace);
169 add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
170 x += title->get_w() + 10;
171 sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
172 add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
173 x += min_db->get_w() + 10;
174 add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
175 x += title->get_w() + 10;
176 sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
177 add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
180 StillImageUseDuration *use_stduration = new StillImageUseDuration(pwindow,
181 pwindow->thread->edl->session->si_useduration, x2, y2);
182 add_subwindow(use_stduration);
184 BC_CheckBox::calculate_extents(this, &tw, &th, 0, 0);
186 y2 += use_stduration->get_h() + 3;
187 StillImageDuration *stduration = new StillImageDuration(pwindow, x2, y2);
188 add_subwindow(stduration);
189 x2 += stduration->get_w() + 10;
191 add_subwindow(new BC_Title(x2, y2, _("Seconds")));
195 add_subwindow(new BC_Bar(5, y, get_w() - 10));
199 add_subwindow(new BC_Title(x, y, _("Index files:"), LARGEFONT, resources->text_default));
202 add_subwindow(new BC_Title(x, y + 5,
203 _("Index files go here:"), MEDIUMFONT, resources->text_default));
205 add_subwindow(ipathtext = new IndexPathText(x1, y, pwindow,
206 pwindow->thread->preferences->index_directory));
207 x1 += ipathtext->get_w();
208 add_subwindow(ipath = new BrowseButton(mwindow->theme, this, ipathtext, x1, y,
209 pwindow->thread->preferences->index_directory,
210 _("Index Path"), _("Select the directory for index files"), 1));
213 add_subwindow(new BC_Title(x, y + 5, _("Size of index file:"),
214 MEDIUMFONT, resources->text_default));
215 sprintf(string, "%jd", pwindow->thread->preferences->index_size);
216 add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
217 add_subwindow(new ScanCommercials(pwindow, 400,y));
220 add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"),
221 MEDIUMFONT, resources->text_default));
222 sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
223 add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
224 add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 400, y));
226 add_subwindow(ffmpeg_marker_files = new IndexFFMPEGMarkerFiles(this, x, y));
230 const char* InterfacePrefs::behavior_to_text(int mode)
233 case MOVE_ALL_EDITS: return _(MOVE_ALL_EDITS_TITLE);
234 case MOVE_ONE_EDIT: return _(MOVE_ONE_EDIT_TITLE);
235 case MOVE_NO_EDITS: return _(MOVE_NO_EDITS_TITLE);
236 case MOVE_EDITS_DISABLED: return _(MOVE_EDITS_DISABLED_TITLE);
241 IndexPathText::IndexPathText(int x, int y, PreferencesWindow *pwindow, char *text)
242 : BC_TextBox(x, y, 240, 1, text)
244 this->pwindow = pwindow;
247 IndexPathText::~IndexPathText() {}
249 int IndexPathText::handle_event()
251 strcpy(pwindow->thread->preferences->index_directory, get_text());
258 IndexSize::IndexSize(int x, int y, PreferencesWindow *pwindow, char *text)
259 : BC_TextBox(x, y, 100, 1, text)
261 this->pwindow = pwindow;
264 int IndexSize::handle_event()
268 result = atol(get_text());
269 if(result < 64000) result = 64000;
270 //if(result < 500000) result = 500000;
271 pwindow->thread->preferences->index_size = result;
277 IndexCount::IndexCount(int x, int y, PreferencesWindow *pwindow, char *text)
278 : BC_TextBox(x, y, 100, 1, text)
280 this->pwindow = pwindow;
283 int IndexCount::handle_event()
287 result = atol(get_text());
288 if(result < 1) result = 1;
289 pwindow->thread->preferences->index_count = result;
295 IndexFFMPEGMarkerFiles::IndexFFMPEGMarkerFiles(InterfacePrefs *iface_prefs, int x, int y)
297 iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes,
298 _("build ffmpeg marker indexes"))
300 this->iface_prefs = iface_prefs;
302 IndexFFMPEGMarkerFiles::~IndexFFMPEGMarkerFiles()
306 int IndexFFMPEGMarkerFiles::handle_event()
308 iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes = get_value();
313 ViewBehaviourText::ViewBehaviourText(int x, int y, const char *text, PreferencesWindow *pwindow,
315 : BC_PopupMenu(x, y, 200, text)
317 this->output = output;
320 ViewBehaviourText::~ViewBehaviourText()
324 int ViewBehaviourText::handle_event()
329 void ViewBehaviourText::create_objects()
331 add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
332 add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
333 add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
334 add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
338 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
342 this->behaviour = behaviour;
345 ViewBehaviourItem::~ViewBehaviourItem()
349 int ViewBehaviourItem::handle_event()
351 popup->set_text(get_text());
352 *(popup->output) = behaviour;
357 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
358 : BC_TextBox(x, y, 50, 1, text)
360 this->pwindow = pwindow;
363 int MeterMinDB::handle_event()
365 pwindow->thread->redraw_meters = 1;
366 pwindow->thread->edl->session->min_meter_db = atol(get_text());
371 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
372 : BC_TextBox(x, y, 50, 1, text)
374 this->pwindow = pwindow;
377 int MeterMaxDB::handle_event()
379 pwindow->thread->redraw_meters = 1;
380 pwindow->thread->edl->session->max_meter_db = atol(get_text());
385 ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y)
388 pwindow->thread->preferences->scan_commercials,
389 _("Scan for commercials during toc build"))
391 this->pwindow = pwindow;
393 int ScanCommercials::handle_event()
395 pwindow->thread->preferences->scan_commercials = get_value();
400 AndroidRemote::AndroidRemote(PreferencesWindow *pwindow, int x, int y)
402 pwindow->thread->preferences->android_remote,
403 _("Android Remote Control"))
405 this->pwindow = pwindow;
407 int AndroidRemote::handle_event()
409 pwindow->thread->preferences->android_remote = get_value();
413 AndroidPIN::AndroidPIN(PreferencesWindow *pwindow, int x, int y)
414 : BC_TextBox(x, y, 240, 1, pwindow->thread->preferences->android_pin)
416 this->pwindow = pwindow;
419 int AndroidPIN::handle_event()
421 char *txt = pwindow->thread->preferences->android_pin;
422 int len = sizeof(pwindow->thread->preferences->android_pin);
423 strncpy(txt, get_text(), len);
428 AndroidPort::AndroidPort(PreferencesWindow *pwindow, int x, int y)
429 : BC_TextBox(x, y, 72, 1, pwindow->thread->preferences->android_port)
431 this->pwindow = pwindow;
434 int AndroidPort::handle_event()
436 unsigned short port = atoi(get_text());
437 if( port < 1024 ) port = 1024;
438 pwindow->thread->preferences->android_port = port;
440 sprintf(str,"%u",port);
445 int InterfacePrefs::start_shbtn_dialog()
448 shbtn_dialog = new ShBtnEditDialog(pwindow);
449 shbtn_dialog->start();
453 ShBtnPrefs::ShBtnPrefs(PreferencesWindow *pwindow, InterfacePrefs *iface_prefs, int x, int y)
454 : BC_GenericButton(x, y, _("Shell Commands"))
456 this->pwindow = pwindow;
457 this->iface_prefs = iface_prefs;
458 set_tooltip(_("Main Menu Shell Commands"));
461 int ShBtnPrefs::handle_event()
463 return iface_prefs->start_shbtn_dialog();
467 StillImageUseDuration::StillImageUseDuration(PreferencesWindow *pwindow, int value, int x, int y)
468 : BC_CheckBox(x, y, value, _("Import images with a duration of"))
470 this->pwindow = pwindow;
473 int StillImageUseDuration::handle_event()
475 pwindow->thread->edl->session->si_useduration = get_value();
479 StillImageDuration::StillImageDuration(PreferencesWindow *pwindow, int x, int y)
480 : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->si_duration)
482 this->pwindow = pwindow;
484 int StillImageDuration::handle_event()
486 pwindow->thread->edl->session->si_duration = atof(get_text());
491 HairlineItem::HairlineItem(KeyframeReticle *popup, int hairline)
492 : BC_MenuItem(popup->hairline_to_string(hairline))
495 this->hairline = hairline;
498 HairlineItem::~HairlineItem()
502 int HairlineItem::handle_event()
504 popup->pwindow->thread->redraw_overlays = 1;
505 popup->set_text(get_text());
506 *(popup->output) = hairline;
511 KeyframeReticle::KeyframeReticle(PreferencesWindow *pwindow,
512 InterfacePrefs *iface_prefs, int x, int y, int *output)
513 : BC_PopupMenu(x, y, 220, hairline_to_string(*output))
515 this->pwindow = pwindow;
516 this->iface_prefs = iface_prefs;
517 this->output = output;
520 KeyframeReticle::~KeyframeReticle()
524 const char *KeyframeReticle::hairline_to_string(int type)
527 case HAIRLINE_NEVER: return _("Never");
528 case HAIRLINE_DRAGGING: return _("Dragging");
529 case HAIRLINE_ALWAYS: return _("Always");
534 void KeyframeReticle::create_objects()
536 add_item(new HairlineItem(this, HAIRLINE_NEVER));
537 add_item(new HairlineItem(this, HAIRLINE_DRAGGING));
538 add_item(new HairlineItem(this, HAIRLINE_ALWAYS));
541 PrefsTrapSigSEGV::PrefsTrapSigSEGV(InterfacePrefs *subwindow, int x, int y)
543 subwindow->pwindow->thread->preferences->trap_sigsegv,
546 this->subwindow = subwindow;
548 PrefsTrapSigSEGV::~PrefsTrapSigSEGV()
551 int PrefsTrapSigSEGV::handle_event()
553 subwindow->pwindow->thread->preferences->trap_sigsegv = get_value();
557 PrefsTrapSigINTR::PrefsTrapSigINTR(InterfacePrefs *subwindow, int x, int y)
559 subwindow->pwindow->thread->preferences->trap_sigintr,
562 this->subwindow = subwindow;
564 PrefsTrapSigINTR::~PrefsTrapSigINTR()
567 int PrefsTrapSigINTR::handle_event()
569 subwindow->pwindow->thread->preferences->trap_sigintr = get_value();
574 void InterfacePrefs::start_probe_dialog()
576 if( !file_probe_dialog )
577 file_probe_dialog = new FileProbeDialog(pwindow);
578 file_probe_dialog->start();
581 PrefsFileProbes::PrefsFileProbes(PreferencesWindow *pwindow,
582 InterfacePrefs *subwindow, int x, int y)
583 : BC_GenericButton(x, y, _("Probe Order"))
585 this->pwindow = pwindow;
586 this->subwindow = subwindow;
587 set_tooltip(_("File Open Probe Ordering"));
590 int PrefsFileProbes::handle_event()
592 subwindow->start_probe_dialog();
597 PrefsYUV420P_DVDlace::PrefsYUV420P_DVDlace(PreferencesWindow *pwindow,
598 InterfacePrefs *subwindow, int x, int y)
599 : BC_CheckBox(x, y, pwindow->thread->preferences->dvd_yuv420p_interlace,
600 _("Use yuv420p dvd interlace format"))
602 this->pwindow = pwindow;
603 this->subwindow = subwindow;
606 int PrefsYUV420P_DVDlace::handle_event()
608 pwindow->thread->preferences->dvd_yuv420p_interlace = get_value();
613 SnapshotPathText::SnapshotPathText(PreferencesWindow *pwindow,
614 InterfacePrefs *subwindow, int x, int y, int w)
615 : BC_TextBox(x, y, w, 1, pwindow->thread->preferences->snapshot_path)
617 this->pwindow = pwindow;
618 this->subwindow = subwindow;
621 SnapshotPathText::~SnapshotPathText()
625 int SnapshotPathText::handle_event()
627 strcpy(pwindow->thread->preferences->snapshot_path, get_text());