00001 #include "deleteallindexes.h"
00002 #include "edl.h"
00003 #include "edlsession.h"
00004 #include "language.h"
00005 #include "mwindow.h"
00006 #include "preferences.h"
00007 #include "preferencesthread.h"
00008 #include "interfaceprefs.h"
00009 #include "theme.h"
00010
00011 #if 0
00012 N_("Drag all following edits")
00013 N_("Drag only one edit")
00014 N_("Drag source only")
00015 N_("No effect")
00016 #endif
00017
00018 #define MOVE_ALL_EDITS_TITLE "Drag all following edits"
00019 #define MOVE_ONE_EDIT_TITLE "Drag only one edit"
00020 #define MOVE_NO_EDITS_TITLE "Drag source only"
00021 #define MOVE_EDITS_DISABLED_TITLE "No effect"
00022
00023 InterfacePrefs::InterfacePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
00024 : PreferencesDialog(mwindow, pwindow)
00025 {
00026 }
00027
00028 int InterfacePrefs::create_objects()
00029 {
00030 int y, x, value;
00031 BC_Resources *resources = BC_WindowBase::get_resources();
00032 char string[1024];
00033 x = mwindow->theme->preferencesoptions_x;
00034 y = mwindow->theme->preferencesoptions_y;
00035
00036 add_subwindow(new BC_Title(x,
00037 y,
00038 _("Time Format"),
00039 LARGEFONT,
00040 resources->text_default));
00041
00042 y += get_text_height(LARGEFONT) + 5;
00043
00044
00045 add_subwindow(hms = new TimeFormatHMS(pwindow,
00046 this,
00047 pwindow->thread->edl->session->time_format == TIME_HMS,
00048 x,
00049 y));
00050 y += 20;
00051 add_subwindow(hmsf = new TimeFormatHMSF(pwindow,
00052 this,
00053 pwindow->thread->edl->session->time_format == TIME_HMSF,
00054 x,
00055 y));
00056 y += 20;
00057 add_subwindow(samples = new TimeFormatSamples(pwindow,
00058 this,
00059 pwindow->thread->edl->session->time_format == TIME_SAMPLES,
00060 x,
00061 y));
00062 y += 20;
00063 add_subwindow(hex = new TimeFormatHex(pwindow,
00064 this,
00065 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX,
00066 x,
00067 y));
00068 y += 20;
00069 add_subwindow(frames = new TimeFormatFrames(pwindow,
00070 this,
00071 pwindow->thread->edl->session->time_format == TIME_FRAMES,
00072 x,
00073 y));
00074 y += 20;
00075 add_subwindow(feet = new TimeFormatFeet(pwindow,
00076 this,
00077 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES,
00078 x,
00079 y));
00080 add_subwindow(new BC_Title(260, y, _("frames per foot")));
00081 sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
00082 add_subwindow(new TimeFormatFeetSetting(pwindow,
00083 x + 155,
00084 y - 5,
00085 string));
00086 y += 20;
00087 add_subwindow(seconds = new TimeFormatSeconds(pwindow,
00088 this,
00089 pwindow->thread->edl->session->time_format == TIME_SECONDS,
00090 x,
00091 y));
00092
00093
00094 y += 35;
00095 add_subwindow(new UseTipWindow(pwindow, x, y));
00096
00097 y += 35;
00098 add_subwindow(new BC_Bar(5, y, get_w() - 10));
00099 y += 5;
00100
00101 add_subwindow(new BC_Title(x, y, _("Index files"), LARGEFONT, resources->text_default));
00102
00103
00104 y += 35;
00105 add_subwindow(new BC_Title(x,
00106 y + 5,
00107 _("Index files go here:"), MEDIUMFONT, resources->text_default));
00108 add_subwindow(ipathtext = new IndexPathText(x + 230,
00109 y,
00110 pwindow,
00111 pwindow->thread->preferences->index_directory));
00112 add_subwindow(ipath = new BrowseButton(mwindow,
00113 this,
00114 ipathtext,
00115 x + 230 + ipathtext->get_w(),
00116 y,
00117 pwindow->thread->preferences->index_directory,
00118 _("Index Path"),
00119 _("Select the directory for index files"),
00120 1));
00121
00122 y += 30;
00123 add_subwindow(new BC_Title(x,
00124 y + 5,
00125 _("Size of index file:"),
00126 MEDIUMFONT,
00127 resources->text_default));
00128 sprintf(string, "%ld", pwindow->thread->preferences->index_size);
00129 add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
00130 y += 30;
00131 add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"), MEDIUMFONT, resources->text_default));
00132 sprintf(string, "%ld", pwindow->thread->preferences->index_count);
00133 add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
00134 add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 350, y));
00135
00136
00137
00138
00139
00140 y += 35;
00141 add_subwindow(new BC_Bar(5, y, get_w() - 10));
00142 y += 5;
00143
00144 add_subwindow(new BC_Title(x, y, _("Editing"), LARGEFONT, resources->text_default));
00145
00146
00147 y += 35;
00148 add_subwindow(thumbnails = new ViewThumbnails(x, y, pwindow));
00149
00150 y += 35;
00151 add_subwindow(new BC_Title(x, y, _("Dragging edit boundaries does what:")));
00152 y += 25;
00153 add_subwindow(new BC_Title(x, y, _("Button 1:")));
00154
00155 ViewBehaviourText *text;
00156 add_subwindow(text = new ViewBehaviourText(80,
00157 y - 5,
00158 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]),
00159 pwindow,
00160 &(pwindow->thread->edl->session->edit_handle_mode[0])));
00161 text->create_objects();
00162 y += 30;
00163 add_subwindow(new BC_Title(x, y, _("Button 2:")));
00164 add_subwindow(text = new ViewBehaviourText(80,
00165 y - 5,
00166 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]),
00167 pwindow,
00168 &(pwindow->thread->edl->session->edit_handle_mode[1])));
00169 text->create_objects();
00170 y += 30;
00171 add_subwindow(new BC_Title(x, y, _("Button 3:")));
00172 add_subwindow(text = new ViewBehaviourText(80,
00173 y - 5,
00174 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]),
00175 pwindow,
00176 &(pwindow->thread->edl->session->edit_handle_mode[2])));
00177 text->create_objects();
00178
00179 y += 40;
00180 int x1 = x;
00181 BC_Title *title;
00182 add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
00183 x += title->get_w() + 10;
00184 sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
00185 add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
00186
00187 x += min_db->get_w() + 10;
00188 add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
00189 x += title->get_w() + 10;
00190 sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
00191 add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
00192
00193 x = x1;
00194 y += 20;
00195 ViewTheme *theme;
00196 add_subwindow(new BC_Title(x, y, _("Theme:")));
00197 x += 60;
00198 add_subwindow(theme = new ViewTheme(x, y, pwindow));
00199 theme->create_objects();
00200
00201 return 0;
00202 }
00203
00204 char* InterfacePrefs::behavior_to_text(int mode)
00205 {
00206 switch(mode)
00207 {
00208 case MOVE_ALL_EDITS:
00209 return _(MOVE_ALL_EDITS_TITLE);
00210 break;
00211 case MOVE_ONE_EDIT:
00212 return _(MOVE_ONE_EDIT_TITLE);
00213 break;
00214 case MOVE_NO_EDITS:
00215 return _(MOVE_NO_EDITS_TITLE);
00216 break;
00217 case MOVE_EDITS_DISABLED:
00218 return _(MOVE_EDITS_DISABLED_TITLE);
00219 break;
00220 default:
00221 return "";
00222 break;
00223 }
00224 }
00225
00226 int InterfacePrefs::update(int new_value)
00227 {
00228 pwindow->thread->redraw_times = 1;
00229 pwindow->thread->edl->session->time_format = new_value;
00230 hms->update(new_value == TIME_HMS);
00231 hmsf->update(new_value == TIME_HMSF);
00232 samples->update(new_value == TIME_SAMPLES);
00233 hex->update(new_value == TIME_SAMPLES_HEX);
00234 frames->update(new_value == TIME_FRAMES);
00235 feet->update(new_value == TIME_FEET_FRAMES);
00236 seconds->update(new_value == TIME_SECONDS);
00237 }
00238
00239 InterfacePrefs::~InterfacePrefs()
00240 {
00241 delete hms;
00242 delete hmsf;
00243 delete samples;
00244 delete frames;
00245 delete hex;
00246 delete feet;
00247 delete min_db;
00248 delete max_db;
00249
00250
00251 delete thumbnails;
00252 }
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269 IndexPathText::IndexPathText(int x,
00270 int y,
00271 PreferencesWindow *pwindow,
00272 char *text)
00273 : BC_TextBox(x, y, 240, 1, text)
00274 {
00275 this->pwindow = pwindow;
00276 }
00277
00278 IndexPathText::~IndexPathText() {}
00279
00280 int IndexPathText::handle_event()
00281 {
00282 strcpy(pwindow->thread->preferences->index_directory, get_text());
00283 }
00284
00285
00286
00287
00288 IndexSize::IndexSize(int x,
00289 int y,
00290 PreferencesWindow *pwindow,
00291 char *text)
00292 : BC_TextBox(x, y, 100, 1, text)
00293 {
00294 this->pwindow = pwindow;
00295 }
00296
00297 int IndexSize::handle_event()
00298 {
00299 long result;
00300
00301 result = atol(get_text());
00302 if(result < 64000) result = 64000;
00303
00304 pwindow->thread->preferences->index_size = result;
00305 return 0;
00306 }
00307
00308
00309
00310 IndexCount::IndexCount(int x,
00311 int y,
00312 PreferencesWindow *pwindow,
00313 char *text)
00314 : BC_TextBox(x, y, 100, 1, text)
00315 {
00316 this->pwindow = pwindow;
00317 }
00318
00319 int IndexCount::handle_event()
00320 {
00321 long result;
00322
00323 result = atol(get_text());
00324 if(result < 1) result = 1;
00325 pwindow->thread->preferences->index_count = result;
00326 return 0;
00327 }
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
00344 : BC_Radial(x, y, value, _("Use Hours:Minutes:Seconds.xxx"))
00345 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
00346
00347 int TimeFormatHMS::handle_event()
00348 {
00349 tfwindow->update(TIME_HMS);
00350 return 1;
00351 }
00352
00353 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
00354 : BC_Radial(x, y, value, _("Use Hours:Minutes:Seconds:Frames"))
00355 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
00356
00357 int TimeFormatHMSF::handle_event()
00358 {
00359 tfwindow->update(TIME_HMSF);
00360 }
00361
00362 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
00363 : BC_Radial(x, y, value, _("Use Samples"))
00364 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
00365
00366 int TimeFormatSamples::handle_event()
00367 {
00368 tfwindow->update(TIME_SAMPLES);
00369 }
00370
00371 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
00372 : BC_Radial(x, y, value, _("Use Frames"))
00373 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
00374
00375 int TimeFormatFrames::handle_event()
00376 {
00377 tfwindow->update(TIME_FRAMES);
00378 }
00379
00380 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
00381 : BC_Radial(x, y, value, _("Use Hex Samples"))
00382 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
00383
00384 int TimeFormatHex::handle_event()
00385 {
00386 tfwindow->update(TIME_SAMPLES_HEX);
00387 }
00388
00389 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
00390 : BC_Radial(x, y, value, _("Use Seconds"))
00391 {
00392 this->pwindow = pwindow;
00393 this->tfwindow = tfwindow;
00394 }
00395
00396 int TimeFormatSeconds::handle_event()
00397 {
00398 tfwindow->update(TIME_SECONDS);
00399 }
00400
00401 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
00402 : BC_Radial(x, y, value, _("Use Feet-frames"))
00403 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
00404
00405 int TimeFormatFeet::handle_event()
00406 {
00407 tfwindow->update(TIME_FEET_FRAMES);
00408 }
00409
00410 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
00411 : BC_TextBox(x, y, 90, 1, string)
00412 { this->pwindow = pwindow; }
00413
00414 int TimeFormatFeetSetting::handle_event()
00415 {
00416 pwindow->thread->edl->session->frames_per_foot = atof(get_text());
00417 if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
00418 return 0;
00419 }
00420
00421
00422
00423
00424 ViewBehaviourText::ViewBehaviourText(int x,
00425 int y,
00426 char *text,
00427 PreferencesWindow *pwindow,
00428 int *output)
00429 : BC_PopupMenu(x, y, 200, text)
00430 {
00431 this->output = output;
00432 }
00433
00434 ViewBehaviourText::~ViewBehaviourText()
00435 {
00436 }
00437
00438 int ViewBehaviourText::handle_event()
00439 {
00440 }
00441
00442 int ViewBehaviourText::create_objects()
00443 {
00444
00445 add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
00446 add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
00447 add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
00448 add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
00449 return 0;
00450 }
00451
00452
00453 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
00454 : BC_MenuItem(text)
00455 {
00456 this->popup = popup;
00457 this->behaviour = behaviour;
00458 }
00459
00460 ViewBehaviourItem::~ViewBehaviourItem()
00461 {
00462 }
00463
00464 int ViewBehaviourItem::handle_event()
00465 {
00466 popup->set_text(get_text());
00467 *(popup->output) = behaviour;
00468 }
00469
00470
00471
00472
00473 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
00474 : BC_TextBox(x, y, 50, 1, text)
00475 {
00476 this->pwindow = pwindow;
00477 }
00478
00479 int MeterMinDB::handle_event()
00480 {
00481 pwindow->thread->redraw_meters = 1;
00482 pwindow->thread->edl->session->min_meter_db = atol(get_text());
00483 return 0;
00484 }
00485
00486
00487
00488
00489 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
00490 : BC_TextBox(x, y, 50, 1, text)
00491 {
00492 this->pwindow = pwindow;
00493 }
00494
00495 int MeterMaxDB::handle_event()
00496 {
00497 pwindow->thread->redraw_meters = 1;
00498 pwindow->thread->edl->session->max_meter_db = atol(get_text());
00499 return 0;
00500 }
00501
00502
00503
00504
00505
00506 MeterVUDB::MeterVUDB(PreferencesWindow *pwindow, char *text, int y)
00507 : BC_Radial(145, y, pwindow->thread->edl->session->meter_format == METER_DB, text)
00508 {
00509 this->pwindow = pwindow;
00510 }
00511
00512 int MeterVUDB::handle_event()
00513 {
00514 pwindow->thread->redraw_meters = 1;
00515
00516 pwindow->thread->edl->session->meter_format = METER_DB;
00517 return 1;
00518 }
00519
00520 MeterVUInt::MeterVUInt(PreferencesWindow *pwindow, char *text, int y)
00521 : BC_Radial(205, y, pwindow->thread->edl->session->meter_format == METER_INT, text)
00522 {
00523 this->pwindow = pwindow;
00524 }
00525
00526 int MeterVUInt::handle_event()
00527 {
00528 pwindow->thread->redraw_meters = 1;
00529 vu_db->update(0);
00530 pwindow->thread->edl->session->meter_format = METER_INT;
00531 return 1;
00532 }
00533
00534
00535
00536
00537 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
00538 : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
00539 {
00540 this->pwindow = pwindow;
00541 }
00542 ViewTheme::~ViewTheme()
00543 {
00544 }
00545
00546 void ViewTheme::create_objects()
00547 {
00548 ArrayList<PluginServer*> themes;
00549 pwindow->mwindow->create_plugindb(0,
00550 0,
00551 0,
00552 0,
00553 1,
00554 themes);
00555
00556 for(int i = 0; i < themes.total; i++)
00557 {
00558 add_item(new ViewThemeItem(this, themes.values[i]->title));
00559 }
00560 }
00561
00562 int ViewTheme::handle_event()
00563 {
00564 return 1;
00565 }
00566
00567
00568
00569
00570
00571 ViewThemeItem::ViewThemeItem(ViewTheme *popup, char *text)
00572 : BC_MenuItem(text)
00573 {
00574 this->popup = popup;
00575 }
00576
00577 int ViewThemeItem::handle_event()
00578 {
00579 popup->set_text(get_text());
00580 strcpy(popup->pwindow->thread->preferences->theme, get_text());
00581 popup->handle_event();
00582 return 1;
00583 }
00584
00585 ViewThumbnails::ViewThumbnails(int x,
00586 int y,
00587 PreferencesWindow *pwindow)
00588 : BC_CheckBox(x,
00589 y,
00590 pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
00591 {
00592 this->pwindow = pwindow;
00593 }
00594
00595 int ViewThumbnails::handle_event()
00596 {
00597 pwindow->thread->preferences->use_thumbnails = get_value();
00598 return 1;
00599 }
00600
00601
00602
00603 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
00604 : BC_CheckBox(x,
00605 y,
00606 pwindow->thread->preferences->use_tipwindow,
00607 _("Show tip of the day"))
00608 {
00609 this->pwindow = pwindow;
00610 }
00611 int UseTipWindow::handle_event()
00612 {
00613 pwindow->thread->preferences->use_tipwindow = get_value();
00614 return 1;
00615 }
00616
00617
00618