r1009: Move the dependencies to newer package names
[cinelerra_cv/mob.git] / cinelerra / interfaceprefs.C
blob7662fb801e845ad81a8492710cd4dca27e7370b9
1 #include "deleteallindexes.h"
2 #include "edl.h"
3 #include "edlsession.h"
4 #include "language.h"
5 #include "mwindow.h"
6 #include "preferences.h"
7 #include "preferencesthread.h"
8 #include "interfaceprefs.h"
9 #include "theme.h"
11 #if 0
12 N_("Drag all following edits")
13 N_("Drag only one edit")
14 N_("Drag source only")
15 N_("No effect")
16 #endif
18 #define MOVE_ALL_EDITS_TITLE "Drag all following edits"
19 #define MOVE_ONE_EDIT_TITLE "Drag only one edit"
20 #define MOVE_NO_EDITS_TITLE "Drag source only"
21 #define MOVE_EDITS_DISABLED_TITLE "No effect"
23 InterfacePrefs::InterfacePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
24  : PreferencesDialog(mwindow, pwindow)
28 int InterfacePrefs::create_objects()
30         int y, x, value;
31         BC_Resources *resources = BC_WindowBase::get_resources();
32         char string[1024];
33         x = mwindow->theme->preferencesoptions_x;
34         y = mwindow->theme->preferencesoptions_y;
36         add_subwindow(new BC_Title(x, 
37                 y, 
38                 _("Time Format"), 
39                 LARGEFONT, 
40                 resources->text_default));
42         y += get_text_height(LARGEFONT) + 5;
45         add_subwindow(hms = new TimeFormatHMS(pwindow, 
46                 this, 
47                 pwindow->thread->edl->session->time_format == TIME_HMS, 
48                 x, 
49                 y));
50         y += 20;
51         add_subwindow(hmsf = new TimeFormatHMSF(pwindow, 
52                 this, 
53                 pwindow->thread->edl->session->time_format == TIME_HMSF, 
54                 x, 
55                 y));
56         y += 20;
57         add_subwindow(samples = new TimeFormatSamples(pwindow, 
58                 this, 
59                 pwindow->thread->edl->session->time_format == TIME_SAMPLES, 
60                 x, 
61                 y));
62         y += 20;
63         add_subwindow(hex = new TimeFormatHex(pwindow, 
64                 this, 
65                 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX, 
66                 x, 
67                 y));
68         y += 20;
69         add_subwindow(frames = new TimeFormatFrames(pwindow, 
70                 this, 
71                 pwindow->thread->edl->session->time_format == TIME_FRAMES, 
72                 x, 
73                 y));
74         y += 20;
75         add_subwindow(feet = new TimeFormatFeet(pwindow, 
76                 this, 
77                 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES, 
78                 x, 
79                 y));
80         add_subwindow(new BC_Title(260, y, _("frames per foot")));
81         sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
82         add_subwindow(new TimeFormatFeetSetting(pwindow, 
83                 x + 155, 
84                 y - 5, 
85                 string));
86         y += 20;
87         add_subwindow(seconds = new TimeFormatSeconds(pwindow, 
88                 this, 
89                 pwindow->thread->edl->session->time_format == TIME_SECONDS, 
90                 x, 
91                 y));
94         y += 35;
95         add_subwindow(new UseTipWindow(pwindow, x, y));
97         y += 35;
98         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
99         y += 5;
101         add_subwindow(new BC_Title(x, y, _("Index files"), LARGEFONT, resources->text_default));
104         y += 35;
105         add_subwindow(new BC_Title(x, 
106                 y + 5, 
107                 _("Index files go here:"), MEDIUMFONT, resources->text_default));
108         add_subwindow(ipathtext = new IndexPathText(x + 230, 
109                 y, 
110                 pwindow, 
111                 pwindow->thread->preferences->index_directory));
112         add_subwindow(ipath = new BrowseButton(mwindow,
113                 this,
114                 ipathtext, 
115                 x + 230 + ipathtext->get_w(), 
116                 y, 
117                 pwindow->thread->preferences->index_directory,
118                 _("Index Path"), 
119                 _("Select the directory for index files"),
120                 1));
122         y += 30;
123         add_subwindow(new BC_Title(x, 
124                 y + 5, 
125                 _("Size of index file:"), 
126                 MEDIUMFONT, 
127                 resources->text_default));
128         sprintf(string, "%ld", pwindow->thread->preferences->index_size);
129         add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
130         y += 30;
131         add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"), MEDIUMFONT, resources->text_default));
132         sprintf(string, "%ld", pwindow->thread->preferences->index_count);
133         add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
134         add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 350, y));
140         y += 35;
141         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
142         y += 5;
144         add_subwindow(new BC_Title(x, y, _("Editing"), LARGEFONT, resources->text_default));
147         y += 35;
148         add_subwindow(thumbnails = new ViewThumbnails(x, y, pwindow));
150         y += 35;
151         add_subwindow(new BC_Title(x, y, _("Dragging edit boundaries does what:")));
152         y += 25;
153         add_subwindow(new BC_Title(x, y, _("Button 1:")));
154         
155         ViewBehaviourText *text;
156         add_subwindow(text = new ViewBehaviourText(80, 
157                 y - 5, 
158                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]), 
159                         pwindow, 
160                         &(pwindow->thread->edl->session->edit_handle_mode[0])));
161         text->create_objects();
162         y += 30;
163         add_subwindow(new BC_Title(x, y, _("Button 2:")));
164         add_subwindow(text = new ViewBehaviourText(80, 
165                 y - 5, 
166                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]), 
167                         pwindow, 
168                         &(pwindow->thread->edl->session->edit_handle_mode[1])));
169         text->create_objects();
170         y += 30;
171         add_subwindow(new BC_Title(x, y, _("Button 3:")));
172         add_subwindow(text = new ViewBehaviourText(80, 
173                 y - 5, 
174                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]), 
175                         pwindow, 
176                         &(pwindow->thread->edl->session->edit_handle_mode[2])));
177         text->create_objects();
179         y += 40;
180         int x1 = x;
181         BC_Title *title;
182         add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
183         x += title->get_w() + 10;
184         sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
185         add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
187         x += min_db->get_w() + 10;
188         add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
189         x += title->get_w() + 10;
190         sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
191         add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
193         x = x1;
194         y += 20;
195         ViewTheme *theme;
196         add_subwindow(new BC_Title(x, y, _("Theme:")));
197         x += 60;
198         add_subwindow(theme = new ViewTheme(x, y, pwindow));
199         theme->create_objects();
201         return 0;
204 char* InterfacePrefs::behavior_to_text(int mode)
206         switch(mode)
207         {
208                 case MOVE_ALL_EDITS:
209                         return _(MOVE_ALL_EDITS_TITLE);
210                         break;
211                 case MOVE_ONE_EDIT:
212                         return _(MOVE_ONE_EDIT_TITLE);
213                         break;
214                 case MOVE_NO_EDITS:
215                         return _(MOVE_NO_EDITS_TITLE);
216                         break;
217                 case MOVE_EDITS_DISABLED:
218                         return _(MOVE_EDITS_DISABLED_TITLE);
219                         break;
220                 default:
221                         return "";
222                         break;
223         }
226 int InterfacePrefs::update(int new_value)
228         pwindow->thread->redraw_times = 1;
229         pwindow->thread->edl->session->time_format = new_value;
230         hms->update(new_value == TIME_HMS);
231         hmsf->update(new_value == TIME_HMSF);
232         samples->update(new_value == TIME_SAMPLES);
233         hex->update(new_value == TIME_SAMPLES_HEX);
234         frames->update(new_value == TIME_FRAMES);
235         feet->update(new_value == TIME_FEET_FRAMES);
236         seconds->update(new_value == TIME_SECONDS);
239 InterfacePrefs::~InterfacePrefs()
241         delete hms;
242         delete hmsf;
243         delete samples;
244         delete frames;
245         delete hex;
246         delete feet;
247         delete min_db;
248         delete max_db;
249 //      delete vu_db;
250 //      delete vu_int;
251         delete thumbnails;
269 IndexPathText::IndexPathText(int x, 
270         int y, 
271         PreferencesWindow *pwindow, 
272         char *text)
273  : BC_TextBox(x, y, 240, 1, text)
275         this->pwindow = pwindow; 
278 IndexPathText::~IndexPathText() {}
280 int IndexPathText::handle_event()
282         strcpy(pwindow->thread->preferences->index_directory, get_text());
288 IndexSize::IndexSize(int x, 
289         int y, 
290         PreferencesWindow *pwindow, 
291         char *text)
292  : BC_TextBox(x, y, 100, 1, text)
294         this->pwindow = pwindow; 
297 int IndexSize::handle_event()
299         long result;
301         result = atol(get_text());
302         if(result < 64000) result = 64000;
303         //if(result < 500000) result = 500000;
304         pwindow->thread->preferences->index_size = result;
305         return 0;
310 IndexCount::IndexCount(int x, 
311         int y, 
312         PreferencesWindow *pwindow, 
313         char *text)
314  : BC_TextBox(x, y, 100, 1, text)
316         this->pwindow = pwindow; 
319 int IndexCount::handle_event()
321         long result;
323         result = atol(get_text());
324         if(result < 1) result = 1;
325         pwindow->thread->preferences->index_count = result;
326         return 0;
343 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
344  : BC_Radial(x, y, value, _("Use Hours:Minutes:Seconds.xxx"))
345 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
347 int TimeFormatHMS::handle_event()
349         tfwindow->update(TIME_HMS);
350         return 1;
353 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
354  : BC_Radial(x, y, value, _("Use Hours:Minutes:Seconds:Frames"))
355 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
357 int TimeFormatHMSF::handle_event()
359         tfwindow->update(TIME_HMSF);
362 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
363  : BC_Radial(x, y, value, _("Use Samples"))
364 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
366 int TimeFormatSamples::handle_event()
368         tfwindow->update(TIME_SAMPLES);
371 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
372  : BC_Radial(x, y, value, _("Use Frames"))
373 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
375 int TimeFormatFrames::handle_event()
377         tfwindow->update(TIME_FRAMES);
380 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
381  : BC_Radial(x, y, value, _("Use Hex Samples"))
382 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
384 int TimeFormatHex::handle_event()
386         tfwindow->update(TIME_SAMPLES_HEX);
389 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
390  : BC_Radial(x, y, value, _("Use Seconds"))
392         this->pwindow = pwindow; 
393         this->tfwindow = tfwindow; 
396 int TimeFormatSeconds::handle_event()
398         tfwindow->update(TIME_SECONDS);
401 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
402  : BC_Radial(x, y, value, _("Use Feet-frames"))
403 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
405 int TimeFormatFeet::handle_event()
407         tfwindow->update(TIME_FEET_FRAMES);
410 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
411  : BC_TextBox(x, y, 90, 1, string)
412 { this->pwindow = pwindow; }
414 int TimeFormatFeetSetting::handle_event()
416         pwindow->thread->edl->session->frames_per_foot = atof(get_text());
417         if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
418         return 0;
424 ViewBehaviourText::ViewBehaviourText(int x, 
425         int y, 
426         char *text, 
427         PreferencesWindow *pwindow, 
428         int *output)
429  : BC_PopupMenu(x, y, 200, text)
431         this->output = output;
434 ViewBehaviourText::~ViewBehaviourText()
438 int ViewBehaviourText::handle_event()
442 int ViewBehaviourText::create_objects()
444 // Video4linux versions are automatically detected
445         add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
446         add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
447         add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
448         add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
449         return 0;
453 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
454  : BC_MenuItem(text)
456         this->popup = popup;
457         this->behaviour = behaviour;
460 ViewBehaviourItem::~ViewBehaviourItem()
464 int ViewBehaviourItem::handle_event()
466         popup->set_text(get_text());
467         *(popup->output) = behaviour;
473 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
474  : BC_TextBox(x, y, 50, 1, text)
476         this->pwindow = pwindow; 
479 int MeterMinDB::handle_event()
481         pwindow->thread->redraw_meters = 1;
482         pwindow->thread->edl->session->min_meter_db = atol(get_text()); 
483         return 0;
489 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
490  : BC_TextBox(x, y, 50, 1, text)
492         this->pwindow = pwindow; 
495 int MeterMaxDB::handle_event()
497         pwindow->thread->redraw_meters = 1;
498         pwindow->thread->edl->session->max_meter_db = atol(get_text()); 
499         return 0;
506 MeterVUDB::MeterVUDB(PreferencesWindow *pwindow, char *text, int y)
507  : BC_Radial(145, y, pwindow->thread->edl->session->meter_format == METER_DB, text)
509         this->pwindow = pwindow; 
512 int MeterVUDB::handle_event() 
514         pwindow->thread->redraw_meters = 1;
515 //      vu_int->update(0); 
516         pwindow->thread->edl->session->meter_format = METER_DB; 
517         return 1;
520 MeterVUInt::MeterVUInt(PreferencesWindow *pwindow, char *text, int y)
521  : BC_Radial(205, y, pwindow->thread->edl->session->meter_format == METER_INT, text)
523         this->pwindow = pwindow; 
526 int MeterVUInt::handle_event() 
528         pwindow->thread->redraw_meters = 1;
529         vu_db->update(0); 
530         pwindow->thread->edl->session->meter_format = METER_INT; 
531         return 1;
537 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
538  : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
540         this->pwindow = pwindow;
542 ViewTheme::~ViewTheme()
546 void ViewTheme::create_objects()
548         ArrayList<PluginServer*> themes;
549         pwindow->mwindow->create_plugindb(0, 
550                 0, 
551                 0, 
552                 0,
553                 1,
554                 themes);
556         for(int i = 0; i < themes.total; i++)
557         {
558                 add_item(new ViewThemeItem(this, themes.values[i]->title));
559         }
562 int ViewTheme::handle_event()
564         return 1;
571 ViewThemeItem::ViewThemeItem(ViewTheme *popup, char *text)
572  : BC_MenuItem(text)
574         this->popup = popup;
577 int ViewThemeItem::handle_event()
579         popup->set_text(get_text());
580         strcpy(popup->pwindow->thread->preferences->theme, get_text());
581         popup->handle_event();
582         return 1;
585 ViewThumbnails::ViewThumbnails(int x, 
586         int y, 
587         PreferencesWindow *pwindow)
588  : BC_CheckBox(x, 
589         y, 
590         pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
592         this->pwindow = pwindow;
595 int ViewThumbnails::handle_event()
597         pwindow->thread->preferences->use_thumbnails = get_value();
598         return 1;
603 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
604  : BC_CheckBox(x, 
605         y, 
606         pwindow->thread->preferences->use_tipwindow, 
607         _("Show tip of the day"))
609         this->pwindow = pwindow;
611 int UseTipWindow::handle_event()
613         pwindow->thread->preferences->use_tipwindow = get_value();
614         return 1;