some code shuffling to make sure that cut mode always operates at the mouse location, with (maybe) the right regions

This commit is contained in:
Paul Davis 2014-07-07 10:13:19 -04:00
parent b39c30dbd1
commit d97199088b
6 changed files with 63 additions and 8 deletions

View 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.

View 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 ();

View 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

View 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);

View 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:

View 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()