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"
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)
50 void InterfacePrefs::create_objects()
53 BC_Resources *resources = BC_WindowBase::get_resources();
54 int margin = mwindow->theme->widget_border;
55 char string[BCTEXTLEN];
56 x = mwindow->theme->preferencesoptions_x;
57 y = mwindow->theme->preferencesoptions_y;
59 add_subwindow(new BC_Title(x, y,
62 resources->text_default));
64 y += get_text_height(LARGEFONT) + 5;
67 add_subwindow(hms = new TimeFormatHMS(pwindow, this,
68 pwindow->thread->edl->session->time_format == TIME_HMS,
71 add_subwindow(hmsf = new TimeFormatHMSF(pwindow, this,
72 pwindow->thread->edl->session->time_format == TIME_HMSF,
75 add_subwindow(samples = new TimeFormatSamples(pwindow, this,
76 pwindow->thread->edl->session->time_format == TIME_SAMPLES,
79 add_subwindow(hex = new TimeFormatHex(pwindow, this,
80 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX,
83 add_subwindow(frames = new TimeFormatFrames(pwindow, this,
84 pwindow->thread->edl->session->time_format == TIME_FRAMES,
88 add_subwindow(feet = new TimeFormatFeet(pwindow, this,
89 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES,
91 x1 += feet->get_w() + margin;
93 add_subwindow(title = new BC_Title(x1, y, _("Frames per foot:")));
94 x1 += title->get_w() + margin;
95 sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
96 add_subwindow(new TimeFormatFeetSetting(pwindow,
99 add_subwindow(seconds = new TimeFormatSeconds(pwindow, this,
100 pwindow->thread->edl->session->time_format == TIME_SECONDS,
104 add_subwindow(new UseTipWindow(pwindow, x, y));
107 add_subwindow(new BC_Bar(5, y, get_w() - 10));
110 add_subwindow(new BC_Title(x, y, _("Index files"), LARGEFONT, resources->text_default));
114 add_subwindow(new BC_Title(x, y + 5,
115 _("Index files go here:"), MEDIUMFONT, resources->text_default));
116 add_subwindow(ipathtext = new IndexPathText(x + 230, y,
118 pwindow->thread->preferences->index_directory));
119 add_subwindow(ipath = new BrowseButton(mwindow, this,
121 x + 230 + ipathtext->get_w(), y,
122 pwindow->thread->preferences->index_directory,
124 _("Select the directory for index files"),
128 add_subwindow(new BC_Title(x, y + 5,
129 _("Size of index file:"),
131 resources->text_default));
132 sprintf(string, "" _LD "", pwindow->thread->preferences->index_size);
134 add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
135 add_subwindow(new ScanCommercials(pwindow, 350,y));
137 add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"), MEDIUMFONT, resources->text_default));
138 sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
139 add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
140 add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 350, y));
147 add_subwindow(new BC_Bar(5, y, get_w() - 10));
150 add_subwindow(new BC_Title(x, y, _("Editing"), LARGEFONT, resources->text_default));
154 add_subwindow(thumbnails = new ViewThumbnails(x, y, pwindow));
156 int x2 = x + 320, y2 = y;
157 AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y2);
158 add_subwindow(android_remote);
159 y2 += android_remote->get_h() + 10;
160 add_subwindow(title = new BC_Title(x2, y2, _("Port:")));
161 int x3 = x2 + title->get_w() + margin;
162 AndroidPort *android_port = new AndroidPort(pwindow, x3, y2);
163 add_subwindow(android_port);
164 y2 += title->get_h() + 10;
165 add_subwindow(title = new BC_Title(x2, y2, _("PIN:")));
166 AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y2);
167 add_subwindow(android_pin);
170 add_subwindow(new BC_Title(x, y, _("Clicking on edit boundaries does what:")));
172 add_subwindow(new BC_Title(x, y, _("Button 1:")));
174 ViewBehaviourText *text;
175 add_subwindow(text = new ViewBehaviourText(80, y - 5,
176 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]),
178 &(pwindow->thread->edl->session->edit_handle_mode[0])));
179 text->create_objects();
181 add_subwindow(new BC_Title(x, y, _("Button 2:")));
182 add_subwindow(text = new ViewBehaviourText(80,
184 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]),
186 &(pwindow->thread->edl->session->edit_handle_mode[1])));
187 text->create_objects();
189 add_subwindow(new BC_Title(x, y, _("Button 3:")));
190 add_subwindow(text = new ViewBehaviourText(80,
192 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]),
194 &(pwindow->thread->edl->session->edit_handle_mode[2])));
195 text->create_objects();
199 add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
200 x += title->get_w() + 10;
201 sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
202 add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
204 x += min_db->get_w() + 10;
205 add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
206 x += title->get_w() + 10;
207 sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
208 add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
213 add_subwindow(new BC_Title(x, y, _("Theme:")));
215 add_subwindow(theme = new ViewTheme(x, y, pwindow));
216 theme->create_objects();
220 const char* InterfacePrefs::behavior_to_text(int mode)
225 return _(MOVE_ALL_EDITS_TITLE);
228 return _(MOVE_ONE_EDIT_TITLE);
231 return _(MOVE_NO_EDITS_TITLE);
233 case MOVE_EDITS_DISABLED:
234 return _(MOVE_EDITS_DISABLED_TITLE);
242 int InterfacePrefs::update(int new_value)
244 pwindow->thread->redraw_times = 1;
245 pwindow->thread->edl->session->time_format = new_value;
246 hms->update(new_value == TIME_HMS);
247 hmsf->update(new_value == TIME_HMSF);
248 samples->update(new_value == TIME_SAMPLES);
249 hex->update(new_value == TIME_SAMPLES_HEX);
250 frames->update(new_value == TIME_FRAMES);
251 feet->update(new_value == TIME_FEET_FRAMES);
252 seconds->update(new_value == TIME_SECONDS);
256 InterfacePrefs::~InterfacePrefs()
286 IndexPathText::IndexPathText(int x,
288 PreferencesWindow *pwindow,
290 : BC_TextBox(x, y, 240, 1, text)
292 this->pwindow = pwindow;
295 IndexPathText::~IndexPathText() {}
297 int IndexPathText::handle_event()
299 strcpy(pwindow->thread->preferences->index_directory, get_text());
306 IndexSize::IndexSize(int x,
308 PreferencesWindow *pwindow,
310 : BC_TextBox(x, y, 100, 1, text)
312 this->pwindow = pwindow;
315 int IndexSize::handle_event()
319 result = atol(get_text());
320 if(result < 64000) result = 64000;
321 //if(result < 500000) result = 500000;
322 pwindow->thread->preferences->index_size = result;
328 IndexCount::IndexCount(int x,
330 PreferencesWindow *pwindow,
332 : BC_TextBox(x, y, 100, 1, text)
334 this->pwindow = pwindow;
337 int IndexCount::handle_event()
341 result = atol(get_text());
342 if(result < 1) result = 1;
343 pwindow->thread->preferences->index_count = result;
361 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
362 : BC_Radial(x, y, value, TIME_HMS_TEXT)
363 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
365 int TimeFormatHMS::handle_event()
367 tfwindow->update(TIME_HMS);
371 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
372 : BC_Radial(x, y, value, TIME_HMSF_TEXT)
373 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
375 int TimeFormatHMSF::handle_event()
377 tfwindow->update(TIME_HMSF);
381 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
382 : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
383 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
385 int TimeFormatSamples::handle_event()
387 tfwindow->update(TIME_SAMPLES);
391 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
392 : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
393 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
395 int TimeFormatFrames::handle_event()
397 tfwindow->update(TIME_FRAMES);
401 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
402 : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
403 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
405 int TimeFormatHex::handle_event()
407 tfwindow->update(TIME_SAMPLES_HEX);
411 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
412 : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
414 this->pwindow = pwindow;
415 this->tfwindow = tfwindow;
418 int TimeFormatSeconds::handle_event()
420 tfwindow->update(TIME_SECONDS);
424 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
425 : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
426 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
428 int TimeFormatFeet::handle_event()
430 tfwindow->update(TIME_FEET_FRAMES);
434 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
435 : BC_TextBox(x, y, 90, 1, string)
436 { this->pwindow = pwindow; }
438 int TimeFormatFeetSetting::handle_event()
440 pwindow->thread->edl->session->frames_per_foot = atof(get_text());
441 if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
448 ViewBehaviourText::ViewBehaviourText(int x,
451 PreferencesWindow *pwindow,
453 : BC_PopupMenu(x, y, 200, text)
455 this->output = output;
458 ViewBehaviourText::~ViewBehaviourText()
462 int ViewBehaviourText::handle_event()
467 void ViewBehaviourText::create_objects()
469 // Video4linux versions are automatically detected
470 add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
471 add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
472 add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
473 add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
477 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
481 this->behaviour = behaviour;
484 ViewBehaviourItem::~ViewBehaviourItem()
488 int ViewBehaviourItem::handle_event()
490 popup->set_text(get_text());
491 *(popup->output) = behaviour;
498 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
499 : BC_TextBox(x, y, 50, 1, text)
501 this->pwindow = pwindow;
504 int MeterMinDB::handle_event()
506 pwindow->thread->redraw_meters = 1;
507 pwindow->thread->edl->session->min_meter_db = atol(get_text());
514 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
515 : BC_TextBox(x, y, 50, 1, text)
517 this->pwindow = pwindow;
520 int MeterMaxDB::handle_event()
522 pwindow->thread->redraw_meters = 1;
523 pwindow->thread->edl->session->max_meter_db = atol(get_text());
531 MeterVUDB::MeterVUDB(PreferencesWindow *pwindow, char *text, int y)
532 : BC_Radial(145, y, pwindow->thread->edl->session->meter_format == METER_DB, text)
534 this->pwindow = pwindow;
537 int MeterVUDB::handle_event()
539 pwindow->thread->redraw_meters = 1;
540 // vu_int->update(0);
541 pwindow->thread->edl->session->meter_format = METER_DB;
545 MeterVUInt::MeterVUInt(PreferencesWindow *pwindow, char *text, int y)
546 : BC_Radial(205, y, pwindow->thread->edl->session->meter_format == METER_INT, text)
548 this->pwindow = pwindow;
551 int MeterVUInt::handle_event()
553 pwindow->thread->redraw_meters = 1;
555 pwindow->thread->edl->session->meter_format = METER_INT;
562 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
563 : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
565 this->pwindow = pwindow;
567 ViewTheme::~ViewTheme()
571 void ViewTheme::create_objects()
573 ArrayList<PluginServer*> themes;
574 MWindow::search_plugindb(0,
581 for(int i = 0; i < themes.total; i++)
583 add_item(new ViewThemeItem(this, themes.values[i]->title));
587 int ViewTheme::handle_event()
596 ViewThemeItem::ViewThemeItem(ViewTheme *popup, char *text)
602 int ViewThemeItem::handle_event()
604 popup->set_text(get_text());
605 strcpy(popup->pwindow->thread->preferences->theme, get_text());
606 popup->handle_event();
610 ViewThumbnails::ViewThumbnails(int x,
612 PreferencesWindow *pwindow)
615 pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
617 this->pwindow = pwindow;
620 int ViewThumbnails::handle_event()
622 pwindow->thread->preferences->use_thumbnails = get_value();
628 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
631 pwindow->thread->preferences->use_tipwindow,
632 _("Show tip of the day"))
634 this->pwindow = pwindow;
636 int UseTipWindow::handle_event()
638 pwindow->thread->preferences->use_tipwindow = get_value();
644 ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y)
647 pwindow->thread->preferences->scan_commercials,
648 _("Scan for commercials during toc build"))
650 this->pwindow = pwindow;
652 int ScanCommercials::handle_event()
654 pwindow->thread->preferences->scan_commercials = get_value();
659 AndroidRemote::AndroidRemote(PreferencesWindow *pwindow, int x, int y)
661 pwindow->thread->preferences->android_remote,
662 _("Android Remote Control"))
664 this->pwindow = pwindow;
666 int AndroidRemote::handle_event()
668 pwindow->thread->preferences->android_remote = get_value();
673 AndroidPIN::AndroidPIN(PreferencesWindow *pwindow, int x, int y)
674 : BC_TextBox(x, y, 240, 1, pwindow->thread->preferences->android_pin)
676 this->pwindow = pwindow;
679 int AndroidPIN::handle_event()
681 char *txt = pwindow->thread->preferences->android_pin;
682 int len = sizeof(pwindow->thread->preferences->android_pin);
683 strncpy(txt, get_text(), len);
688 AndroidPort::AndroidPort(PreferencesWindow *pwindow, int x, int y)
689 : BC_TextBox(x, y, 72, 1, pwindow->thread->preferences->android_port)
691 this->pwindow = pwindow;
694 int AndroidPort::handle_event()
696 unsigned short port = atoi(get_text());
697 if( port < 1024 ) port = 1024;
698 pwindow->thread->preferences->android_port = port;
700 sprintf(str,"%u",port);