2 #include "localsession.h"
3 #include "mainsession.h"
6 #include "mwindowgui.h"
9 #include "plugindialog.h"
10 #include "pluginserver.h"
14 #include "transition.h"
17 #define _(String) gettext(String)
18 #define gettext_noop(String) String
19 #define N_(String) gettext_noop (String)
22 PluginDialogThread::PluginDialogThread(MWindow *mwindow)
25 this->mwindow = mwindow;
28 Thread::set_synchronous(0);
31 PluginDialogThread::~PluginDialogThread()
41 void PluginDialogThread::start_window(Track *track,
47 window->raise_window();
53 this->data_type = track->data_type;
54 this->plugin = plugin;
58 plugin->calculate_title(plugin_title);
59 this->shared_location = plugin->shared_location;
60 this->plugin_type = plugin->plugin_type;
64 this->plugin_title[0] = 0;
65 this->shared_location.plugin = -1;
66 this->shared_location.module = -1;
67 this->plugin_type = PLUGIN_NONE;
70 strcpy(this->window_title, title);
77 int PluginDialogThread::set_dialog(Transition *transition, char *title)
82 void PluginDialogThread::run()
86 window = new PluginDialog(mwindow, this, window_title);
87 window->create_objects();
88 result = window->run_window();
98 mwindow->gui->lock_window();
100 mwindow->undo->update_undo_before(_("attach effect"), LOAD_EDITS | LOAD_PATCHES);
104 plugin->change_plugin(plugin_title,
110 mwindow->insert_effect(plugin_title,
120 mwindow->save_backup();
121 mwindow->undo->update_undo_after();
122 mwindow->restart_brender();
123 mwindow->update_plugin_states();
124 mwindow->sync_parameters(CHANGE_EDL);
125 mwindow->gui->update(1,
133 mwindow->gui->unlock_window();
147 PluginDialog::PluginDialog(MWindow *mwindow,
148 PluginDialogThread *thread,
150 : BC_Window(window_title,
151 mwindow->gui->get_abs_cursor_x() - mwindow->session->plugindialog_w / 2,
152 mwindow->gui->get_abs_cursor_y() - mwindow->session->plugindialog_h / 2,
153 mwindow->session->plugindialog_w,
154 mwindow->session->plugindialog_h,
161 this->mwindow = mwindow;
162 this->thread = thread;
166 PluginDialog::~PluginDialog()
169 for(i = 0; i < standalone_data.total; i++) delete standalone_data.values[i];
170 standalone_data.remove_all();
172 for(i = 0; i < shared_data.total; i++) delete shared_data.values[i];
173 shared_data.remove_all();
175 for(i = 0; i < module_data.total; i++) delete module_data.values[i];
176 module_data.remove_all();
178 for(i = 0; i < plugin_locations.total; i++) delete plugin_locations.values[i];
179 plugin_locations.remove_all();
181 for(i = 0; i < module_locations.total; i++) delete module_locations.values[i];
182 module_locations.remove_all();
186 delete standalone_list;
189 delete standalone_attach;
190 delete shared_attach;
191 delete module_attach;
196 int PluginDialog::create_objects()
199 char string[BCTEXTLEN];
201 mwindow->theme->get_plugindialog_sizes();
205 strcpy(string, thread->plugin->title);
211 sprintf(string, _("None"));
219 // GET A LIST OF ALL THE PLUGINS AVAILABLE
220 ArrayList<PluginServer*> plugindb;
221 mwindow->create_plugindb(thread->data_type == TRACK_AUDIO,
222 thread->data_type == TRACK_VIDEO,
228 mwindow->edl->get_shared_plugins(thread->track,
231 mwindow->edl->get_shared_tracks(thread->track,
241 // Construct listbox items
242 for(int i = 0; i < plugindb.total; i++)
243 standalone_data.append(new BC_ListBoxItem(plugindb.values[i]->title));
244 for(int i = 0; i < plugin_locations.total; i++)
246 Track *track = mwindow->edl->tracks->number(plugin_locations.values[i]->module);
247 char *track_title = track->title;
248 int number = plugin_locations.values[i]->plugin;
249 Plugin *plugin = track->get_current_plugin(mwindow->edl->local_session->selectionstart,
253 char *plugin_title = plugin->title;
254 char string[BCTEXTLEN];
256 sprintf(string, "%s: %s", track_title, plugin_title);
257 shared_data.append(new BC_ListBoxItem(string));
259 for(int i = 0; i < module_locations.total; i++)
261 Track *track = mwindow->edl->tracks->number(module_locations.values[i]->module);
262 module_data.append(new BC_ListBoxItem(track->title));
270 add_subwindow(standalone_title = new BC_Title(mwindow->theme->plugindialog_new_x,
271 mwindow->theme->plugindialog_new_y - 20,
273 add_subwindow(standalone_list = new PluginDialogNew(this,
275 mwindow->theme->plugindialog_new_x,
276 mwindow->theme->plugindialog_new_y,
277 mwindow->theme->plugindialog_new_w,
278 mwindow->theme->plugindialog_new_h));
279 add_subwindow(standalone_attach = new PluginDialogAttachNew(mwindow,
281 mwindow->theme->plugindialog_newattach_x,
282 mwindow->theme->plugindialog_newattach_y));
291 add_subwindow(shared_title = new BC_Title(mwindow->theme->plugindialog_shared_x,
292 mwindow->theme->plugindialog_shared_y - 20,
293 _("Shared effects:")));
294 add_subwindow(shared_list = new PluginDialogShared(this,
296 mwindow->theme->plugindialog_shared_x,
297 mwindow->theme->plugindialog_shared_y,
298 mwindow->theme->plugindialog_shared_w,
299 mwindow->theme->plugindialog_shared_h));
300 add_subwindow(shared_attach = new PluginDialogAttachShared(mwindow,
302 mwindow->theme->plugindialog_sharedattach_x,
303 mwindow->theme->plugindialog_sharedattach_y));
313 add_subwindow(module_title = new BC_Title(mwindow->theme->plugindialog_module_x,
314 mwindow->theme->plugindialog_module_y - 20,
315 _("Shared tracks:")));
316 add_subwindow(module_list = new PluginDialogModules(this,
318 mwindow->theme->plugindialog_module_x,
319 mwindow->theme->plugindialog_module_y,
320 mwindow->theme->plugindialog_module_w,
321 mwindow->theme->plugindialog_module_h));
322 add_subwindow(module_attach = new PluginDialogAttachModule(mwindow,
324 mwindow->theme->plugindialog_moduleattach_x,
325 mwindow->theme->plugindialog_moduleattach_y));
333 add_subwindow(new BC_CancelButton(this));
335 selected_available = -1;
336 selected_shared = -1;
337 selected_modules = -1;
344 int PluginDialog::resize_event(int w, int h)
346 mwindow->session->plugindialog_w = w;
347 mwindow->session->plugindialog_h = h;
348 mwindow->theme->get_plugindialog_sizes();
351 standalone_title->reposition_window(mwindow->theme->plugindialog_new_x,
352 mwindow->theme->plugindialog_new_y - 20);
353 standalone_list->reposition_window(mwindow->theme->plugindialog_new_x,
354 mwindow->theme->plugindialog_new_y,
355 mwindow->theme->plugindialog_new_w,
356 mwindow->theme->plugindialog_new_h);
357 standalone_attach->reposition_window(mwindow->theme->plugindialog_newattach_x,
358 mwindow->theme->plugindialog_newattach_y);
364 shared_title->reposition_window(mwindow->theme->plugindialog_shared_x,
365 mwindow->theme->plugindialog_shared_y - 20);
366 shared_list->reposition_window(mwindow->theme->plugindialog_shared_x,
367 mwindow->theme->plugindialog_shared_y,
368 mwindow->theme->plugindialog_shared_w,
369 mwindow->theme->plugindialog_shared_h);
370 shared_attach->reposition_window(mwindow->theme->plugindialog_sharedattach_x,
371 mwindow->theme->plugindialog_sharedattach_y);
377 module_title->reposition_window(mwindow->theme->plugindialog_module_x,
378 mwindow->theme->plugindialog_module_y - 20);
379 module_list->reposition_window(mwindow->theme->plugindialog_module_x,
380 mwindow->theme->plugindialog_module_y,
381 mwindow->theme->plugindialog_module_w,
382 mwindow->theme->plugindialog_module_h);
383 module_attach->reposition_window(mwindow->theme->plugindialog_moduleattach_x,
384 mwindow->theme->plugindialog_moduleattach_y);
388 int PluginDialog::attach_new(int number)
390 if(number > -1 && number < standalone_data.total)
392 strcpy(thread->plugin_title, standalone_data.values[number]->get_text());
393 thread->plugin_type = PLUGIN_STANDALONE; // type is plugin
398 int PluginDialog::attach_shared(int number)
400 if(number > -1 && number < shared_data.total)
402 thread->plugin_type = PLUGIN_SHAREDPLUGIN; // type is shared plugin
403 thread->shared_location = *(plugin_locations.values[number]); // copy location
408 int PluginDialog::attach_module(int number)
410 if(number > -1 && number < module_data.total)
412 // title->update(module_data.values[number]->get_text());
413 thread->plugin_type = PLUGIN_SHAREDMODULE; // type is module
414 thread->shared_location = *(module_locations.values[number]); // copy location
419 int PluginDialog::save_settings()
430 PluginDialogTextBox::PluginDialogTextBox(PluginDialog *dialog, char *text, int x, int y)
431 : BC_TextBox(x, y, 200, 1, text)
433 this->dialog = dialog;
435 PluginDialogTextBox::~PluginDialogTextBox()
437 int PluginDialogTextBox::handle_event()
440 PluginDialogDetach::PluginDialogDetach(MWindow *mwindow, PluginDialog *dialog, int x, int y)
441 : BC_GenericButton(x, y, _("Detach"))
443 this->dialog = dialog;
445 PluginDialogDetach::~PluginDialogDetach()
447 int PluginDialogDetach::handle_event()
449 // dialog->title->update(_("None"));
450 dialog->thread->plugin_type = 0; // type is none
451 dialog->thread->plugin_title[0] = 0;
468 PluginDialogNew::PluginDialogNew(PluginDialog *dialog,
469 ArrayList<BC_ListBoxItem*> *standalone_data,
481 this->dialog = dialog;
483 PluginDialogNew::~PluginDialogNew() { }
484 int PluginDialogNew::handle_event()
486 dialog->attach_new(get_selection_number(0, 0));
492 int PluginDialogNew::selection_changed()
494 dialog->selected_available = get_selection_number(0, 0);
498 PluginDialogAttachNew::PluginDialogAttachNew(MWindow *mwindow, PluginDialog *dialog, int x, int y)
499 : BC_GenericButton(x, y, _("Attach"))
501 this->dialog = dialog;
503 PluginDialogAttachNew::~PluginDialogAttachNew()
505 int PluginDialogAttachNew::handle_event()
507 dialog->attach_new(dialog->selected_available);
521 PluginDialogShared::PluginDialogShared(PluginDialog *dialog,
522 ArrayList<BC_ListBoxItem*> *shared_data,
534 this->dialog = dialog;
536 PluginDialogShared::~PluginDialogShared() { }
537 int PluginDialogShared::handle_event()
539 dialog->attach_shared(get_selection_number(0, 0));
544 int PluginDialogShared::selection_changed()
546 dialog->selected_shared = get_selection_number(0, 0);
550 PluginDialogAttachShared::PluginDialogAttachShared(MWindow *mwindow,
551 PluginDialog *dialog,
554 : BC_GenericButton(x, y, _("Attach"))
556 this->dialog = dialog;
558 PluginDialogAttachShared::~PluginDialogAttachShared() { }
559 int PluginDialogAttachShared::handle_event()
561 dialog->attach_module(dialog->selected_shared);
577 PluginDialogModules::PluginDialogModules(PluginDialog *dialog,
578 ArrayList<BC_ListBoxItem*> *module_data,
590 this->dialog = dialog;
592 PluginDialogModules::~PluginDialogModules() { }
593 int PluginDialogModules::handle_event()
595 dialog->attach_module(get_selection_number(0, 0));
601 int PluginDialogModules::selection_changed()
603 dialog->selected_modules = get_selection_number(0, 0);
608 PluginDialogAttachModule::PluginDialogAttachModule(MWindow *mwindow,
609 PluginDialog *dialog,
612 : BC_GenericButton(x, y, _("Attach"))
614 this->dialog = dialog;
616 PluginDialogAttachModule::~PluginDialogAttachModule() { }
617 int PluginDialogAttachModule::handle_event()
619 dialog->attach_module(dialog->selected_modules);
637 PluginDialogIn::PluginDialogIn(PluginDialog *dialog, int setting, int x, int y)
638 : BC_CheckBox(x, y, setting, _("Send"))
640 this->dialog = dialog;
642 PluginDialogIn::~PluginDialogIn() { }
643 int PluginDialogIn::handle_event()
645 // dialog->thread->in = get_value();
648 int PluginDialogIn::button_press()
650 dialog->inoutthru = 1;
651 dialog->new_value = get_value();
654 int PluginDialogIn::button_release()
656 if(dialog->inoutthru) dialog->inoutthru = 0;
658 int PluginDialogIn::cursor_moved_over()
660 if(dialog->inoutthru && get_value() != dialog->new_value)
662 update(dialog->new_value);
666 PluginDialogOut::PluginDialogOut(PluginDialog *dialog, int setting, int x, int y)
667 : BC_CheckBox(x, y, setting, _("Receive"))
669 this->dialog = dialog;
671 PluginDialogOut::~PluginDialogOut() { }
672 int PluginDialogOut::handle_event()
674 // dialog->thread->out = get_value();
677 int PluginDialogOut::button_press()
679 dialog->inoutthru = 1;
680 dialog->new_value = get_value();
683 int PluginDialogOut::button_release()
685 if(dialog->inoutthru) dialog->inoutthru = 0;
687 int PluginDialogOut::cursor_moved_over()
689 if(dialog->inoutthru && get_value() != dialog->new_value)
691 update(dialog->new_value);
695 PluginDialogThru::PluginDialogThru(PluginDialog *dialog, int setting)
696 : BC_CheckBox(300, 350, setting, _("Thru"))
698 this->dialog = dialog;
700 PluginDialogThru::~PluginDialogThru() { }
701 int PluginDialogThru::handle_event() { }
702 int PluginDialogThru::button_press()
704 dialog->inoutthru = 1;
705 dialog->new_value = get_value();
708 int PluginDialogThru::button_release()
710 if(dialog->inoutthru) dialog->inoutthru = 0;
712 int PluginDialogThru::cursor_moved_over()
714 if(dialog->inoutthru && get_value() != dialog->new_value)
716 update(dialog->new_value);