some code shuffling to make sure that cut mode always operates at the mouse location...
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 7 Jul 2014 14:13:19 +0000 (10:13 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 7 Jul 2014 14:13:26 +0000 (10:13 -0400)
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_drag.cc
gtk2_ardour/editor_drag.h
gtk2_ardour/editor_mouse.cc
gtk2_ardour/public_editor.h

index e489f39103d909271fa9abbd0bb91928c29a9db8..07bd6f7d78612f150ec2491e89b165e48a6c2ed6 100644 (file)
@@ -4560,6 +4560,50 @@ Editor::get_regions_from_selection_and_edit_point ()
        return regions;
 }
 
+/** Get regions using the following method:
+ *
+ *  Make a region list using:
+ *   (a) any selected regions
+ *   (b) the intersection of any selected tracks and the edit point(*)
+ *   (c) if neither exists, then whatever region is under the mouse
+ *
+ *  (*) NOTE: in this case, if 'No Selection = All Tracks' is active, search all tracks
+ *
+ *  Note that we have forced the rule that selected regions and selected tracks are mutually exclusive
+ */
+RegionSelection
+Editor::get_regions_from_selection_and_mouse ()
+{
+       RegionSelection regions;
+
+       if (entered_regionview && selection->tracks.empty() && selection->regions.empty() ) {
+               regions.add (entered_regionview);
+       } else {
+               regions = selection->regions;
+       }
+
+       if ( regions.empty() ) {
+               TrackViewList tracks = selection->tracks;
+
+               if (_route_groups->all_group_active_button().get_active() && tracks.empty()) {
+                       /* tracks is empty (no track selected), and 'No Selection = All Tracks'
+                        * is enabled, so consider all tracks
+                        */
+                       tracks = track_views; 
+               }
+
+               if (!tracks.empty()) {
+                       /* no region selected or entered, but some selected tracks:
+                        * act on all regions on the selected tracks at the edit point
+                        */ 
+                       framepos_t const where = get_preferred_edit_position ();
+                       get_regions_at(regions, where, tracks);
+               }
+       }
+
+       return regions;
+}
+
 /** Start with regions that are selected, or the entered regionview if none are selected.
  *  Then add equivalent regions on tracks in the same active edit-enabled route group as any
  *  of the regions that we started with.
index eca9714b015a8ac9de3aaa5db1005b554d01a7c8..75b66d6f047c7a3047a0fff6c25aa347a0a69a5c 100644 (file)
@@ -472,8 +472,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        /* editing operations that need to be public */
        void mouse_add_new_marker (framepos_t where, bool is_cd=false, bool is_xrun=false);
-       void split_region ();
+       void split_regions_at (framepos_t, RegionSelection&);
        void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret, bool select_new = false);
+       RegionSelection get_regions_from_selection_and_mouse ();
        
   protected:
        void map_transport_state ();
@@ -1137,7 +1138,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void change_region_layering_order (bool from_context_menu);
        void lower_region ();
        void lower_region_to_bottom ();
-       void split_regions_at (framepos_t, RegionSelection&);
        void split_region_at_transients ();
        void crop_region_to_selection ();
        void crop_region_to (framepos_t start, framepos_t end);
@@ -1190,6 +1190,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void reset_focus ();
 
+       void split_region ();
+
        void delete_ ();
        void cut ();
        void copy ();
index 10968d1cfb5d19694942965d68b6bceef1c624ec..bf013c43527a75a117cbf03726fb243dacb2b7e2 100644 (file)
@@ -5449,11 +5449,12 @@ CrossfadeEdgeDrag::aborted (bool)
        }
 }
 
-RegionCutDrag::RegionCutDrag (Editor* e, ArdourCanvas::Item* item)
+RegionCutDrag::RegionCutDrag (Editor* e, ArdourCanvas::Item* item, framepos_t pos)
        : Drag (e, item, true)
        , line (new EditorCursor (*e))
 {
-       line->set_position (_editor->get_preferred_edit_position());
+       line->set_position (pos);
+       line->show ();
 }
 
 RegionCutDrag::~RegionCutDrag ()
@@ -5471,7 +5472,14 @@ void
 RegionCutDrag::finished (GdkEvent*, bool)
 {
        line->hide ();
-       _editor->split_region ();
+
+       RegionSelection rs = _editor->get_regions_from_selection_and_mouse ();
+
+       if (rs.empty()) {
+               return;
+       }
+
+       _editor->split_regions_at (_drags->current_pointer_frame(), rs);
 }
 
 void
index bf049953094a856d9b67d6a310b06523899b38a9..378162621e5a9efde9bb2ecfdeea5a46da2f6931 100644 (file)
@@ -444,7 +444,7 @@ private:
 class RegionCutDrag : public Drag
 {
     public:
-       RegionCutDrag (Editor*, ArdourCanvas::Item*);
+       RegionCutDrag (Editor*, ArdourCanvas::Item*, framepos_t);
        ~RegionCutDrag ();
 
        void motion (GdkEvent*, bool);
index 438b3b6a8a9ccd70f220f2c70fc12f79ce3d5a48..5948610f8211057829edaa4a5b7093e2e1aae541 100644 (file)
@@ -857,7 +857,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
                case FeatureLineItem:
                case RegionViewNameHighlight:
                case RegionViewName:
-                       _drags->set (new RegionCutDrag (this, item), event, current_canvas_cursor);
+                       _drags->set (new RegionCutDrag (this, item, canvas_event_sample (event)), event, current_canvas_cursor);
                        return true;
                        break;
                default:
index fe34289c407f3039fc11f47f2b10417648cf6e0d..11e8931457a3699058d74eb80cb949b4d833460c 100644 (file)
@@ -295,7 +295,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi
        virtual void update_tearoff_visibility () = 0;
        virtual framepos_t get_preferred_edit_position (bool ignore_playhead = false, bool from_context_menu = false) = 0;
        virtual void toggle_meter_updating() = 0;
-       virtual void split_region () = 0;
+       virtual void split_regions_at (framepos_t, RegionSelection&) = 0;
        virtual void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret, bool select_new = false) = 0;
        virtual void mouse_add_new_marker (framepos_t where, bool is_cd=false, bool is_xrun=false) = 0;
        virtual void foreach_time_axis_view (sigc::slot<void,TimeAxisView&>) = 0;
@@ -416,6 +416,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi
        virtual void snap_to_with_modifier (framepos_t &, GdkEvent const *, int32_t direction = 0, bool for_mark = false) = 0;
 
        virtual void get_regions_at (RegionSelection &, framepos_t where, TrackViewList const &) const = 0;
+       virtual RegionSelection get_regions_from_selection_and_mouse () = 0;
 
        /// Singleton instance, set up by Editor::Editor()