mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-06 07:37:37 +03:00
Improvements to indicators and button interaction
This commit is contained in:
parent
c2d0dce438
commit
5d81d7cac3
@ -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);
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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<std::string> bookTitles; // Display titles for each book
|
||||
std::vector<std::string> bookPaths; // Paths for each visible book (excludes missing)
|
||||
std::vector<std::string> bookTitles; // Display titles for each book
|
||||
std::vector<std::string>
|
||||
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<void()> onGoHome;
|
||||
const std::function<void(const std::string& path)> onSelectBook;
|
||||
const std::function<void(const std::string &path)> 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<void()>& onGoHome,
|
||||
const std::function<void(const std::string& path)>& 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<void()> &onGoHome,
|
||||
const std::function<void(const std::string &path)> &onSelectBook,
|
||||
Tab initialTab = Tab::Recent)
|
||||
: Activity("MyLibrary", renderer, mappedInput), currentTab(initialTab),
|
||||
onGoHome(onGoHome), onSelectBook(onSelectBook) {}
|
||||
void onEnter() override;
|
||||
void onExit() override;
|
||||
void loop() override;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user