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));
105 add_subwindow(new UseWarnIndecies(pwindow, x+200, y));
108 add_subwindow(new BC_Bar(5, y, get_w() - 10));
111 add_subwindow(new BC_Title(x, y, _("Index files"), LARGEFONT, resources->text_default));
115 add_subwindow(new BC_Title(x, y + 5,
116 _("Index files go here:"), MEDIUMFONT, resources->text_default));
117 add_subwindow(ipathtext = new IndexPathText(x + 230, y,
119 pwindow->thread->preferences->index_directory));
120 add_subwindow(ipath = new BrowseButton(mwindow, this,
122 x + 230 + ipathtext->get_w(), y,
123 pwindow->thread->preferences->index_directory,
125 _("Select the directory for index files"),
129 add_subwindow(new BC_Title(x, y + 5,
130 _("Size of index file:"),
132 resources->text_default));
133 sprintf(string, "" _LD "", pwindow->thread->preferences->index_size);
135 add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
136 add_subwindow(new ScanCommercials(pwindow, 350,y));
138 add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"), MEDIUMFONT, resources->text_default));
139 sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
140 add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
141 add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 350, y));
148 add_subwindow(new BC_Bar(5, y, get_w() - 10));
151 add_subwindow(new BC_Title(x, y, _("Editing"), LARGEFONT, resources->text_default));
155 add_subwindow(thumbnails = new ViewThumbnails(x, y, pwindow));
157 int x2 = x + 320, y2 = y;
158 AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y2);
159 add_subwindow(android_remote);
160 y2 += android_remote->get_h() + 10;
161 add_subwindow(title = new BC_Title(x2, y2, _("Port:")));
162 int x3 = x2 + title->get_w() + margin;
163 AndroidPort *android_port = new AndroidPort(pwindow, x3, y2);
164 add_subwindow(android_port);
165 y2 += title->get_h() + 10;
166 add_subwindow(title = new BC_Title(x2, y2, _("PIN:")));
167 AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y2);
168 add_subwindow(android_pin);
171 add_subwindow(new BC_Title(x, y, _("Clicking on edit boundaries does what:")));
173 add_subwindow(new BC_Title(x, y, _("Button 1:")));
175 ViewBehaviourText *text;
176 add_subwindow(text = new ViewBehaviourText(80, y - 5,
177 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]),
179 &(pwindow->thread->edl->session->edit_handle_mode[0])));
180 text->create_objects();
182 add_subwindow(new BC_Title(x, y, _("Button 2:")));
183 add_subwindow(text = new ViewBehaviourText(80,
185 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]),
187 &(pwindow->thread->edl->session->edit_handle_mode[1])));
188 text->create_objects();
190 add_subwindow(new BC_Title(x, y, _("Button 3:")));
191 add_subwindow(text = new ViewBehaviourText(80,
193 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]),
195 &(pwindow->thread->edl->session->edit_handle_mode[2])));
196 text->create_objects();
200 add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
201 x += title->get_w() + 10;
202 sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
203 add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
205 x += min_db->get_w() + 10;
206 add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
207 x += title->get_w() + 10;
208 sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
209 add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
214 add_subwindow(new BC_Title(x, y, _("Theme:")));
216 add_subwindow(theme = new ViewTheme(x, y, pwindow));
217 theme->create_objects();
221 const char* InterfacePrefs::behavior_to_text(int mode)
226 return _(MOVE_ALL_EDITS_TITLE);
229 return _(MOVE_ONE_EDIT_TITLE);
232 return _(MOVE_NO_EDITS_TITLE);
234 case MOVE_EDITS_DISABLED:
235 return _(MOVE_EDITS_DISABLED_TITLE);
243 int InterfacePrefs::update(int new_value)
245 pwindow->thread->redraw_times = 1;
246 pwindow->thread->edl->session->time_format = new_value;
247 hms->update(new_value == TIME_HMS);
248 hmsf->update(new_value == TIME_HMSF);
249 samples->update(new_value == TIME_SAMPLES);
250 hex->update(new_value == TIME_SAMPLES_HEX);
251 frames->update(new_value == TIME_FRAMES);
252 feet->update(new_value == TIME_FEET_FRAMES);
253 seconds->update(new_value == TIME_SECONDS);
257 InterfacePrefs::~InterfacePrefs()
287 IndexPathText::IndexPathText(int x,
289 PreferencesWindow *pwindow,
291 : BC_TextBox(x, y, 240, 1, text)
293 this->pwindow = pwindow;
296 IndexPathText::~IndexPathText() {}
298 int IndexPathText::handle_event()
300 strcpy(pwindow->thread->preferences->index_directory, get_text());
307 IndexSize::IndexSize(int x,
309 PreferencesWindow *pwindow,
311 : BC_TextBox(x, y, 100, 1, text)
313 this->pwindow = pwindow;
316 int IndexSize::handle_event()
320 result = atol(get_text());
321 if(result < 64000) result = 64000;
322 //if(result < 500000) result = 500000;
323 pwindow->thread->preferences->index_size = result;
329 IndexCount::IndexCount(int x,
331 PreferencesWindow *pwindow,
333 : BC_TextBox(x, y, 100, 1, text)
335 this->pwindow = pwindow;
338 int IndexCount::handle_event()
342 result = atol(get_text());
343 if(result < 1) result = 1;
344 pwindow->thread->preferences->index_count = result;
362 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
363 : BC_Radial(x, y, value, TIME_HMS_TEXT)
364 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
366 int TimeFormatHMS::handle_event()
368 tfwindow->update(TIME_HMS);
372 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
373 : BC_Radial(x, y, value, TIME_HMSF_TEXT)
374 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
376 int TimeFormatHMSF::handle_event()
378 tfwindow->update(TIME_HMSF);
382 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
383 : BC_Radial(x, y, value, TIME_SAMPLES_TEXT)
384 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
386 int TimeFormatSamples::handle_event()
388 tfwindow->update(TIME_SAMPLES);
392 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
393 : BC_Radial(x, y, value, TIME_FRAMES_TEXT)
394 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
396 int TimeFormatFrames::handle_event()
398 tfwindow->update(TIME_FRAMES);
402 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
403 : BC_Radial(x, y, value, TIME_SAMPLES_HEX_TEXT)
404 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
406 int TimeFormatHex::handle_event()
408 tfwindow->update(TIME_SAMPLES_HEX);
412 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
413 : BC_Radial(x, y, value, TIME_SECONDS_TEXT)
415 this->pwindow = pwindow;
416 this->tfwindow = tfwindow;
419 int TimeFormatSeconds::handle_event()
421 tfwindow->update(TIME_SECONDS);
425 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
426 : BC_Radial(x, y, value, TIME_FEET_FRAMES_TEXT)
427 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
429 int TimeFormatFeet::handle_event()
431 tfwindow->update(TIME_FEET_FRAMES);
435 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
436 : BC_TextBox(x, y, 90, 1, string)
437 { this->pwindow = pwindow; }
439 int TimeFormatFeetSetting::handle_event()
441 pwindow->thread->edl->session->frames_per_foot = atof(get_text());
442 if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
449 ViewBehaviourText::ViewBehaviourText(int x,
452 PreferencesWindow *pwindow,
454 : BC_PopupMenu(x, y, 200, text)
456 this->output = output;
459 ViewBehaviourText::~ViewBehaviourText()
463 int ViewBehaviourText::handle_event()
468 void ViewBehaviourText::create_objects()
470 // Video4linux versions are automatically detected
471 add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
472 add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
473 add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
474 add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
478 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
482 this->behaviour = behaviour;
485 ViewBehaviourItem::~ViewBehaviourItem()
489 int ViewBehaviourItem::handle_event()
491 popup->set_text(get_text());
492 *(popup->output) = behaviour;
499 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
500 : BC_TextBox(x, y, 50, 1, text)
502 this->pwindow = pwindow;
505 int MeterMinDB::handle_event()
507 pwindow->thread->redraw_meters = 1;
508 pwindow->thread->edl->session->min_meter_db = atol(get_text());
515 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
516 : BC_TextBox(x, y, 50, 1, text)
518 this->pwindow = pwindow;
521 int MeterMaxDB::handle_event()
523 pwindow->thread->redraw_meters = 1;
524 pwindow->thread->edl->session->max_meter_db = atol(get_text());
532 MeterVUDB::MeterVUDB(PreferencesWindow *pwindow, char *text, int y)
533 : BC_Radial(145, y, pwindow->thread->edl->session->meter_format == METER_DB, text)
535 this->pwindow = pwindow;
538 int MeterVUDB::handle_event()
540 pwindow->thread->redraw_meters = 1;
541 // vu_int->update(0);
542 pwindow->thread->edl->session->meter_format = METER_DB;
546 MeterVUInt::MeterVUInt(PreferencesWindow *pwindow, char *text, int y)
547 : BC_Radial(205, y, pwindow->thread->edl->session->meter_format == METER_INT, text)
549 this->pwindow = pwindow;
552 int MeterVUInt::handle_event()
554 pwindow->thread->redraw_meters = 1;
556 pwindow->thread->edl->session->meter_format = METER_INT;
563 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
564 : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
566 this->pwindow = pwindow;
568 ViewTheme::~ViewTheme()
572 void ViewTheme::create_objects()
574 ArrayList<PluginServer*> themes;
575 MWindow::search_plugindb(0,
582 for(int i = 0; i < themes.total; i++)
584 add_item(new ViewThemeItem(this, themes.values[i]->title));
588 int ViewTheme::handle_event()
597 ViewThemeItem::ViewThemeItem(ViewTheme *popup, char *text)
603 int ViewThemeItem::handle_event()
605 popup->set_text(get_text());
606 strcpy(popup->pwindow->thread->preferences->theme, get_text());
607 popup->handle_event();
611 ViewThumbnails::ViewThumbnails(int x,
613 PreferencesWindow *pwindow)
616 pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
618 this->pwindow = pwindow;
621 int ViewThumbnails::handle_event()
623 pwindow->thread->preferences->use_thumbnails = get_value();
629 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
632 pwindow->thread->preferences->use_tipwindow,
633 _("Show tip of the day"))
635 this->pwindow = pwindow;
637 int UseTipWindow::handle_event()
639 pwindow->thread->preferences->use_tipwindow = get_value();
644 UseWarnIndecies::UseWarnIndecies(PreferencesWindow *pwindow, int x, int y)
647 pwindow->thread->preferences->warn_indecies,
648 _("ffmpeg probe warns rebuild indecies"))
650 this->pwindow = pwindow;
653 int UseWarnIndecies::handle_event()
655 pwindow->thread->preferences->warn_indecies = get_value();
662 ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y)
665 pwindow->thread->preferences->scan_commercials,
666 _("Scan for commercials during toc build"))
668 this->pwindow = pwindow;
670 int ScanCommercials::handle_event()
672 pwindow->thread->preferences->scan_commercials = get_value();
677 AndroidRemote::AndroidRemote(PreferencesWindow *pwindow, int x, int y)
679 pwindow->thread->preferences->android_remote,
680 _("Android Remote Control"))
682 this->pwindow = pwindow;
684 int AndroidRemote::handle_event()
686 pwindow->thread->preferences->android_remote = get_value();
691 AndroidPIN::AndroidPIN(PreferencesWindow *pwindow, int x, int y)
692 : BC_TextBox(x, y, 240, 1, pwindow->thread->preferences->android_pin)
694 this->pwindow = pwindow;
697 int AndroidPIN::handle_event()
699 char *txt = pwindow->thread->preferences->android_pin;
700 int len = sizeof(pwindow->thread->preferences->android_pin);
701 strncpy(txt, get_text(), len);
706 AndroidPort::AndroidPort(PreferencesWindow *pwindow, int x, int y)
707 : BC_TextBox(x, y, 72, 1, pwindow->thread->preferences->android_port)
709 this->pwindow = pwindow;
712 int AndroidPort::handle_event()
714 unsigned short port = atoi(get_text());
715 if( port < 1024 ) port = 1024;
716 pwindow->thread->preferences->android_port = port;
718 sprintf(str,"%u",port);