From: Good Guy Date: Fri, 12 Apr 2019 01:39:37 +0000 (-0600) Subject: add edit drag-handle constraits, add plugin/attach dialog apply btn X-Git-Tag: 2019-08~69 X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=5c8da1404ee2707ea621e9361541bdc973bcfbb9;p=goodguy%2Fcinelerra.git add edit drag-handle constraits, add plugin/attach dialog apply btn --- diff --git a/cinelerra-5.1/cinelerra/edit.C b/cinelerra-5.1/cinelerra/edit.C index 47ca63c3..bd82f451 100644 --- a/cinelerra-5.1/cinelerra/edit.C +++ b/cinelerra-5.1/cinelerra/edit.C @@ -443,7 +443,11 @@ int Edit::shift_start(int edit_mode, int64_t newposition, int64_t oldposition, int edit_labels, int edit_autos, int edit_plugins, Edits *trim_edits) { int64_t cut_length = newposition - oldposition; - if( !cut_length ) return 0; + if( cut_length > length ) + cut_length = length; + else if( cut_length < -length ) + cut_length = -length; + int64_t start = startproject, end = start + length; Edit *prev = this->previous, *next = this->next; int edits_moved = 0, rest_moved = 0; @@ -458,6 +462,8 @@ int Edit::shift_start(int edit_mode, int64_t newposition, int64_t oldposition, edit->startproject += cut_length; break; case MOVE_ROLL: + if( prev && prev->length + cut_length < 0 ) + cut_length = -prev->length; if( prev ) prev->trim(cut_length); startproject += cut_length; startsource += cut_length; @@ -469,6 +475,10 @@ int Edit::shift_start(int edit_mode, int64_t newposition, int64_t oldposition, break; case MOVE_SLIDE: edits_moved = 1; + if( prev && prev->length + cut_length < 0 ) + cut_length = -prev->length; + if( next && next->length - cut_length < 0 ) + cut_length = next->length; if( prev ) prev->trim(cut_length); startproject += cut_length; if( next ) { @@ -486,7 +496,6 @@ int Edit::shift_start(int edit_mode, int64_t newposition, int64_t oldposition, break; } trim(0); - return follow_edits(start, end, cut_length, edits_moved, rest_moved, edit_labels, edit_autos, edit_plugins, trim_edits); } @@ -495,7 +504,10 @@ int Edit::shift_end(int edit_mode, int64_t newposition, int64_t oldposition, int edit_labels, int edit_autos, int edit_plugins, Edits *trim_edits) { int64_t cut_length = newposition - oldposition; - if( !cut_length ) return 0; + if( cut_length > length ) + cut_length = length; + else if( cut_length < -length ) + cut_length = -length; int64_t start = startproject, end = start + length; Edit *prev = this->previous, *next = this->next; int edits_moved = 0, rest_moved = 0; @@ -509,6 +521,8 @@ int Edit::shift_end(int edit_mode, int64_t newposition, int64_t oldposition, edit->startproject += cut_length; break; case MOVE_ROLL: + if( next && next->length - cut_length < 0 ) + cut_length = next->length; length += cut_length; if( next ) { next->startproject += cut_length; @@ -522,6 +536,10 @@ int Edit::shift_end(int edit_mode, int64_t newposition, int64_t oldposition, break; case MOVE_SLIDE: edits_moved = 1; + if( prev && prev->length + cut_length < 0 ) + cut_length = -prev->length; + if( next && next->length - cut_length < 0 ) + cut_length = next->length; if( prev ) prev->trim(cut_length); startproject += cut_length; if( next ) { @@ -532,7 +550,6 @@ int Edit::shift_end(int edit_mode, int64_t newposition, int64_t oldposition, break; } trim(0); - return follow_edits(start, end, cut_length, edits_moved, rest_moved, edit_labels, edit_autos, edit_plugins, trim_edits); } diff --git a/cinelerra-5.1/cinelerra/plugindialog.C b/cinelerra-5.1/cinelerra/plugindialog.C index 89de2f99..d9e73d39 100644 --- a/cinelerra-5.1/cinelerra/plugindialog.C +++ b/cinelerra-5.1/cinelerra/plugindialog.C @@ -107,89 +107,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); - } - else - if(window->selected_modules >= 0) - { - window->attach_module(window->selected_modules); + if( !result ) { + PluginDialog *dialog = (PluginDialog *)get_gui(); + dialog->apply(); } - 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, NORMAL_DRAW, 0, 0, 1, 0, 0); - mwindow->gui->unlock_window(); - } - } - plugin = 0; } - - - - PluginDialog::PluginDialog(MWindow *mwindow, PluginDialogThread *thread, const char *window_title, @@ -360,9 +292,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; @@ -432,6 +367,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; } @@ -472,6 +412,70 @@ void PluginDialog::save_settings() } +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(); + return 1; +} + @@ -793,4 +797,3 @@ int PluginDialogSingle::handle_event() - diff --git a/cinelerra-5.1/cinelerra/plugindialog.h b/cinelerra-5.1/cinelerra/plugindialog.h index e53e0f22..0559d9e7 100644 --- a/cinelerra-5.1/cinelerra/plugindialog.h +++ b/cinelerra-5.1/cinelerra/plugindialog.h @@ -22,26 +22,13 @@ #ifndef PLUGINDIALOG_H #define PLUGINDIALOG_H -class PluginDialogTextBox; -class PluginDialogDetach; -class PluginDialogNew; -class PluginDialogShared; -class PluginDialogSearchText; -class PluginDialogModules; -class PluginDialogAttachNew; -class PluginDialogChangeNew; -class PluginDialogIn; -class PluginDialogOut; -class PluginDialogThru; -class PluginDialogSingle; -class PluginDialog; - #include "bcdialog.h" #include "condition.inc" #include "guicast.h" #include "mutex.inc" #include "mwindow.inc" #include "plugin.inc" +#include "plugindialog.inc" #include "pluginserver.inc" #include "sharedlocation.h" #include "thread.h" @@ -63,6 +50,7 @@ public: BC_Window* new_gui(); void handle_done_event(int result); void handle_close_event(int result); + void apply(); MWindow *mwindow; Track *track; @@ -114,6 +102,7 @@ public: void save_settings(); int resize_event(int w, int h); void load_plugin_list(int redraw); + void apply(); BC_Title *standalone_title; PluginDialogNew *standalone_list; @@ -123,9 +112,9 @@ public: PluginDialogModules *module_list; PluginDialogSingle *single_standalone; PluginDialogSearchText *search_text; - - PluginDialogThru *thru; - + BC_OKButton *ok_btn; + BC_CancelButton *can_btn; + PluginDialogApply *apy_btn; PluginDialogThread *thread; ArrayList standalone_data; @@ -255,6 +244,14 @@ public: PluginDialog *dialog; }; +class PluginDialogApply : public BC_GenericButton +{ +public: + PluginDialogApply(PluginDialog *dialog, int x, int y); + int handle_event(); + + PluginDialog *dialog; +}; /* * class PluginDialogAttachShared : public BC_GenericButton * { diff --git a/cinelerra-5.1/cinelerra/plugindialog.inc b/cinelerra-5.1/cinelerra/plugindialog.inc index 7cdebef8..f11f9bb3 100644 --- a/cinelerra-5.1/cinelerra/plugindialog.inc +++ b/cinelerra-5.1/cinelerra/plugindialog.inc @@ -23,5 +23,13 @@ #define PLUGINDIALOG_INC class PluginDialogThread; +class PluginDialogListItem; +class PluginDialog; +class PluginDialogNew; +class PluginDialogShared; +class PluginDialogModules; +class PluginDialogSingle; +class PluginDialogSearchText; +class PluginDialogApply; #endif