From 797dd872e33baecf3dc87f9894b38ca33dbb792e Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Thu, 6 Oct 2022 22:41:07 +0200 Subject: [PATCH] ArdourGraphs::time_axis : Replace xalign by clamping Prepare for more flexible placement of the labels, where the last label not necessarily is completely at the end. --- gtk2_ardour/export_analysis_graphs.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/export_analysis_graphs.cc b/gtk2_ardour/export_analysis_graphs.cc index c734ed7f91..8b40cd7219 100644 --- a/gtk2_ardour/export_analysis_graphs.cc +++ b/gtk2_ardour/export_analysis_graphs.cc @@ -497,14 +497,14 @@ ArdourGraphs::time_axis (Glib::RefPtr pctx, int width, int m_l, for (int i = 0; i <= n_labels; ++i) { const float fract = (float)i / n_labels; const int label_pos = width * fract; - const float xalign = (i == n_labels) ? 1.f : (i == 0) ? 0 : .5f; char buf[16]; AudioClock::print_minsec (start + length * fract, buf, sizeof (buf), sample_rate, 1); layout->set_text (&buf[1]); layout->get_pixel_size (w, h); - cr->move_to (rint (m_l + label_pos - w * xalign), rint (.5 * (height - h))); + cr->move_to (rint (m_l + std::min(std::max(0, label_pos - w / 2), width - w)), + rint (.5 * (height - h))); cr->set_source_rgba (.9, .9, .9, 1.0); layout->show_in_cairo_context (cr);