r802: Remove renderframfsclient and renderfarmfsserver .h and .C from Makefile.am...
[cinelerra_cv/mob.git] / cinelerra / interfaceprefs.C
blobc3f916fa6d79629af12273be75f835a1de9151ec
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         add_subwindow(new BC_Title(mwindow->theme->preferencestitle_x, 
34                 mwindow->theme->preferencestitle_y, 
35                 _("Interface"), 
36                 LARGEFONT, 
37                 resources->text_default));
40         x = mwindow->theme->preferencesoptions_x;
41         y = mwindow->theme->preferencesoptions_y;
43         add_subwindow(hms = new TimeFormatHMS(pwindow, 
44                 this, 
45                 pwindow->thread->edl->session->time_format == TIME_HMS, 
46                 x, 
47                 y));
48         y += 20;
49         add_subwindow(hmsf = new TimeFormatHMSF(pwindow, 
50                 this, 
51                 pwindow->thread->edl->session->time_format == TIME_HMSF, 
52                 x, 
53                 y));
54         y += 20;
55         add_subwindow(samples = new TimeFormatSamples(pwindow, 
56                 this, 
57                 pwindow->thread->edl->session->time_format == TIME_SAMPLES, 
58                 x, 
59                 y));
60         y += 20;
61         add_subwindow(hex = new TimeFormatHex(pwindow, 
62                 this, 
63                 pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX, 
64                 x, 
65                 y));
66         y += 20;
67         add_subwindow(frames = new TimeFormatFrames(pwindow, 
68                 this, 
69                 pwindow->thread->edl->session->time_format == TIME_FRAMES, 
70                 x, 
71                 y));
72         y += 20;
73         add_subwindow(feet = new TimeFormatFeet(pwindow, 
74                 this, 
75                 pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES, 
76                 x, 
77                 y));
78         add_subwindow(new BC_Title(260, y, _("frames per foot")));
79         sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
80         add_subwindow(new TimeFormatFeetSetting(pwindow, 
81                 x + 155, 
82                 y - 5, 
83                 string));
84         y += 20;
85         add_subwindow(seconds = new TimeFormatSeconds(pwindow, 
86                 this, 
87                 pwindow->thread->edl->session->time_format == TIME_SECONDS, 
88                 x, 
89                 y));
92         y += 35;
93         add_subwindow(new UseTipWindow(pwindow, x, y));
95         y += 35;
96         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
97         y += 5;
99         add_subwindow(new BC_Title(x, y, _("Index files"), LARGEFONT, resources->text_default));
102         y += 35;
103         add_subwindow(new BC_Title(x, 
104                 y + 5, 
105                 _("Index files go here:"), MEDIUMFONT, resources->text_default));
106         add_subwindow(ipathtext = new IndexPathText(x + 230, 
107                 y, 
108                 pwindow, 
109                 pwindow->thread->preferences->index_directory));
110         add_subwindow(ipath = new BrowseButton(mwindow,
111                 this,
112                 ipathtext, 
113                 x + 230 + ipathtext->get_w(), 
114                 y, 
115                 pwindow->thread->preferences->index_directory,
116                 _("Index Path"), 
117                 _("Select the directory for index files"),
118                 1));
120         y += 30;
121         add_subwindow(new BC_Title(x, 
122                 y + 5, 
123                 _("Size of index file:"), 
124                 MEDIUMFONT, 
125                 resources->text_default));
126         sprintf(string, "%ld", pwindow->thread->preferences->index_size);
127         add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
128         y += 30;
129         add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"), MEDIUMFONT, resources->text_default));
130         sprintf(string, "%ld", pwindow->thread->preferences->index_count);
131         add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
132         add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 350, y));
138         y += 35;
139         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
140         y += 5;
142         add_subwindow(new BC_Title(x, y, _("Editing"), LARGEFONT, resources->text_default));
145         y += 35;
146         add_subwindow(thumbnails = new ViewThumbnails(x, y, pwindow));
148         y += 35;
149         add_subwindow(new BC_Title(x, y, _("Clicking on in/out points does what:")));
150         y += 25;
151         add_subwindow(new BC_Title(x, y, _("Button 1:")));
152         
153         ViewBehaviourText *text;
154         add_subwindow(text = new ViewBehaviourText(80, 
155                 y - 5, 
156                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]), 
157                         pwindow, 
158                         &(pwindow->thread->edl->session->edit_handle_mode[0])));
159         text->create_objects();
160         y += 30;
161         add_subwindow(new BC_Title(x, y, _("Button 2:")));
162         add_subwindow(text = new ViewBehaviourText(80, 
163                 y - 5, 
164                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]), 
165                         pwindow, 
166                         &(pwindow->thread->edl->session->edit_handle_mode[1])));
167         text->create_objects();
168         y += 30;
169         add_subwindow(new BC_Title(x, y, _("Button 3:")));
170         add_subwindow(text = new ViewBehaviourText(80, 
171                 y - 5, 
172                 behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]), 
173                         pwindow, 
174                         &(pwindow->thread->edl->session->edit_handle_mode[2])));
175         text->create_objects();
177         y += 40;
178         int x1 = x;
179         BC_Title *title;
180         add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
181         x += title->get_w() + 10;
182         sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
183         add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));
185         x += min_db->get_w() + 10;
186         add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
187         x += title->get_w() + 10;
188         sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
189         add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));
191         x = x1;
192         y += 20;
193         ViewTheme *theme;
194         add_subwindow(new BC_Title(x, y, _("Theme:")));
195         x += 60;
196         add_subwindow(theme = new ViewTheme(x, y, pwindow));
197         theme->create_objects();
199         return 0;
202 char* InterfacePrefs::behavior_to_text(int mode)
204         switch(mode)
205         {
206                 case MOVE_ALL_EDITS:
207                         return _(MOVE_ALL_EDITS_TITLE);
208                         break;
209                 case MOVE_ONE_EDIT:
210                         return _(MOVE_ONE_EDIT_TITLE);
211                         break;
212                 case MOVE_NO_EDITS:
213                         return _(MOVE_NO_EDITS_TITLE);
214                         break;
215                 case MOVE_EDITS_DISABLED:
216                         return _(MOVE_EDITS_DISABLED_TITLE);
217                         break;
218                 default:
219                         return "";
220                         break;
221         }
224 int InterfacePrefs::update(int new_value)
226         pwindow->thread->redraw_times = 1;
227         pwindow->thread->edl->session->time_format = new_value;
228         hms->update(new_value == TIME_HMS);
229         hmsf->update(new_value == TIME_HMSF);
230         samples->update(new_value == TIME_SAMPLES);
231         hex->update(new_value == TIME_SAMPLES_HEX);
232         frames->update(new_value == TIME_FRAMES);
233         feet->update(new_value == TIME_FEET_FRAMES);
234         seconds->update(new_value == TIME_SECONDS);
237 InterfacePrefs::~InterfacePrefs()
239         delete hms;
240         delete hmsf;
241         delete samples;
242         delete frames;
243         delete hex;
244         delete feet;
245         delete min_db;
246         delete max_db;
247 //      delete vu_db;
248 //      delete vu_int;
249         delete thumbnails;
267 IndexPathText::IndexPathText(int x, 
268         int y, 
269         PreferencesWindow *pwindow, 
270         char *text)
271  : BC_TextBox(x, y, 240, 1, text)
273         this->pwindow = pwindow; 
276 IndexPathText::~IndexPathText() {}
278 int IndexPathText::handle_event()
280         strcpy(pwindow->thread->preferences->index_directory, get_text());
286 IndexSize::IndexSize(int x, 
287         int y, 
288         PreferencesWindow *pwindow, 
289         char *text)
290  : BC_TextBox(x, y, 100, 1, text)
292         this->pwindow = pwindow; 
295 int IndexSize::handle_event()
297         long result;
299         result = atol(get_text());
300         if(result < 64000) result = 64000;
301         //if(result < 500000) result = 500000;
302         pwindow->thread->preferences->index_size = result;
303         return 0;
308 IndexCount::IndexCount(int x, 
309         int y, 
310         PreferencesWindow *pwindow, 
311         char *text)
312  : BC_TextBox(x, y, 100, 1, text)
314         this->pwindow = pwindow; 
317 int IndexCount::handle_event()
319         long result;
321         result = atol(get_text());
322         if(result < 1) result = 1;
323         pwindow->thread->preferences->index_count = result;
324         return 0;
341 TimeFormatHMS::TimeFormatHMS(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
342  : BC_Radial(x, y, value, _("Use Hours:Minutes:Seconds.xxx"))
343 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
345 int TimeFormatHMS::handle_event()
347         tfwindow->update(TIME_HMS);
348         return 1;
351 TimeFormatHMSF::TimeFormatHMSF(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
352  : BC_Radial(x, y, value, _("Use Hours:Minutes:Seconds:Frames"))
353 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
355 int TimeFormatHMSF::handle_event()
357         tfwindow->update(TIME_HMSF);
360 TimeFormatSamples::TimeFormatSamples(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
361  : BC_Radial(x, y, value, _("Use Samples"))
362 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
364 int TimeFormatSamples::handle_event()
366         tfwindow->update(TIME_SAMPLES);
369 TimeFormatFrames::TimeFormatFrames(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
370  : BC_Radial(x, y, value, _("Use Frames"))
371 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
373 int TimeFormatFrames::handle_event()
375         tfwindow->update(TIME_FRAMES);
378 TimeFormatHex::TimeFormatHex(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
379  : BC_Radial(x, y, value, _("Use Hex Samples"))
380 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
382 int TimeFormatHex::handle_event()
384         tfwindow->update(TIME_SAMPLES_HEX);
387 TimeFormatSeconds::TimeFormatSeconds(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
388  : BC_Radial(x, y, value, _("Use Seconds"))
390         this->pwindow = pwindow; 
391         this->tfwindow = tfwindow; 
394 int TimeFormatSeconds::handle_event()
396         tfwindow->update(TIME_SECONDS);
399 TimeFormatFeet::TimeFormatFeet(PreferencesWindow *pwindow, InterfacePrefs *tfwindow, int value, int x, int y)
400  : BC_Radial(x, y, value, _("Use Feet-frames"))
401 { this->pwindow = pwindow; this->tfwindow = tfwindow; }
403 int TimeFormatFeet::handle_event()
405         tfwindow->update(TIME_FEET_FRAMES);
408 TimeFormatFeetSetting::TimeFormatFeetSetting(PreferencesWindow *pwindow, int x, int y, char *string)
409  : BC_TextBox(x, y, 90, 1, string)
410 { this->pwindow = pwindow; }
412 int TimeFormatFeetSetting::handle_event()
414         pwindow->thread->edl->session->frames_per_foot = atof(get_text());
415         if(pwindow->thread->edl->session->frames_per_foot < 1) pwindow->thread->edl->session->frames_per_foot = 1;
416         return 0;
422 ViewBehaviourText::ViewBehaviourText(int x, 
423         int y, 
424         char *text, 
425         PreferencesWindow *pwindow, 
426         int *output)
427  : BC_PopupMenu(x, y, 200, text)
429         this->output = output;
432 ViewBehaviourText::~ViewBehaviourText()
436 int ViewBehaviourText::handle_event()
440 int ViewBehaviourText::create_objects()
442 // Video4linux versions are automatically detected
443         add_item(new ViewBehaviourItem(this, _(MOVE_ALL_EDITS_TITLE), MOVE_ALL_EDITS));
444         add_item(new ViewBehaviourItem(this, _(MOVE_ONE_EDIT_TITLE), MOVE_ONE_EDIT));
445         add_item(new ViewBehaviourItem(this, _(MOVE_NO_EDITS_TITLE), MOVE_NO_EDITS));
446         add_item(new ViewBehaviourItem(this, _(MOVE_EDITS_DISABLED_TITLE), MOVE_EDITS_DISABLED));
447         return 0;
451 ViewBehaviourItem::ViewBehaviourItem(ViewBehaviourText *popup, char *text, int behaviour)
452  : BC_MenuItem(text)
454         this->popup = popup;
455         this->behaviour = behaviour;
458 ViewBehaviourItem::~ViewBehaviourItem()
462 int ViewBehaviourItem::handle_event()
464         popup->set_text(get_text());
465         *(popup->output) = behaviour;
471 MeterMinDB::MeterMinDB(PreferencesWindow *pwindow, char *text, int x, int y)
472  : BC_TextBox(x, y, 50, 1, text)
474         this->pwindow = pwindow; 
477 int MeterMinDB::handle_event()
479         pwindow->thread->redraw_meters = 1;
480         pwindow->thread->edl->session->min_meter_db = atol(get_text()); 
481         return 0;
487 MeterMaxDB::MeterMaxDB(PreferencesWindow *pwindow, char *text, int x, int y)
488  : BC_TextBox(x, y, 50, 1, text)
490         this->pwindow = pwindow; 
493 int MeterMaxDB::handle_event()
495         pwindow->thread->redraw_meters = 1;
496         pwindow->thread->edl->session->max_meter_db = atol(get_text()); 
497         return 0;
504 MeterVUDB::MeterVUDB(PreferencesWindow *pwindow, char *text, int y)
505  : BC_Radial(145, y, pwindow->thread->edl->session->meter_format == METER_DB, text)
507         this->pwindow = pwindow; 
510 int MeterVUDB::handle_event() 
512         pwindow->thread->redraw_meters = 1;
513 //      vu_int->update(0); 
514         pwindow->thread->edl->session->meter_format = METER_DB; 
515         return 1;
518 MeterVUInt::MeterVUInt(PreferencesWindow *pwindow, char *text, int y)
519  : BC_Radial(205, y, pwindow->thread->edl->session->meter_format == METER_INT, text)
521         this->pwindow = pwindow; 
524 int MeterVUInt::handle_event() 
526         pwindow->thread->redraw_meters = 1;
527         vu_db->update(0); 
528         pwindow->thread->edl->session->meter_format = METER_INT; 
529         return 1;
535 ViewTheme::ViewTheme(int x, int y, PreferencesWindow *pwindow)
536  : BC_PopupMenu(x, y, 200, pwindow->thread->preferences->theme, 1)
538         this->pwindow = pwindow;
540 ViewTheme::~ViewTheme()
544 void ViewTheme::create_objects()
546         ArrayList<PluginServer*> themes;
547         pwindow->mwindow->create_plugindb(0, 
548                 0, 
549                 0, 
550                 0,
551                 1,
552                 themes);
554         for(int i = 0; i < themes.total; i++)
555         {
556                 add_item(new ViewThemeItem(this, themes.values[i]->title));
557         }
560 int ViewTheme::handle_event()
562         return 1;
569 ViewThemeItem::ViewThemeItem(ViewTheme *popup, char *text)
570  : BC_MenuItem(text)
572         this->popup = popup;
575 int ViewThemeItem::handle_event()
577         popup->set_text(get_text());
578         strcpy(popup->pwindow->thread->preferences->theme, get_text());
579         popup->handle_event();
580         return 1;
583 ViewThumbnails::ViewThumbnails(int x, 
584         int y, 
585         PreferencesWindow *pwindow)
586  : BC_CheckBox(x, 
587         y, 
588         pwindow->thread->preferences->use_thumbnails, _("Use thumbnails in resource window"))
590         this->pwindow = pwindow;
593 int ViewThumbnails::handle_event()
595         pwindow->thread->preferences->use_thumbnails = get_value();
596         return 1;
601 UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y)
602  : BC_CheckBox(x, 
603         y, 
604         pwindow->thread->preferences->use_tipwindow, 
605         _("Show tip of the day"))
607         this->pwindow = pwindow;
609 int UseTipWindow::handle_event()
611         pwindow->thread->preferences->use_tipwindow = get_value();
612         return 1;