From 54f6132ecdf24a752add9218c7a118faa0e42a22 Mon Sep 17 00:00:00 2001 From: supermerill Date: Tue, 26 Dec 2023 19:45:27 +0100 Subject: [PATCH] Fix slider ticks supermerill/SuperSlicer#3975 --- src/slic3r/GUI/DoubleSlider.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp index f3735fc3397..c9fedc22575 100644 --- a/src/slic3r/GUI/DoubleSlider.cpp +++ b/src/slic3r/GUI/DoubleSlider.cpp @@ -1108,7 +1108,7 @@ void Control::Ruler::update(wxWindow* win, const std::vector& values, do int pow = -2; int step = 0; - auto end_it = std::find(values.begin() + 1, values.end(), values.front()); + auto end_it = std::find(values.begin() + 2, values.end(), values.front()); while (pow < 3) { for (int istep : {1, 2, 5}) { @@ -1119,11 +1119,11 @@ void Control::Ruler::update(wxWindow* win, const std::vector& values, do break; int tick = val_it - values.begin(); - // find next tick with istep - val *= 2; - val_it = std::lower_bound(values.begin(), end_it, val - epsilon()); - // count of short ticks between ticks - int short_ticks_cnt = val_it == values.end() ? tick : val_it - values.begin() - tick; + // find next tick with istep + val *= 2; + val_it = std::lower_bound(values.begin(), end_it, val - epsilon()); + // count of short ticks between ticks + int short_ticks_cnt = val_it == values.end() ? tick : val_it - values.begin() - tick; if (lround(short_ticks_cnt * scroll_step) > pixels_per_sm) { step = istep; @@ -1156,12 +1156,13 @@ void Control::draw_ruler(wxDC& dc) wxColour old_clr = dc.GetTextForeground(); dc.SetTextForeground(GREY_PEN.GetColour()); - if (m_ruler.long_step < 0) + if (m_ruler.long_step < 0) { for (size_t tick = 1; tick < m_values.size(); tick++) { wxCoord pos = get_position_from_value(tick); draw_ticks_pair(dc, pos, mid, 5); draw_tick_text(dc, wxPoint(mid, pos), tick); - } else { + } + } else { auto draw_short_ticks = [this, mid](wxDC& dc, double& current_tick, int max_tick) { while (current_tick < max_tick) { wxCoord pos = get_position_from_value(lround(current_tick));