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"
28 #include "preferences.h"
29 #include "preferencesthread.h"
30 #include "interfaceprefs.h"
31 #include "shbtnprefs.h"
35 N_("Drag all following edits")
36 N_("Drag only one edit")
37 N_("Drag source only")
41 #define MOVE_ALL_EDITS_TITLE "Drag all following edits"
42 #define MOVE_ONE_EDIT_TITLE "Drag only one edit"
43 #define MOVE_NO_EDITS_TITLE "Drag source only"
44 #define MOVE_EDITS_DISABLED_TITLE "No effect"
46 InterfacePrefs::InterfacePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
47 : PreferencesDialog(mwindow, pwindow)
63 InterfacePrefs::~InterfacePrefs()
80 void InterfacePrefs::create_objects()
83 BC_Resources *resources = BC_WindowBase::get_resources();
84 int margin = mwindow->theme->widget_border;
85 char string[BCTEXTLEN];
86 x = mwindow->theme->preferencesoptions_x;
87 y = mwindow->theme->preferencesoptions_y;
89 add_subwindow(new BC_Title(x, y,
92 resources->text_default));
94 y += get_text_height(LARGEFONT) + 5;
97 add_subwindow(hms = new TimeFormatHMS(pwindow, this,
98 pwindow->thread->edl->session->time_format == TIME_HMS,
101 add_subwindow(hmsf = new TimeFormatHMSF(pwindow, this,
102 pwindow->thread->edl->session->time_format == TIME_HMSF,
105 add_subwindow(samples = new TimeFormatSamples(pwindow, this,
106 pwindow->thread->edl->session->time_format == TIME_SAMPLES,
109 add_subwindow(hex = new TimeFormatHex(pwindow, this,
110 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX,
113 add_subwindow(frames = new TimeFormatFrames(pwindow, this,
114 pwindow->thread->edl->session->time_format == TIME_FRAMES,
118 add_subwindow(feet = new TimeFormatFeet(pwindow, this,
119 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES,
121 x1 += feet->get_w() + margin;
123 add_subwindow(title = new BC_Title(x1, y, _("Frames per foot:")));
124 x1 += title->get_w() + margin;
125 sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
126 add_subwindow(new TimeFormatFeetSetting(pwindow,
129 add_subwindow(seconds = new TimeFormatSeconds(pwindow, this,
130 pwindow->thread->edl->session->time_format == TIME_SECONDS,
134 add_subwindow(new UseTipWindow(pwindow, x, y));
135 add_subwindow(new UseWarnIndecies(pwindow, x+200, y));
138 add_subwindow(new BC_Bar(5, y, get_w() - 10));
141 add_subwindow(new BC_Title(x, y, _("Index files"), LARGEFONT, resources->text_default));
145 add_subwindow(new BC_Title(x, y + 5,
146 _("Index files go here:"), MEDIUMFONT, resources->text_default));
147 add_subwindow(ipathtext = new IndexPathText(x + 230, y,
149 pwindow->thread->preferences->index_directory));
150 add_subwindow(ipath = new BrowseButton(mwindow, this,
152 x + 230 + ipathtext->get_w(), y,
153 pwindow->thread->preferences->index_directory,
155 _("Select the directory for index files"),
159 add_subwindow(new BC_Title(x, y + 5,
160 _("Size of index file:"),
162 resources->text_default));
163 sprintf(string, "" _LD "", pwindow->thread->preferences->index_size);
165 add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
166 add_subwindow(new ScanCommercials(pwindow, 350,y));
168 add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"), MEDIUMFONT, resources->text_default));
169 sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
170 add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
171 add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 350, y));
178 add_subwindow(new BC_Bar(5, y, get_w() - 10));
181 add_subwindow(new BC_Title(x, y, _("Editing"), LARGEFONT, resources->text_default));
185 add_subwindow(thumbnails = new ViewThumbnails(x, y, pwindow));
187 int x2 = x + 400, y2 = y;
188 AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y2);
189 add_subwindow(android_remote);
190 y2 += android_remote->get_h() + 10;
191 add_subwindow(title = new BC_Title(x2, y2, _("Port:")));
192 int x3 = x2 + title->get_w() + margin;
193 AndroidPort *android_port = new AndroidPort(pwindow, x3, y2);
194 add_subwindow(android_port);
195 y2 += title->get_h() + 10;
196 add_subwindow(title = new BC_Title(x2, y2, _("PIN:")));
197 AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y2);
198 add_subwindow(android_pin);
200 y2 += title->get_h() + 30;
201 add_subwindow(new ShBtnPrefs(pwindow, this, x2, y2));
204 add_subwindow(new BC_Title(x, y, _("Clicking on edit boundaries does what:")));
206 add_subwindow(new BC_Title(x, y, _("Button 1:")));
208 ViewBehaviourText *text;
209 add_subwindow(text = new ViewBehaviourText(80, y - 5,
210 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]),
212 &(pwindow->thread->edl->session->edit_handle_mode[0])));
213 text->create_objects();
215 add_subwindow(new BC_Title(x, y, _("Button 2:")));
216 add_subwindow(text = new ViewBehaviourText(80,
218 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]),
220 &(pwindow->thread->edl->session->edit_handle_mode[1])));
221 text->create_objects();
223 add_subwindow(new BC_Title(x, y, _("Button 3:")));
224 add_subwindow(text = new ViewBehaviourText(80,
226 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]),
228 &(pwindow->thread->edl->session->edit_handle_mode[2])));
229 text->create_objects();
233 add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
234 x += title->get_w() + 10;
235 sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
236 add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
238 x += min_db->get_w() + 10;
239 add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
240 x += title->get_w() + 10;
241 sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
242 add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
247 add_subwindow(new BC_Title(x, y, _("Theme:")));
249 add_subwindow(theme = new ViewTheme(x, y, pwindow));
250 theme->create_objects();
254 const char* InterfacePrefs::behavior_to_text(int mode)
259 return _(MOVE_ALL_EDITS_TITLE);
262 return _(MOVE_ONE_EDIT_TITLE);
265 return _(MOVE_NO_EDITS_TITLE);
267 case MOVE_EDITS_DISABLED:
268 return _(MOVE_EDITS_DISABLED_TITLE);
276 int InterfacePrefs::update(int new_value)
278 pwindow->thread->redraw_times = 1;
279 pwindow->thread->edl->session->time_format = new_value;
280 hms->update(new_value == TIME_HMS);
281 hmsf->update(new_value == TIME_HMSF);
282 samples->update(new_value == TIME_SAMPLES);
283 hex->update(new_value == TIME_SAMPLES_HEX);
284 frames->update(new_value == TIME_FRAMES);
285 feet->update(new_value == TIME_FEET_FRAMES);
286 seconds->update(new_value == TIME_SECONDS);
304 IndexPathText::IndexPathText(int x,
306 PreferencesWindow *pwindow,
308 : BC_TextBox(x, y, 240, 1, text)
310 this->pwindow = pwindow;
313 IndexPathText::~IndexPathText() {}
315 int IndexPathText::handle_event()
317 strcpy(pwindow->thread->preferences->index_directory, get_text());
324 IndexSize::IndexSize(int x,
326 PreferencesWindow *pwindow,
328 : BC_TextBox(x, y, 100, 1, text)
330 this->pwindow = pwindow;
333 int IndexSize::handle_event()
337 result = atol(get_text());
338 if(result < 64000) result = 64000;
339 //if(result < 500000) result = 500000;
340 pwindow->thread->preferences->index_size = result;
346 IndexCount::IndexCount(int x,
348 PreferencesWindow *pwindow,
350 : BC_TextBox(x, y, 100, 1, text)
352 this->pwindow = pwindow;
355 int IndexCount::handle_event()
359 result = atol(get_text());
360 if(result < 1) result = 1;
361 pwindow->thread->preferences->index_count = result;
379 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
380 : BC_Radial(x, y, value, TIME_HMS_TEXT)
381 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
383 int TimeFormatHMS::handle_event()
385 tfwindow->update(TIME_HMS);
389 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
390 : BC_Radial(x, y, value, TIME_HMSF_TEXT)
391 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
393 int TimeFormatHMSF::handle_event()
395 tfwindow->update(TIME_HMSF);
399 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
400 : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
401 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
403 int TimeFormatSamples::handle_event()
405 tfwindow->update(TIME_SAMPLES);
409 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
410 : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
411 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
413 int TimeFormatFrames::handle_event()
415 tfwindow->update(TIME_FRAMES);
419 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
420 : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
421 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
423 int TimeFormatHex::handle_event()
425 tfwindow->update(TIME_SAMPLES_HEX);
429 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
430 : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
432 this->pwindow = pwindow;
433 this->tfwindow = tfwindow;
436 int TimeFormatSeconds::handle_event()
438 tfwindow->update(TIME_SECONDS);
442 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
443 : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
444 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
446 int TimeFormatFeet::handle_event()
448 tfwindow->update(TIME_FEET_FRAMES);
452 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
453 : BC_TextBox(x, y, 90, 1, string)
454 { this->pwindow = pwindow; }
456 int TimeFormatFeetSetting::handle_event()
458 pwindow->thread->edl->session->frames_per_foot = atof(get_text());
459 if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
466 ViewBehaviourText::ViewBehaviourText(int x,
469 PreferencesWindow *pwindow,
471 : BC_PopupMenu(x, y, 200, text)
473 this->output = output;
476 ViewBehaviourText::~ViewBehaviourText()
480 int ViewBehaviourText::handle_event()
485 void ViewBehaviourText::create_objects()
487 // Video4linux versions are automatically detected
488 add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
489 add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
490 add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
491 add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
495 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
499 this->behaviour = behaviour;
502 ViewBehaviourItem::~ViewBehaviourItem()
506 int ViewBehaviourItem::handle_event()
508 popup->set_text(get_text());
509 *(popup->output) = behaviour;
516 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
517 : BC_TextBox(x, y, 50, 1, text)
519 this->pwindow = pwindow;
522 int MeterMinDB::handle_event()
524 pwindow->thread->redraw_meters = 1;
525 pwindow->thread->edl->session->min_meter_db = atol(get_text());
532 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
533 : BC_TextBox(x, y, 50, 1, text)
535 this->pwindow = pwindow;
538 int MeterMaxDB::handle_event()
540 pwindow->thread->redraw_meters = 1;
541 pwindow->thread->edl->session->max_meter_db = atol(get_text());
549 MeterVUDB::MeterVUDB(PreferencesWindow *pwindow, char *text, int y)
550 : BC_Radial(145, y, pwindow->thread->edl->session->meter_format == METER_DB, text)
552 this->pwindow = pwindow;
555 int MeterVUDB::handle_event()
557 pwindow->thread->redraw_meters = 1;
558 // vu_int->update(0);
559 pwindow->thread->edl->session->meter_format = METER_DB;
563 MeterVUInt::MeterVUInt(PreferencesWindow *pwindow, char *text, int y)
564 : BC_Radial(205, y, pwindow->thread->edl->session->meter_format == METER_INT, text)
566 this->pwindow = pwindow;
569 int MeterVUInt::handle_event()
571 pwindow->thread->redraw_meters = 1;
573 pwindow->thread->edl->session->meter_format = METER_INT;
580 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
581 : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
583 this->pwindow = pwindow;
585 ViewTheme::~ViewTheme()
589 void ViewTheme::create_objects()
591 ArrayList<PluginServer*> themes;
592 MWindow::search_plugindb(0,
599 for(int i = 0; i < themes.total; i++)
601 add_item(new ViewThemeItem(this, themes.values[i]->title));
605 int ViewTheme::handle_event()
614 ViewThemeItem::ViewThemeItem(ViewTheme *popup, char *text)
620 int ViewThemeItem::handle_event()
622 popup->set_text(get_text());
623 strcpy(popup->pwindow->thread->preferences->theme, get_text());
624 popup->handle_event();
628 ViewThumbnails::ViewThumbnails(int x,
630 PreferencesWindow *pwindow)
633 pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
635 this->pwindow = pwindow;
638 int ViewThumbnails::handle_event()
640 pwindow->thread->preferences->use_thumbnails = get_value();
646 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
649 pwindow->thread->preferences->use_tipwindow,
650 _("Show tip of the day"))
652 this->pwindow = pwindow;
654 int UseTipWindow::handle_event()
656 pwindow->thread->preferences->use_tipwindow = get_value();
661 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
664 pwindow->thread->preferences->warn_indecies,
665 _("ffmpeg probe warns rebuild indecies"))
667 this->pwindow = pwindow;
670 int UseWarnIndecies::handle_event()
672 pwindow->thread->preferences->warn_indecies = get_value();
679 ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y)
682 pwindow->thread->preferences->scan_commercials,
683 _("Scan for commercials during toc build"))
685 this->pwindow = pwindow;
687 int ScanCommercials::handle_event()
689 pwindow->thread->preferences->scan_commercials = get_value();
694 AndroidRemote::AndroidRemote(PreferencesWindow *pwindow, int x, int y)
696 pwindow->thread->preferences->android_remote,
697 _("Android Remote Control"))
699 this->pwindow = pwindow;
701 int AndroidRemote::handle_event()
703 pwindow->thread->preferences->android_remote = get_value();
707 AndroidPIN::AndroidPIN(PreferencesWindow *pwindow, int x, int y)
708 : BC_TextBox(x, y, 240, 1, pwindow->thread->preferences->android_pin)
710 this->pwindow = pwindow;
713 int AndroidPIN::handle_event()
715 char *txt = pwindow->thread->preferences->android_pin;
716 int len = sizeof(pwindow->thread->preferences->android_pin);
717 strncpy(txt, get_text(), len);
722 AndroidPort::AndroidPort(PreferencesWindow *pwindow, int x, int y)
723 : BC_TextBox(x, y, 72, 1, pwindow->thread->preferences->android_port)
725 this->pwindow = pwindow;
728 int AndroidPort::handle_event()
730 unsigned short port = atoi(get_text());
731 if( port < 1024 ) port = 1024;
732 pwindow->thread->preferences->android_port = port;
734 sprintf(str,"%u",port);
739 int InterfacePrefs::start_shbtn_dialog()
742 shbtn_dialog = new ShBtnEditDialog(pwindow);
743 shbtn_dialog->start();
747 ShBtnPrefs::ShBtnPrefs(PreferencesWindow *pwindow, InterfacePrefs *iface_prefs, int x, int y)
748 : BC_GenericButton(x, y, _("Shell Commands"))
750 this->pwindow = pwindow;
751 this->iface_prefs = iface_prefs;
752 set_tooltip(_("Main Menu Shell Commands"));
755 int ShBtnPrefs::handle_event()
757 return iface_prefs->start_shbtn_dialog();