X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fplugindialog.C;h=fa24bb5b27989db1dee6eda77bd7f7db215f9e66;hb=83b70dd60863377cb281e6be5206304e10373e30;hp=439a6efb5d5feffb6d83f6b48bae9b94fd412dc7;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/plugindialog.C b/cinelerra-5.1/cinelerra/plugindialog.C index 439a6efb..fa24bb5b 100644 --- a/cinelerra-5.1/cinelerra/plugindialog.C +++ b/cinelerra-5.1/cinelerra/plugindialog.C @@ -44,7 +44,8 @@ PluginDialogThread::PluginDialogThread(MWindow *mwindow) : BC_DialogThread() { this->mwindow = mwindow; - plugin = 0; + this->plugin_id = -1; + this->plugin_type = PLUGIN_NONE; } PluginDialogThread::~PluginDialogThread() @@ -61,7 +62,6 @@ void PluginDialogThread::start_window(Track *track, // mwindow->gui->lock_window("PluginDialogThread::start_window"); this->track = track; this->data_type = data_type; - this->plugin = plugin; this->is_mainmenu = is_mainmenu; single_standalone = mwindow->edl->session->single_standalone; @@ -70,6 +70,7 @@ void PluginDialogThread::start_window(Track *track, plugin->calculate_title(plugin_title, 0); this->shared_location = plugin->shared_location; this->plugin_type = plugin->plugin_type; + this->plugin_id = plugin->orig_id; } else { @@ -77,6 +78,7 @@ void PluginDialogThread::start_window(Track *track, this->shared_location.plugin = -1; this->shared_location.module = -1; this->plugin_type = PLUGIN_NONE; + this->plugin_id = -1; } strcpy(this->window_title, title); @@ -94,7 +96,7 @@ BC_Window* PluginDialogThread::new_gui() mwindow->session->plugindialog_w / 2; int y = mwindow->gui->get_abs_cursor_y(0) - mwindow->session->plugindialog_h / 2; - plugin_type = 0; + plugin_type = PLUGIN_NONE; PluginDialog *window = new PluginDialog(mwindow, this, window_title, @@ -107,115 +109,46 @@ BC_Window* PluginDialogThread::new_gui() void PluginDialogThread::handle_done_event(int result) { - PluginDialog *window = (PluginDialog*)BC_DialogThread::get_gui(); - if(window->selected_available >= 0) - { - window->attach_new(window->selected_available); - } - else - if(window->selected_shared >= 0) - { - window->attach_shared(window->selected_shared); + if( !result ) { + PluginDialog *dialog = (PluginDialog *)get_gui(); + dialog->apply(); } - else - if(window->selected_modules >= 0) - { - window->attach_module(window->selected_modules); - } - if( mwindow->edl ) - mwindow->edl->session->single_standalone = single_standalone; } + void PluginDialogThread::handle_close_event(int result) { - if(!result) - { - if(plugin_type) - { - mwindow->gui->lock_window("PluginDialogThread::run 3"); - - - mwindow->undo->update_undo_before(); - if(is_mainmenu) - { - mwindow->insert_effect(plugin_title, - &shared_location, - data_type, - plugin_type, - single_standalone); - } - else - { - if(plugin) - { - if(mwindow->edl->tracks->plugin_exists(plugin)) - { - plugin->change_plugin(plugin_title, - &shared_location, - plugin_type); - } - } - else - { - if(mwindow->edl->tracks->track_exists(track)) - { - mwindow->insert_effect(plugin_title, - &shared_location, - track, - 0, - 0, - 0, - plugin_type); - } - } - } - - mwindow->save_backup(); - mwindow->undo->update_undo_after(_("attach effect"), LOAD_EDITS | LOAD_PATCHES); - mwindow->restart_brender(); - mwindow->update_plugin_states(); - mwindow->sync_parameters(CHANGE_EDL); - mwindow->gui->update(1, - 1, - 0, - 0, - 1, - 0, - 0); - - mwindow->gui->unlock_window(); - } - } - plugin = 0; } - - - - PluginDialog::PluginDialog(MWindow *mwindow, PluginDialogThread *thread, const char *window_title, int x, int y) - : BC_Window(window_title, - x, - y, + : BC_Window(window_title, x, y, mwindow->session->plugindialog_w, mwindow->session->plugindialog_h, - 510, - 415, - 1, - 0, - 1) + xS(510), yS(415), 1, 0, 1) { this->mwindow = mwindow; this->thread = thread; single_standalone = 0; +// *** CONTEXT_HELP *** + switch( thread->data_type ) { + case TRACK_AUDIO: + context_help_set_keyword("Audio Effects"); + break; + case TRACK_VIDEO: + context_help_set_keyword("Video Effects"); + break; + default: + context_help_set_keyword("How to Use Plugins"); + break; + } } PluginDialog::~PluginDialog() @@ -239,6 +172,8 @@ PluginDialog::~PluginDialog() void PluginDialog::create_objects() { + int xs10 = xS(10); + int ys10 = yS(10), ys20 = yS(20); // int use_default = 1; mwindow->theme->get_plugindialog_sizes(); lock_window("PluginDialog::create_objects"); @@ -258,18 +193,19 @@ void PluginDialog::create_objects() thread->data_type); // Construct listbox items - for(int i = 0; i < plugin_locations.total; i++) + for(int i = 0; i < plugin_locations.total; ) { Track *track = mwindow->edl->tracks->number(plugin_locations.values[i]->module); char *track_title = track->title; int number = plugin_locations.values[i]->plugin; double start = mwindow->edl->local_session->get_selectionstart(1); Plugin *plugin = track->get_current_plugin(start, number, PLAY_FORWARD, 1, 0); - if( !plugin ) continue; + if( !plugin ) { plugin_locations.remove_object_number(i); continue; } char string[BCTEXTLEN]; const char *plugin_title = _(plugin->title); snprintf(string, sizeof(string), "%s: %s", track_title, plugin_title); shared_data.append(new BC_ListBoxItem(string)); + ++i; } for(int i = 0; i < module_locations.total; i++) { @@ -277,18 +213,14 @@ void PluginDialog::create_objects() module_data.append(new BC_ListBoxItem(track->title)); } - - - - // Create widgets add_subwindow(standalone_title = new BC_Title(mwindow->theme->plugindialog_new_x, - mwindow->theme->plugindialog_new_y - 20, + mwindow->theme->plugindialog_new_y - ys20, _("Plugins:"))); int x1 = mwindow->theme->plugindialog_new_x, y1 = mwindow->theme->plugindialog_new_y; int w1 = mwindow->theme->plugindialog_new_w, h1 = mwindow->theme->plugindialog_new_h; add_subwindow(search_text = new PluginDialogSearchText(this, x1, y1, w1)); - int dy = search_text->get_h() + 10; + int dy = search_text->get_h() + ys10; y1 += dy; h1 -= dy; load_plugin_list(0); @@ -308,7 +240,7 @@ void PluginDialog::create_objects() // add_subwindow(shared_title = new BC_Title(mwindow->theme->plugindialog_shared_x, - mwindow->theme->plugindialog_shared_y - 20, + mwindow->theme->plugindialog_shared_y - ys20, _("Shared effects:"))); add_subwindow(shared_list = new PluginDialogShared(this, &shared_data, @@ -329,7 +261,7 @@ void PluginDialog::create_objects() // add_subwindow(module_title = new BC_Title(mwindow->theme->plugindialog_module_x, - mwindow->theme->plugindialog_module_y - 20, + mwindow->theme->plugindialog_module_y - ys20, _("Shared tracks:"))); add_subwindow(module_list = new PluginDialogModules(this, &module_data, @@ -359,16 +291,16 @@ void PluginDialog::create_objects() if(thread->is_mainmenu) add_subwindow(single_standalone = new PluginDialogSingle(this, - mwindow->theme->plugindialog_new_x + BC_OKButton::calculate_w() + 10, - mwindow->theme->plugindialog_new_y + - mwindow->theme->plugindialog_new_h + + mwindow->theme->plugindialog_new_x + BC_OKButton::calculate_w() + xs10, + mwindow->theme->plugindialog_new_y + mwindow->theme->plugindialog_new_h + get_text_height(MEDIUMFONT))); - - - add_subwindow(new BC_OKButton(this)); - add_subwindow(new BC_CancelButton(this)); - + add_subwindow(ok_btn = new BC_OKButton(this)); + add_subwindow(can_btn = new BC_CancelButton(this)); + int aw = PluginDialogApply::calculate_w(this, _("Apply")); + int ax = (ok_btn->get_x()+can_btn->get_x()-aw) / 2; + int ay = ok_btn->get_y() + ok_btn->get_h() - PluginDialogApply::calculate_h(); + add_subwindow(apy_btn = new PluginDialogApply(this, ax, ay)); selected_available = -1; selected_shared = -1; selected_modules = -1; @@ -380,17 +312,17 @@ void PluginDialog::create_objects() int PluginDialog::resize_event(int w, int h) { + int ys10 = yS(10), ys20 = yS(20); mwindow->session->plugindialog_w = w; mwindow->session->plugindialog_h = h; mwindow->theme->get_plugindialog_sizes(); - standalone_title->reposition_window(mwindow->theme->plugindialog_new_x, - mwindow->theme->plugindialog_new_y - 20); + mwindow->theme->plugindialog_new_y - ys20); int x1 = mwindow->theme->plugindialog_new_x, y1 = mwindow->theme->plugindialog_new_y; int w1 = mwindow->theme->plugindialog_new_w, h1 = mwindow->theme->plugindialog_new_h; search_text->reposition_window(x1, y1, w1); - int dy = search_text->get_h() + 10; + int dy = search_text->get_h() + ys10; y1 += dy; h1 -= dy; standalone_list->reposition_window(x1, y1, w1, h1); @@ -402,7 +334,7 @@ int PluginDialog::resize_event(int w, int h) // mwindow->theme->plugindialog_newattach_y); shared_title->reposition_window(mwindow->theme->plugindialog_shared_x, - mwindow->theme->plugindialog_shared_y - 20); + mwindow->theme->plugindialog_shared_y - ys20); shared_list->reposition_window(mwindow->theme->plugindialog_shared_x, mwindow->theme->plugindialog_shared_y, mwindow->theme->plugindialog_shared_w, @@ -419,7 +351,7 @@ int PluginDialog::resize_event(int w, int h) module_title->reposition_window(mwindow->theme->plugindialog_module_x, - mwindow->theme->plugindialog_module_y - 20); + mwindow->theme->plugindialog_module_y - ys20); module_list->reposition_window(mwindow->theme->plugindialog_module_x, mwindow->theme->plugindialog_module_y, mwindow->theme->plugindialog_module_w, @@ -434,10 +366,15 @@ int PluginDialog::resize_event(int w, int h) if(single_standalone) single_standalone->reposition_window( - mwindow->theme->plugindialog_new_x + BC_OKButton::calculate_w() + 10, + mwindow->theme->plugindialog_new_x + BC_OKButton::calculate_w() + ys10, mwindow->theme->plugindialog_new_y + mwindow->theme->plugindialog_new_h + get_text_height(MEDIUMFONT)); + int aw = PluginDialogApply::calculate_w(this, _("Apply")); + int ax = (ok_btn->get_x()+can_btn->get_x()-aw) / 2; + int ay = ok_btn->get_y() + ok_btn->get_h() - PluginDialogApply::calculate_h(); + apy_btn->reposition_window(ax, ay); + flush(); return 0; } @@ -478,6 +415,89 @@ void PluginDialog::save_settings() } +void PluginDialog::clear_selection() +{ + standalone_list->set_all_selected(&standalone_data, 0); + standalone_list->draw_items(1); + shared_list->set_all_selected(&shared_data, 0); + shared_list->draw_items(1); + module_list->set_all_selected(&module_data, 0); + module_list->draw_items(1); + selected_available = -1; + selected_shared = -1; + selected_modules = -1; + thread->plugin_id = -1; + thread->plugin_type = PLUGIN_NONE; +} + +void PluginDialog::apply() +{ + if( selected_available >= 0 ) { + attach_new(selected_available); + } + else if( selected_shared >= 0 ) { + attach_shared(selected_shared); + } + else if( selected_modules >= 0 ) { + attach_module(selected_modules); + } + + thread->apply(); +} + +void PluginDialogThread::apply() +{ + Plugin *plugin = 0; + EDL *edl = mwindow->edl; + if( edl ) + edl->session->single_standalone = single_standalone; + if(plugin_type) { + mwindow->gui->lock_window("PluginDialogThread::run 3"); + mwindow->undo->update_undo_before(); + if( is_mainmenu ) { + mwindow->insert_effect(plugin_title, &shared_location, + data_type, plugin_type, single_standalone); + } + else if( (plugin=edl->tracks->plugin_exists(plugin_id)) != 0 ) { + plugin->change_plugin(plugin_title, + &shared_location, plugin_type); + } + else if( edl->tracks->track_exists(track) ) { + double start = edl->local_session->get_selectionstart(); + double end = edl->local_session->get_selectionend(); + if( start >= end ) { + start = 0; + end = track->get_length(); + } + double length = end - start; + mwindow->insert_effect(plugin_title, &shared_location, + track, 0, start, length, plugin_type); + } + + mwindow->save_backup(); + mwindow->undo->update_undo_after(_("attach effect"), LOAD_EDITS | LOAD_PATCHES); + mwindow->restart_brender(); + mwindow->update_plugin_states(); + mwindow->sync_parameters(CHANGE_EDL); + mwindow->gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0); + mwindow->gui->unlock_window(); + } + plugin_id = -1; +} + +PluginDialogApply::PluginDialogApply(PluginDialog *dialog, int x, int y) + : BC_GenericButton(x, y, _("Apply")) +{ + this->dialog = dialog; +} + +int PluginDialogApply::handle_event() +{ + dialog->apply(); + dialog->clear_selection(); + return 1; +} + @@ -485,7 +505,7 @@ void PluginDialog::save_settings() // // PluginDialogTextBox::PluginDialogTextBox(PluginDialog *dialog, char *text, int x, int y) -// : BC_TextBox(x, y, 200, 1, text) +// : BC_TextBox(x, y, xS(200), 1, text) // { // this->dialog = dialog; // } @@ -512,16 +532,6 @@ void PluginDialog::save_settings() - - - - - - - - - - PluginDialogNew::PluginDialogNew(PluginDialog *dialog, ArrayList *standalone_data, int x, int y, int w, int h) @@ -553,6 +563,67 @@ int PluginDialogNew::selection_changed() return 1; } +// *** CONTEXT_HELP *** +int PluginDialogNew::keypress_event() +{ + int item, plugin_no; + char title[BCTEXTLEN]; + PluginServer *plugin = 0; + +// printf("PluginDialogNew::keypress_event: %d\n", get_keypress()); + + // If not our context help keystroke, redispatch it + // to the event handler of the base class + if (get_keypress() != 'h' || ! alt_down() || + ! is_tooltip_event_win() || ! cursor_inside()) + return BC_ListBox::keypress_event(); + + // Try to show help for the plugin currently under mouse + item = get_highlighted_item(); + if (item >= 0 && item < dialog->standalone_data.size()) { + plugin_no = ((PluginDialogListItem *)dialog->standalone_data[item])->item_no; + if (plugin_no >= 0 && plugin_no < dialog->plugindb.total) + plugin = dialog->plugindb.values[plugin_no]; + } + + // If some plugin is highlighted, show its help + // Otherwise show more general help + if (plugin) { + strcpy(title, plugin->title); + if (! strcmp(title, "Overlay")) { + // "Overlay" plugin title is ambiguous + if (plugin->audio) strcat(title, " \\(Audio\\)"); + if (plugin->video) strcat(title, " \\(Video\\)"); + } + if (plugin->is_ffmpeg()) { + // FFmpeg plugins can be audio or video + if (plugin->audio) + strcpy(title, "FFmpeg Audio Plugins"); + if (plugin->video) + strcpy(title, "FFmpeg Video Plugins"); + } + context_help_show(title); + return 1; + } + else { + switch (dialog->thread->data_type) { + case TRACK_AUDIO: + context_help_show("Audio Effects"); + return 1; + case TRACK_VIDEO: + context_help_show("Video Effects"); + return 1; + default: + context_help_show("How to Use Plugins"); + return 1; + } + context_help_show("How to Use Plugins"); + return 1; + } + context_help_show("How to Use Plugins"); + return 1; +} + // PluginDialogAttachNew::PluginDialogAttachNew(MWindow *mwindow, PluginDialog *dialog, int x, int y) // : BC_GenericButton(x, y, _("Attach")) // { @@ -584,28 +655,13 @@ int PluginDialogNew::selection_changed() // } - - - - - - - - PluginDialogShared::PluginDialogShared(PluginDialog *dialog, ArrayList *shared_data, - int x, - int y, - int w, - int h) - : BC_ListBox(x, - y, - w, - h, - LISTBOX_TEXT, - shared_data) + int x, int y, int w, int h) + : BC_ListBox(x, y, w, h, LISTBOX_TEXT, shared_data) { this->dialog = dialog; + context_help_set_keyword("Shared Effects and Shared Tracks"); } PluginDialogShared::~PluginDialogShared() { } int PluginDialogShared::handle_event() @@ -675,18 +731,11 @@ int PluginDialogShared::selection_changed() PluginDialogModules::PluginDialogModules(PluginDialog *dialog, ArrayList *module_data, - int x, - int y, - int w, - int h) - : BC_ListBox(x, - y, - w, - h, - LISTBOX_TEXT, - module_data) + int x, int y, int w, int h) + : BC_ListBox(x, y, w, h, LISTBOX_TEXT, module_data) { this->dialog = dialog; + context_help_set_keyword("Shared Effects and Shared Tracks"); } PluginDialogModules::~PluginDialogModules() { } int PluginDialogModules::handle_event() @@ -739,12 +788,11 @@ int PluginDialogSearchText::handle_event() } PluginDialogSingle::PluginDialogSingle(PluginDialog *dialog, int x, int y) - : BC_CheckBox(x, - y, - dialog->thread->single_standalone, + : BC_CheckBox(x, y, dialog->thread->single_standalone, _("Attach single standalone and share others")) { this->dialog = dialog; + context_help_set_keyword("Shared Effects and Shared Tracks"); } int PluginDialogSingle::handle_event() @@ -787,16 +835,3 @@ int PluginDialogSingle::handle_event() // } // - - - - - - - - - - - - -