X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fplugindialog.C;h=006cf40e2ce1dc82e845ce68c48871e73b179447;hp=ad964d52bbdef8801e530f21cf45d9d17b8599b9;hb=686bc04a488847170d80ec603f8c33962a7aa928;hpb=b46dd3711f7aaa94d2df9f27cd2ce16f7487693a diff --git a/cinelerra-5.1/cinelerra/plugindialog.C b/cinelerra-5.1/cinelerra/plugindialog.C index ad964d52..006cf40e 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 = 0; + this->plugin_type = PLUGIN_NONE; } PluginDialogThread::~PluginDialogThread() @@ -94,7 +95,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,96 +108,21 @@ 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, @@ -367,9 +293,12 @@ void PluginDialog::create_objects() - 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; @@ -439,6 +368,11 @@ int PluginDialog::resize_event(int w, int h) 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; } @@ -479,6 +413,86 @@ 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 = 0; + 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() +{ + if( mwindow->edl ) + mwindow->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 ) { + 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, NORMAL_DRAW, 0, 0, 1, 0, 0); + mwindow->gui->unlock_window(); + } + plugin = 0; +} + +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; +} + @@ -800,4 +814,3 @@ int PluginDialogSingle::handle_event() -