summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-07-07 10:13:19 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2014-07-07 10:13:26 -0400
commitd97199088bb6ee95e4cd6b4e6450ad9a54f559c1 (patch)
tree52285566a3a5707013fecf870cdbd8de0bb60422
parentb39c30dbd16d982529396d5a096382f88b3b6a38 (diff)
some code shuffling to make sure that cut mode always operates at the mouse location, with (maybe) the right regions
-rw-r--r--gtk2_ardour/editor.cc44
-rw-r--r--gtk2_ardour/editor.h6
-rw-r--r--gtk2_ardour/editor_drag.cc14
-rw-r--r--gtk2_ardour/editor_drag.h2
-rw-r--r--gtk2_ardour/editor_mouse.cc2
-rw-r--r--gtk2_ardour/public_editor.h3
6 files changed, 63 insertions, 8 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index e489f39103..07bd6f7d78 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -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.
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index eca9714b01..75b66d6f04 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -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 ();
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 10968d1cfb..bf013c4352 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -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
diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h
index bf04995309..378162621e 100644
--- a/gtk2_ardour/editor_drag.h
+++ b/gtk2_ardour/editor_drag.h
@@ -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);
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index 438b3b6a8a..5948610f82 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -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:
diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h
index fe34289c40..11e8931457 100644
--- a/gtk2_ardour/public_editor.h
+++ b/gtk2_ardour/public_editor.h
@@ -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()