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()
96 int x = mwindow->gui->get_abs_cursor_x(1) - mwindow->session->plugindialog_w / 2;
97 int y = mwindow->gui->get_abs_cursor_y(1) - mwindow->session->plugindialog_h / 2;
99 window_lock->lock("PluginDialogThread::run 1");
100 window = new PluginDialog(mwindow, this, window_title, x, y);
101 window->create_objects();
102 window_lock->unlock();
104 result = window->run_window();
107 window_lock->lock("PluginDialogThread::run 2");
109 if(window->selected_available >= 0)
111 window->attach_new(window->selected_available);
114 if(window->selected_shared >= 0)
116 window->attach_shared(window->selected_shared);
119 if(window->selected_modules >= 0)
121 window->attach_module(window->selected_modules);
129 window_lock->unlock();
131 completion->unlock();
140 mwindow->gui->lock_window("PluginDialogThread::run 3");
145 plugin->change_plugin(plugin_title,
151 mwindow->insert_effect(plugin_title,
161 mwindow->save_backup();
162 mwindow->undo->update_undo(_("attach effect"), LOAD_EDITS | LOAD_PATCHES);
163 mwindow->restart_brender();
164 mwindow->update_plugin_states();
165 mwindow->sync_parameters(CHANGE_EDL);
166 mwindow->gui->update(1,
174 mwindow->gui->unlock_window();
188 PluginDialog::PluginDialog(MWindow *mwindow,
189 PluginDialogThread *thread,
193 : BC_Window(window_title,
196 mwindow->session->plugindialog_w,
197 mwindow->session->plugindialog_h,
204 this->mwindow = mwindow;
205 this->thread = thread;
206 // standalone_attach = 0;
207 // shared_attach = 0;
208 // module_attach = 0;
209 // standalone_change = 0;
210 // shared_change = 0;
211 // module_change = 0;
215 PluginDialog::~PluginDialog()
218 standalone_data.remove_all_objects();
220 shared_data.remove_all_objects();
222 module_data.remove_all_objects();
224 plugin_locations.remove_all_objects();
226 module_locations.remove_all_objects();
230 delete standalone_list;
233 // if(standalone_attach) delete standalone_attach;
234 // if(shared_attach) delete shared_attach;
235 // if(module_attach) delete module_attach;
236 // if(standalone_change) delete standalone_change;
237 // if(shared_change) delete shared_change;
238 // if(module_change) delete module_change;
243 int PluginDialog::create_objects()
246 char string[BCTEXTLEN];
248 mwindow->theme->get_plugindialog_sizes();
252 strcpy(string, thread->plugin->title);
258 sprintf(string, _("None"));
266 // GET A LIST OF ALL THE PLUGINS AVAILABLE
267 mwindow->create_plugindb(thread->data_type == TRACK_AUDIO,
268 thread->data_type == TRACK_VIDEO,
274 mwindow->edl->get_shared_plugins(thread->track,
277 mwindow->edl->get_shared_tracks(thread->track,
287 // Construct listbox items
288 for(int i = 0; i < plugindb.total; i++)
289 standalone_data.append(new BC_ListBoxItem(_(plugindb.values[i]->title)));
290 for(int i = 0; i < plugin_locations.total; i++)
292 Track *track = mwindow->edl->tracks->number(plugin_locations.values[i]->module);
293 char *track_title = track->title;
294 int number = plugin_locations.values[i]->plugin;
295 Plugin *plugin = track->get_current_plugin(mwindow->edl->local_session->get_selectionstart(1),
300 char *plugin_title = plugin->title;
301 char string[BCTEXTLEN];
303 sprintf(string, "%s: %s", track_title, _(plugin_title));
304 shared_data.append(new BC_ListBoxItem(string));
306 for(int i = 0; i < module_locations.total; i++)
308 Track *track = mwindow->edl->tracks->number(module_locations.values[i]->module);
309 module_data.append(new BC_ListBoxItem(track->title));
317 add_subwindow(standalone_title = new BC_Title(mwindow->theme->plugindialog_new_x,
318 mwindow->theme->plugindialog_new_y - 20,
320 add_subwindow(standalone_list = new PluginDialogNew(this,
322 mwindow->theme->plugindialog_new_x,
323 mwindow->theme->plugindialog_new_y,
324 mwindow->theme->plugindialog_new_w,
325 mwindow->theme->plugindialog_new_h));
327 // if(thread->plugin)
328 // add_subwindow(standalone_change = new PluginDialogChangeNew(mwindow,
330 // mwindow->theme->plugindialog_newattach_x,
331 // mwindow->theme->plugindialog_newattach_y));
333 // add_subwindow(standalone_attach = new PluginDialogAttachNew(mwindow,
335 // mwindow->theme->plugindialog_newattach_x,
336 // mwindow->theme->plugindialog_newattach_y));
345 add_subwindow(shared_title = new BC_Title(mwindow->theme->plugindialog_shared_x,
346 mwindow->theme->plugindialog_shared_y - 20,
347 _("Shared effects:")));
348 add_subwindow(shared_list = new PluginDialogShared(this,
350 mwindow->theme->plugindialog_shared_x,
351 mwindow->theme->plugindialog_shared_y,
352 mwindow->theme->plugindialog_shared_w,
353 mwindow->theme->plugindialog_shared_h));
354 // if(thread->plugin)
355 // add_subwindow(shared_change = new PluginDialogChangeShared(mwindow,
357 // mwindow->theme->plugindialog_sharedattach_x,
358 // mwindow->theme->plugindialog_sharedattach_y));
360 // add_subwindow(shared_attach = new PluginDialogAttachShared(mwindow,
362 // mwindow->theme->plugindialog_sharedattach_x,
363 // mwindow->theme->plugindialog_sharedattach_y));
373 add_subwindow(module_title = new BC_Title(mwindow->theme->plugindialog_module_x,
374 mwindow->theme->plugindialog_module_y - 20,
375 _("Shared tracks:")));
376 add_subwindow(module_list = new PluginDialogModules(this,
378 mwindow->theme->plugindialog_module_x,
379 mwindow->theme->plugindialog_module_y,
380 mwindow->theme->plugindialog_module_w,
381 mwindow->theme->plugindialog_module_h));
382 // if(thread->plugin)
383 // add_subwindow(module_change = new PluginDialogChangeModule(mwindow,
385 // mwindow->theme->plugindialog_moduleattach_x,
386 // mwindow->theme->plugindialog_moduleattach_y));
388 // add_subwindow(module_attach = new PluginDialogAttachModule(mwindow,
390 // mwindow->theme->plugindialog_moduleattach_x,
391 // mwindow->theme->plugindialog_moduleattach_y));
398 add_subwindow(new BC_OKButton(this));
401 add_subwindow(new BC_CancelButton(this));
403 selected_available = -1;
404 selected_shared = -1;
405 selected_modules = -1;
412 int PluginDialog::resize_event(int w, int h)
414 mwindow->session->plugindialog_w = w;
415 mwindow->session->plugindialog_h = h;
416 mwindow->theme->get_plugindialog_sizes();
419 standalone_title->reposition_window(mwindow->theme->plugindialog_new_x,
420 mwindow->theme->plugindialog_new_y - 20);
421 standalone_list->reposition_window(mwindow->theme->plugindialog_new_x,
422 mwindow->theme->plugindialog_new_y,
423 mwindow->theme->plugindialog_new_w,
424 mwindow->theme->plugindialog_new_h);
425 // if(standalone_attach)
426 // standalone_attach->reposition_window(mwindow->theme->plugindialog_newattach_x,
427 // mwindow->theme->plugindialog_newattach_y);
429 // standalone_change->reposition_window(mwindow->theme->plugindialog_newattach_x,
430 // mwindow->theme->plugindialog_newattach_y);
436 shared_title->reposition_window(mwindow->theme->plugindialog_shared_x,
437 mwindow->theme->plugindialog_shared_y - 20);
438 shared_list->reposition_window(mwindow->theme->plugindialog_shared_x,
439 mwindow->theme->plugindialog_shared_y,
440 mwindow->theme->plugindialog_shared_w,
441 mwindow->theme->plugindialog_shared_h);
443 // shared_attach->reposition_window(mwindow->theme->plugindialog_sharedattach_x,
444 // mwindow->theme->plugindialog_sharedattach_y);
446 // shared_change->reposition_window(mwindow->theme->plugindialog_sharedattach_x,
447 // mwindow->theme->plugindialog_sharedattach_y);
453 module_title->reposition_window(mwindow->theme->plugindialog_module_x,
454 mwindow->theme->plugindialog_module_y - 20);
455 module_list->reposition_window(mwindow->theme->plugindialog_module_x,
456 mwindow->theme->plugindialog_module_y,
457 mwindow->theme->plugindialog_module_w,
458 mwindow->theme->plugindialog_module_h);
460 // module_attach->reposition_window(mwindow->theme->plugindialog_moduleattach_x,
461 // mwindow->theme->plugindialog_moduleattach_y);
463 // module_change->reposition_window(mwindow->theme->plugindialog_moduleattach_x,
464 // mwindow->theme->plugindialog_moduleattach_y);
468 int PluginDialog::attach_new(int number)
470 if(number > -1 && number < standalone_data.total)
472 strcpy(thread->plugin_title, plugindb.values[number]->title);
473 thread->plugin_type = PLUGIN_STANDALONE; // type is plugin
478 int PluginDialog::attach_shared(int number)
480 if(number > -1 && number < shared_data.total)
482 thread->plugin_type = PLUGIN_SHAREDPLUGIN; // type is shared plugin
483 thread->shared_location = *(plugin_locations.values[number]); // copy location
488 int PluginDialog::attach_module(int number)
490 if(number > -1 && number < module_data.total)
492 // title->update(module_data.values[number]->get_text());
493 thread->plugin_type = PLUGIN_SHAREDMODULE; // type is module
494 thread->shared_location = *(module_locations.values[number]); // copy location
499 int PluginDialog::save_settings()
510 // PluginDialogTextBox::PluginDialogTextBox(PluginDialog *dialog, char *text, int x, int y)
511 // : BC_TextBox(x, y, 200, 1, text)
513 // this->dialog = dialog;
515 // PluginDialogTextBox::~PluginDialogTextBox()
517 // int PluginDialogTextBox::handle_event()
520 // PluginDialogDetach::PluginDialogDetach(MWindow *mwindow, PluginDialog *dialog, int x, int y)
521 // : BC_GenericButton(x, y, _("Detach"))
523 // this->dialog = dialog;
525 // PluginDialogDetach::~PluginDialogDetach()
527 // int PluginDialogDetach::handle_event()
529 // // dialog->title->update(_("None"));
530 // dialog->thread->plugin_type = 0; // type is none
531 // dialog->thread->plugin_title[0] = 0;
548 PluginDialogNew::PluginDialogNew(PluginDialog *dialog,
549 ArrayList<BC_ListBoxItem*> *standalone_data,
561 this->dialog = dialog;
563 PluginDialogNew::~PluginDialogNew() { }
564 int PluginDialogNew::handle_event()
566 // dialog->attach_new(get_selection_number(0, 0));
572 int PluginDialogNew::selection_changed()
574 dialog->selected_available = get_selection_number(0, 0);
577 dialog->shared_list->set_all_selected(&dialog->shared_data, 0);
578 dialog->shared_list->draw_items(1);
579 dialog->module_list->set_all_selected(&dialog->module_data, 0);
580 dialog->module_list->draw_items(1);
581 dialog->selected_shared = -1;
582 dialog->selected_modules = -1;
586 // PluginDialogAttachNew::PluginDialogAttachNew(MWindow *mwindow, PluginDialog *dialog, int x, int y)
587 // : BC_GenericButton(x, y, _("Attach"))
589 // this->dialog = dialog;
591 // PluginDialogAttachNew::~PluginDialogAttachNew()
594 // int PluginDialogAttachNew::handle_event()
596 // dialog->attach_new(dialog->selected_available);
601 // PluginDialogChangeNew::PluginDialogChangeNew(MWindow *mwindow, PluginDialog *dialog, int x, int y)
602 // : BC_GenericButton(x, y, _("Change"))
604 // this->dialog = dialog;
606 // PluginDialogChangeNew::~PluginDialogChangeNew()
609 // int PluginDialogChangeNew::handle_event()
611 // dialog->attach_new(dialog->selected_available);
625 PluginDialogShared::PluginDialogShared(PluginDialog *dialog,
626 ArrayList<BC_ListBoxItem*> *shared_data,
638 this->dialog = dialog;
640 PluginDialogShared::~PluginDialogShared() { }
641 int PluginDialogShared::handle_event()
643 // dialog->attach_shared(get_selection_number(0, 0));
648 int PluginDialogShared::selection_changed()
650 dialog->selected_shared = get_selection_number(0, 0);
653 dialog->standalone_list->set_all_selected(&dialog->standalone_data, 0);
654 dialog->standalone_list->draw_items(1);
655 dialog->module_list->set_all_selected(&dialog->module_data, 0);
656 dialog->module_list->draw_items(1);
657 dialog->selected_available = -1;
658 dialog->selected_modules = -1;
662 // PluginDialogAttachShared::PluginDialogAttachShared(MWindow *mwindow,
663 // PluginDialog *dialog,
666 // : BC_GenericButton(x, y, _("Attach"))
668 // this->dialog = dialog;
670 // PluginDialogAttachShared::~PluginDialogAttachShared() { }
671 // int PluginDialogAttachShared::handle_event()
673 // dialog->attach_shared(dialog->selected_shared);
678 // PluginDialogChangeShared::PluginDialogChangeShared(MWindow *mwindow,
679 // PluginDialog *dialog,
682 // : BC_GenericButton(x, y, _("Change"))
684 // this->dialog = dialog;
686 // PluginDialogChangeShared::~PluginDialogChangeShared() { }
687 // int PluginDialogChangeShared::handle_event()
689 // dialog->attach_shared(dialog->selected_shared);
706 PluginDialogModules::PluginDialogModules(PluginDialog *dialog,
707 ArrayList<BC_ListBoxItem*> *module_data,
719 this->dialog = dialog;
721 PluginDialogModules::~PluginDialogModules() { }
722 int PluginDialogModules::handle_event()
724 // dialog->attach_module(get_selection_number(0, 0));
730 int PluginDialogModules::selection_changed()
732 dialog->selected_modules = get_selection_number(0, 0);
735 dialog->standalone_list->set_all_selected(&dialog->standalone_data, 0);
736 dialog->standalone_list->draw_items(1);
737 dialog->shared_list->set_all_selected(&dialog->shared_data, 0);
738 dialog->shared_list->draw_items(1);
739 dialog->selected_available = -1;
740 dialog->selected_shared = -1;
745 // PluginDialogAttachModule::PluginDialogAttachModule(MWindow *mwindow,
746 // PluginDialog *dialog,
749 // : BC_GenericButton(x, y, _("Attach"))
751 // this->dialog = dialog;
753 // PluginDialogAttachModule::~PluginDialogAttachModule() { }
754 // int PluginDialogAttachModule::handle_event()
756 // dialog->attach_module(dialog->selected_modules);
761 // PluginDialogChangeModule::PluginDialogChangeModule(MWindow *mwindow,
762 // PluginDialog *dialog,
765 // : BC_GenericButton(x, y, _("Change"))
767 // this->dialog = dialog;
769 // PluginDialogChangeModule::~PluginDialogChangeModule() { }
770 // int PluginDialogChangeModule::handle_event()
772 // dialog->attach_module(dialog->selected_modules);