add deselect to editpopup menu, drag edit select/deselect
authorGood Guy <good1.2guy@gmail.com>
Sun, 11 Oct 2020 21:52:16 +0000 (15:52 -0600)
committerGood Guy <good1.2guy@gmail.com>
Sun, 11 Oct 2020 21:52:16 +0000 (15:52 -0600)
cinelerra-5.1/cinelerra/editpopup.C
cinelerra-5.1/cinelerra/editpopup.h
cinelerra-5.1/cinelerra/mainsession.inc
cinelerra-5.1/cinelerra/mwindow.h
cinelerra-5.1/cinelerra/mwindowedit.C
cinelerra-5.1/cinelerra/mwindowgui.C
cinelerra-5.1/cinelerra/trackcanvas.C
cinelerra-5.1/cinelerra/trackcanvas.h
cinelerra-5.1/cinelerra/tracks.C
cinelerra-5.1/cinelerra/tracks.h
cinelerra-5.1/doc/shortcuts.html

index 60dcafb8ae8a09a5814ca423e8a275f1029ad350..b1fef22f4315000c2011ef1c6db23e5c5a706ec9 100644 (file)
@@ -68,6 +68,7 @@ void EditPopup::create_objects()
        add_item(open_edl = new EditPopupOpenEDL(mwindow, this));
        add_item(new EditPopupClearSelect(mwindow, this));
        add_item(new EditPopupSelectEdits(mwindow, this));
+       add_item(new EditPopupDeselectEdits(mwindow, this));
        add_item(new EditPopupCopy(mwindow, this));
        add_item(new EditPopupCut(mwindow, this));
        add_item(new EditPopupMute(mwindow, this));
@@ -171,7 +172,20 @@ EditPopupSelectEdits::EditPopupSelectEdits(MWindow *mwindow, EditPopup *popup)
 
 int EditPopupSelectEdits::handle_event()
 {
-       mwindow->select_edits();
+       mwindow->select_edits(1);
+       return 1;
+}
+
+EditPopupDeselectEdits::EditPopupDeselectEdits(MWindow *mwindow, EditPopup *popup)
+ : BC_MenuItem(_("Deselect Edits"))
+{
+       this->mwindow = mwindow;
+       this->popup = popup;
+}
+
+int EditPopupDeselectEdits::handle_event()
+{
+       mwindow->select_edits(0);
        return 1;
 }
 
index ed3fe2f8c09e2de5b68ef8002e3295c7089b56d7..6a859bb3db07117530c1bdd42d5a4c2c25121e16 100644 (file)
@@ -83,6 +83,16 @@ public:
        EditPopup *popup;
 };
 
+class EditPopupDeselectEdits : public BC_MenuItem
+{
+public:
+       EditPopupDeselectEdits(MWindow *mwindow, EditPopup *popup);
+       int handle_event();
+
+       MWindow *mwindow;
+       EditPopup *popup;
+};
+
 class EditPopupCopy : public BC_MenuItem
 {
 public:
index 754183c29e85ce21b9b24c6504880bbbd6724813..e16e82bc9d127cd01b0cadeaac81a3be33d5a5b2 100644 (file)
@@ -67,6 +67,7 @@ enum
        DRAG_GROUP,
        GROUP_TOGGLE,
        DROP_TARGETING,
+       DRAG_EDIT_SELECT,
 };
 
 
index c636d787f337f71a0ad33b94cca2bf5ec292e9e2..73cdcfac22721a610fafe690123712b073444bc6 100644 (file)
@@ -448,7 +448,7 @@ public:
        void clear_hard_edges();
        int clear_hard_edges(double start, double end);
        void clear_select();
-       void select_edits();
+       void select_edits(int v);
        void concatenate_tracks();
        int copy_flags(int copy_flags=COPY_CLIPBOARD);
        void copy();
index b35cd335e7457f48b25e3d50200dc6951af75883..6f74435b63610b0e6a6157267a1a9dadaf15aa2f 100644 (file)
@@ -426,11 +426,11 @@ void MWindow::clear_select()
        gui->draw_overlays(1);
 }
 
-void MWindow::select_edits()
+void MWindow::select_edits(int v)
 {
        double start = edl->local_session->get_selectionstart();
        double end = edl->local_session->get_selectionend();
-       edl->tracks->select_edits(start, end);
+       edl->tracks->select_edits(start, end, v);
        gui->draw_overlays(1);
 }
 
index 5f9edd9202ec5eeb27d89294df40877f6d16c017..17078ba4eae650dc1a50c4a308b5204e37023458 100644 (file)
@@ -1098,7 +1098,7 @@ int MWindowGUI::keypress_event()
                        result = 1;
                }
                else if( ctrl_down() && alt_down() ) {
-                       mwindow->select_edits();
+                       mwindow->select_edits(1);
                        result = 1;
                }
                break;
