mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-13 08:45:04 +00:00
Add Scrollbar for Action menus
This commit is contained in:
parent
3a5dc870e0
commit
1736db6b56
@ -196,7 +196,6 @@ void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisp
|
|||||||
int yOffset = 3;
|
int yOffset = 3;
|
||||||
display->drawString(textX, lineY - yOffset, lineBuffer);
|
display->drawString(textX, lineY - yOffset, lineBuffer);
|
||||||
display->setColor(WHITE);
|
display->setColor(WHITE);
|
||||||
|
|
||||||
lineY += (effectiveLineHeight - 2 - background_yOffset);
|
lineY += (effectiveLineHeight - 2 - background_yOffset);
|
||||||
} else {
|
} else {
|
||||||
// Pop-up
|
// Pop-up
|
||||||
@ -228,6 +227,24 @@ void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisp
|
|||||||
display->drawString(textX, lineY, lineBuffer);
|
display->drawString(textX, lineY, lineBuffer);
|
||||||
lineY += effectiveLineHeight;
|
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
|
/// Draw the last text message we received
|
||||||
|
Loading…
Reference in New Issue
Block a user