Flatten the scrollbar highlight iteration (#3326)

This commit is contained in:
pajlada 2021-10-30 12:54:43 +02:00 committed by GitHub
parent c33efab751
commit 8ead95b959
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -287,36 +287,38 @@ void Scrollbar::paintEvent(QPaintEvent *)
int highlightHeight =
int(std::ceil(std::max<float>(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:;
}
}
}