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.
/* 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 ();
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);
void reset_focus ();
+ void split_region ();
+
void delete_ ();
void cut ();
void copy ();
}
}
-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 ()
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
class RegionCutDrag : public Drag
{
public:
- RegionCutDrag (Editor*, ArdourCanvas::Item*);
+ RegionCutDrag (Editor*, ArdourCanvas::Item*, framepos_t);
~RegionCutDrag ();
void motion (GdkEvent*, bool);
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:
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;
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()