From 8ead95b959e53bcf23b0c2a58c0424f44c942ddb Mon Sep 17 00:00:00 2001 From: pajlada Date: Sat, 30 Oct 2021 12:54:43 +0200 Subject: [PATCH] Flatten the scrollbar highlight iteration (#3326) --- src/widgets/Scrollbar.cpp | 50 ++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/widgets/Scrollbar.cpp b/src/widgets/Scrollbar.cpp index c581723b6..adbd8e4d1 100644 --- a/src/widgets/Scrollbar.cpp +++ b/src/widgets/Scrollbar.cpp @@ -287,36 +287,38 @@ void Scrollbar::paintEvent(QPaintEvent *) int highlightHeight = int(std::ceil(std::max(this->scale() * 2, dY))); - for (size_t i = 0; i < snapshotLength; i++) + for (size_t i = 0; i < snapshotLength; i++, y += dY) { ScrollbarHighlight const &highlight = snapshot[i]; - if (!highlight.isNull()) + if (highlight.isNull()) { - if (!highlight.isRedeemedHighlight() || enableRedeemedHighlights) - { - QColor color = highlight.getColor(); - color.setAlpha(255); - - switch (highlight.getStyle()) - { - case ScrollbarHighlight::Default: { - painter.fillRect(w / 8 * 3, int(y), w / 4, - highlightHeight, color); - } - break; - - case ScrollbarHighlight::Line: { - painter.fillRect(0, int(y), w, 1, color); - } - break; - - case ScrollbarHighlight::None:; - } - } + continue; } - y += dY; + if (highlight.isRedeemedHighlight() && !enableRedeemedHighlights) + { + continue; + } + + QColor color = highlight.getColor(); + color.setAlpha(255); + + switch (highlight.getStyle()) + { + case ScrollbarHighlight::Default: { + painter.fillRect(w / 8 * 3, int(y), w / 4, highlightHeight, + color); + } + break; + + case ScrollbarHighlight::Line: { + painter.fillRect(0, int(y), w, 1, color); + } + break; + + case ScrollbarHighlight::None:; + } } }