r370: Heroine Virutal's official release 1.2.1
[cinelerra_cv/mob.git] / hvirtual / cinelerra / interfaceprefs.C
blobba4552d645d4a149e798b104815743b619d206ca
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"
10 #if 0
11 N_("Drag all following edits")
12 N_("Drag only one edit")
13 N_("Drag source only")
14 N_("No effect")
15 #endif
17 #define MOVE_ALL_EDITS_TITLE "Drag all following edits"
18 #define MOVE_ONE_EDIT_TITLE "Drag only one edit"
19 #define MOVE_NO_EDITS_TITLE "Drag source only"
20 #define MOVE_EDITS_DISABLED_TITLE "No effect"
22 InterfacePrefs::InterfacePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
23  : PreferencesDialog(mwindow, pwindow)
27 int InterfacePrefs::create_objects()
29         int y = 5, x = 5, value;
30         char string[1024];
31 //      add_border(get_resources()->get_bg_shadow1(),
32 //              get_resources()->get_bg_shadow2(),
33 //              get_resources()->get_bg_color(),
34 //              get_resources()->get_bg_light2(),
35 //              get_resources()->get_bg_light1());
36         add_subwindow(new BC_Title(x, y, _("Interface"), LARGEFONT, BLACK));
39         y += 35;
40         add_subwindow(hms = new TimeFormatHMS(pwindow, 
41                 this, 
42                 pwindow->thread->edl->session->time_format == 0, 
43                 x, 
44                 y));
45         y += 20;
46         add_subwindow(hmsf = new TimeFormatHMSF(pwindow, 
47                 this, 
48                 pwindow->thread->edl->session->time_format == 1, 
49                 x, 
50                 y));
51         y += 20;
52         add_subwindow(samples = new TimeFormatSamples(pwindow, 
53                 this, 
54                 pwindow->thread->edl->session->time_format == 2, 
55                 x, 
56                 y));
57         y += 20;
58         add_subwindow(hex = new TimeFormatHex(pwindow, 
59                 this, 
60                 pwindow->thread->edl->session->time_format == 3, 
61                 x, 
62                 y));
63         y += 20;
64         add_subwindow(frames = new TimeFormatFrames(pwindow, 
65                 this, 
66                 pwindow->thread->edl->session->time_format == 4, 
67                 x, 
68                 y));
69         y += 20;
70         add_subwindow(feet = new TimeFormatFeet(pwindow, 
71                 this, 
72                 pwindow->thread->edl->session->time_format == 5, 
73                 x, 
74                 y));
75         add_subwindow(new BC_Title(260, y, _("frames per foot")));
76         sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
77         add_subwindow(new TimeFormatFeetSetting(pwindow, 
78                 x + 155, 
79                 y - 5, 
80                 string));
83         y += 35;
85         add_subwindow(new BC_Title(x, y, _("Index files"), LARGEFONT, BLACK));
88         y += 35;
89         add_subwindow(new BC_Title(x, 
90                 y + 5, 
91                 _("Index files go here:"), MEDIUMFONT, BLACK));
92         add_subwindow(ipathtext = new IndexPathText(x + 230, 
93                 y, 
94                 pwindow, 
95                 pwindow->thread->preferences->index_directory));
96         add_subwindow(ipath = new BrowseButton(mwindow,
97                 this,
98                 ipathtext, 
99                 x + 230 + ipathtext->get_w(), 
100                 y, 
101                 pwindow->thread->preferences->index_directory,
102                 _("Index Path"), 
103                 _("Select the directory for index files"),
104                 1));
106         y += 30;
107         add_subwindow(new BC_Title(x, 
108                 y + 5, 
109                 _("Size of index file:"), 
110                 MEDIUMFONT, 
111                 BLACK));
112         sprintf(string, "%ld", pwindow->thread->preferences->index_size);
113         add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
114         y += 30;
115         add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"), MEDIUMFONT, BLACK));
116         sprintf(string, "%ld", pwindow->thread->preferences->index_count);
117         add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
118         add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 350, y));
124         y += 35;
126         add_subwindow(new BC_Title(x, y, _("Editing"), LARGEFONT, BLACK));
129         y += 35;
130         add_subwindow(thumbnails = new ViewThumbnails(x, y, pwindow));
132         y += 35;
133         add_subwindow(new BC_Title(x, y, _("Clicking on in/out points does what:")));
134         y += 25;
135         add_subwindow(new BC_Title(x, y, _("Button 1:")));
136         
137         ViewBehaviourText *text;
138         add_subwindow(text = new ViewBehaviourText(80, 
139                 y - 5, 
140                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]), 
141                         pwindow, 
142                         &(pwindow->thread->edl->session->edit_handle_mode[0])));
143         text->create_objects();
144         y += 30;
145         add_subwindow(new BC_Title(x, y, _("Button 2:")));
146         add_subwindow(text = new ViewBehaviourText(80, 
147                 y - 5, 
148                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]), 
149                         pwindow, 
150                         &(pwindow->thread->edl->session->edit_handle_mode[1])));
151         text->create_objects();
152         y += 30;
153         add_subwindow(new BC_Title(x, y, _("Button 3:")));
154         add_subwindow(text = new ViewBehaviourText(80, 
155                 y - 5, 
156                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]), 
157                         pwindow, 
158                         &(pwindow->thread->edl->session->edit_handle_mode[2])));
159         text->create_objects();
161         y += 40;
162         int x1 = x;
163         BC_Title *title;
164         add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
165         x += title->get_w() + 10;
166         sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
167         add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
169         x += min_db->get_w() + 10;
170         add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
171         x += title->get_w() + 10;
172         sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
173         add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
175         x = x1;
176         y += 30;
177 //      add_subwindow(new BC_Title(x, y, _("Format for meter:")));
178 //      add_subwindow(vu_db = new MeterVUDB(pwindow, _("DB"), y));
179 //      add_subwindow(vu_int = new MeterVUInt(pwindow, _("Percent of maximum"), y));
180 //      vu_db->vu_int = vu_int;
181 //      vu_int->vu_db = vu_db;
182         
183         y += 30;
184         ViewTheme *theme;
185         add_subwindow(new BC_Title(x, y, _("Theme:")));
186         x += 60;
187         add_subwindow(theme = new ViewTheme(x, y, pwindow));
188         theme->create_objects();
189         return 0;
192 char* InterfacePrefs::behavior_to_text(int mode)
194         switch(mode)
195         {
196                 case MOVE_ALL_EDITS:
197                         return _(MOVE_ALL_EDITS_TITLE);
198                         break;
199                 case MOVE_ONE_EDIT:
200                         return _(MOVE_ONE_EDIT_TITLE);
201                         break;
202                 case MOVE_NO_EDITS:
203                         return _(MOVE_NO_EDITS_TITLE);
204                         break;
205                 case MOVE_EDITS_DISABLED:
206                         return _(MOVE_EDITS_DISABLED_TITLE);
207                         break;
208                 default:
209                         return "";
210                         break;
211         }
214 int InterfacePrefs::update(int new_value)
216         pwindow->thread->redraw_times = 1;
217         pwindow->thread->edl->session->time_format = new_value;
218         hms->update(new_value == 0);
219         hmsf->update(new_value == 1);
220         samples->update(new_value == 2);
221         hex->update(new_value == 3);
222         frames->update(new_value == 4);
223         feet->update(new_value == 5);
226 InterfacePrefs::~InterfacePrefs()
228         delete hms;
229         delete hmsf;
230         delete samples;
231         delete frames;
232         delete hex;
233         delete feet;
234         delete min_db;
235         delete max_db;
236 //      delete vu_db;
237 //      delete vu_int;
238         delete thumbnails;
256 IndexPathText::IndexPathText(int x, 
257         int y, 
258         PreferencesWindow *pwindow, 
259         char *text)
260  : BC_TextBox(x, y, 240, 1, text)
262         this->pwindow = pwindow; 
265 IndexPathText::~IndexPathText() {}
267 int IndexPathText::handle_event()
269         strcpy(pwindow->thread->preferences->index_directory, get_text());
275 IndexSize::IndexSize(int x, 
276         int y, 
277         PreferencesWindow *pwindow, 
278         char *text)
279  : BC_TextBox(x, y, 100, 1, text)
281         this->pwindow = pwindow; 
284 int IndexSize::handle_event()
286         long result;
288         result = atol(get_text());
289         if(result < 64000) result = 64000;
290         //if(result < 500000) result = 500000;
291         pwindow->thread->preferences->index_size = result;
292         return 0;
297 IndexCount::IndexCount(int x, 
298         int y, 
299         PreferencesWindow *pwindow, 
300         char *text)
301  : BC_TextBox(x, y, 100, 1, text)
303         this->pwindow = pwindow; 
306 int IndexCount::handle_event()
308         long result;
310         result = atol(get_text());
311         if(result < 1) result = 1;
312         pwindow->thread->preferences->index_count = result;
313         return 0;
330 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
331  : BC_Radial(x, y, value, _("Use Hours:Minutes:Seconds.xxx"))
332 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
334 int TimeFormatHMS::handle_event()
336         tfwindow->update(0);
337         return 1;
340 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
341  : BC_Radial(x, y, value, _("Use Hours:Minutes:Seconds:Frames"))
342 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
344 int TimeFormatHMSF::handle_event()
346         tfwindow->update(1);
349 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
350  : BC_Radial(x, y, value, _("Use Samples"))
351 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
353 int TimeFormatSamples::handle_event()
355         tfwindow->update(2);
358 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
359  : BC_Radial(x, y, value, _("Use Frames"))
360 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
362 int TimeFormatFrames::handle_event()
364         tfwindow->update(4);
367 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
368  : BC_Radial(x, y, value, _("Use Hex Samples"))
369 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
371 int TimeFormatHex::handle_event()
373         tfwindow->update(3);
376 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
377  : BC_Radial(x, y, value, _("Use Feet-frames"))
378 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
380 int TimeFormatFeet::handle_event()
382         tfwindow->update(5);
385 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
386  : BC_TextBox(x, y, 90, 1, string)
387 { this->pwindow = pwindow; }
389 int TimeFormatFeetSetting::handle_event()
391         pwindow->thread->edl->session->frames_per_foot = atof(get_text());
392         if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
393         return 0;
399 ViewBehaviourText::ViewBehaviourText(int x, 
400         int y, 
401         char *text, 
402         PreferencesWindow *pwindow, 
403         int *output)
404  : BC_PopupMenu(x, y, 200, text)
406         this->output = output;
409 ViewBehaviourText::~ViewBehaviourText()
413 int ViewBehaviourText::handle_event()
417 int ViewBehaviourText::create_objects()
419 // Video4linux versions are automatically detected
420         add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
421         add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
422         add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
423         add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
424         return 0;
428 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
429  : BC_MenuItem(text)
431         this->popup = popup;
432         this->behaviour = behaviour;
435 ViewBehaviourItem::~ViewBehaviourItem()
439 int ViewBehaviourItem::handle_event()
441         popup->set_text(get_text());
442         *(popup->output) = behaviour;
448 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
449  : BC_TextBox(x, y, 50, 1, text)
451         this->pwindow = pwindow; 
454 int MeterMinDB::handle_event()
456         pwindow->thread->redraw_meters = 1;
457         pwindow->thread->edl->session->min_meter_db = atol(get_text()); 
458         return 0;
464 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
465  : BC_TextBox(x, y, 50, 1, text)
467         this->pwindow = pwindow; 
470 int MeterMaxDB::handle_event()
472         pwindow->thread->redraw_meters = 1;
473         pwindow->thread->edl->session->max_meter_db = atol(get_text()); 
474         return 0;
481 MeterVUDB::MeterVUDB(PreferencesWindow *pwindow, char *text, int y)
482  : BC_Radial(145, y, pwindow->thread->edl->session->meter_format == METER_DB, text)
484         this->pwindow = pwindow; 
487 int MeterVUDB::handle_event() 
489         pwindow->thread->redraw_meters = 1;
490 //      vu_int->update(0); 
491         pwindow->thread->edl->session->meter_format = METER_DB; 
492         return 1;
495 MeterVUInt::MeterVUInt(PreferencesWindow *pwindow, char *text, int y)
496  : BC_Radial(205, y, pwindow->thread->edl->session->meter_format == METER_INT, text)
498         this->pwindow = pwindow; 
501 int MeterVUInt::handle_event() 
503         pwindow->thread->redraw_meters = 1;
504         vu_db->update(0); 
505         pwindow->thread->edl->session->meter_format = METER_INT; 
506         return 1;
512 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
513  : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
515         this->pwindow = pwindow;
517 ViewTheme::~ViewTheme()
521 void ViewTheme::create_objects()
523         ArrayList<PluginServer*> themes;
524         pwindow->mwindow->create_plugindb(0, 
525                 0, 
526                 0, 
527                 0,
528                 1,
529                 themes);
531         for(int i = 0; i < themes.total; i++)
532         {
533                 add_item(new ViewThemeItem(this, themes.values[i]->title));
534         }
537 int ViewTheme::handle_event()
539         return 1;
546 ViewThemeItem::ViewThemeItem(ViewTheme *popup, char *text)
547  : BC_MenuItem(text)
549         this->popup = popup;
552 int ViewThemeItem::handle_event()
554         popup->set_text(get_text());
555         strcpy(popup->pwindow->thread->preferences->theme, get_text());
556         popup->handle_event();
557         return 1;
560 ViewThumbnails::ViewThumbnails(int x, 
561         int y, 
562         PreferencesWindow *pwindow)
563  : BC_CheckBox(x, 
564         y, 
565         pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
567         this->pwindow = pwindow;
570 int ViewThumbnails::handle_event()
572         pwindow->thread->preferences->use_thumbnails = get_value();
573         return 1;