Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

interfaceprefs.C

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

Generated on Sun Jan 8 13:38:56 2006 for Cinelerra-svn by  doxygen 1.4.4