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"
27 #include "preferences.h"
28 #include "preferencesthread.h"
29 #include "interfaceprefs.h"
30 #include "shbtnprefs.h"
34 N_("Drag all following edits")
35 N_("Drag only one edit")
36 N_("Drag source only")
40 #define MOVE_ALL_EDITS_TITLE "Drag all following edits"
41 #define MOVE_ONE_EDIT_TITLE "Drag only one edit"
42 #define MOVE_NO_EDITS_TITLE "Drag source only"
43 #define MOVE_EDITS_DISABLED_TITLE "No effect"
45 InterfacePrefs::InterfacePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
46 : PreferencesDialog(mwindow, pwindow)
62 InterfacePrefs::~InterfacePrefs()
79 void InterfacePrefs::create_objects()
82 BC_Resources *resources = BC_WindowBase::get_resources();
83 int margin = mwindow->theme->widget_border;
84 char string[BCTEXTLEN];
85 x = mwindow->theme->preferencesoptions_x;
86 y = mwindow->theme->preferencesoptions_y;
88 add_subwindow(new BC_Title(x, y,
91 resources->text_default));
93 y += get_text_height(LARGEFONT) + 5;
96 add_subwindow(hms = new TimeFormatHMS(pwindow, this,
97 pwindow->thread->edl->session->time_format == TIME_HMS,
100 add_subwindow(hmsf = new TimeFormatHMSF(pwindow, this,
101 pwindow->thread->edl->session->time_format == TIME_HMSF,
104 add_subwindow(samples = new TimeFormatSamples(pwindow, this,
105 pwindow->thread->edl->session->time_format == TIME_SAMPLES,
108 add_subwindow(hex = new TimeFormatHex(pwindow, this,
109 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX,
112 add_subwindow(frames = new TimeFormatFrames(pwindow, this,
113 pwindow->thread->edl->session->time_format == TIME_FRAMES,
117 add_subwindow(feet = new TimeFormatFeet(pwindow, this,
118 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES,
120 x1 += feet->get_w() + margin;
122 add_subwindow(title = new BC_Title(x1, y, _("Frames per foot:")));
123 x1 += title->get_w() + margin;
124 sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
125 add_subwindow(new TimeFormatFeetSetting(pwindow,
128 add_subwindow(seconds = new TimeFormatSeconds(pwindow, this,
129 pwindow->thread->edl->session->time_format == TIME_SECONDS,
133 add_subwindow(new UseTipWindow(pwindow, x, y));
134 add_subwindow(new UseWarnIndecies(pwindow, x+200, y));
137 add_subwindow(new BC_Bar(5, y, get_w() - 10));
140 add_subwindow(new BC_Title(x, y, _("Index files"), LARGEFONT, resources->text_default));
144 add_subwindow(new BC_Title(x, y + 5,
145 _("Index files go here:"), MEDIUMFONT, resources->text_default));
146 add_subwindow(ipathtext = new IndexPathText(x + 230, y,
148 pwindow->thread->preferences->index_directory));
149 add_subwindow(ipath = new BrowseButton(mwindow, this,
151 x + 230 + ipathtext->get_w(), y,
152 pwindow->thread->preferences->index_directory,
154 _("Select the directory for index files"),
158 add_subwindow(new BC_Title(x, y + 5,
159 _("Size of index file:"),
161 resources->text_default));
162 sprintf(string, "%jd", pwindow->thread->preferences->index_size);
164 add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
165 add_subwindow(new ScanCommercials(pwindow, 350,y));
167 add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"), MEDIUMFONT, resources->text_default));
168 sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
169 add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
170 add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 350, y));
177 add_subwindow(new BC_Bar(5, y, get_w() - 10));
180 add_subwindow(new BC_Title(x, y, _("Editing"), LARGEFONT, resources->text_default));
184 add_subwindow(thumbnails = new ViewThumbnails(x, y, pwindow));
186 int x2 = x + 400, y2 = y;
187 AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y2);
188 add_subwindow(android_remote);
189 y2 += android_remote->get_h() + 10;
190 add_subwindow(title = new BC_Title(x2, y2, _("Port:")));
191 int x3 = x2 + title->get_w() + margin;
192 AndroidPort *android_port = new AndroidPort(pwindow, x3, y2);
193 add_subwindow(android_port);
194 y2 += title->get_h() + 10;
195 add_subwindow(title = new BC_Title(x2, y2, _("PIN:")));
196 AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y2);
197 add_subwindow(android_pin);
199 y2 += title->get_h() + 30;
200 ShBtnPrefs *shbtn_prefs = new ShBtnPrefs(pwindow, this, x2, y2);
201 add_subwindow(shbtn_prefs);
203 y2 += shbtn_prefs->get_h() + 30;
204 StillImageUseDuration *use_stduration = new StillImageUseDuration(pwindow,
205 pwindow->thread->edl->session->si_useduration, x2, y2);
206 add_subwindow(use_stduration);
208 BC_CheckBox::calculate_extents(this, &tw, &th, 0, 0);
210 y2 += use_stduration->get_h() + 3;
211 StillImageDuration *stduration = new StillImageDuration(pwindow, x2, y2);
212 add_subwindow(stduration);
213 x2 += stduration->get_w() + 10;
215 add_subwindow(new BC_Title(x2, y2, _("Seconds")));
218 add_subwindow(new BC_Title(x, y, _("Clicking on edit boundaries does what:")));
220 add_subwindow(new BC_Title(x, y, _("Button 1:")));
222 ViewBehaviourText *text;
223 add_subwindow(text = new ViewBehaviourText(80, y - 5,
224 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]),
226 &(pwindow->thread->edl->session->edit_handle_mode[0])));
227 text->create_objects();
229 add_subwindow(new BC_Title(x, y, _("Button 2:")));
230 add_subwindow(text = new ViewBehaviourText(80,
232 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]),
234 &(pwindow->thread->edl->session->edit_handle_mode[1])));
235 text->create_objects();
237 add_subwindow(new BC_Title(x, y, _("Button 3:")));
238 add_subwindow(text = new ViewBehaviourText(80,
240 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]),
242 &(pwindow->thread->edl->session->edit_handle_mode[2])));
243 text->create_objects();
247 add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
248 x += title->get_w() + 10;
249 sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
250 add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
252 x += min_db->get_w() + 10;
253 add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
254 x += title->get_w() + 10;
255 sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
256 add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
261 add_subwindow(new BC_Title(x, y, _("Theme:")));
263 add_subwindow(theme = new ViewTheme(x, y, pwindow));
264 theme->create_objects();
268 const char* InterfacePrefs::behavior_to_text(int mode)
273 return _(MOVE_ALL_EDITS_TITLE);
276 return _(MOVE_ONE_EDIT_TITLE);
279 return _(MOVE_NO_EDITS_TITLE);
281 case MOVE_EDITS_DISABLED:
282 return _(MOVE_EDITS_DISABLED_TITLE);
290 int InterfacePrefs::update(int new_value)
292 pwindow->thread->redraw_times = 1;
293 pwindow->thread->edl->session->time_format = new_value;
294 hms->update(new_value == TIME_HMS);
295 hmsf->update(new_value == TIME_HMSF);
296 samples->update(new_value == TIME_SAMPLES);
297 hex->update(new_value == TIME_SAMPLES_HEX);
298 frames->update(new_value == TIME_FRAMES);
299 feet->update(new_value == TIME_FEET_FRAMES);
300 seconds->update(new_value == TIME_SECONDS);
318 IndexPathText::IndexPathText(int x,
320 PreferencesWindow *pwindow,
322 : BC_TextBox(x, y, 240, 1, text)
324 this->pwindow = pwindow;
327 IndexPathText::~IndexPathText() {}
329 int IndexPathText::handle_event()
331 strcpy(pwindow->thread->preferences->index_directory, get_text());
338 IndexSize::IndexSize(int x,
340 PreferencesWindow *pwindow,
342 : BC_TextBox(x, y, 100, 1, text)
344 this->pwindow = pwindow;
347 int IndexSize::handle_event()
351 result = atol(get_text());
352 if(result < 64000) result = 64000;
353 //if(result < 500000) result = 500000;
354 pwindow->thread->preferences->index_size = result;
360 IndexCount::IndexCount(int x,
362 PreferencesWindow *pwindow,
364 : BC_TextBox(x, y, 100, 1, text)
366 this->pwindow = pwindow;
369 int IndexCount::handle_event()
373 result = atol(get_text());
374 if(result < 1) result = 1;
375 pwindow->thread->preferences->index_count = result;
393 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
394 : BC_Radial(x, y, value, TIME_HMS_TEXT)
395 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
397 int TimeFormatHMS::handle_event()
399 tfwindow->update(TIME_HMS);
403 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
404 : BC_Radial(x, y, value, TIME_HMSF_TEXT)
405 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
407 int TimeFormatHMSF::handle_event()
409 tfwindow->update(TIME_HMSF);
413 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
414 : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
415 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
417 int TimeFormatSamples::handle_event()
419 tfwindow->update(TIME_SAMPLES);
423 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
424 : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
425 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
427 int TimeFormatFrames::handle_event()
429 tfwindow->update(TIME_FRAMES);
433 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
434 : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
435 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
437 int TimeFormatHex::handle_event()
439 tfwindow->update(TIME_SAMPLES_HEX);
443 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
444 : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
446 this->pwindow = pwindow;
447 this->tfwindow = tfwindow;
450 int TimeFormatSeconds::handle_event()
452 tfwindow->update(TIME_SECONDS);
456 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
457 : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
458 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
460 int TimeFormatFeet::handle_event()
462 tfwindow->update(TIME_FEET_FRAMES);
466 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
467 : BC_TextBox(x, y, 90, 1, string)
468 { this->pwindow = pwindow; }
470 int TimeFormatFeetSetting::handle_event()
472 pwindow->thread->edl->session->frames_per_foot = atof(get_text());
473 if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
480 ViewBehaviourText::ViewBehaviourText(int x,
483 PreferencesWindow *pwindow,
485 : BC_PopupMenu(x, y, 200, text)
487 this->output = output;
490 ViewBehaviourText::~ViewBehaviourText()
494 int ViewBehaviourText::handle_event()
499 void ViewBehaviourText::create_objects()
501 // Video4linux versions are automatically detected
502 add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
503 add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
504 add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
505 add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
509 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
513 this->behaviour = behaviour;
516 ViewBehaviourItem::~ViewBehaviourItem()
520 int ViewBehaviourItem::handle_event()
522 popup->set_text(get_text());
523 *(popup->output) = behaviour;
530 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
531 : BC_TextBox(x, y, 50, 1, text)
533 this->pwindow = pwindow;
536 int MeterMinDB::handle_event()
538 pwindow->thread->redraw_meters = 1;
539 pwindow->thread->edl->session->min_meter_db = atol(get_text());
546 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
547 : BC_TextBox(x, y, 50, 1, text)
549 this->pwindow = pwindow;
552 int MeterMaxDB::handle_event()
554 pwindow->thread->redraw_meters = 1;
555 pwindow->thread->edl->session->max_meter_db = atol(get_text());
563 MeterVUDB::MeterVUDB(PreferencesWindow *pwindow, char *text, int y)
564 : BC_Radial(145, y, pwindow->thread->edl->session->meter_format == METER_DB, text)
566 this->pwindow = pwindow;
569 int MeterVUDB::handle_event()
571 pwindow->thread->redraw_meters = 1;
572 // vu_int->update(0);
573 pwindow->thread->edl->session->meter_format = METER_DB;
577 MeterVUInt::MeterVUInt(PreferencesWindow *pwindow, char *text, int y)
578 : BC_Radial(205, y, pwindow->thread->edl->session->meter_format == METER_INT, text)
580 this->pwindow = pwindow;
583 int MeterVUInt::handle_event()
585 pwindow->thread->redraw_meters = 1;
587 pwindow->thread->edl->session->meter_format = METER_INT;
594 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
595 : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
597 this->pwindow = pwindow;
599 ViewTheme::~ViewTheme()
603 void ViewTheme::create_objects()
605 ArrayList<PluginServer*> themes;
606 MWindow::search_plugindb(0,
613 for(int i = 0; i < themes.total; i++)
615 add_item(new ViewThemeItem(this, themes.values[i]->title));
619 int ViewTheme::handle_event()
628 ViewThemeItem::ViewThemeItem(ViewTheme *popup, char *text)
634 int ViewThemeItem::handle_event()
636 popup->set_text(get_text());
637 strcpy(popup->pwindow->thread->preferences->theme, get_text());
638 popup->handle_event();
642 ViewThumbnails::ViewThumbnails(int x,
644 PreferencesWindow *pwindow)
647 pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
649 this->pwindow = pwindow;
652 int ViewThumbnails::handle_event()
654 pwindow->thread->preferences->use_thumbnails = get_value();
660 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
663 pwindow->thread->preferences->use_tipwindow,
664 _("Show tip of the day"))
666 this->pwindow = pwindow;
668 int UseTipWindow::handle_event()
670 pwindow->thread->preferences->use_tipwindow = get_value();
675 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
678 pwindow->thread->preferences->warn_indexes,
679 _("ffmpeg probe warns rebuild indexes"))
681 this->pwindow = pwindow;
684 int UseWarnIndecies::handle_event()
686 pwindow->thread->preferences->warn_indexes = get_value();
693 ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y)
696 pwindow->thread->preferences->scan_commercials,
697 _("Scan for commercials during toc build"))
699 this->pwindow = pwindow;
701 int ScanCommercials::handle_event()
703 pwindow->thread->preferences->scan_commercials = get_value();
708 AndroidRemote::AndroidRemote(PreferencesWindow *pwindow, int x, int y)
710 pwindow->thread->preferences->android_remote,
711 _("Android Remote Control"))
713 this->pwindow = pwindow;
715 int AndroidRemote::handle_event()
717 pwindow->thread->preferences->android_remote = get_value();
721 AndroidPIN::AndroidPIN(PreferencesWindow *pwindow, int x, int y)
722 : BC_TextBox(x, y, 240, 1, pwindow->thread->preferences->android_pin)
724 this->pwindow = pwindow;
727 int AndroidPIN::handle_event()
729 char *txt = pwindow->thread->preferences->android_pin;
730 int len = sizeof(pwindow->thread->preferences->android_pin);
731 strncpy(txt, get_text(), len);
736 AndroidPort::AndroidPort(PreferencesWindow *pwindow, int x, int y)
737 : BC_TextBox(x, y, 72, 1, pwindow->thread->preferences->android_port)
739 this->pwindow = pwindow;
742 int AndroidPort::handle_event()
744 unsigned short port = atoi(get_text());
745 if( port < 1024 ) port = 1024;
746 pwindow->thread->preferences->android_port = port;
748 sprintf(str,"%u",port);
753 int InterfacePrefs::start_shbtn_dialog()
756 shbtn_dialog = new ShBtnEditDialog(pwindow);
757 shbtn_dialog->start();
761 ShBtnPrefs::ShBtnPrefs(PreferencesWindow *pwindow, InterfacePrefs *iface_prefs, int x, int y)
762 : BC_GenericButton(x, y, _("Shell Commands"))
764 this->pwindow = pwindow;
765 this->iface_prefs = iface_prefs;
766 set_tooltip(_("Main Menu Shell Commands"));
769 int ShBtnPrefs::handle_event()
771 return iface_prefs->start_shbtn_dialog();
775 StillImageUseDuration::StillImageUseDuration(PreferencesWindow *pwindow, int value, int x, int y)
776 : BC_CheckBox(x, y, value, _("Import images with a duration of"))
778 this->pwindow = pwindow;
781 int StillImageUseDuration::handle_event()
783 pwindow->thread->edl->session->si_useduration = get_value();
787 StillImageDuration::StillImageDuration(PreferencesWindow *pwindow, int x, int y)
788 : BC_TextBox(x, y, 70, 1, pwindow->thread->edl->session->si_duration)
790 this->pwindow = pwindow;
792 int StillImageDuration::handle_event()
794 pwindow->thread->edl->session->si_duration = atof(get_text());