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:")));
84 keyframe_reticle = new KeyframeReticle(x, y, &pwindow->thread->preferences->keyframe_reticle);
85 add_subwindow(keyframe_reticle);
86 keyframe_reticle->create_objects();
89 add_subwindow(new BC_Title(x, y, _("Clicking on edit boundaries does what:")));
91 add_subwindow(new BC_Title(x, y, _("Button 1:")));
94 ViewBehaviourText *text;
95 add_subwindow(text = new ViewBehaviourText(x1, y - 5,
96 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]),
98 &(pwindow->thread->edl->session->edit_handle_mode[0])));
99 text->create_objects();
101 add_subwindow(new BC_Title(x, y, _("Button 2:")));
102 add_subwindow(text = new ViewBehaviourText(x1,
104 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]),
106 &(pwindow->thread->edl->session->edit_handle_mode[1])));
107 text->create_objects();
109 add_subwindow(new BC_Title(x, y, _("Button 3:")));
110 add_subwindow(text = new ViewBehaviourText(x1, y - 5,
111 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]),
113 &(pwindow->thread->edl->session->edit_handle_mode[2])));
114 text->create_objects();
115 y += text->get_h() + 30;
118 add_subwindow(new BC_Bar(5, y, get_w() - 10));
120 add_subwindow(new BC_Title(x, y, _("Operation:"), LARGEFONT,
121 resources->text_default));
125 AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y);
126 add_subwindow(android_remote);
127 y += android_remote->get_h() + 10;
128 add_subwindow(title = new BC_Title(x2, y, _("Port:")));
129 int x3 = x2 + title->get_w() + margin;
130 AndroidPort *android_port = new AndroidPort(pwindow, x3, y);
131 add_subwindow(android_port);
132 y += title->get_h() + 10;
133 add_subwindow(title = new BC_Title(x2, y, _("PIN:")));
134 AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y);
135 add_subwindow(android_pin);
136 y += title->get_h() + 30;
138 ShBtnPrefs *shbtn_prefs = new ShBtnPrefs(pwindow, this, x2, y);
139 add_subwindow(shbtn_prefs);
140 y += shbtn_prefs->get_h() + 30;
144 add_subwindow(file_probes = new PrefsFileProbes(pwindow, this, x, y));
147 PrefsTrapSigSEGV *trap_segv = new PrefsTrapSigSEGV(this, x, y);
148 add_subwindow(trap_segv);
149 x1 = x + trap_segv->get_w() + 10;
150 add_subwindow(new BC_Title(x1, y, _("(must be root)"), MEDIUMFONT, RED));
153 PrefsTrapSigINTR *trap_intr = new PrefsTrapSigINTR(this, x, y);
154 add_subwindow(trap_intr);
155 add_subwindow(new BC_Title(x1, y, _("(must be root)"), MEDIUMFONT, RED));
158 yuv420p_dvdlace = new PrefsYUV420P_DVDlace(pwindow, this, x, y);
159 add_subwindow(yuv420p_dvdlace);
163 add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
164 x += title->get_w() + 10;
165 sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
166 add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
167 x += min_db->get_w() + 10;
168 add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
169 x += title->get_w() + 10;
170 sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
171 add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
174 StillImageUseDuration *use_stduration = new StillImageUseDuration(pwindow,
175 pwindow->thread->edl->session->si_useduration, x2, y2);
176 add_subwindow(use_stduration);
178 BC_CheckBox::calculate_extents(this, &tw, &th, 0, 0);
180 y2 += use_stduration->get_h() + 3;
181 StillImageDuration *stduration = new StillImageDuration(pwindow, x2, y2);
182 add_subwindow(stduration);
183 x2 += stduration->get_w() + 10;
185 add_subwindow(new BC_Title(x2, y2, _("Seconds")));
189 add_subwindow(new BC_Bar(5, y, get_w() - 10));
193 add_subwindow(new BC_Title(x, y, _("Index files:"), LARGEFONT, resources->text_default));
196 add_subwindow(new BC_Title(x, y + 5,
197 _("Index files go here:"), MEDIUMFONT, resources->text_default));
199 add_subwindow(ipathtext = new IndexPathText(x1, y, pwindow,
200 pwindow->thread->preferences->index_directory));
201 x1 += ipathtext->get_w();
202 add_subwindow(ipath = new BrowseButton(mwindow->theme, this, ipathtext, x1, y,
203 pwindow->thread->preferences->index_directory,
204 _("Index Path"), _("Select the directory for index files"), 1));
207 add_subwindow(new BC_Title(x, y + 5, _("Size of index file:"),
208 MEDIUMFONT, resources->text_default));
209 sprintf(string, "%jd", pwindow->thread->preferences->index_size);
210 add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
211 add_subwindow(new ScanCommercials(pwindow, 400,y));
214 add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"),
215 MEDIUMFONT, resources->text_default));
216 sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
217 add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
218 add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 400, y));
220 add_subwindow(ffmpeg_marker_files = new IndexFFMPEGMarkerFiles(this, x, y));
224 const char* InterfacePrefs::behavior_to_text(int mode)
227 case MOVE_ALL_EDITS: return _(MOVE_ALL_EDITS_TITLE);
228 case MOVE_ONE_EDIT: return _(MOVE_ONE_EDIT_TITLE);
229 case MOVE_NO_EDITS: return _(MOVE_NO_EDITS_TITLE);
230 case MOVE_EDITS_DISABLED: return _(MOVE_EDITS_DISABLED_TITLE);
235 IndexPathText::IndexPathText(int x, int y, PreferencesWindow *pwindow, char *text)
236 : BC_TextBox(x, y, 240, 1, text)
238 this->pwindow = pwindow;
241 IndexPathText::~IndexPathText() {}
243 int IndexPathText::handle_event()
245 strcpy(pwindow->thread->preferences->index_directory, get_text());
252 IndexSize::IndexSize(int x, int y, PreferencesWindow *pwindow, char *text)
253 : BC_TextBox(x, y, 100, 1, text)
255 this->pwindow = pwindow;
258 int IndexSize::handle_event()
262 result = atol(get_text());
263 if(result < 64000) result = 64000;
264 //if(result < 500000) result = 500000;
265 pwindow->thread->preferences->index_size = result;
271 IndexCount::IndexCount(int x, int y, PreferencesWindow *pwindow, char *text)
272 : BC_TextBox(x, y, 100, 1, text)
274 this->pwindow = pwindow;
277 int IndexCount::handle_event()
281 result = atol(get_text());
282 if(result < 1) result = 1;
283 pwindow->thread->preferences->index_count = result;
289 IndexFFMPEGMarkerFiles::IndexFFMPEGMarkerFiles(InterfacePrefs *iface_prefs, int x, int y)
291 iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes,
292 _("build ffmpeg marker indexes"))
294 this->iface_prefs = iface_prefs;
296 IndexFFMPEGMarkerFiles::~IndexFFMPEGMarkerFiles()
300 int IndexFFMPEGMarkerFiles::handle_event()
302 iface_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes = get_value();
307 ViewBehaviourText::ViewBehaviourText(int x, int y, const char *text, PreferencesWindow *pwindow,
309 : BC_PopupMenu(x, y, 200, text)
311 this->output = output;
314 ViewBehaviourText::~ViewBehaviourText()
318 int ViewBehaviourText::handle_event()
323 void ViewBehaviourText::create_objects()
325 add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
326 add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
327 add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
328 add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
332 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
336 this->behaviour = behaviour;
339 ViewBehaviourItem::~ViewBehaviourItem()
343 int ViewBehaviourItem::handle_event()
345 popup->set_text(get_text());
346 *(popup->output) = behaviour;
351 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
352 : BC_TextBox(x, y, 50, 1, text)
354 this->pwindow = pwindow;
357 int MeterMinDB::handle_event()
359 pwindow->thread->redraw_meters = 1;
360 pwindow->thread->edl->session->min_meter_db = atol(get_text());
365 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
366 : BC_TextBox(x, y, 50, 1, text)
368 this->pwindow = pwindow;
371 int MeterMaxDB::handle_event()
373 pwindow->thread->redraw_meters = 1;
374 pwindow->thread->edl->session->max_meter_db = atol(get_text());
379 ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y)
382 pwindow->thread->preferences->scan_commercials,
383 _("Scan for commercials during toc build"))
385 this->pwindow = pwindow;
387 int ScanCommercials::handle_event()
389 pwindow->thread->preferences->scan_commercials = get_value();
394 AndroidRemote::AndroidRemote(PreferencesWindow *pwindow, int x, int y)
396 pwindow->thread->preferences->android_remote,
397 _("Android Remote Control"))
399 this->pwindow = pwindow;
401 int AndroidRemote::handle_event()
403 pwindow->thread->preferences->android_remote = get_value();
407 AndroidPIN::AndroidPIN(PreferencesWindow *pwindow, int x, int y)
408 : BC_TextBox(x, y, 240, 1, pwindow->thread->preferences->android_pin)
410 this->pwindow = pwindow;
413 int AndroidPIN::handle_event()
415 char *txt = pwindow->thread->preferences->android_pin;
416 int len = sizeof(pwindow->thread->preferences->android_pin);
417 strncpy(txt, get_text(), len);
422 AndroidPort::AndroidPort(PreferencesWindow *pwindow, int x, int y)
423 : BC_TextBox(x, y, 72, 1, pwindow->thread->preferences->android_port)
425 this->pwindow = pwindow;
428 int AndroidPort::handle_event()
430 unsigned short port = atoi(get_text());
431 if( port < 1024 ) port = 1024;
432 pwindow->thread->preferences->android_port = port;
434 sprintf(str,"%u",port);
439 int InterfacePrefs::start_shbtn_dialog()
442 shbtn_dialog = new ShBtnEditDialog(pwindow);
443 shbtn_dialog->start();
447 ShBtnPrefs::ShBtnPrefs(PreferencesWindow *pwindow, InterfacePrefs *iface_prefs, int x, int y)
448 : BC_GenericButton(x, y, _("Shell Commands"))
450 this->pwindow = pwindow;
451 this->iface_prefs = iface_prefs;
452 set_tooltip(_("Main Menu Shell Commands"));
455 int ShBtnPrefs::handle_event()
457 return iface_prefs->start_shbtn_dialog();
461 StillImageUseDuration::StillImageUseDuration(PreferencesWindow *pwindow, int value, int x, int y)
462 : BC_CheckBox(x, y, value, _("Import images with a duration of"))
464 this->pwindow = pwindow;
467 int StillImageUseDuration::handle_event()
469 pwindow->thread->edl->session->si_useduration = get_value();
473 StillImageDuration::StillImageDuration(PreferencesWindow *pwindow, int x, int y)
474 : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->si_duration)
476 this->pwindow = pwindow;
478 int StillImageDuration::handle_event()
480 pwindow->thread->edl->session->si_duration = atof(get_text());
485 HairlineItem::HairlineItem(KeyframeReticle *popup, int hairline)
486 : BC_MenuItem(popup->hairline_to_string(hairline))
489 this->hairline = hairline;
492 HairlineItem::~HairlineItem()
496 int HairlineItem::handle_event()
498 popup->set_text(get_text());
499 *(popup->output) = hairline;
504 KeyframeReticle::KeyframeReticle(int x, int y, int *output)
505 : BC_PopupMenu(x, y, 175, hairline_to_string(*output))
507 this->output = output;
510 KeyframeReticle::~KeyframeReticle()
514 const char *KeyframeReticle::hairline_to_string(int type)
517 case HAIRLINE_NEVER: return _("Never");
518 case HAIRLINE_DRAGGING: return _("Dragging");
519 case HAIRLINE_ALWAYS: return _("Always");
524 void KeyframeReticle::create_objects()
526 add_item(new HairlineItem(this, HAIRLINE_NEVER));
527 add_item(new HairlineItem(this, HAIRLINE_DRAGGING));
528 add_item(new HairlineItem(this, HAIRLINE_ALWAYS));
531 PrefsTrapSigSEGV::PrefsTrapSigSEGV(InterfacePrefs *subwindow, int x, int y)
533 subwindow->pwindow->thread->preferences->trap_sigsegv,
536 this->subwindow = subwindow;
538 PrefsTrapSigSEGV::~PrefsTrapSigSEGV()
541 int PrefsTrapSigSEGV::handle_event()
543 subwindow->pwindow->thread->preferences->trap_sigsegv = get_value();
547 PrefsTrapSigINTR::PrefsTrapSigINTR(InterfacePrefs *subwindow, int x, int y)
549 subwindow->pwindow->thread->preferences->trap_sigintr,
552 this->subwindow = subwindow;
554 PrefsTrapSigINTR::~PrefsTrapSigINTR()
557 int PrefsTrapSigINTR::handle_event()
559 subwindow->pwindow->thread->preferences->trap_sigintr = get_value();
564 void InterfacePrefs::start_probe_dialog()
566 if( !file_probe_dialog )
567 file_probe_dialog = new FileProbeDialog(pwindow);
568 file_probe_dialog->start();
571 PrefsFileProbes::PrefsFileProbes(PreferencesWindow *pwindow,
572 InterfacePrefs *subwindow, int x, int y)
573 : BC_GenericButton(x, y, _("Probe Order"))
575 this->pwindow = pwindow;
576 this->subwindow = subwindow;
577 set_tooltip(_("File Open Probe Ordering"));
580 int PrefsFileProbes::handle_event()
582 subwindow->start_probe_dialog();
587 PrefsYUV420P_DVDlace::PrefsYUV420P_DVDlace(PreferencesWindow *pwindow,
588 InterfacePrefs *subwindow, int x, int y)
589 : BC_CheckBox(x, y, pwindow->thread->preferences->dvd_yuv420p_interlace,
590 _("Use yuv420p dvd interlace format"))
592 this->pwindow = pwindow;
593 this->subwindow = subwindow;
596 int PrefsYUV420P_DVDlace::handle_event()
598 pwindow->thread->preferences->dvd_yuv420p_interlace = get_value();