From 1736db6b56402c8688e27a0d8444e7d7a4aee349 Mon Sep 17 00:00:00 2001 From: HarukiToreda <116696711+HarukiToreda@users.noreply.github.com> Date: Thu, 26 Jun 2025 00:03:06 -0400 Subject: [PATCH] Add Scrollbar for Action menus --- src/graphics/draw/NotificationRenderer.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/graphics/draw/NotificationRenderer.cpp b/src/graphics/draw/NotificationRenderer.cpp index e19328c7e..4866b4060 100644 --- a/src/graphics/draw/NotificationRenderer.cpp +++ b/src/graphics/draw/NotificationRenderer.cpp @@ -196,7 +196,6 @@ void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisp int yOffset = 3; display->drawString(textX, lineY - yOffset, lineBuffer); display->setColor(WHITE); - lineY += (effectiveLineHeight - 2 - background_yOffset); } else { // Pop-up @@ -228,6 +227,24 @@ void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisp display->drawString(textX, lineY, lineBuffer); lineY += effectiveLineHeight; } + + // === Scroll Bar (Thicker, inside box, not over title) === + if (totalLines > visibleTotalLines) { + const uint8_t scrollBarWidth = 5; + const uint8_t scrollPadding = 2; + + int16_t scrollBarX = boxLeft + boxWidth - scrollBarWidth - 2; + int16_t scrollBarY = boxTop + vPadding + effectiveLineHeight; // start after title line + uint16_t scrollBarHeight = boxHeight - vPadding * 2 - effectiveLineHeight; + + float ratio = (float)visibleTotalLines / totalLines; + uint16_t indicatorHeight = std::max((int)(scrollBarHeight * ratio), 4); + float scrollRatio = (float)(firstOptionToShow + linesShown - visibleTotalLines) / (totalLines - visibleTotalLines); + uint16_t indicatorY = scrollBarY + scrollRatio * (scrollBarHeight - indicatorHeight); + + display->drawRect(scrollBarX, scrollBarY, scrollBarWidth, scrollBarHeight); + display->fillRect(scrollBarX + 1, indicatorY, scrollBarWidth - 2, indicatorHeight); + } } /// Draw the last text message we received