r632: Boost up the requirement for mjpegtools to 1.6.3
[cinelerra_cv/mob.git] / cinelerra / interfaceprefs.C
blob04c9e916cd5f5aab8212528c5f7beaa1b13a7902
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 == TIME_HMS, 
43                 x, 
44                 y));
45         y += 20;
46         add_subwindow(hmsf = new TimeFormatHMSF(pwindow, 
47                 this, 
48                 pwindow->thread->edl->session->time_format == TIME_HMSF, 
49                 x, 
50                 y));
51         y += 20;
52         add_subwindow(samples = new TimeFormatSamples(pwindow, 
53                 this, 
54                 pwindow->thread->edl->session->time_format == TIME_SAMPLES, 
55                 x, 
56                 y));
57         y += 20;
58         add_subwindow(hex = new TimeFormatHex(pwindow, 
59                 this, 
60                 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX, 
61                 x, 
62                 y));
63         y += 20;
64         add_subwindow(frames = new TimeFormatFrames(pwindow, 
65                 this, 
66                 pwindow->thread->edl->session->time_format == TIME_FRAMES, 
67                 x, 
68                 y));
69         y += 20;
70         add_subwindow(feet = new TimeFormatFeet(pwindow, 
71                 this, 
72                 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES, 
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));
81         y += 20;
82         add_subwindow(seconds = new TimeFormatSeconds(pwindow, 
83                 this, 
84                 pwindow->thread->edl->session->time_format == TIME_SECONDS, 
85                 x, 
86                 y));
89         y += 35;
91         add_subwindow(new BC_Title(x, y, _("Index files"), LARGEFONT, BLACK));
94         y += 35;
95         add_subwindow(new BC_Title(x, 
96                 y + 5, 
97                 _("Index files go here:"), MEDIUMFONT, BLACK));
98         add_subwindow(ipathtext = new IndexPathText(x + 230, 
99                 y, 
100                 pwindow, 
101                 pwindow->thread->preferences->index_directory));
102         add_subwindow(ipath = new BrowseButton(mwindow,
103                 this,
104                 ipathtext, 
105                 x + 230 + ipathtext->get_w(), 
106                 y, 
107                 pwindow->thread->preferences->index_directory,
108                 _("Index Path"), 
109                 _("Select the directory for index files"),
110                 1));
112         y += 30;
113         add_subwindow(new BC_Title(x, 
114                 y + 5, 
115                 _("Size of index file:"), 
116                 MEDIUMFONT, 
117                 BLACK));
118         sprintf(string, "%ld", pwindow->thread->preferences->index_size);
119         add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
120         y += 30;
121         add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"), MEDIUMFONT, BLACK));
122         sprintf(string, "%ld", pwindow->thread->preferences->index_count);
123         add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
124         add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 350, y));
130         y += 35;
132         add_subwindow(new BC_Title(x, y, _("Editing"), LARGEFONT, BLACK));
135         y += 35;
136         add_subwindow(thumbnails = new ViewThumbnails(x, y, pwindow));
138         y += 35;
139         add_subwindow(new BC_Title(x, y, _("Clicking on in/out points does what:")));
140         y += 25;
141         add_subwindow(new BC_Title(x, y, _("Button 1:")));
142         
143         ViewBehaviourText *text;
144         add_subwindow(text = new ViewBehaviourText(80, 
145                 y - 5, 
146                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]), 
147                         pwindow, 
148                         &(pwindow->thread->edl->session->edit_handle_mode[0])));
149         text->create_objects();
150         y += 30;
151         add_subwindow(new BC_Title(x, y, _("Button 2:")));
152         add_subwindow(text = new ViewBehaviourText(80, 
153                 y - 5, 
154                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]), 
155                         pwindow, 
156                         &(pwindow->thread->edl->session->edit_handle_mode[1])));
157         text->create_objects();
158         y += 30;
159         add_subwindow(new BC_Title(x, y, _("Button 3:")));
160         add_subwindow(text = new ViewBehaviourText(80, 
161                 y - 5, 
162                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]), 
163                         pwindow, 
164                         &(pwindow->thread->edl->session->edit_handle_mode[2])));
165         text->create_objects();
167         y += 40;
168         int x1 = x;
169         BC_Title *title;
170         add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
171         x += title->get_w() + 10;
172         sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
173         add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
175         x += min_db->get_w() + 10;
176         add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
177         x += title->get_w() + 10;
178         sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
179         add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
181         x = x1;
182         y += 20;
183         ViewTheme *theme;
184         add_subwindow(new BC_Title(x, y, _("Theme:")));
185         x += 60;
186         add_subwindow(theme = new ViewTheme(x, y, pwindow));
187         theme->create_objects();
188         return 0;
191 char* InterfacePrefs::behavior_to_text(int mode)
193         switch(mode)
194         {
195                 case MOVE_ALL_EDITS:
196                         return _(MOVE_ALL_EDITS_TITLE);
197                         break;
198                 case MOVE_ONE_EDIT:
199                         return _(MOVE_ONE_EDIT_TITLE);
200                         break;
201                 case MOVE_NO_EDITS:
202                         return _(MOVE_NO_EDITS_TITLE);
203                         break;
204                 case MOVE_EDITS_DISABLED:
205                         return _(MOVE_EDITS_DISABLED_TITLE);
206                         break;
207                 default:
208                         return "";
209                         break;
210         }
213 int InterfacePrefs::update(int new_value)
215         pwindow->thread->redraw_times = 1;
216         pwindow->thread->edl->session->time_format = new_value;
217         hms->update(new_value == TIME_HMS);
218         hmsf->update(new_value == TIME_HMSF);
219         samples->update(new_value == TIME_SAMPLES);
220         hex->update(new_value == TIME_SAMPLES_HEX);
221         frames->update(new_value == TIME_FRAMES);
222         feet->update(new_value == TIME_FEET_FRAMES);
223         seconds->update(new_value == TIME_SECONDS);
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(TIME_HMS);
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(TIME_HMSF);
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(TIME_SAMPLES);
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(TIME_FRAMES);
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(TIME_SAMPLES_HEX);
376 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
377  : BC_Radial(x, y, value, _("Use Seconds"))
379         this->pwindow = pwindow; 
380         this->tfwindow = tfwindow; 
383 int TimeFormatSeconds::handle_event()
385         tfwindow->update(TIME_SECONDS);
388 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
389  : BC_Radial(x, y, value, _("Use Feet-frames"))
390 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
392 int TimeFormatFeet::handle_event()
394         tfwindow->update(TIME_FEET_FRAMES);
397 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
398  : BC_TextBox(x, y, 90, 1, string)
399 { this->pwindow = pwindow; }
401 int TimeFormatFeetSetting::handle_event()
403         pwindow->thread->edl->session->frames_per_foot = atof(get_text());
404         if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
405         return 0;
411 ViewBehaviourText::ViewBehaviourText(int x, 
412         int y, 
413         char *text, 
414         PreferencesWindow *pwindow, 
415         int *output)
416  : BC_PopupMenu(x, y, 200, text)
418         this->output = output;
421 ViewBehaviourText::~ViewBehaviourText()
425 int ViewBehaviourText::handle_event()
429 int ViewBehaviourText::create_objects()
431 // Video4linux versions are automatically detected
432         add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
433         add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
434         add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
435         add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
436         return 0;
440 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
441  : BC_MenuItem(text)
443         this->popup = popup;
444         this->behaviour = behaviour;
447 ViewBehaviourItem::~ViewBehaviourItem()
451 int ViewBehaviourItem::handle_event()
453         popup->set_text(get_text());
454         *(popup->output) = behaviour;
460 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
461  : BC_TextBox(x, y, 50, 1, text)
463         this->pwindow = pwindow; 
466 int MeterMinDB::handle_event()
468         pwindow->thread->redraw_meters = 1;
469         pwindow->thread->edl->session->min_meter_db = atol(get_text()); 
470         return 0;
476 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
477  : BC_TextBox(x, y, 50, 1, text)
479         this->pwindow = pwindow; 
482 int MeterMaxDB::handle_event()
484         pwindow->thread->redraw_meters = 1;
485         pwindow->thread->edl->session->max_meter_db = atol(get_text()); 
486         return 0;
493 MeterVUDB::MeterVUDB(PreferencesWindow *pwindow, char *text, int y)
494  : BC_Radial(145, y, pwindow->thread->edl->session->meter_format == METER_DB, text)
496         this->pwindow = pwindow; 
499 int MeterVUDB::handle_event() 
501         pwindow->thread->redraw_meters = 1;
502 //      vu_int->update(0); 
503         pwindow->thread->edl->session->meter_format = METER_DB; 
504         return 1;
507 MeterVUInt::MeterVUInt(PreferencesWindow *pwindow, char *text, int y)
508  : BC_Radial(205, y, pwindow->thread->edl->session->meter_format == METER_INT, text)
510         this->pwindow = pwindow; 
513 int MeterVUInt::handle_event() 
515         pwindow->thread->redraw_meters = 1;
516         vu_db->update(0); 
517         pwindow->thread->edl->session->meter_format = METER_INT; 
518         return 1;
524 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
525  : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
527         this->pwindow = pwindow;
529 ViewTheme::~ViewTheme()
533 void ViewTheme::create_objects()
535         ArrayList<PluginServer*> themes;
536         pwindow->mwindow->create_plugindb(0, 
537                 0, 
538                 0, 
539                 0,
540                 1,
541                 themes);
543         for(int i = 0; i < themes.total; i++)
544         {
545                 add_item(new ViewThemeItem(this, themes.values[i]->title));
546         }
549 int ViewTheme::handle_event()
551         return 1;
558 ViewThemeItem::ViewThemeItem(ViewTheme *popup, char *text)
559  : BC_MenuItem(text)
561         this->popup = popup;
564 int ViewThemeItem::handle_event()
566         popup->set_text(get_text());
567         strcpy(popup->pwindow->thread->preferences->theme, get_text());
568         popup->handle_event();
569         return 1;
572 ViewThumbnails::ViewThumbnails(int x, 
573         int y, 
574         PreferencesWindow *pwindow)
575  : BC_CheckBox(x, 
576         y, 
577         pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
579         this->pwindow = pwindow;
582 int ViewThumbnails::handle_event()
584         pwindow->thread->preferences->use_thumbnails = get_value();
585         return 1;