From 5d81d7cac3f59809f6e90570aac9798bf42312b1 Mon Sep 17 00:00:00 2001 From: Kenneth Date: Tue, 13 Jan 2026 13:33:45 -0500 Subject: [PATCH] Improvements to indicators and button interaction --- src/ScreenComponents.cpp | 13 +++++---- src/activities/home/MyLibraryActivity.cpp | 32 +++++++++++------------ src/activities/home/MyLibraryActivity.h | 30 ++++++++++----------- 3 files changed, 36 insertions(+), 39 deletions(-) diff --git a/src/ScreenComponents.cpp b/src/ScreenComponents.cpp index e6bd9825..f414ca06 100644 --- a/src/ScreenComponents.cpp +++ b/src/ScreenComponents.cpp @@ -99,19 +99,18 @@ void ScreenComponents::drawScrollIndicator(const GfxRenderer &renderer, contentTop + 60; // Offset to avoid overlapping side button hints const int indicatorBottom = contentTop + contentHeight - 30; - // Draw up arrow at top (triangle pointing up - wide at bottom, narrow at top) + // Draw up arrow at top (^) - narrow point at top, wide base at bottom for (int i = 0; i < arrowSize; ++i) { - const int lineWidth = 1 + (arrowSize - 1 - i) * 2; - const int startX = centerX - (arrowSize - 1 - i); + const int lineWidth = 1 + i * 2; + const int startX = centerX - i; renderer.drawLine(startX, indicatorTop + i, startX + lineWidth - 1, indicatorTop + i); } - // Draw down arrow at bottom (triangle pointing down - narrow at top, wide at - // bottom) + // Draw down arrow at bottom (v) - wide base at top, narrow point at bottom for (int i = 0; i < arrowSize; ++i) { - const int lineWidth = 1 + i * 2; - const int startX = centerX - i; + const int lineWidth = 1 + (arrowSize - 1 - i) * 2; + const int startX = centerX - (arrowSize - 1 - i); renderer.drawLine(startX, indicatorBottom - arrowSize + 1 + i, startX + lineWidth - 1, indicatorBottom - arrowSize + 1 + i); diff --git a/src/activities/home/MyLibraryActivity.cpp b/src/activities/home/MyLibraryActivity.cpp index 0b684bcf..23bc9a85 100644 --- a/src/activities/home/MyLibraryActivity.cpp +++ b/src/activities/home/MyLibraryActivity.cpp @@ -269,25 +269,23 @@ void MyLibraryActivity::loop() { return; } - // Tab switching: Left/Right when selectorIndex == 0 - if (selectorIndex == 0) { - if (leftReleased && currentTab == Tab::Files) { - currentTab = Tab::Recent; - selectorIndex = 0; - updateRequired = true; - return; - } - if (rightReleased && currentTab == Tab::Recent) { - currentTab = Tab::Files; - selectorIndex = 0; - updateRequired = true; - return; - } + // Tab switching: Left/Right always control tabs + if (leftReleased && currentTab == Tab::Files) { + currentTab = Tab::Recent; + selectorIndex = 0; + updateRequired = true; + return; + } + if (rightReleased && currentTab == Tab::Recent) { + currentTab = Tab::Files; + selectorIndex = 0; + updateRequired = true; + return; } - // Navigation: Up/Down moves through items, Left/Right also work as prev/next - const bool prevReleased = upReleased || leftReleased; - const bool nextReleased = downReleased || rightReleased; + // Navigation: Up/Down moves through items only + const bool prevReleased = upReleased; + const bool nextReleased = downReleased; if (prevReleased && itemCount > 0) { if (skipPage) { diff --git a/src/activities/home/MyLibraryActivity.h b/src/activities/home/MyLibraryActivity.h index dc87aae6..8e01c666 100644 --- a/src/activities/home/MyLibraryActivity.h +++ b/src/activities/home/MyLibraryActivity.h @@ -10,10 +10,10 @@ #include "../Activity.h" class MyLibraryActivity final : public Activity { - public: +public: enum class Tab { Recent, Files }; - private: +private: TaskHandle_t displayTaskHandle = nullptr; SemaphoreHandle_t renderingMutex = nullptr; @@ -22,8 +22,9 @@ class MyLibraryActivity final : public Activity { bool updateRequired = false; // Recent tab state (from RecentBooksActivity) - std::vector bookTitles; // Display titles for each book - std::vector bookPaths; // Paths for each visible book (excludes missing) + std::vector bookTitles; // Display titles for each book + std::vector + bookPaths; // Paths for each visible book (excludes missing) // Files tab state (from FileSelectionActivity) std::string basepath = "/"; @@ -31,7 +32,7 @@ class MyLibraryActivity final : public Activity { // Callbacks const std::function onGoHome; - const std::function onSelectBook; + const std::function onSelectBook; // Number of items that fit on a page int getPageItems() const; @@ -44,21 +45,20 @@ class MyLibraryActivity final : public Activity { void loadFiles(); // Rendering - static void taskTrampoline(void* param); + static void taskTrampoline(void *param); [[noreturn]] void displayTaskLoop(); void render() const; void renderRecentTab() const; void renderFilesTab() const; - public: - explicit MyLibraryActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, - const std::function& onGoHome, - const std::function& onSelectBook, - Tab initialTab = Tab::Recent) - : Activity("MyLibrary", renderer, mappedInput), - currentTab(initialTab), - onGoHome(onGoHome), - onSelectBook(onSelectBook) {} +public: + explicit MyLibraryActivity( + GfxRenderer &renderer, MappedInputManager &mappedInput, + const std::function &onGoHome, + const std::function &onSelectBook, + Tab initialTab = Tab::Recent) + : Activity("MyLibrary", renderer, mappedInput), currentTab(initialTab), + onGoHome(onGoHome), onSelectBook(onSelectBook) {} void onEnter() override; void onExit() override; void loop() override;