From 01ef5a5b24b10f534032ad65524e71faca033b19 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Mon, 14 Mar 2022 19:14:43 -0500 Subject: [PATCH] ripple (gui part): should_ripple_all() encapsulates modes Ripple+RippleAll --- gtk2_ardour/editor.h | 1 + gtk2_ardour/editor_drag.cc | 10 +++++---- gtk2_ardour/editor_ops.cc | 36 ++++++++++++++++++++++++--------- gtk2_ardour/editor_selection.cc | 10 ++++----- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index fd168a1c55..4d86b00cf3 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -608,6 +608,7 @@ public: void edit_meter_section (Temporal::MeterPoint&); bool should_ripple () const; + bool should_ripple_all () const; /* RippleAll will ripple all similar regions and the timeline markers */ void do_ripple (boost::shared_ptr, Temporal::timepos_t const &, Temporal::timecnt_t const &, ARDOUR::RegionList* exclude, bool add_to_command); void do_ripple (boost::shared_ptr, Temporal::timepos_t const &, Temporal::timecnt_t const &, boost::shared_ptr exclude, bool add_to_command); void ripple_marks (boost::shared_ptr target_playlist, Temporal::timepos_t at, Temporal::timecnt_t const & distance); diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 93f2bd0f3e..317ac1c3f1 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -1823,7 +1823,7 @@ RegionMoveDrag::finished_copy (bool const changed_position, bool const changed_t /* Ripple marks & ranges if appropriate */ - if (Config->get_edit_mode() == RippleAll) { + if (_editor->should_ripple_all()) { _editor->ripple_marks (_primary->region()->playlist(), extent_min, extent_min.distance (extent_max)); } @@ -2042,7 +2042,7 @@ RegionMoveDrag::finished_no_copy ( (*p)->thaw(); } - if (Config->get_edit_mode() == RippleAll) { + if (_editor->should_ripple_all()) { _editor->ripple_marks (_primary->region()->playlist(), extent_min, -drag_delta); } @@ -5704,7 +5704,7 @@ SelectionDrag::motion (GdkEvent* event, bool first_move) } if (first_move) { - if (Config->get_edit_mode() == RippleAll && !Config->get_interview_editing()) { + if (_editor->should_ripple_all()) { _editor->selection->set (_editor->get_track_views()); } _track_selection_at_start = _editor->selection->tracks; @@ -5771,7 +5771,9 @@ SelectionDrag::motion (GdkEvent* event, bool first_move) ArdourCanvas::Coord const top = grab_y(); ArdourCanvas::Coord const bottom = current_pointer_y(); - if ((Config->get_edit_mode() != RippleAll || Config->get_interview_editing()) && top >= 0 && bottom >= 0) { + bool RippleAll = _editor->should_ripple_all(); + + if (!RippleAll && top >= 0 && bottom >= 0) { //first, find the tracks that are covered in the y range selection for (TrackViewList::const_iterator i = all_tracks.begin(); i != all_tracks.end(); ++i) { diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 4da54c76cf..f4b9fef99f 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -9374,8 +9374,30 @@ Editor::remove_gaps (timecnt_t const & gap_threshold, timecnt_t const & leave_ga bool Editor::should_ripple () const { - return (Config->get_edit_mode() == Ripple || - (Config->get_edit_mode() == RippleAll && (selection->tracks.size() > 1 || !Config->get_interview_editing()))); + /*only ripple if edit mode is Ripple (duh) */ + if (Config->get_edit_mode() != Ripple) { + return false; + } + + /* RippleInterview does not ripple if only one track is selected */ + if (Config->get_ripple_mode() == RippleInterview && selection->tracks.size() == 1) { + return false; + } + + return true; +} + +bool +Editor::should_ripple_all () const +{ + /*first check if ripple is engaged at all*/ + if (!should_ripple()) { + return false; + } + + /*TODO: maybe if in RippleInterview and ALL tracks are selected, this means RippleAll? */ + + return (Config->get_ripple_mode() == RippleAll); } void @@ -9396,7 +9418,7 @@ Editor::do_ripple (boost::shared_ptr target_playlist, timepos_t const playlists.insert (target_playlist); - if (Config->get_edit_mode() == RippleAll) { + if (should_ripple_all()) { TrackViewList ts = track_views.filter_to_unique_playlists (); boost::shared_ptr pl; @@ -9455,13 +9477,9 @@ Editor::do_ripple (boost::shared_ptr target_playlist, timepos_t const } /* Ripple marks & ranges if appropriate */ - - if (Config->get_edit_mode() != RippleAll) { - cerr << "out here\n"; - return; + if (should_ripple_all()) { + ripple_marks (target_playlist, at, distance); } - - ripple_marks (target_playlist, at, distance); } timepos_t diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index 7e54d8f93f..2ed88ce7d4 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -677,7 +677,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op) * permitted button release */ - if (Config->get_edit_mode() == RippleAll) { + if (should_ripple_all()) { get_all_equivalent_regions (clicked_regionview, all_equivalent_regions); selection->remove (all_equivalent_regions); } else { @@ -697,7 +697,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op) if (press) { - if (Config->get_edit_mode() == RippleAll) { + if (should_ripple_all()) { get_all_equivalent_regions (clicked_regionview, all_equivalent_regions); } else { if (selection->selected (clicked_routeview)) { @@ -720,7 +720,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op) case Selection::Set: if (!selection->selected (clicked_regionview)) { - if (Config->get_edit_mode() == RippleAll) { + if (should_ripple_all()) { get_all_equivalent_regions (clicked_regionview, all_equivalent_regions); } else { get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id); @@ -734,7 +734,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op) else { if (selection->regions.size() > 1) { /* collapse region selection down to just this one region (and its equivalents) */ - if (Config->get_edit_mode() == RippleAll) { + if (should_ripple_all()) { get_all_equivalent_regions (clicked_regionview, all_equivalent_regions); } else { get_equivalent_regions(clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id); @@ -847,7 +847,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op) set relevant_tracks; - if (Config->get_edit_mode() == RippleAll) { + if (should_ripple_all()) { for (TrackSelection::iterator i = track_views.begin(); i != track_views.end(); ++i) { RouteTimeAxisView* r = dynamic_cast (*i); if (r) {