r105: This commit was manufactured by cvs2svn to create tag
[cinelerra_cv/mob.git] / hvirtual / cinelerra / interfaceprefs.C
blob3efe7b22ab3ddf2ed503ea981d31781054507f30
1 #include "deleteallindexes.h"
2 #include "edl.h"
3 #include "edlsession.h"
4 #include "mwindow.h"
5 #include "preferences.h"
6 #include "preferencesthread.h"
7 #include "interfaceprefs.h"
9 #include <libintl.h>
10 #define _(String) gettext(String)
11 #define gettext_noop(String) String
12 #define N_(String) gettext_noop (String)
14 #if 0
15 N_("Drag all following edits")
16 N_("Drag only one edit")
17 N_("Drag source only")
18 N_("No effect")
19 #endif
21 #define MOVE_ALL_EDITS_TITLE "Drag all following edits"
22 #define MOVE_ONE_EDIT_TITLE "Drag only one edit"
23 #define MOVE_NO_EDITS_TITLE "Drag source only"
24 #define MOVE_EDITS_DISABLED_TITLE "No effect"
26 InterfacePrefs::InterfacePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
27  : PreferencesDialog(mwindow, pwindow)
31 int InterfacePrefs::create_objects()
33         int y = 5, x = 5, value;
34         char string[1024];
35 //      add_border(get_resources()->get_bg_shadow1(),
36 //              get_resources()->get_bg_shadow2(),
37 //              get_resources()->get_bg_color(),
38 //              get_resources()->get_bg_light2(),
39 //              get_resources()->get_bg_light1());
40         add_subwindow(new BC_Title(x, y, _("Interface"), LARGEFONT, BLACK));
43         y += 35;
44         add_subwindow(hms = new TimeFormatHMS(pwindow, 
45                 this, 
46                 pwindow->thread->edl->session->time_format == 0, 
47                 x, 
48                 y));
49         y += 20;
50         add_subwindow(hmsf = new TimeFormatHMSF(pwindow, 
51                 this, 
52                 pwindow->thread->edl->session->time_format == 1, 
53                 x, 
54                 y));
55         y += 20;
56         add_subwindow(samples = new TimeFormatSamples(pwindow, 
57                 this, 
58                 pwindow->thread->edl->session->time_format == 2, 
59                 x, 
60                 y));
61         y += 20;
62         add_subwindow(hex = new TimeFormatHex(pwindow, 
63                 this, 
64                 pwindow->thread->edl->session->time_format == 3, 
65                 x, 
66                 y));
67         y += 20;
68         add_subwindow(frames = new TimeFormatFrames(pwindow, 
69                 this, 
70                 pwindow->thread->edl->session->time_format == 4, 
71                 x, 
72                 y));
73         y += 20;
74         add_subwindow(feet = new TimeFormatFeet(pwindow, 
75                 this, 
76                 pwindow->thread->edl->session->time_format == 5, 
77                 x, 
78                 y));
79         add_subwindow(new BC_Title(260, y, _("frames per foot")));
80         sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
81         add_subwindow(new TimeFormatFeetSetting(pwindow, 
82                 x + 155, 
83                 y - 5, 
84                 string));
87         y += 35;
89         add_subwindow(new BC_Title(x, y, _("Index files"), LARGEFONT, BLACK));
92         y += 35;
93         add_subwindow(new BC_Title(x, 
94                 y + 5, 
95                 _("Index files go here:"), MEDIUMFONT, BLACK));
96         add_subwindow(ipathtext = new IndexPathText(x + 230, 
97                 y, 
98                 pwindow, 
99                 pwindow->thread->preferences->index_directory));
100         add_subwindow(ipath = new BrowseButton(mwindow,
101                 this,
102                 ipathtext, 
103                 x + 230 + ipathtext->get_w(), 
104                 y, 
105                 pwindow->thread->preferences->index_directory,
106                 _("Index Path"), 
107                 _("Select the directory for index files"),
108                 1));
110         y += 30;
111         add_subwindow(new BC_Title(x, 
112                 y + 5, 
113                 _("Size of index file:"), 
114                 MEDIUMFONT, 
115                 BLACK));
116         sprintf(string, "%ld", pwindow->thread->preferences->index_size);
117         add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
118         y += 30;
119         add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"), MEDIUMFONT, BLACK));
120         sprintf(string, "%ld", pwindow->thread->preferences->index_count);
121         add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
122         add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 350, y));
128         y += 35;
130         add_subwindow(new BC_Title(x, y, _("Editing"), LARGEFONT, BLACK));
133         y += 35;
134         add_subwindow(thumbnails = new ViewThumbnails(x, y, pwindow));
136         y += 35;
137         add_subwindow(new BC_Title(x, y, _("Clicking on in/out points does what:")));
138         y += 25;
139         add_subwindow(new BC_Title(x, y, _("Button 1:")));
140         
141         ViewBehaviourText *text;
142         add_subwindow(text = new ViewBehaviourText(80, 
143                 y - 5, 
144                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]), 
145                         pwindow, 
146                         &(pwindow->thread->edl->session->edit_handle_mode[0])));
147         text->create_objects();
148         y += 30;
149         add_subwindow(new BC_Title(x, y, _("Button 2:")));
150         add_subwindow(text = new ViewBehaviourText(80, 
151                 y - 5, 
152                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]), 
153                         pwindow, 
154                         &(pwindow->thread->edl->session->edit_handle_mode[1])));
155         text->create_objects();
156         y += 30;
157         add_subwindow(new BC_Title(x, y, _("Button 3:")));
158         add_subwindow(text = new ViewBehaviourText(80, 
159                 y - 5, 
160                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]), 
161                         pwindow, 
162                         &(pwindow->thread->edl->session->edit_handle_mode[2])));
163         text->create_objects();
165         y += 40;
166         add_subwindow(new BC_Title(x, y, _("Min DB for meter:")));
167         sprintf(string, "%.0f", pwindow->thread->edl->session->min_meter_db);
168         add_subwindow(min_db = new MeterMinDB(pwindow, string, y));
169         y += 30;
170         add_subwindow(new BC_Title(x, y, _("Format for meter:")));
171         add_subwindow(vu_db = new MeterVUDB(pwindow, _("DB"), y));
172 //      add_subwindow(vu_int = new MeterVUInt(pwindow, _("Percent of maximum"), y));
173 //      vu_db->vu_int = vu_int;
174 //      vu_int->vu_db = vu_db;
175         
176         y += 30;
177         ViewTheme *theme;
178         add_subwindow(new BC_Title(x, y, _("Theme:")));
179         x += 60;
180         add_subwindow(theme = new ViewTheme(x, y, pwindow));
181         theme->create_objects();
182         return 0;
185 char* InterfacePrefs::behavior_to_text(int mode)
187         switch(mode)
188         {
189                 case MOVE_ALL_EDITS:
190                         return _(MOVE_ALL_EDITS_TITLE);
191                         break;
192                 case MOVE_ONE_EDIT:
193                         return _(MOVE_ONE_EDIT_TITLE);
194                         break;
195                 case MOVE_NO_EDITS:
196                         return _(MOVE_NO_EDITS_TITLE);
197                         break;
198                 case MOVE_EDITS_DISABLED:
199                         return _(MOVE_EDITS_DISABLED_TITLE);
200                         break;
201                 default:
202                         return "";
203                         break;
204         }
207 int InterfacePrefs::update(int new_value)
209         pwindow->thread->redraw_times = 1;
210         pwindow->thread->edl->session->time_format = new_value;
211         hms->update(new_value == 0);
212         hmsf->update(new_value == 1);
213         samples->update(new_value == 2);
214         hex->update(new_value == 3);
215         frames->update(new_value == 4);
216         feet->update(new_value == 5);
219 InterfacePrefs::~InterfacePrefs()
221         delete hms;
222         delete hmsf;
223         delete samples;
224         delete frames;
225         delete hex;
226         delete feet;
227         delete min_db;
228         delete vu_db;
229 //      delete vu_int;
230         delete thumbnails;
248 IndexPathText::IndexPathText(int x, 
249         int y, 
250         PreferencesWindow *pwindow, 
251         char *text)
252  : BC_TextBox(x, y, 240, 1, text)
254         this->pwindow = pwindow; 
257 IndexPathText::~IndexPathText() {}
259 int IndexPathText::handle_event()
261         strcpy(pwindow->thread->preferences->index_directory, get_text());
267 IndexSize::IndexSize(int x, 
268         int y, 
269         PreferencesWindow *pwindow, 
270         char *text)
271  : BC_TextBox(x, y, 100, 1, text)
273         this->pwindow = pwindow; 
276 int IndexSize::handle_event()
278         long result;
280         result = atol(get_text());
281         if(result < 64000) result = 64000;
282         //if(result < 500000) result = 500000;
283         pwindow->thread->preferences->index_size = result;
284         return 0;
289 IndexCount::IndexCount(int x, 
290         int y, 
291         PreferencesWindow *pwindow, 
292         char *text)
293  : BC_TextBox(x, y, 100, 1, text)
295         this->pwindow = pwindow; 
298 int IndexCount::handle_event()
300         long result;
302         result = atol(get_text());
303         if(result < 1) result = 1;
304         pwindow->thread->preferences->index_count = result;
305         return 0;
322 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
323  : BC_Radial(x, y, value, _("Use Hours:Minutes:Seconds.xxx"))
324 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
326 int TimeFormatHMS::handle_event()
328         tfwindow->update(0);
329         return 1;
332 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
333  : BC_Radial(x, y, value, _("Use Hours:Minutes:Seconds:Frames"))
334 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
336 int TimeFormatHMSF::handle_event()
338         tfwindow->update(1);
341 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
342  : BC_Radial(x, y, value, _("Use Samples"))
343 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
345 int TimeFormatSamples::handle_event()
347         tfwindow->update(2);
350 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
351  : BC_Radial(x, y, value, _("Use Frames"))
352 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
354 int TimeFormatFrames::handle_event()
356         tfwindow->update(4);
359 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
360  : BC_Radial(x, y, value, _("Use Hex Samples"))
361 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
363 int TimeFormatHex::handle_event()
365         tfwindow->update(3);
368 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
369  : BC_Radial(x, y, value, _("Use Feet-frames"))
370 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
372 int TimeFormatFeet::handle_event()
374         tfwindow->update(5);
377 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
378  : BC_TextBox(x, y, 90, 1, string)
379 { this->pwindow = pwindow; }
381 int TimeFormatFeetSetting::handle_event()
383         pwindow->thread->edl->session->frames_per_foot = atof(get_text());
384         if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
385         return 0;
391 ViewBehaviourText::ViewBehaviourText(int x, 
392         int y, 
393         char *text, 
394         PreferencesWindow *pwindow, 
395         int *output)
396  : BC_PopupMenu(x, y, 200, text)
398         this->output = output;
401 ViewBehaviourText::~ViewBehaviourText()
405 int ViewBehaviourText::handle_event()
409 int ViewBehaviourText::create_objects()
411 // Video4linux versions are automatically detected
412         add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
413         add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
414         add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
415         add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
416         return 0;
420 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
421  : BC_MenuItem(text)
423         this->popup = popup;
424         this->behaviour = behaviour;
427 ViewBehaviourItem::~ViewBehaviourItem()
431 int ViewBehaviourItem::handle_event()
433         popup->set_text(get_text());
434         *(popup->output) = behaviour;
440 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int y)
441  : BC_TextBox(145, y, 50, 1, text)
442 { this->pwindow = pwindow; }
444 int MeterMinDB::handle_event()
446         pwindow->thread->redraw_meters = 1;
447         pwindow->thread->edl->session->min_meter_db = atol(get_text()); 
448         return 0;
456 MeterVUDB::MeterVUDB(PreferencesWindow *pwindow, char *text, int y)
457  : BC_Radial(145, y, pwindow->thread->edl->session->meter_format == METER_DB, text)
459         this->pwindow = pwindow; 
462 int MeterVUDB::handle_event() 
464         pwindow->thread->redraw_meters = 1;
465 //      vu_int->update(0); 
466         pwindow->thread->edl->session->meter_format = METER_DB; 
467         return 1;
470 MeterVUInt::MeterVUInt(PreferencesWindow *pwindow, char *text, int y)
471  : BC_Radial(205, y, pwindow->thread->edl->session->meter_format == METER_INT, text)
473         this->pwindow = pwindow; 
476 int MeterVUInt::handle_event() 
478         pwindow->thread->redraw_meters = 1;
479         vu_db->update(0); 
480         pwindow->thread->edl->session->meter_format = METER_INT; 
481         return 1;
487 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
488  : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
490         this->pwindow = pwindow;
492 ViewTheme::~ViewTheme()
496 void ViewTheme::create_objects()
498         ArrayList<PluginServer*> themes;
499         pwindow->mwindow->create_plugindb(0, 
500                 0, 
501                 0, 
502                 0,
503                 1,
504                 themes);
506         for(int i = 0; i < themes.total; i++)
507         {
508                 add_item(new ViewThemeItem(this, themes.values[i]->title));
509         }
512 int ViewTheme::handle_event()
514         return 1;
521 ViewThemeItem::ViewThemeItem(ViewTheme *popup, char *text)
522  : BC_MenuItem(text)
524         this->popup = popup;
527 int ViewThemeItem::handle_event()
529         popup->set_text(get_text());
530         strcpy(popup->pwindow->thread->preferences->theme, get_text());
531         popup->handle_event();
532         return 1;
535 ViewThumbnails::ViewThumbnails(int x, 
536         int y, 
537         PreferencesWindow *pwindow)
538  : BC_CheckBox(x, 
539         y, 
540         pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
542         this->pwindow = pwindow;
545 int ViewThumbnails::handle_event()
547         pwindow->thread->preferences->use_thumbnails = get_value();
548         return 1;