1 #include "aboutprefs.h"
3 #include "audiodevice.inc"
7 #include "cwindowgui.h"
10 #include "edlsession.h"
11 #include "filesystem.h"
13 #include "interfaceprefs.h"
15 #include "levelwindow.h"
16 #include "levelwindowgui.h"
17 #include "meterpanel.h"
19 #include "mwindowgui.h"
21 #include "performanceprefs.h"
22 #include "playbackengine.h"
23 #include "playbackprefs.h"
24 #include "preferences.h"
25 #include "recordprefs.h"
27 #include "trackcanvas.h"
28 #include "transportque.h"
30 #include "vwindowgui.h"
35 #define _(String) gettext(String)
36 #define gettext_noop(String) String
37 #define N_(String) gettext_noop (String)
39 PreferencesMenuitem::PreferencesMenuitem(MWindow *mwindow)
40 : BC_MenuItem(_("Preferences..."), "Shift+P", 'P')
42 this->mwindow = mwindow;
45 thread = new PreferencesThread(mwindow);
48 PreferencesMenuitem::~PreferencesMenuitem()
54 int PreferencesMenuitem::handle_event()
56 if(thread->thread_running) return 1;
64 PreferencesThread::PreferencesThread(MWindow *mwindow)
67 this->mwindow = mwindow;
72 PreferencesThread::~PreferencesThread()
76 void PreferencesThread::run()
80 preferences = new Preferences;
82 edl->create_objects();
83 current_dialog = mwindow->defaults->get("DEFAULTPREF", 0);
84 *preferences = *mwindow->preferences;
85 edl->copy_session(mwindow->edl);
95 window = new PreferencesWindow(mwindow, this);
96 window->create_objects();
98 int result = window->run_window();
104 mwindow->save_defaults();
112 mwindow->defaults->update("DEFAULTPREF", current_dialog);
115 int PreferencesThread::update_framerate()
117 if(thread_running && window)
119 window->update_framerate();
124 int PreferencesThread::apply_settings()
129 AudioOutConfig *this_aconfig = edl->session->playback_config[edl->session->playback_strategy].values[0]->aconfig;
130 VideoOutConfig *this_vconfig = edl->session->playback_config[edl->session->playback_strategy].values[0]->vconfig;
131 AudioOutConfig *aconfig = mwindow->edl->session->playback_config[edl->session->playback_strategy].values[0]->aconfig;
132 VideoOutConfig *vconfig = mwindow->edl->session->playback_config[edl->session->playback_strategy].values[0]->vconfig;
136 (edl->session->playback_preload != mwindow->edl->session->playback_preload) ||
137 (edl->session->interpolation_type != mwindow->edl->session->interpolation_type) ||
138 (edl->session->video_every_frame != mwindow->edl->session->video_every_frame) ||
139 (edl->session->real_time_playback != mwindow->edl->session->real_time_playback) ||
140 (edl->session->playback_software_position != mwindow->edl->session->playback_software_position) ||
141 (edl->session->test_playback_edits != mwindow->edl->session->test_playback_edits) ||
142 (edl->session->playback_buffer != mwindow->edl->session->playback_buffer) ||
143 (edl->session->audio_module_fragment != mwindow->edl->session->audio_module_fragment) ||
144 (edl->session->audio_read_length != mwindow->edl->session->audio_read_length) ||
145 (edl->session->playback_strategy != mwindow->edl->session->playback_strategy) ||
146 (edl->session->force_uniprocessor != mwindow->edl->session->force_uniprocessor) ||
147 (*this_aconfig != *aconfig) ||
148 (*this_vconfig != *vconfig) ||
149 !preferences->brender_asset->equivalent(*mwindow->preferences->brender_asset, 0, 1);
154 // TODO: Need to copy just the parameters in PreferencesThread
155 mwindow->edl->copy_session(edl);
156 *mwindow->preferences = *preferences;
157 mwindow->init_brender();
161 mwindow->cwindow->gui->lock_window();
162 mwindow->cwindow->gui->meters->change_format(edl->session->meter_format,
163 edl->session->min_meter_db);
164 mwindow->cwindow->gui->unlock_window();
168 mwindow->vwindow->gui->lock_window();
169 mwindow->vwindow->gui->meters->change_format(edl->session->meter_format,
170 edl->session->min_meter_db);
171 mwindow->vwindow->gui->unlock_window();
175 mwindow->gui->lock_window();
176 mwindow->gui->patchbay->change_meter_format(edl->session->meter_format,
177 edl->session->min_meter_db);
178 mwindow->gui->unlock_window();
182 mwindow->lwindow->gui->lock_window();
183 mwindow->lwindow->gui->panel->change_format(edl->session->meter_format,
184 edl->session->min_meter_db);
185 mwindow->lwindow->gui->unlock_window();
190 mwindow->gui->lock_window();
191 mwindow->gui->canvas->draw_overlays();
192 mwindow->gui->canvas->flash();
193 mwindow->gui->unlock_window();
198 mwindow->gui->lock_window();
199 mwindow->gui->update(0, 0, 1, 0, 0, 1, 0);
200 mwindow->gui->redraw_time_dependancies();
201 mwindow->gui->unlock_window();
206 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
212 if(redraw_times || redraw_overlays)
214 mwindow->gui->flush();
219 char* PreferencesThread::category_to_text(int category)
224 return _("Playback");
227 return _("Recording");
230 return _("Performance");
233 return _("Interface");
236 // return _("Plugin Set");
245 int PreferencesThread::text_to_category(char *category)
247 int min_result = -1, result, result_num = 0;
248 for(int i = 0; i < CATEGORIES; i++)
250 result = labs(strcmp(category_to_text(i), category));
251 if(result < min_result || min_result < 0)
272 PreferencesWindow::PreferencesWindow(MWindow *mwindow,
273 PreferencesThread *thread)
274 : BC_Window(PROGRAM_NAME ": Preferences",
275 mwindow->gui->get_root_w() / 2 - WIDTH / 2,
276 mwindow->gui->get_root_h() / 2 - HEIGHT / 2,
285 this->mwindow = mwindow;
286 this->thread = thread;
290 PreferencesWindow::~PreferencesWindow()
293 if(dialog) delete dialog;
294 for(int i = 0; i < categories.total; i++)
295 delete categories.values[i];
298 int PreferencesWindow::create_objects()
305 mwindow->theme->draw_preferences_bg(this);
309 //printf("PreferencesWindow::create_objects 1\n");
310 for(int i = 0; i < CATEGORIES; i++)
311 categories.append(new BC_ListBoxItem(thread->category_to_text(i)));
312 // add_subwindow(new BC_Title(x, y, _("Category:"), LARGEFONT_3D, RED));
313 category = new PreferencesCategory(mwindow, thread, x, y);
314 category->create_objects();
316 //printf("PreferencesWindow::create_objects 1\n");
317 y += category->get_h();
319 //printf("PreferencesWindow::create_objects 1\n");
320 add_subwindow(button = new BC_OKButton(this));
321 //printf("PreferencesWindow::create_objects 1\n");
322 add_subwindow(new PreferencesApply(mwindow,
327 //printf("PreferencesWindow::create_objects 1\n");
328 add_subwindow(new BC_CancelButton(this));
330 //printf("PreferencesWindow::create_objects 1\n");
331 set_current_dialog(thread->current_dialog);
332 //printf("PreferencesWindow::create_objects 1\n");
334 //printf("PreferencesWindow::create_objects 2\n");
338 int PreferencesWindow::update_framerate()
341 //printf("PreferencesWindow::update_framerate 1\n");
342 if(thread->current_dialog == 0)
344 //printf("PreferencesWindow::update_framerate 2\n");
345 thread->edl->session->actual_frame_rate =
346 mwindow->edl->session->actual_frame_rate;
347 //printf("PreferencesWindow::update_framerate 3\n");
348 dialog->draw_framerate();
349 //printf("PreferencesWindow::update_framerate 4\n");
352 //printf("PreferencesWindow::update_framerate 5\n");
357 int PreferencesWindow::set_current_dialog(int number)
359 thread->current_dialog = number;
360 if(dialog) delete dialog;
366 add_subwindow(dialog = new PlaybackPrefs(mwindow, this));
370 add_subwindow(dialog = new RecordPrefs(mwindow, this));
374 add_subwindow(dialog = new PerformancePrefs(mwindow, this));
378 add_subwindow(dialog = new InterfacePrefs(mwindow, this));
382 // add_subwindow(dialog = new PluginPrefs(mwindow, this));
386 add_subwindow(dialog = new AboutPrefs(mwindow, this));
391 dialog->draw_top_background(this, 0, 0, dialog->get_w(), dialog->get_h());
393 dialog->create_objects();
398 // ================================== save values
402 PreferencesDialog::PreferencesDialog(MWindow *mwindow, PreferencesWindow *pwindow)
403 : BC_SubWindow(10, 40, pwindow->get_w() - 20, pwindow->get_h() - 100)
405 this->pwindow = pwindow;
406 this->mwindow = mwindow;
407 preferences = pwindow->thread->preferences;
410 PreferencesDialog::~PreferencesDialog()
414 // ============================== category window
419 PreferencesApply::PreferencesApply(MWindow *mwindow, PreferencesThread *thread, int x, int y)
420 : BC_GenericButton(x, y, _("Apply"))
422 this->mwindow = mwindow;
423 this->thread = thread;
426 PreferencesApply::~PreferencesApply()
430 int PreferencesApply::handle_event()
432 thread->apply_settings();
438 PreferencesCategory::PreferencesCategory(MWindow *mwindow, PreferencesThread *thread, int x, int y)
439 : BC_PopupTextBox(thread->window,
440 &thread->window->categories,
441 thread->category_to_text(thread->current_dialog),
447 this->mwindow = mwindow;
448 this->thread = thread;
451 PreferencesCategory::~PreferencesCategory()
455 int PreferencesCategory::handle_event()
457 thread->window->set_current_dialog(thread->text_to_category(get_text()));