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 "Drag all following edits"
44 #define MOVE_ONE_EDIT_TITLE "Drag only one edit"
45 #define MOVE_NO_EDITS_TITLE "Drag source only"
46 #define MOVE_EDITS_DISABLED_TITLE "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(new BC_Title(x, y, _("Clicking on edit boundaries does what:")));
92 add_subwindow(new BC_Title(x, y, _("Button 1:")));
95 ViewBehaviourText *text;
96 add_subwindow(text = new ViewBehaviourText(x1, y - 5,
97 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]),
99 &(pwindow->thread->edl->session->edit_handle_mode[0])));
100 text->create_objects();
102 add_subwindow(new BC_Title(x, y, _("Button 2:")));
103 add_subwindow(text = new ViewBehaviourText(x1,
105 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]),
107 &(pwindow->thread->edl->session->edit_handle_mode[1])));
108 text->create_objects();
110 add_subwindow(new BC_Title(x, y, _("Button 3:")));
111 add_subwindow(text = new ViewBehaviourText(x1, y - 5,
112 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]),
114 &(pwindow->thread->edl->session->edit_handle_mode[2])));
115 text->create_objects();
116 y += text->get_h() + 30;
119 add_subwindow(new BC_Bar(5, y, get_w() - 10));
121 add_subwindow(new BC_Title(x, y, _("Operation:"), LARGEFONT,
122 resources->text_default));
126 AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y);
127 add_subwindow(android_remote);
128 y += android_remote->get_h() + 10;
129 add_subwindow(title = new BC_Title(x2, y, _("Port:")));
130 int x3 = x2 + title->get_w() + margin;
131 AndroidPort *android_port = new AndroidPort(pwindow, x3, y);
132 add_subwindow(android_port);
133 y += title->get_h() + 10;
134 add_subwindow(title = new BC_Title(x2, y, _("PIN:")));
135 AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y);
136 add_subwindow(android_pin);
137 y += title->get_h() + 30;
139 ShBtnPrefs *shbtn_prefs = new ShBtnPrefs(pwindow, this, x2, y);
140 add_subwindow(shbtn_prefs);
141 y += shbtn_prefs->get_h() + 30;
145 add_subwindow(file_probes = new PrefsFileProbes(pwindow, this, x, y));
148 PrefsTrapSigSEGV *trap_segv = new PrefsTrapSigSEGV(this, x, y);
149 add_subwindow(trap_segv);
150 x1 = x + trap_segv->get_w() + 10;
151 add_subwindow(new BC_Title(x1, y, _("(must be root)"), MEDIUMFONT, RED));
154 PrefsTrapSigINTR *trap_intr = new PrefsTrapSigINTR(this, x, y);
155 add_subwindow(trap_intr);
156 add_subwindow(new BC_Title(x1, y, _("(must be root)"), MEDIUMFONT, RED));
159 yuv420p_dvdlace = new PrefsYUV420P_DVDlace(pwindow, this, x, y);
160 add_subwindow(yuv420p_dvdlace);
164 add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
165 x += title->get_w() + 10;
166 sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
167 add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
168 x += min_db->get_w() + 10;
169 add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
170 x += title->get_w() + 10;
171 sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
172 add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
175 StillImageUseDuration *use_stduration = new StillImageUseDuration(pwindow,
176 pwindow->thread->edl->session->si_useduration, x2, y2);
177 add_subwindow(use_stduration);
179 BC_CheckBox::calculate_extents(this, &tw, &th, 0, 0);
181 y2 += use_stduration->get_h() + 3;
182 StillImageDuration *stduration = new StillImageDuration(pwindow, x2, y2);
183 add_subwindow(stduration);
184 x2 += stduration->get_w() + 10;
186 add_subwindow(new BC_Title(x2, y2, _("Seconds")));
190 add_subwindow(new BC_Bar(5, y, get_w() - 10));
194 add_subwindow(new BC_Title(x, y, _("Index files:"), LARGEFONT, resources->text_default));
197 add_subwindow(new BC_Title(x, y + 5,
198 _("Index files go here:"), MEDIUMFONT, resources->text_default));
200 add_subwindow(ipathtext = new IndexPathText(x1, y, pwindow,
201 pwindow->thread->preferences->index_directory));
202 x1 += ipathtext->get_w();
203 add_subwindow(ipath = new BrowseButton(mwindow->theme, this, ipathtext, x1, y,
204 pwindow->thread->preferences->index_directory,
205 _("Index Path"), _("Select the directory for index files"), 1));
208 add_subwindow(new BC_Title(x, y + 5, _("Size of index file:"),
209 MEDIUMFONT, resources->text_default));
210 sprintf(string, "%jd", pwindow->thread->preferences->index_size);
211 add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
212 add_subwindow(new ScanCommercials(pwindow, 400,y));
215 add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"),
216 MEDIUMFONT, resources->text_default));
217 sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
218 add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
219 add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 400, y));
221 add_subwindow(ffmpeg_marker_files = new IndexFFMPEGMarkerFiles(this, x, y));
225 const char* InterfacePrefs::behavior_to_text(int mode)
228 case MOVE_ALL_EDITS: return _(MOVE_ALL_EDITS_TITLE);
229 case MOVE_ONE_EDIT: return _(MOVE_ONE_EDIT_TITLE);
230 case MOVE_NO_EDITS: return _(MOVE_NO_EDITS_TITLE);
231 case MOVE_EDITS_DISABLED: return _(MOVE_EDITS_DISABLED_TITLE);
236 IndexPathText::IndexPathText(int x, int y, PreferencesWindow *pwindow, char *text)
237 : BC_TextBox(x, y, 240, 1, text)
239 this->pwindow = pwindow;
242 IndexPathText::~IndexPathText() {}
244 int IndexPathText::handle_event()
246 strcpy(pwindow->thread->preferences->index_directory, get_text());
253 IndexSize::IndexSize(int x, int y, PreferencesWindow *pwindow, char *text)
254 : BC_TextBox(x, y, 100, 1, text)
256 this->pwindow = pwindow;
259 int IndexSize::handle_event()
263 result = atol(get_text());
264 if(result < 64000) result = 64000;
265 //if(result < 500000) result = 500000;
266 pwindow->thread->preferences->index_size = result;
272 IndexCount::IndexCount(int x, int y, PreferencesWindow *pwindow, char *text)
273 : BC_TextBox(x, y, 100, 1, text)
275 this->pwindow = pwindow;
278 int IndexCount::handle_event()
282 result = atol(get_text());
283 if(result < 1) result = 1;
284 pwindow->thread->preferences->index_count = result;
290 IndexFFMPEGMarkerFiles::IndexFFMPEGMarkerFiles(InterfacePrefs *iface_prefs, int x, int y)
292 iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes,
293 _("build ffmpeg marker indexes"))
295 this->iface_prefs = iface_prefs;
297 IndexFFMPEGMarkerFiles::~IndexFFMPEGMarkerFiles()
301 int IndexFFMPEGMarkerFiles::handle_event()
303 iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes = get_value();
308 ViewBehaviourText::ViewBehaviourText(int x, int y, const char *text, PreferencesWindow *pwindow,
310 : BC_PopupMenu(x, y, 200, text)
312 this->output = output;
315 ViewBehaviourText::~ViewBehaviourText()
319 int ViewBehaviourText::handle_event()
324 void ViewBehaviourText::create_objects()
326 add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
327 add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
328 add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
329 add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
333 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
337 this->behaviour = behaviour;
340 ViewBehaviourItem::~ViewBehaviourItem()
344 int ViewBehaviourItem::handle_event()
346 popup->set_text(get_text());
347 *(popup->output) = behaviour;
352 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
353 : BC_TextBox(x, y, 50, 1, text)
355 this->pwindow = pwindow;
358 int MeterMinDB::handle_event()
360 pwindow->thread->redraw_meters = 1;
361 pwindow->thread->edl->session->min_meter_db = atol(get_text());
366 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
367 : BC_TextBox(x, y, 50, 1, text)
369 this->pwindow = pwindow;
372 int MeterMaxDB::handle_event()
374 pwindow->thread->redraw_meters = 1;
375 pwindow->thread->edl->session->max_meter_db = atol(get_text());
380 ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y)
383 pwindow->thread->preferences->scan_commercials,
384 _("Scan for commercials during toc build"))
386 this->pwindow = pwindow;
388 int ScanCommercials::handle_event()
390 pwindow->thread->preferences->scan_commercials = get_value();
395 AndroidRemote::AndroidRemote(PreferencesWindow *pwindow, int x, int y)
397 pwindow->thread->preferences->android_remote,
398 _("Android Remote Control"))
400 this->pwindow = pwindow;
402 int AndroidRemote::handle_event()
404 pwindow->thread->preferences->android_remote = get_value();
408 AndroidPIN::AndroidPIN(PreferencesWindow *pwindow, int x, int y)
409 : BC_TextBox(x, y, 240, 1, pwindow->thread->preferences->android_pin)
411 this->pwindow = pwindow;
414 int AndroidPIN::handle_event()
416 char *txt = pwindow->thread->preferences->android_pin;
417 int len = sizeof(pwindow->thread->preferences->android_pin);
418 strncpy(txt, get_text(), len);
423 AndroidPort::AndroidPort(PreferencesWindow *pwindow, int x, int y)
424 : BC_TextBox(x, y, 72, 1, pwindow->thread->preferences->android_port)
426 this->pwindow = pwindow;
429 int AndroidPort::handle_event()
431 unsigned short port = atoi(get_text());
432 if( port < 1024 ) port = 1024;
433 pwindow->thread->preferences->android_port = port;
435 sprintf(str,"%u",port);
440 int InterfacePrefs::start_shbtn_dialog()
443 shbtn_dialog = new ShBtnEditDialog(pwindow);
444 shbtn_dialog->start();
448 ShBtnPrefs::ShBtnPrefs(PreferencesWindow *pwindow, InterfacePrefs *iface_prefs, int x, int y)
449 : BC_GenericButton(x, y, _("Shell Commands"))
451 this->pwindow = pwindow;
452 this->iface_prefs = iface_prefs;
453 set_tooltip(_("Main Menu Shell Commands"));
456 int ShBtnPrefs::handle_event()
458 return iface_prefs->start_shbtn_dialog();
462 StillImageUseDuration::StillImageUseDuration(PreferencesWindow *pwindow, int value, int x, int y)
463 : BC_CheckBox(x, y, value, _("Import images with a duration of"))
465 this->pwindow = pwindow;
468 int StillImageUseDuration::handle_event()
470 pwindow->thread->edl->session->si_useduration = get_value();
474 StillImageDuration::StillImageDuration(PreferencesWindow *pwindow, int x, int y)
475 : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->si_duration)
477 this->pwindow = pwindow;
479 int StillImageDuration::handle_event()
481 pwindow->thread->edl->session->si_duration = atof(get_text());
486 HairlineItem::HairlineItem(KeyframeReticle *popup, int hairline)
487 : BC_MenuItem(popup->hairline_to_string(hairline))
490 this->hairline = hairline;
493 HairlineItem::~HairlineItem()
497 int HairlineItem::handle_event()
499 popup->pwindow->thread->redraw_overlays = 1;
500 popup->set_text(get_text());
501 *(popup->output) = hairline;
506 KeyframeReticle::KeyframeReticle(PreferencesWindow *pwindow,
507 InterfacePrefs *iface_prefs, int x, int y, int *output)
508 : BC_PopupMenu(x, y, 220, hairline_to_string(*output))
510 this->pwindow = pwindow;
511 this->iface_prefs = iface_prefs;
512 this->output = output;
515 KeyframeReticle::~KeyframeReticle()
519 const char *KeyframeReticle::hairline_to_string(int type)
522 case HAIRLINE_NEVER: return _("Never");
523 case HAIRLINE_DRAGGING: return _("Dragging");
524 case HAIRLINE_ALWAYS: return _("Always");
529 void KeyframeReticle::create_objects()
531 add_item(new HairlineItem(this, HAIRLINE_NEVER));
532 add_item(new HairlineItem(this, HAIRLINE_DRAGGING));
533 add_item(new HairlineItem(this, HAIRLINE_ALWAYS));
536 PrefsTrapSigSEGV::PrefsTrapSigSEGV(InterfacePrefs *subwindow, int x, int y)
538 subwindow->pwindow->thread->preferences->trap_sigsegv,
541 this->subwindow = subwindow;
543 PrefsTrapSigSEGV::~PrefsTrapSigSEGV()
546 int PrefsTrapSigSEGV::handle_event()
548 subwindow->pwindow->thread->preferences->trap_sigsegv = get_value();
552 PrefsTrapSigINTR::PrefsTrapSigINTR(InterfacePrefs *subwindow, int x, int y)
554 subwindow->pwindow->thread->preferences->trap_sigintr,
557 this->subwindow = subwindow;
559 PrefsTrapSigINTR::~PrefsTrapSigINTR()
562 int PrefsTrapSigINTR::handle_event()
564 subwindow->pwindow->thread->preferences->trap_sigintr = get_value();
569 void InterfacePrefs::start_probe_dialog()
571 if( !file_probe_dialog )
572 file_probe_dialog = new FileProbeDialog(pwindow);
573 file_probe_dialog->start();
576 PrefsFileProbes::PrefsFileProbes(PreferencesWindow *pwindow,
577 InterfacePrefs *subwindow, int x, int y)
578 : BC_GenericButton(x, y, _("Probe Order"))
580 this->pwindow = pwindow;
581 this->subwindow = subwindow;
582 set_tooltip(_("File Open Probe Ordering"));
585 int PrefsFileProbes::handle_event()
587 subwindow->start_probe_dialog();
592 PrefsYUV420P_DVDlace::PrefsYUV420P_DVDlace(PreferencesWindow *pwindow,
593 InterfacePrefs *subwindow, int x, int y)
594 : BC_CheckBox(x, y, pwindow->thread->preferences->dvd_yuv420p_interlace,
595 _("Use yuv420p dvd interlace format"))
597 this->pwindow = pwindow;
598 this->subwindow = subwindow;
601 int PrefsYUV420P_DVDlace::handle_event()
603 pwindow->thread->preferences->dvd_yuv420p_interlace = get_value();