From a0dc432e7a74d3b2754419c144208b72572147ac Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 8 May 2024 19:07:09 +0200 Subject: [PATCH] Fix Marker label ellipsis for concurrent markers * Sort markers: range-end before range-start * When two marker have the same position, use distance to next marker not on the same position --- gtk2_ardour/editor_markers.cc | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 7c4eb510cf..288550a1d1 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -306,7 +306,10 @@ Editor::check_marker_label (ArdourMarker* m) list::iterator prev = sorted.end (); list::iterator next = i; - ++next; + + if (next != sorted.end()) { + ++next; + } /* Look to see if the previous marker is still behind `m' in time */ if (i != sorted.begin()) { @@ -314,7 +317,7 @@ Editor::check_marker_label (ArdourMarker* m) prev = i; --prev; - if ((*prev)->position() > m->position()) { + if ((*prev)->position() >= m->position()) { /* This marker is no longer in the correct order with the previous one, so * update all the markers in this group. */ @@ -351,8 +354,11 @@ Editor::check_marker_label (ArdourMarker* m) } } - if (next != sorted.end()) { + while (next != sorted.end() && (*next)->position () == m->position ()) { + ++next; + } + if (next != sorted.end()) { /* Update just the available space between this marker and the next */ double const p = sample_to_pixel (m->position().distance ((*next)->position()).samples()); @@ -373,6 +379,9 @@ Editor::check_marker_label (ArdourMarker* m) struct MarkerComparator { bool operator() (ArdourMarker const * a, ArdourMarker const * b) { + if (a->position() == b->position()) { + return a->label_on_left (); + } return a->position() < b->position(); } }; @@ -420,7 +429,13 @@ Editor::update_marker_labels (ArdourCanvas::Item* group) while (i != sorted.end()) { if (prev != sorted.end()) { - double const p = sample_to_pixel ((*prev)->position().distance ((*i)->position()).samples()); + + list::iterator pi = prev; + while (pi != sorted.begin () && (*pi)->position () == (*i)->position()) { + --pi; + } + + double const p = sample_to_pixel ((*pi)->position().distance ((*i)->position()).samples()); if ((*prev)->label_on_left()) { (*i)->set_left_label_limit (p); @@ -430,6 +445,10 @@ Editor::update_marker_labels (ArdourCanvas::Item* group) } + while (next != sorted.end() && (*next)->position () == (*i)->position ()) { + ++next; + } + if (next != sorted.end()) { double const p = sample_to_pixel ((*i)->position().distance ((*next)->position()).samples());