4 #include "localsession.h"
5 #include "mainsession.h"
8 #include "mwindowgui.h"
12 #include "plugindialog.h"
13 #include "pluginserver.h"
17 #include "transition.h"
20 PluginDialogThread::PluginDialogThread(MWindow *mwindow)
23 this->mwindow = mwindow;
26 Thread::set_synchronous(0);
27 window_lock = new Mutex("PluginDialogThread::window_lock");
28 completion = new Condition(1, "PluginDialogThread::completion");
31 PluginDialogThread::~PluginDialogThread()
36 completion->lock("PluginDialogThread::~PluginDialogThread");
43 void PluginDialogThread::start_window(Track *track,
49 window_lock->lock("PluginDialogThread::start_window");
52 window->lock_window("PluginDialogThread::start_window");
53 window->raise_window();
55 window->unlock_window();
57 window_lock->unlock();
62 this->data_type = track->data_type;
63 this->plugin = plugin;
67 plugin->calculate_title(plugin_title, 0);
68 this->shared_location = plugin->shared_location;
69 this->plugin_type = plugin->plugin_type;
73 this->plugin_title[0] = 0;
74 this->shared_location.plugin = -1;
75 this->shared_location.module = -1;
76 this->plugin_type = PLUGIN_NONE;
79 strcpy(this->window_title, title);
80 completion->lock("PluginDialogThread::start_window");
86 int PluginDialogThread::set_dialog(Transition *transition, char *title)
91 void PluginDialogThread::run()
95 int x = mwindow->gui->get_abs_cursor_x(1) - mwindow->session->plugindialog_w / 2;
96 int y = mwindow->gui->get_abs_cursor_y(1) - mwindow->session->plugindialog_h / 2;
98 window_lock->lock("PluginDialogThread::run 1");
99 window = new PluginDialog(mwindow, this, window_title, x, y);
100 window->create_objects();
101 window_lock->unlock();
103 result = window->run_window();
106 window_lock->lock("PluginDialogThread::run 2");
109 window_lock->unlock();
111 completion->unlock();
118 mwindow->gui->lock_window("PluginDialogThread::run 3");
123 plugin->change_plugin(plugin_title,
129 mwindow->insert_effect(plugin_title,
139 mwindow->save_backup();
140 mwindow->undo->update_undo(_("attach effect"), LOAD_EDITS | LOAD_PATCHES);
141 mwindow->restart_brender();
142 mwindow->update_plugin_states();
143 mwindow->sync_parameters(CHANGE_EDL);
144 mwindow->gui->update(1,
152 mwindow->gui->unlock_window();
166 PluginDialog::PluginDialog(MWindow *mwindow,
167 PluginDialogThread *thread,
171 : BC_Window(window_title,
174 mwindow->session->plugindialog_w,
175 mwindow->session->plugindialog_h,
182 this->mwindow = mwindow;
183 this->thread = thread;
184 standalone_attach = 0;
187 standalone_change = 0;
193 PluginDialog::~PluginDialog()
196 standalone_data.remove_all_objects();
198 shared_data.remove_all_objects();
200 module_data.remove_all_objects();
202 plugin_locations.remove_all_objects();
204 module_locations.remove_all_objects();
208 delete standalone_list;
211 if(standalone_attach) delete standalone_attach;
212 if(shared_attach) delete shared_attach;
213 if(module_attach) delete module_attach;
214 if(standalone_change) delete standalone_change;
215 if(shared_change) delete shared_change;
216 if(module_change) delete module_change;
221 int PluginDialog::create_objects()
224 char string[BCTEXTLEN];
226 mwindow->theme->get_plugindialog_sizes();
230 strcpy(string, thread->plugin->title);
236 sprintf(string, _("None"));
244 // GET A LIST OF ALL THE PLUGINS AVAILABLE
245 mwindow->create_plugindb(thread->data_type == TRACK_AUDIO,
246 thread->data_type == TRACK_VIDEO,
252 mwindow->edl->get_shared_plugins(thread->track,
255 mwindow->edl->get_shared_tracks(thread->track,
265 // Construct listbox items
266 for(int i = 0; i < plugindb.total; i++)
267 standalone_data.append(new BC_ListBoxItem(_(plugindb.values[i]->title)));
268 for(int i = 0; i < plugin_locations.total; i++)
270 Track *track = mwindow->edl->tracks->number(plugin_locations.values[i]->module);
271 char *track_title = track->title;
272 int number = plugin_locations.values[i]->plugin;
273 Plugin *plugin = track->get_current_plugin(mwindow->edl->local_session->get_selectionstart(1),
278 char *plugin_title = plugin->title;
279 char string[BCTEXTLEN];
281 sprintf(string, "%s: %s", track_title, _(plugin_title));
282 shared_data.append(new BC_ListBoxItem(string));
284 for(int i = 0; i < module_locations.total; i++)
286 Track *track = mwindow->edl->tracks->number(module_locations.values[i]->module);
287 module_data.append(new BC_ListBoxItem(track->title));
295 add_subwindow(standalone_title = new BC_Title(mwindow->theme->plugindialog_new_x,
296 mwindow->theme->plugindialog_new_y - 20,
298 add_subwindow(standalone_list = new PluginDialogNew(this,
300 mwindow->theme->plugindialog_new_x,
301 mwindow->theme->plugindialog_new_y,
302 mwindow->theme->plugindialog_new_w,
303 mwindow->theme->plugindialog_new_h));
306 add_subwindow(standalone_change = new PluginDialogChangeNew(mwindow,
308 mwindow->theme->plugindialog_newattach_x,
309 mwindow->theme->plugindialog_newattach_y));
311 add_subwindow(standalone_attach = new PluginDialogAttachNew(mwindow,
313 mwindow->theme->plugindialog_newattach_x,
314 mwindow->theme->plugindialog_newattach_y));
323 add_subwindow(shared_title = new BC_Title(mwindow->theme->plugindialog_shared_x,
324 mwindow->theme->plugindialog_shared_y - 20,
325 _("Shared effects:")));
326 add_subwindow(shared_list = new PluginDialogShared(this,
328 mwindow->theme->plugindialog_shared_x,
329 mwindow->theme->plugindialog_shared_y,
330 mwindow->theme->plugindialog_shared_w,
331 mwindow->theme->plugindialog_shared_h));
333 add_subwindow(shared_change = new PluginDialogChangeShared(mwindow,
335 mwindow->theme->plugindialog_sharedattach_x,
336 mwindow->theme->plugindialog_sharedattach_y));
338 add_subwindow(shared_attach = new PluginDialogAttachShared(mwindow,
340 mwindow->theme->plugindialog_sharedattach_x,
341 mwindow->theme->plugindialog_sharedattach_y));
351 add_subwindow(module_title = new BC_Title(mwindow->theme->plugindialog_module_x,
352 mwindow->theme->plugindialog_module_y - 20,
353 _("Shared tracks:")));
354 add_subwindow(module_list = new PluginDialogModules(this,
356 mwindow->theme->plugindialog_module_x,
357 mwindow->theme->plugindialog_module_y,
358 mwindow->theme->plugindialog_module_w,
359 mwindow->theme->plugindialog_module_h));
361 add_subwindow(module_change = new PluginDialogChangeModule(mwindow,
363 mwindow->theme->plugindialog_moduleattach_x,
364 mwindow->theme->plugindialog_moduleattach_y));
366 add_subwindow(module_attach = new PluginDialogAttachModule(mwindow,
368 mwindow->theme->plugindialog_moduleattach_x,
369 mwindow->theme->plugindialog_moduleattach_y));
377 add_subwindow(new BC_CancelButton(this));
379 selected_available = -1;
380 selected_shared = -1;
381 selected_modules = -1;
388 int PluginDialog::resize_event(int w, int h)
390 mwindow->session->plugindialog_w = w;
391 mwindow->session->plugindialog_h = h;
392 mwindow->theme->get_plugindialog_sizes();
395 standalone_title->reposition_window(mwindow->theme->plugindialog_new_x,
396 mwindow->theme->plugindialog_new_y - 20);
397 standalone_list->reposition_window(mwindow->theme->plugindialog_new_x,
398 mwindow->theme->plugindialog_new_y,
399 mwindow->theme->plugindialog_new_w,
400 mwindow->theme->plugindialog_new_h);
401 if(standalone_attach)
402 standalone_attach->reposition_window(mwindow->theme->plugindialog_newattach_x,
403 mwindow->theme->plugindialog_newattach_y);
405 standalone_change->reposition_window(mwindow->theme->plugindialog_newattach_x,
406 mwindow->theme->plugindialog_newattach_y);
412 shared_title->reposition_window(mwindow->theme->plugindialog_shared_x,
413 mwindow->theme->plugindialog_shared_y - 20);
414 shared_list->reposition_window(mwindow->theme->plugindialog_shared_x,
415 mwindow->theme->plugindialog_shared_y,
416 mwindow->theme->plugindialog_shared_w,
417 mwindow->theme->plugindialog_shared_h);
419 shared_attach->reposition_window(mwindow->theme->plugindialog_sharedattach_x,
420 mwindow->theme->plugindialog_sharedattach_y);
422 shared_change->reposition_window(mwindow->theme->plugindialog_sharedattach_x,
423 mwindow->theme->plugindialog_sharedattach_y);
429 module_title->reposition_window(mwindow->theme->plugindialog_module_x,
430 mwindow->theme->plugindialog_module_y - 20);
431 module_list->reposition_window(mwindow->theme->plugindialog_module_x,
432 mwindow->theme->plugindialog_module_y,
433 mwindow->theme->plugindialog_module_w,
434 mwindow->theme->plugindialog_module_h);
436 module_attach->reposition_window(mwindow->theme->plugindialog_moduleattach_x,
437 mwindow->theme->plugindialog_moduleattach_y);
439 module_change->reposition_window(mwindow->theme->plugindialog_moduleattach_x,
440 mwindow->theme->plugindialog_moduleattach_y);
444 int PluginDialog::attach_new(int number)
446 if(number > -1 && number < standalone_data.total)
448 strcpy(thread->plugin_title, plugindb.values[number]->title);
449 thread->plugin_type = PLUGIN_STANDALONE; // type is plugin
454 int PluginDialog::attach_shared(int number)
456 if(number > -1 && number < shared_data.total)
458 thread->plugin_type = PLUGIN_SHAREDPLUGIN; // type is shared plugin
459 thread->shared_location = *(plugin_locations.values[number]); // copy location
464 int PluginDialog::attach_module(int number)
466 if(number > -1 && number < module_data.total)
468 // title->update(module_data.values[number]->get_text());
469 thread->plugin_type = PLUGIN_SHAREDMODULE; // type is module
470 thread->shared_location = *(module_locations.values[number]); // copy location
475 int PluginDialog::save_settings()
486 PluginDialogTextBox::PluginDialogTextBox(PluginDialog *dialog, char *text, int x, int y)
487 : BC_TextBox(x, y, 200, 1, text)
489 this->dialog = dialog;
491 PluginDialogTextBox::~PluginDialogTextBox()
493 int PluginDialogTextBox::handle_event()
496 PluginDialogDetach::PluginDialogDetach(MWindow *mwindow, PluginDialog *dialog, int x, int y)
497 : BC_GenericButton(x, y, _("Detach"))
499 this->dialog = dialog;
501 PluginDialogDetach::~PluginDialogDetach()
503 int PluginDialogDetach::handle_event()
505 // dialog->title->update(_("None"));
506 dialog->thread->plugin_type = 0; // type is none
507 dialog->thread->plugin_title[0] = 0;
524 PluginDialogNew::PluginDialogNew(PluginDialog *dialog,
525 ArrayList<BC_ListBoxItem*> *standalone_data,
537 this->dialog = dialog;
539 PluginDialogNew::~PluginDialogNew() { }
540 int PluginDialogNew::handle_event()
542 dialog->attach_new(get_selection_number(0, 0));
548 int PluginDialogNew::selection_changed()
550 dialog->selected_available = get_selection_number(0, 0);
554 PluginDialogAttachNew::PluginDialogAttachNew(MWindow *mwindow, PluginDialog *dialog, int x, int y)
555 : BC_GenericButton(x, y, _("Attach"))
557 this->dialog = dialog;
559 PluginDialogAttachNew::~PluginDialogAttachNew()
562 int PluginDialogAttachNew::handle_event()
564 dialog->attach_new(dialog->selected_available);
569 PluginDialogChangeNew::PluginDialogChangeNew(MWindow *mwindow, PluginDialog *dialog, int x, int y)
570 : BC_GenericButton(x, y, _("Change"))
572 this->dialog = dialog;
574 PluginDialogChangeNew::~PluginDialogChangeNew()
577 int PluginDialogChangeNew::handle_event()
579 dialog->attach_new(dialog->selected_available);
593 PluginDialogShared::PluginDialogShared(PluginDialog *dialog,
594 ArrayList<BC_ListBoxItem*> *shared_data,
606 this->dialog = dialog;
608 PluginDialogShared::~PluginDialogShared() { }
609 int PluginDialogShared::handle_event()
611 dialog->attach_shared(get_selection_number(0, 0));
616 int PluginDialogShared::selection_changed()
618 dialog->selected_shared = get_selection_number(0, 0);
622 PluginDialogAttachShared::PluginDialogAttachShared(MWindow *mwindow,
623 PluginDialog *dialog,
626 : BC_GenericButton(x, y, _("Attach"))
628 this->dialog = dialog;
630 PluginDialogAttachShared::~PluginDialogAttachShared() { }
631 int PluginDialogAttachShared::handle_event()
633 dialog->attach_shared(dialog->selected_shared);
638 PluginDialogChangeShared::PluginDialogChangeShared(MWindow *mwindow,
639 PluginDialog *dialog,
642 : BC_GenericButton(x, y, _("Change"))
644 this->dialog = dialog;
646 PluginDialogChangeShared::~PluginDialogChangeShared() { }
647 int PluginDialogChangeShared::handle_event()
649 dialog->attach_shared(dialog->selected_shared);
666 PluginDialogModules::PluginDialogModules(PluginDialog *dialog,
667 ArrayList<BC_ListBoxItem*> *module_data,
679 this->dialog = dialog;
681 PluginDialogModules::~PluginDialogModules() { }
682 int PluginDialogModules::handle_event()
684 dialog->attach_module(get_selection_number(0, 0));
690 int PluginDialogModules::selection_changed()
692 dialog->selected_modules = get_selection_number(0, 0);
697 PluginDialogAttachModule::PluginDialogAttachModule(MWindow *mwindow,
698 PluginDialog *dialog,
701 : BC_GenericButton(x, y, _("Attach"))
703 this->dialog = dialog;
705 PluginDialogAttachModule::~PluginDialogAttachModule() { }
706 int PluginDialogAttachModule::handle_event()
708 dialog->attach_module(dialog->selected_modules);
713 PluginDialogChangeModule::PluginDialogChangeModule(MWindow *mwindow,
714 PluginDialog *dialog,
717 : BC_GenericButton(x, y, _("Change"))
719 this->dialog = dialog;
721 PluginDialogChangeModule::~PluginDialogChangeModule() { }
722 int PluginDialogChangeModule::handle_event()
724 dialog->attach_module(dialog->selected_modules);
743 PluginDialogIn::PluginDialogIn(PluginDialog *dialog, int setting, int x, int y)
744 : BC_CheckBox(x, y, setting, _("Send"))
746 this->dialog = dialog;
748 PluginDialogIn::~PluginDialogIn() { }
749 int PluginDialogIn::handle_event()
751 // dialog->thread->in = get_value();
754 int PluginDialogIn::button_press()
756 dialog->inoutthru = 1;
757 dialog->new_value = get_value();
760 int PluginDialogIn::button_release()
762 if(dialog->inoutthru) dialog->inoutthru = 0;
764 int PluginDialogIn::cursor_moved_over()
766 if(dialog->inoutthru && get_value() != dialog->new_value)
768 update(dialog->new_value);
772 PluginDialogOut::PluginDialogOut(PluginDialog *dialog, int setting, int x, int y)
773 : BC_CheckBox(x, y, setting, _("Receive"))
775 this->dialog = dialog;
777 PluginDialogOut::~PluginDialogOut() { }
778 int PluginDialogOut::handle_event()
780 // dialog->thread->out = get_value();
783 int PluginDialogOut::button_press()
785 dialog->inoutthru = 1;
786 dialog->new_value = get_value();
789 int PluginDialogOut::button_release()
791 if(dialog->inoutthru) dialog->inoutthru = 0;
793 int PluginDialogOut::cursor_moved_over()
795 if(dialog->inoutthru && get_value() != dialog->new_value)
797 update(dialog->new_value);
801 PluginDialogThru::PluginDialogThru(PluginDialog *dialog, int setting)
802 : BC_CheckBox(300, 350, setting, _("Thru"))
804 this->dialog = dialog;
806 PluginDialogThru::~PluginDialogThru() { }
807 int PluginDialogThru::handle_event() { }
808 int PluginDialogThru::button_press()
810 dialog->inoutthru = 1;
811 dialog->new_value = get_value();
814 int PluginDialogThru::button_release()
816 if(dialog->inoutthru) dialog->inoutthru = 0;
818 int PluginDialogThru::cursor_moved_over()
820 if(dialog->inoutthru && get_value() != dialog->new_value)
822 update(dialog->new_value);