From e75280a1870e9fff3553e406a4328c6f8b87eb0d Mon Sep 17 00:00:00 2001 From: forntoh Date: Sun, 6 Oct 2024 23:34:52 +0200 Subject: [PATCH] Rename --- src/MenuScreen.cpp | 8 +++--- src/renderer/CharacterDisplayRenderer.cpp | 20 ++----------- src/renderer/CharacterDisplayRenderer.h | 10 +++---- src/renderer/MenuRenderer.cpp | 10 ++++++- src/renderer/MenuRenderer.h | 34 +++++++++++++++++++---- 5 files changed, 48 insertions(+), 34 deletions(-) diff --git a/src/MenuScreen.cpp b/src/MenuScreen.cpp index 3cd825c1..f883f79e 100644 --- a/src/MenuScreen.cpp +++ b/src/MenuScreen.cpp @@ -46,14 +46,14 @@ void MenuScreen::draw(MenuRenderer* renderer) { void MenuScreen::markScroll(uint8_t i, MenuRenderer* renderer) { if (i == 0 && view > 0) { - renderer->markUpScroll(); + renderer->flagHiddenItemsAbove(); } else { - renderer->clearUpScroll(); + renderer->unsetFlagHiddenItemsAbove(); } if (i == renderer->maxRows - 1 && (view + renderer->maxRows) < itemCount) { - renderer->markDownScroll(); + renderer->flagHiddenItemsBelow(); } else { - renderer->clearDownScroll(); + renderer->unsetFlagHiddenItemsBelow(); } } diff --git a/src/renderer/CharacterDisplayRenderer.cpp b/src/renderer/CharacterDisplayRenderer.cpp index a56e79f5..8f5b7c13 100644 --- a/src/renderer/CharacterDisplayRenderer.cpp +++ b/src/renderer/CharacterDisplayRenderer.cpp @@ -67,9 +67,9 @@ void CharacterDisplayRenderer::appendCursorToText(uint8_t screenRow, const char* void CharacterDisplayRenderer::appendIndicatorToText(uint8_t screenRow, const char* text, char* buf) { uint8_t indicator = 0; - if (upScroll) { + if (hasHiddenItemsAbove) { indicator = 1; - } else if (downScroll) { + } else if (hasHiddenItemsBelow) { indicator = 2; } @@ -94,20 +94,4 @@ void CharacterDisplayRenderer::padText(const char* text, uint8_t itemIndex, char uint8_t CharacterDisplayRenderer::calculateAvailableLength() { return maxCols - (upArrow != NULL || downArrow != NULL ? 1 : 0); -} - -void CharacterDisplayRenderer::markUpScroll() { - upScroll = true; -} - -void CharacterDisplayRenderer::clearUpScroll() { - upScroll = false; -} - -void CharacterDisplayRenderer::markDownScroll() { - downScroll = true; -} - -void CharacterDisplayRenderer::clearDownScroll() { - downScroll = false; } \ No newline at end of file diff --git a/src/renderer/CharacterDisplayRenderer.h b/src/renderer/CharacterDisplayRenderer.h index 87000531..9ecd51d6 100644 --- a/src/renderer/CharacterDisplayRenderer.h +++ b/src/renderer/CharacterDisplayRenderer.h @@ -25,8 +25,6 @@ class CharacterDisplayRenderer : public MenuRenderer { uint8_t* downArrow; const uint8_t cursorIcon; const uint8_t editCursorIcon; - bool upScroll = false; - bool downScroll = false; /** * @brief Appends a cursor icon to the given text if the specified screen row is active. @@ -118,8 +116,8 @@ class CharacterDisplayRenderer : public MenuRenderer { void drawBlinker() override; void clearBlinker() override; void moveCursor(uint8_t cursorCol, uint8_t cursorRow) override; - void markUpScroll() override; - void clearUpScroll() override; - void markDownScroll() override; - void clearDownScroll() override; + void flagHiddenItemsAbove() override; + void unsetFlagHiddenItemsAbove() override; + void flagHiddenItemsBelow() override; + void unsetFlagHiddenItemsBelow() override; }; \ No newline at end of file diff --git a/src/renderer/MenuRenderer.cpp b/src/renderer/MenuRenderer.cpp index 849069e2..4ac0301c 100644 --- a/src/renderer/MenuRenderer.cpp +++ b/src/renderer/MenuRenderer.cpp @@ -39,4 +39,12 @@ uint8_t MenuRenderer::getMaxRows() const { return maxRows; } uint8_t MenuRenderer::getMaxCols() const { return maxCols; } -uint8_t MenuRenderer::getActiveRow() const { return activeRow; } \ No newline at end of file +uint8_t MenuRenderer::getActiveRow() const { return activeRow; } + +void MenuRenderer::flagHiddenItemsAbove() { hasHiddenItemsAbove = true; } + +void MenuRenderer::unsetFlagHiddenItemsAbove() { hasHiddenItemsAbove = false; } + +void MenuRenderer::flagHiddenItemsBelow() { hasHiddenItemsBelow = true; } + +void MenuRenderer::unsetFlagHiddenItemsBelow() { hasHiddenItemsBelow = false; } \ No newline at end of file diff --git a/src/renderer/MenuRenderer.h b/src/renderer/MenuRenderer.h index 22e7c548..fcc35d30 100644 --- a/src/renderer/MenuRenderer.h +++ b/src/renderer/MenuRenderer.h @@ -20,6 +20,15 @@ class MenuRenderer { const uint8_t maxCols; const uint8_t maxRows; + /** + * @brief Flag indicating that there are hidden items above the current view. + */ + bool hasHiddenItemsAbove = false; + /** + * @brief Flag indicating that there are hidden items below the current view. + */ + bool hasHiddenItemsBelow = false; + uint8_t cursorCol; uint8_t cursorRow; @@ -66,11 +75,6 @@ class MenuRenderer { */ virtual void drawItem(uint8_t screenRow, const char* text); - virtual void markUpScroll() = 0; - virtual void clearUpScroll() = 0; - virtual void markDownScroll() = 0; - virtual void clearDownScroll() = 0; - /** * @brief Function to clear the blinker from the display. */ @@ -145,6 +149,26 @@ class MenuRenderer { * @return the active row. */ uint8_t getActiveRow() const; + + /** + * @brief Flags that there are hidden items above the current view. + */ + void flagHiddenItemsAbove(); + + /** + * @brief Unsets the flag indicating hidden items above the current view. + */ + void unsetFlagHiddenItemsAbove(); + + /** + * @brief Flags that there are hidden items below the current view. + */ + void flagHiddenItemsBelow(); + + /** + * @brief Unsets the flag indicating hidden items below the current view. + */ + void unsetFlagHiddenItemsBelow(); }; #endif // MENU_RENDERER_H \ No newline at end of file