implement a delete operation that works like "cut" but doesn't put the deleted items... 3.0-alpha6
authorPaul Davis <paul@linuxaudiosystems.com>
Sun, 12 Jun 2011 15:50:47 +0000 (15:50 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Sun, 12 Jun 2011 15:50:47 +0000 (15:50 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9711 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour.menus.in
gtk2_ardour/automation_time_axis.cc
gtk2_ardour/editing.h
gtk2_ardour/editor.h
gtk2_ardour/editor_actions.cc
gtk2_ardour/editor_ops.cc
gtk2_ardour/midi_region_view.cc
gtk2_ardour/mnemonic-us.bindings.in
gtk2_ardour/route_time_axis.cc

index 1c2c6b5194b5eb6cb99e8c12dce76a873e799945..417c3b552ab0b788c7e2a3977b3266f15a9b1bda 100644 (file)
         <menuitem action='select-prev-route'/>
       </menu>     
       <separator/>
+      <menuitem action='editor-delete'/>
       <menuitem action='editor-crop'/>
       <menuitem action='split-region'/>
       <menuitem action='split-region-at-transients'/>
index d12dfa97bd6d9eee80a5318d02abfac568cf9eff..85ba4b378cc50906d7cea176c3d5dc1395f4e7b7 100644 (file)
@@ -627,6 +627,12 @@ AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& sel
        double const end = tc.from (selection.time.front().end - tc.origin_b ());
 
        switch (op) {
+       case Delete:
+               if (alist->cut (start, end) != 0) {
+                       _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
+               }
+               break;
+
        case Cut:
 
                if ((what_we_got = alist->cut (start, end)) != 0) {
@@ -720,6 +726,11 @@ AutomationTimeAxisView::cut_copy_clear_objects_one (AutomationLine& line, PointS
                }
 
                switch (op) {
+               case Delete:
+                       if (alist->cut ((*i).start, (*i).end) != 0) {
+                               _session->add_command (new MementoCommand<AutomationList>(*alist.get(), new XMLNode (before), &alist->get_state()));
+                       }
+                       break;
                case Cut:
                        if ((what_we_got = alist->cut ((*i).start, (*i).end)) != 0) {
                                _editor.get_cut_buffer().add (what_we_got);
index 6bc575116ba78e1da3e1c85f56ae4b8104a9f7d7..6ce6b74a514e3fdcdfe2365a27325a6001d8ce5c 100644 (file)
@@ -196,6 +196,7 @@ enum InsertTimeOption {
 /////////////////////
 // These don't need their state saved. yet...
 enum CutCopyOp {
+       Delete,
        Cut,
        Copy,
        Clear
index d38238acbfa0041b0cb9115da47df8d4fabedf41..8486a999b007f77b19c45232f8577501f3f52ab1 100644 (file)
@@ -1134,6 +1134,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void split_region ();
 
+       void delete_ ();
        void cut ();
        void copy ();
        void paste (float times);
index cec7b03721c5b0f5c11d99a704f478da9be5bd81..b1ef5328d1d6e3cfe7242db3bbed94e4e2344c83 100644 (file)
@@ -295,6 +295,7 @@ Editor::register_actions ()
        ActionManager::mouse_edit_point_requires_canvas_actions.push_back (act);
 
        reg_sens (editor_actions, "editor-cut", _("Cut"), sigc::mem_fun(*this, &Editor::cut));
+       reg_sens (editor_actions, "editor-delete", _("Delete"), sigc::mem_fun(*this, &Editor::delete_));
 
        reg_sens (editor_actions, "editor-copy", _("Copy"), sigc::mem_fun(*this, &Editor::copy));
        reg_sens (editor_actions, "editor-paste", _("Paste"), sigc::mem_fun(*this, &Editor::keyboard_paste));
index 622b102de80f81b52b382da33abae39979f09dc5..9c541191b4f8a908f3b4c5222a50c7cc69c11896 100644 (file)
@@ -3375,6 +3375,13 @@ Editor::bounce_range_selection (bool replace, bool enable_processing)
        commit_reversible_command ();
 }
 
+/** Delete selected regions, automation points or a time range */
+void
+Editor::delete_ ()
+{
+       cut_copy (Delete);
+}
+
 /** Cut selected regions, automation points or a time range */
 void
 Editor::cut ()
@@ -3427,6 +3434,9 @@ Editor::cut_copy (CutCopyOp op)
        string opname;
 
        switch (op) {
+       case Delete:
+               opname = _("delete");
+               break;
        case Cut:
                opname = _("cut");
                break;
@@ -3444,7 +3454,7 @@ Editor::cut_copy (CutCopyOp op)
           this function.
        */
 
-       if (op == Cut || op == Clear) {
+       if (op == Delete || op == Cut || op == Clear) {
                if (_drags->active ()) {
                        _drags->abort ();
                }
@@ -3497,7 +3507,7 @@ Editor::cut_copy (CutCopyOp op)
                                if (!rs.empty()) {
                                        cut_copy_regions (op, rs);
 
-                                       if (op == Cut) {
+                                       if (op == Cut || op == Delete) {
                                                selection->clear_regions ();
                                        }
                                }
@@ -3505,7 +3515,7 @@ Editor::cut_copy (CutCopyOp op)
                                if (!selection->points.empty()) {
                                        cut_copy_points (op);
 
-                                       if (op == Cut) {
+                                       if (op == Cut || op == Delete) {
                                                selection->clear_points ();
                                        }
                                }
@@ -3532,7 +3542,7 @@ Editor::cut_copy (CutCopyOp op)
                        cut_copy_ranges (op);
                        commit_reversible_command ();
 
-                       if (op == Cut) {
+                       if (op == Cut || op == Delete) {
                                selection->clear_time ();
                        }
 
@@ -3543,7 +3553,7 @@ Editor::cut_copy (CutCopyOp op)
                }
        }
 
-       if (op == Cut || op == Clear) {
+       if (op == Delete || op == Cut || op == Clear) {
                _drags->abort ();
        }
 }
@@ -3703,13 +3713,13 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs)
 
                first_position = min ((framepos_t) (*x)->region()->position(), first_position);
 
-               if (op == Cut || op == Clear) {
+               if (op == Cut || op == Clear || op == Delete) {
                        boost::shared_ptr<Playlist> pl = (*x)->region()->playlist();
 
                        if (pl) {
                                FreezeList::iterator fl;
 
-                               //only take state if this is a new playlist.
+                               // only take state if this is a new playlist.
                                for (fl = freezelist.begin(); fl != freezelist.end(); ++fl) {
                                        if ((*fl) == pl) {
                                                break;
@@ -3757,22 +3767,25 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs)
                tmp = x;
                ++tmp;
 
-               vector<PlaylistMapping>::iterator z;
+               if (op != Delete) {
 
-               for (z = pmap.begin(); z != pmap.end(); ++z) {
-                       if ((*z).tv == &tv) {
-                               break;
+                       vector<PlaylistMapping>::iterator z;
+                       
+                       for (z = pmap.begin(); z != pmap.end(); ++z) {
+                               if ((*z).tv == &tv) {
+                                       break;
+                               }
+                       }
+                       
+                       assert (z != pmap.end());
+                       
+                       if (!(*z).pl) {
+                               npl = PlaylistFactory::create (pl->data_type(), *_session, "cutlist", true);
+                               npl->freeze();
+                               (*z).pl = npl;
+                       } else {
+                               npl = (*z).pl;
                        }
-               }
-
-               assert (z != pmap.end());
-
-               if (!(*z).pl) {
-                       npl = PlaylistFactory::create (pl->data_type(), *_session, "cutlist", true);
-                       npl->freeze();
-                       (*z).pl = npl;
-               } else {
-                       npl = (*z).pl;
                }
 
                boost::shared_ptr<Region> r = (*x)->region();
@@ -3781,6 +3794,10 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs)
                assert (r != 0);
 
                switch (op) {
+               case Delete:
+                       pl->remove_region (r);
+                       break;
+                       
                case Cut:
                        _xx = RegionFactory::create (r);
                        npl->add_region (_xx, r->position() - first_position);
@@ -3790,9 +3807,7 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs)
                case Copy:
                        /* copy region before adding, so we're not putting same object into two different playlists */
                        npl->add_region (RegionFactory::create (r), r->position() - first_position);
-                       break;
-
-               case Clear:
+                                       case Clear:
                        pl->remove_region (r);
                        break;
                }
@@ -3800,25 +3815,28 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs)
                x = tmp;
        }
 
-       list<boost::shared_ptr<Playlist> > foo;
+       if (op != Delete) {
 
-       /* the pmap is in the same order as the tracks in which selected regions occured */
-
-       for (vector<PlaylistMapping>::iterator i = pmap.begin(); i != pmap.end(); ++i) {
-               if ((*i).pl) {
-                       (*i).pl->thaw();
-                       foo.push_back ((*i).pl);
+               list<boost::shared_ptr<Playlist> > foo;
+               
+               /* the pmap is in the same order as the tracks in which selected regions occured */
+               
+               for (vector<PlaylistMapping>::iterator i = pmap.begin(); i != pmap.end(); ++i) {
+                       if ((*i).pl) {
+                               (*i).pl->thaw();
+                               foo.push_back ((*i).pl);
+                       }
+               }
+               
+               if (!foo.empty()) {
+                       cut_buffer->set (foo);
+               }
+               
+               if (pmap.empty()) {
+                       _last_cut_copy_source_track = 0;
+               } else {
+                       _last_cut_copy_source_track = pmap.front().tv;
                }
-       }
-
-       if (!foo.empty()) {
-               cut_buffer->set (foo);
-       }
-
-       if (pmap.empty()) {
-               _last_cut_copy_source_track = 0;
-       } else {
-               _last_cut_copy_source_track = pmap.front().tv;
        }
 
        for (FreezeList::iterator pl = freezelist.begin(); pl != freezelist.end(); ++pl) {
index 802263810e032cd495d99443562b0b061d488a71..8553900278306b0fe3508b555d07c90794800cf8 100644 (file)
@@ -2943,6 +2943,9 @@ MidiRegionView::cut_copy_clear (Editing::CutCopyOp op)
        PublicEditor& editor (trackview.editor());
 
        switch (op) {
+       case Delete:
+               /* XXX what to do ? */
+               break;
        case Cut:
        case Copy:
                editor.get_cut_buffer().add (selection_as_cut_buffer());
@@ -2959,6 +2962,7 @@ MidiRegionView::cut_copy_clear (Editing::CutCopyOp op)
                        switch (op) {
                        case Copy:
                                break;
+                       case Delete:
                        case Cut:
                        case Clear:
                                note_diff_remove_note (*i);
index fe1837ed3df9f118049a305fdbe39ffb2c9a072b..434924c3c71bbae5267716b478508fcf610b4de6 100644 (file)
@@ -250,7 +250,7 @@ This mode provides many different operations on both regions and control points,
 @vis|Editor/scroll-tracks-up|Page_Up|scroll up (page)
 @movp|Transport/GotoStart|Home|to start marker
 @movp|Transport/GotoEnd|End|to end marker
-@edit|Editor/editor-cut|Delete|cut
+@edit|Editor/editor-delete|Delete|delete
 
 @movp|Editor/playhead-to-edit|Return|to edit point
 @eep|Editor/edit-to-playhead|<@SECONDARY@>Return|move EP to playhead
index b4ad4da1f4c1dfdb27d5a9b821bbc6ccfc3e0d42..7f9575f015e11267380b96130c59bff705a02c39 100644 (file)
@@ -1369,10 +1369,19 @@ RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
         playlist->clear_owned_changes ();
 
        switch (op) {
+       case Delete:
+               if (playlist->cut (time) != 0) {
+                        vector<Command*> cmds;
+                        playlist->rdiff (cmds);
+                        _session->add_commands (cmds);
+                       
+                        _session->add_command (new StatefulDiffCommand (playlist));
+               }
+               break;
+               
        case Cut:
                if ((what_we_got = playlist->cut (time)) != 0) {
                        _editor.get_cut_buffer().add (what_we_got);
-
                         vector<Command*> cmds;
                         playlist->rdiff (cmds);
                         _session->add_commands (cmds);