Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
forntoh committed Oct 6, 2024
1 parent 9552522 commit e75280a
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 34 deletions.
8 changes: 4 additions & 4 deletions src/MenuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
20 changes: 2 additions & 18 deletions src/renderer/CharacterDisplayRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
10 changes: 4 additions & 6 deletions src/renderer/CharacterDisplayRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
};
10 changes: 9 additions & 1 deletion src/renderer/MenuRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
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; }
34 changes: 29 additions & 5 deletions src/renderer/MenuRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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

0 comments on commit e75280a

Please sign in to comment.