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");
120 mwindow->undo->update_undo_before(_("attach effect"), LOAD_EDITS | LOAD_PATCHES);
124 plugin->change_plugin(plugin_title,
130 mwindow->insert_effect(plugin_title,
140 mwindow->save_backup();
141 mwindow->undo->update_undo_after();
142 mwindow->restart_brender();
143 mwindow->update_plugin_states();
144 mwindow->sync_parameters(CHANGE_EDL);
145 mwindow->gui->update(1,
153 mwindow->gui->unlock_window();
167 PluginDialog::PluginDialog(MWindow *mwindow,
168 PluginDialogThread *thread,
172 : BC_Window(window_title,
175 mwindow->session->plugindialog_w,
176 mwindow->session->plugindialog_h,
183 this->mwindow = mwindow;
184 this->thread = thread;
185 standalone_attach = 0;
188 standalone_change = 0;
194 PluginDialog::~PluginDialog()
197 standalone_data.remove_all_objects();
199 shared_data.remove_all_objects();
201 module_data.remove_all_objects();
203 plugin_locations.remove_all_objects();
205 module_locations.remove_all_objects();
209 delete standalone_list;
212 if(standalone_attach) delete standalone_attach;
213 if(shared_attach) delete shared_attach;
214 if(module_attach) delete module_attach;
215 if(standalone_change) delete standalone_change;
216 if(shared_change) delete shared_change;
217 if(module_change) delete module_change;
222 int PluginDialog::create_objects()
225 char string[BCTEXTLEN];
227 mwindow->theme->get_plugindialog_sizes();
231 strcpy(string, thread->plugin->title);
237 sprintf(string, _("None"));
245 // GET A LIST OF ALL THE PLUGINS AVAILABLE
246 mwindow->create_plugindb(thread->data_type == TRACK_AUDIO,
247 thread->data_type == TRACK_VIDEO,
253 mwindow->edl->get_shared_plugins(thread->track,
256 mwindow->edl->get_shared_tracks(thread->track,
266 // Construct listbox items
267 for(int i = 0; i < plugindb.total; i++)
268 standalone_data.append(new BC_ListBoxItem(_(plugindb.values[i]->title)));
269 for(int i = 0; i < plugin_locations.total; i++)
271 Track *track = mwindow->edl->tracks->number(plugin_locations.values[i]->module);
272 char *track_title = track->title;
273 int number = plugin_locations.values[i]->plugin;
274 Plugin *plugin = track->get_current_plugin(mwindow->edl->local_session->selectionstart,
279 char *plugin_title = plugin->title;
280 char string[BCTEXTLEN];
282 sprintf(string, "%s: %s", track_title, _(plugin_title));
283 shared_data.append(new BC_ListBoxItem(string));
285 for(int i = 0; i < module_locations.total; i++)
287 Track *track = mwindow->edl->tracks->number(module_locations.values[i]->module);
288 module_data.append(new BC_ListBoxItem(track->title));
296 add_subwindow(standalone_title = new BC_Title(mwindow->theme->plugindialog_new_x,
297 mwindow->theme->plugindialog_new_y - 20,
299 add_subwindow(standalone_list = new PluginDialogNew(this,
301 mwindow->theme->plugindialog_new_x,
302 mwindow->theme->plugindialog_new_y,
303 mwindow->theme->plugindialog_new_w,
304 mwindow->theme->plugindialog_new_h));
307 add_subwindow(standalone_change = new PluginDialogChangeNew(mwindow,
309 mwindow->theme->plugindialog_newattach_x,
310 mwindow->theme->plugindialog_newattach_y));
312 add_subwindow(standalone_attach = new PluginDialogAttachNew(mwindow,
314 mwindow->theme->plugindialog_newattach_x,
315 mwindow->theme->plugindialog_newattach_y));
324 add_subwindow(shared_title = new BC_Title(mwindow->theme->plugindialog_shared_x,
325 mwindow->theme->plugindialog_shared_y - 20,
326 _("Shared effects:")));
327 add_subwindow(shared_list = new PluginDialogShared(this,
329 mwindow->theme->plugindialog_shared_x,
330 mwindow->theme->plugindialog_shared_y,
331 mwindow->theme->plugindialog_shared_w,
332 mwindow->theme->plugindialog_shared_h));
334 add_subwindow(shared_change = new PluginDialogChangeShared(mwindow,
336 mwindow->theme->plugindialog_sharedattach_x,
337 mwindow->theme->plugindialog_sharedattach_y));
339 add_subwindow(shared_attach = new PluginDialogAttachShared(mwindow,
341 mwindow->theme->plugindialog_sharedattach_x,
342 mwindow->theme->plugindialog_sharedattach_y));
352 add_subwindow(module_title = new BC_Title(mwindow->theme->plugindialog_module_x,
353 mwindow->theme->plugindialog_module_y - 20,
354 _("Shared tracks:")));
355 add_subwindow(module_list = new PluginDialogModules(this,
357 mwindow->theme->plugindialog_module_x,
358 mwindow->theme->plugindialog_module_y,
359 mwindow->theme->plugindialog_module_w,
360 mwindow->theme->plugindialog_module_h));
362 add_subwindow(module_change = new PluginDialogChangeModule(mwindow,
364 mwindow->theme->plugindialog_moduleattach_x,
365 mwindow->theme->plugindialog_moduleattach_y));
367 add_subwindow(module_attach = new PluginDialogAttachModule(mwindow,
369 mwindow->theme->plugindialog_moduleattach_x,
370 mwindow->theme->plugindialog_moduleattach_y));
378 add_subwindow(new BC_CancelButton(this));
380 selected_available = -1;
381 selected_shared = -1;
382 selected_modules = -1;
389 int PluginDialog::resize_event(int w, int h)
391 mwindow->session->plugindialog_w = w;
392 mwindow->session->plugindialog_h = h;
393 mwindow->theme->get_plugindialog_sizes();
396 standalone_title->reposition_window(mwindow->theme->plugindialog_new_x,
397 mwindow->theme->plugindialog_new_y - 20);
398 standalone_list->reposition_window(mwindow->theme->plugindialog_new_x,
399 mwindow->theme->plugindialog_new_y,
400 mwindow->theme->plugindialog_new_w,
401 mwindow->theme->plugindialog_new_h);
402 if(standalone_attach)
403 standalone_attach->reposition_window(mwindow->theme->plugindialog_newattach_x,
404 mwindow->theme->plugindialog_newattach_y);
406 standalone_change->reposition_window(mwindow->theme->plugindialog_newattach_x,
407 mwindow->theme->plugindialog_newattach_y);
413 shared_title->reposition_window(mwindow->theme->plugindialog_shared_x,
414 mwindow->theme->plugindialog_shared_y - 20);
415 shared_list->reposition_window(mwindow->theme->plugindialog_shared_x,
416 mwindow->theme->plugindialog_shared_y,
417 mwindow->theme->plugindialog_shared_w,
418 mwindow->theme->plugindialog_shared_h);
420 shared_attach->reposition_window(mwindow->theme->plugindialog_sharedattach_x,
421 mwindow->theme->plugindialog_sharedattach_y);
423 shared_change->reposition_window(mwindow->theme->plugindialog_sharedattach_x,
424 mwindow->theme->plugindialog_sharedattach_y);
430 module_title->reposition_window(mwindow->theme->plugindialog_module_x,
431 mwindow->theme->plugindialog_module_y - 20);
432 module_list->reposition_window(mwindow->theme->plugindialog_module_x,
433 mwindow->theme->plugindialog_module_y,
434 mwindow->theme->plugindialog_module_w,
435 mwindow->theme->plugindialog_module_h);
437 module_attach->reposition_window(mwindow->theme->plugindialog_moduleattach_x,
438 mwindow->theme->plugindialog_moduleattach_y);
440 module_change->reposition_window(mwindow->theme->plugindialog_moduleattach_x,
441 mwindow->theme->plugindialog_moduleattach_y);
445 int PluginDialog::attach_new(int number)
447 if(number > -1 && number < standalone_data.total)
449 strcpy(thread->plugin_title, plugindb.values[number]->title);
450 thread->plugin_type = PLUGIN_STANDALONE; // type is plugin
455 int PluginDialog::attach_shared(int number)
457 if(number > -1 && number < shared_data.total)
459 thread->plugin_type = PLUGIN_SHAREDPLUGIN; // type is shared plugin
460 thread->shared_location = *(plugin_locations.values[number]); // copy location
465 int PluginDialog::attach_module(int number)
467 if(number > -1 && number < module_data.total)
469 // title->update(module_data.values[number]->get_text());
470 thread->plugin_type = PLUGIN_SHAREDMODULE; // type is module
471 thread->shared_location = *(module_locations.values[number]); // copy location
476 int PluginDialog::save_settings()
487 PluginDialogTextBox::PluginDialogTextBox(PluginDialog *dialog, char *text, int x, int y)
488 : BC_TextBox(x, y, 200, 1, text)
490 this->dialog = dialog;
492 PluginDialogTextBox::~PluginDialogTextBox()
494 int PluginDialogTextBox::handle_event()
497 PluginDialogDetach::PluginDialogDetach(MWindow *mwindow, PluginDialog *dialog, int x, int y)
498 : BC_GenericButton(x, y, _("Detach"))
500 this->dialog = dialog;
502 PluginDialogDetach::~PluginDialogDetach()
504 int PluginDialogDetach::handle_event()
506 // dialog->title->update(_("None"));
507 dialog->thread->plugin_type = 0; // type is none
508 dialog->thread->plugin_title[0] = 0;
525 PluginDialogNew::PluginDialogNew(PluginDialog *dialog,
526 ArrayList<BC_ListBoxItem*> *standalone_data,
538 this->dialog = dialog;
540 PluginDialogNew::~PluginDialogNew() { }
541 int PluginDialogNew::handle_event()
543 dialog->attach_new(get_selection_number(0, 0));
549 int PluginDialogNew::selection_changed()
551 dialog->selected_available = get_selection_number(0, 0);
555 PluginDialogAttachNew::PluginDialogAttachNew(MWindow *mwindow, PluginDialog *dialog, int x, int y)
556 : BC_GenericButton(x, y, _("Attach"))
558 this->dialog = dialog;
560 PluginDialogAttachNew::~PluginDialogAttachNew()
563 int PluginDialogAttachNew::handle_event()
565 dialog->attach_new(dialog->selected_available);
570 PluginDialogChangeNew::PluginDialogChangeNew(MWindow *mwindow, PluginDialog *dialog, int x, int y)
571 : BC_GenericButton(x, y, _("Change"))
573 this->dialog = dialog;
575 PluginDialogChangeNew::~PluginDialogChangeNew()
578 int PluginDialogChangeNew::handle_event()
580 dialog->attach_new(dialog->selected_available);
594 PluginDialogShared::PluginDialogShared(PluginDialog *dialog,
595 ArrayList<BC_ListBoxItem*> *shared_data,
607 this->dialog = dialog;
609 PluginDialogShared::~PluginDialogShared() { }
610 int PluginDialogShared::handle_event()
612 dialog->attach_shared(get_selection_number(0, 0));
617 int PluginDialogShared::selection_changed()
619 dialog->selected_shared = get_selection_number(0, 0);
623 PluginDialogAttachShared::PluginDialogAttachShared(MWindow *mwindow,
624 PluginDialog *dialog,
627 : BC_GenericButton(x, y, _("Attach"))
629 this->dialog = dialog;
631 PluginDialogAttachShared::~PluginDialogAttachShared() { }
632 int PluginDialogAttachShared::handle_event()
634 dialog->attach_shared(dialog->selected_shared);
639 PluginDialogChangeShared::PluginDialogChangeShared(MWindow *mwindow,
640 PluginDialog *dialog,
643 : BC_GenericButton(x, y, _("Change"))
645 this->dialog = dialog;
647 PluginDialogChangeShared::~PluginDialogChangeShared() { }
648 int PluginDialogChangeShared::handle_event()
650 dialog->attach_shared(dialog->selected_shared);
667 PluginDialogModules::PluginDialogModules(PluginDialog *dialog,
668 ArrayList<BC_ListBoxItem*> *module_data,
680 this->dialog = dialog;
682 PluginDialogModules::~PluginDialogModules() { }
683 int PluginDialogModules::handle_event()
685 dialog->attach_module(get_selection_number(0, 0));
691 int PluginDialogModules::selection_changed()
693 dialog->selected_modules = get_selection_number(0, 0);
698 PluginDialogAttachModule::PluginDialogAttachModule(MWindow *mwindow,
699 PluginDialog *dialog,
702 : BC_GenericButton(x, y, _("Attach"))
704 this->dialog = dialog;
706 PluginDialogAttachModule::~PluginDialogAttachModule() { }
707 int PluginDialogAttachModule::handle_event()
709 dialog->attach_module(dialog->selected_modules);
714 PluginDialogChangeModule::PluginDialogChangeModule(MWindow *mwindow,
715 PluginDialog *dialog,
718 : BC_GenericButton(x, y, _("Change"))
720 this->dialog = dialog;
722 PluginDialogChangeModule::~PluginDialogChangeModule() { }
723 int PluginDialogChangeModule::handle_event()
725 dialog->attach_module(dialog->selected_modules);
744 PluginDialogIn::PluginDialogIn(PluginDialog *dialog, int setting, int x, int y)
745 : BC_CheckBox(x, y, setting, _("Send"))
747 this->dialog = dialog;
749 PluginDialogIn::~PluginDialogIn() { }
750 int PluginDialogIn::handle_event()
752 // dialog->thread->in = get_value();
755 int PluginDialogIn::button_press()
757 dialog->inoutthru = 1;
758 dialog->new_value = get_value();
761 int PluginDialogIn::button_release()
763 if(dialog->inoutthru) dialog->inoutthru = 0;
765 int PluginDialogIn::cursor_moved_over()
767 if(dialog->inoutthru && get_value() != dialog->new_value)
769 update(dialog->new_value);
773 PluginDialogOut::PluginDialogOut(PluginDialog *dialog, int setting, int x, int y)
774 : BC_CheckBox(x, y, setting, _("Receive"))
776 this->dialog = dialog;
778 PluginDialogOut::~PluginDialogOut() { }
779 int PluginDialogOut::handle_event()
781 // dialog->thread->out = get_value();
784 int PluginDialogOut::button_press()
786 dialog->inoutthru = 1;
787 dialog->new_value = get_value();
790 int PluginDialogOut::button_release()
792 if(dialog->inoutthru) dialog->inoutthru = 0;
794 int PluginDialogOut::cursor_moved_over()
796 if(dialog->inoutthru && get_value() != dialog->new_value)
798 update(dialog->new_value);
802 PluginDialogThru::PluginDialogThru(PluginDialog *dialog, int setting)
803 : BC_CheckBox(300, 350, setting, _("Thru"))
805 this->dialog = dialog;
807 PluginDialogThru::~PluginDialogThru() { }
808 int PluginDialogThru::handle_event() { }
809 int PluginDialogThru::button_press()
811 dialog->inoutthru = 1;
812 dialog->new_value = get_value();
815 int PluginDialogThru::button_release()
817 if(dialog->inoutthru) dialog->inoutthru = 0;
819 int PluginDialogThru::cursor_moved_over()
821 if(dialog->inoutthru && get_value() != dialog->new_value)
823 update(dialog->new_value);