index 098090a693c4d419f0ebfbf17b26ebd76fef2981..536fabc6325e5d31e07c9ea444680291fa997ae0 100644 (file)
@@ -188,6 +188,7 @@ int TrackCanvas::drag_motion(
                Track **over_track, Edit **over_edit,
                PluginSet **over_pluginset, Plugin **over_plugin)
 {
+       int update_scroll = 0;
        int cursor_x = get_relative_cursor_x();
        int cursor_y = get_relative_cursor_y();
        if( get_cursor_over_window() ) {
@@ -196,6 +197,28 @@ int TrackCanvas::drag_motion(
        }
        if( over_track && !*over_track )
                *over_track = pane->over_patchbay();
+
+       switch( mwindow->session->current_operation ) {
+       case DRAG_EDIT_SELECT: {
+               Edit *edit = over_edit ? *over_edit : 0;
+               double position = mwindow->edl->get_cursor_position(cursor_x, pane->number);
+               mwindow->session->drag_position = mwindow->edl->align_to_frame(position, 0);
+               drag_edit_select(edit, 0, 1);
+               update_scroll = 1;
+               break; }
+       }
+
+       if( update_scroll ) {
+               if( !drag_scroll &&
+                   (cursor_x >= get_w() || cursor_x < 0 ||
+                    cursor_y >= get_h() || cursor_y < 0))
+                       start_dragscroll();
+               else if( drag_scroll &&
+                        cursor_x < get_w() && cursor_x >= 0 &&
+                        cursor_y < get_h() && cursor_y >= 0 )
+                       stop_dragscroll();
+       }
+
        return 0;
 }
 
@@ -500,7 +523,7 @@ int TrackCanvas::drag_stop(int *redraw)
                                result = 1;
                        }
                        break;
-               case DRAG_GROUP:
+               case DRAG_GROUP: {
                        mwindow->session->current_operation = NO_OPERATION;
                        EDL *drag_group = mwindow->session->drag_group;
                        if( drag_group ) {
@@ -532,10 +555,21 @@ int TrackCanvas::drag_stop(int *redraw)
                                }
                        }
                        result = 1;
+                       break; }
+               case DRAG_EDIT_SELECT:
+                       int select = ctrl_down() ? -1 : 1;
+                       drag_edit_select(mwindow->session->edit_highlighted, select, 0);
                        break;
                }
        }
 
+       switch( mwindow->session->current_operation ) {
+       case DRAG_EDIT_SELECT:
+               mwindow->session->current_operation = NO_OPERATION;
+               result = 1;
+               break;
+       }
+
        return result;
 }
 
@@ -4293,6 +4327,53 @@ void TrackCanvas::update_drag_caption()
 }
 
 
