add edit drag-handle constraits, add plugin/attach dialog apply btn
authorGood Guy <good1.2guy@gmail.com>
Fri, 12 Apr 2019 01:39:37 +0000 (19:39 -0600)
committerGood Guy <good1.2guy@gmail.com>
Fri, 12 Apr 2019 01:39:37 +0000 (19:39 -0600)
cinelerra-5.1/cinelerra/edit.C
cinelerra-5.1/cinelerra/plugindialog.C
cinelerra-5.1/cinelerra/plugindialog.h
cinelerra-5.1/cinelerra/plugindialog.inc

index 47ca63c3ffe915a28469da28700988e616b28186..bd82f45130cbe9f1fb88bdb74cac39ffb162a7a8 100644 (file)
@@ -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);
 }
index 89de2f99356d909f642cf41aee9d8dc5dbf53947..d9e73d39aa5e30cfaadf65d3b82a52437f2924c3 100644 (file)
@@ -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()
 
 
 
-
index e53e0f22f5c430cb27981f9b906fa11bc4d88b73..0559d9e75748116e164c7305ebf96a892c51a021 100644 (file)
 #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<BC_ListBoxItem*> 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
  * {
index 7cdebef878f00a7253f4459bb9e8b0f68e338ab5..f11f9bb331a43b81535617d3060dfffad358b508 100644 (file)
 #define PLUGINDIALOG_INC
 
 class PluginDialogThread;
+class PluginDialogListItem;
+class PluginDialog;
+class PluginDialogNew;
+class PluginDialogShared;
+class PluginDialogModules;
+class PluginDialogSingle;
+class PluginDialogSearchText;
+class PluginDialogApply;
 
 #endif