Modify get_regions_for_action to fix #2960. Rationale is in the comment for that...
authorCarl Hetherington <carl@carlh.net>
Tue, 19 Oct 2010 22:08:39 +0000 (22:08 +0000)
committerCarl Hetherington <carl@carlh.net>
Tue, 19 Oct 2010 22:08:39 +0000 (22:08 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7908 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_ops.cc

index 9ec1014843ff1ff639d6076250a5c5a1bcf4773a..5ae90095c83ae839b23065231d4a4ee4bea2f1a7 100644 (file)
@@ -4930,46 +4930,64 @@ Editor::get_regions_after (RegionSelection& rs, framepos_t where, const TrackVie
        }
 }
 
-/** Find all regions which are either:
- *      - selected or
- *      - the entered_regionview (if allow_entered == true) or
- *      - under the preferred edit position AND on a selected track, or on a track
- *        which is in the same active edit-enable route group as a selected region (if allow_edit_position == true)
+/** Get regions using the following conditions:
+ *  If check_edit_position == false, then return the selected regions.
+ *  Otherwise:
+ *    1.  If the edit point is `mouse':
+ *          if the mouse is over a selected region, or no region, return all selected regions.
+ *          if the mouse is over an unselected region, return just that region.
+ *    2.  For all other edit points:
+ *          return the selected regions AND those that are both under the edit position
+ *          AND on a selected track, or on a track which is in the same active edit-enabled route group
+ *          as a selected region.
+ *
+ *  The rationale here is that the mouse edit point is special in that its position describes
+ *  both a time and a track; the other edit modes only describe a time.
+ *
  *  @param rs Returned region list.
- *  @param allow_entered true to include the entered_regionview in the list.
  */
 void
-Editor::get_regions_for_action (RegionSelection& rs, bool allow_entered, bool allow_edit_position)
+Editor::get_regions_for_action (RegionSelection& rs, bool check_edit_point)
 {
-       /* Start with selected regions */
-       rs = selection->regions;
-
-       /* Add the entered_regionview, if requested */
-       if (allow_entered && entered_regionview) {
-               rs.add (entered_regionview);
+       if (!check_edit_point) {
+               rs = selection->regions;
+               return;
        }
 
-       if (allow_edit_position) {
+       if (_edit_point == EditAtMouse) {
+               if (entered_regionview == 0 || selection->regions.contains (entered_regionview)) {
+                       rs = selection->regions;
+                       return;
+               } else {
+                       rs.add (entered_regionview);
+                       return;
+               }
+       }
 
-               TrackViewList tracks = selection->tracks;
+       /* We're using the edit point, but its not EditAtMouse */
 
-               /* tracks is currently the set of selected tracks; add any other tracks that
-                * have regions that are in the same edit-activated route group as one of
-                * our regions */
-               for (RegionSelection::iterator i = rs.begin (); i != rs.end(); ++i) {
+       /* Start with selected regions */
+       rs = selection->regions;
 
-                       RouteGroup* g = (*i)->get_time_axis_view().route_group ();
-                       if (g && g->is_active() && g->is_edit()) {
-                               tracks.add (axis_views_from_routes (g->route_list()));
-                       }
-                       
-               }
+       TrackViewList tracks = selection->tracks;
 
-               if (!tracks.empty()) {
-                       /* now find regions that are at the edit position on those tracks */
-                       framepos_t const where = get_preferred_edit_position ();
-                       get_regions_at (rs, where, tracks);
+       /* Tracks is currently the set of selected tracks; add any other tracks that
+          have regions that are in the same edit-activated route group as one of
+          our regions.
+        */
+       for (RegionSelection::iterator i = rs.begin (); i != rs.end(); ++i) {
+               
+               RouteGroup* g = (*i)->get_time_axis_view().route_group ();
+               if (g && g->is_active() && g->is_edit()) {
+                       tracks.add (axis_views_from_routes (g->route_list()));
                }
+               
+       }
+       
+       if (!tracks.empty()) {
+               /* now find regions that are at the edit position on those tracks */
+               framepos_t const where = get_preferred_edit_position ();
+               get_regions_at (rs, where, tracks);
        }
 }
 
index c1573b99a5ef603df45a520fbd4b533ac19a72a7..a2f9770051b9969f44d9e45ce44602f8a7a1f18f 100644 (file)
@@ -1993,8 +1993,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void get_regions_at (RegionSelection&, framepos_t where, const TrackViewList& ts) const;
        void get_regions_after (RegionSelection&, framepos_t where, const TrackViewList& ts) const;
 
-       void get_regions_for_action (RegionSelection&, bool allow_entered = false, bool allow_edit_position = true);
-
+       void get_regions_for_action (RegionSelection&, bool check_edit_point = true);
+       
        void start_updating_meters ();
        void stop_updating_meters ();
        bool meters_running;
index 751c94fefa7ad0c678ad3aa5b525ac023eb43412..0f921992f548103186f43f3c85bf351a70e64dba 100644 (file)
@@ -3881,7 +3881,7 @@ Editor::cut_copy (CutCopyOp op)
                /* we only want to cut regions if some are selected */
 
                if (!selection->regions.empty()) {
-                       get_regions_for_action (rs, false, false);
+                       get_regions_for_action (rs, false);
                }
 
                switch (current_mouse_mode()) {