+void TrackCanvas::drag_edit_select(Edit *over_edit, int select, int draw)
+{
+       if( !over_edit ) return;
+       if( !mwindow->session->drag_edit ) return;
+       Track *drag_track = mwindow->session->drag_edit->track;
+       Track *over_track = over_edit->track;
+       if( !drag_track || !over_track ) return;
+       if( drag_track->number_of() > over_track->number_of() ) {
+               Track *trk = drag_track;
+               drag_track = over_track;
+               over_track = trk;
+       }
+       double start_pos = mwindow->session->drag_start;
+       double end_pos = mwindow->session->drag_position;
+       if( start_pos > end_pos ) {
+               double pos = start_pos;
+               start_pos = end_pos;
+               end_pos = pos;
+       }
+       int done = 0, do_flash = 0;
+       for( Track *track=drag_track; !done; track=track->next ) {
+               if( !track->is_armed() ) continue;
+               for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+                       int64_t pos = edit->startproject;
+                       int64_t end = pos + edit->length;
+                       double edit_start = track->from_units(pos);
+                       double edit_end = track->from_units(end);
+                       if( start_pos >= edit_end ) continue;
+                       if( edit_start > end_pos ) continue;
+                       if( select > 0 )
+                               edit->is_selected = 1;
+                       else if( select < 0 )
+                               edit->is_selected = 0;
+                       if( draw ) {
+                               int64_t edit_x, edit_y, edit_w, edit_h;
+                               edit_dimensions(edit, edit_x, edit_y, edit_w, edit_h);
+                               set_color(YELLOW);
+                               draw_rectangle(edit_x, edit_y, edit_w, edit_h);
+                               do_flash = 1;
+                       }
+               }
+               if( track == over_track ) done = 1;
+       }
+       if( do_flash )
+               flash();
+}
+
 
 int TrackCanvas::cursor_update(int in_motion)
 {
@@ -4306,7 +4387,7 @@ int TrackCanvas::cursor_update(int in_motion)
        int update_cursor = 0;
        int rerender = 0;
        double position = 0.;
-//printf("TrackCanvas::cursor_update %d\n", __LINE__);
+//printf("TrackCanvas::cursor_update %d %d,%d\n", __LINE__, get_cursor_x(), get_cursor_y());
 
 // Default cursor
        int new_cursor =
@@ -4577,6 +4658,7 @@ int TrackCanvas::repeat_event(int64_t duration)
        int result = 0;
 
        switch(mwindow->session->current_operation) {
+               case DRAG_EDIT_SELECT:
                case SELECT_REGION:
 //printf("TrackCanvas::repeat_event 1 %d\n", mwindow->edl->local_session->view_start);
                if(get_cursor_x() > get_w()) {
@@ -4774,6 +4856,10 @@ int TrackCanvas::button_release_event()
                        drag_scroll = 0;
                        break; }
 
+               case DRAG_EDIT_SELECT:
+                       //result = 0;
+                       break;
+
                default:
                        if( mwindow->session->current_operation ) {
 //                             if(mwindow->session->current_operation == SELECT_REGION) {
@@ -5185,8 +5271,15 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag
                                        mwindow->session->drag_origin_x = cursor_x;
                                        mwindow->session->drag_origin_y = cursor_y;
 // Where the drag started, so we know relative position inside the edit later
-                                       mwindow->session->drag_position =
-                                               mwindow->edl->get_cursor_position(cursor_x, pane->number);
+                                       double position = mwindow->edl->get_cursor_position(cursor_x, pane->number);
+                                       mwindow->session->drag_position = mwindow->edl->align_to_frame(position, 1);
+                                       if( get_buttonpress() == LEFT_BUTTON && alt_down() ) {
+                                               mwindow->session->drag_start = mwindow->session->drag_position;
+                                               drag_edit_select(edit, 0, 1);
+                                               mwindow->session->current_operation = DRAG_EDIT_SELECT;
+                                               result = 1;
+                                               continue;
+                                       }
                                        drag_start = 0; // if unselected "fast" drag
                                        if( !edit->silence() && !edit->is_selected ) {
                                                mwindow->edl->tracks->clear_selected_edits();
index 3d1ded196c39c94e69e7a7e068379c4382c9b127..15f8db630e6233c13506fde87251866c11c8cc38 100644 (file)
@@ -308,6 +308,7 @@ public:
 
 // Update status bar to reflect drag operation
        void update_drag_caption();
+       void drag_edit_select(Edit *over_edit, int select, int draw);
 
        int get_title_h();
 
index 07524f1f342ccb296a1b32dfb9eda4b6e6b7071d..8cbf92cec4c927bc3a7732d7b8547e858f5bb85a 100644 (file)
@@ -126,7 +126,7 @@ void Tracks::get_selected_edits(ArrayList<Edit*> *drag_edits)
        }
 }
 
-void Tracks::select_edits(double start, double end)
+void Tracks::select_edits(double start, double end, int v)
 {
        for( Track *track=first; track; track=track->next ) {
                if( !track->is_armed() ) continue;
@@ -135,7 +135,7 @@ void Tracks::select_edits(double start, double end)
                for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
                        if( start_pos >= edit->startproject+edit->length ) continue;
                        if( edit->startproject >= end_pos ) continue;
-                       edit->is_selected = 1;
+                       edit->is_selected = v > 1 ? 1 : v < 0 ? 0 : !edit->is_selected ;
                }
        }
 }
index cc1486d828f8dd32d852612ab4271a812d02cafb..0f4b9647602396318cd389c8e3660901205228cd 100644 (file)
@@ -59,7 +59,7 @@ public:
        void clear_selected_edits();
        int clear_hard_edges(double start, double end);
        void get_selected_edits(ArrayList<Edit*> *drag_edits);
-       void select_edits(double start, double end);
+       void select_edits(double start, double end, int v);
        int next_group_id();
        int new_group(int id);
        int set_group_selected(int id, int v);
index a5bbc041b0bd2e4c3a8c6b19b45374bd32462e6a..57abd0890101cc4af7420710f04333560fe54aa2 100644 (file)
                 <td align="left"><font face="Liberation Serif" size=4>Ctrl-Alt-a</font></td>
                 <td align="left"><font face="Liberation Serif" size=4>Add highlighted to selected edits</font></td>
         </tr>
+        <tr>
+                <td height="26" align="left"><font face="Liberation Serif" size=4><br></font></td>
+                <td align="left"><font face="Liberation Serif" size=4>LMB</font></td>
+                <td align="left"><font face="Liberation Serif" size=4>Alt + Drag </font></td>
+                <td align="left"><font face="Liberation Serif" size=4>Drag Select</font></td>
+        </tr>
+        <tr>
+                <td height="26" align="left"><font face="Liberation Serif" size=4><br></font></td>
+                <td align="left"><font face="Liberation Serif" size=4>LMB</font></td>
+                <td align="left"><font face="Liberation Serif" size=4>Ctrl+Alt + Drag </font></td>
+                <td align="left"><font face="Liberation Serif" size=4>Drag Deselect</font></td>
+        </tr>
         <tr>
                 <td height="26" align="left"><font face="Liberation Serif" size=4><br></font></td>
                 <td align="left"><font face="Liberation Serif" size=4>Copy</font></td>