From 4e71a78bc7c3d4f8915e04026e08caea0a97d1ff Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Sep 2025 15:11:07 -0600 Subject: [PATCH] simplify Pianoroll::snap_to_internal() Since we have only 1 type of snap (the grid, which is BBT based always), this method doesn't need as much of the baggage as the equivalent Editor method --- gtk2_ardour/pianoroll.cc | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/gtk2_ardour/pianoroll.cc b/gtk2_ardour/pianoroll.cc index 0826c0cb05..bdae54d41a 100644 --- a/gtk2_ardour/pianoroll.cc +++ b/gtk2_ardour/pianoroll.cc @@ -673,20 +673,8 @@ Pianoroll::snap_to_internal (timepos_t& start, Temporal::RoundMode direction, Sn EC_LOCAL_TEMPO_SCOPE; UIConfiguration const& uic (UIConfiguration::instance ()); - const timepos_t presnap = start; - - timepos_t dist = timepos_t::max (start.time_domain()); // this records the distance of the best snap result we've found so far - timepos_t best = timepos_t::max (start.time_domain()); // this records the best snap-result we've found so far - - timepos_t pre (presnap); - timepos_t post (snap_to_grid (pre, direction, pref)); - - check_best_snap (presnap, post, dist, best); - - if (timepos_t::max (start.time_domain()) == best) { - return; - } + timepos_t post (snap_to_grid (start, direction, pref)); /* now check "magnetic" state: is the grid within reasonable on-screen distance to trigger a snap? * this also helps to avoid snapping to somewhere the user can't see. (i.e.: I clicked on a region and it disappeared!!) @@ -694,11 +682,11 @@ Pianoroll::snap_to_internal (timepos_t& start, Temporal::RoundMode direction, Sn */ samplecnt_t snap_threshold_s = pixel_to_sample (uic.get_snap_threshold ()); - if (!ensure_snap && ::llabs (best.distance (presnap).samples()) > snap_threshold_s) { + if (!ensure_snap && ::llabs (post.distance (start).samples()) > snap_threshold_s) { return; } - start = best; + start = post; } void