From c4164e8302c719bec267febaffa8abe774d6c061 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 14 May 2020 09:22:25 +0200 Subject: [PATCH] Roller fixes --- radio/src/thirdparty/libopenui/src/roller.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/roller.h b/radio/src/thirdparty/libopenui/src/roller.h index bd7199c2f..b2f567be8 100644 --- a/radio/src/thirdparty/libopenui/src/roller.h +++ b/radio/src/thirdparty/libopenui/src/roller.h @@ -66,15 +66,14 @@ class Roller: public Choice { void paint(BitmapBuffer * dc) override { int32_t value = getValue(); + auto valuesCount = getValuesCount(); int index = (scrollPositionY - ROLLER_LINE_HEIGHT + 1) / ROLLER_LINE_HEIGHT; coord_t y = index * ROLLER_LINE_HEIGHT; coord_t yMax = scrollPositionY + 3 * ROLLER_LINE_HEIGHT; while (y < yMax) { - auto displayedValue = getValueFromIndex(index % getValuesCount()); - if (displayedValue < vmin) - displayedValue += getValuesCount(); + auto displayedValue = getValueFromIndex((index + valuesCount) % valuesCount); auto fgColor = DISABLE_COLOR; @@ -130,10 +129,8 @@ class Roller: public Choice { { lastScrollPositionY = scrollPositionY; - auto newValue = getValueFromIndex(((scrollPositionY / ROLLER_LINE_HEIGHT) + 1) % getValuesCount()); - if (newValue < vmin) { - newValue += getValuesCount(); - } + auto valuesCount = getValuesCount(); + auto newValue = getValueFromIndex((((scrollPositionY / ROLLER_LINE_HEIGHT) + 1) + valuesCount) % valuesCount); setValue(newValue); invalidate();