mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-06 15:47:39 +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
|
contentTop + 60; // Offset to avoid overlapping side button hints
|
||||||
const int indicatorBottom = contentTop + contentHeight - 30;
|
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) {
|
for (int i = 0; i < arrowSize; ++i) {
|
||||||
const int lineWidth = 1 + (arrowSize - 1 - i) * 2;
|
const int lineWidth = 1 + i * 2;
|
||||||
const int startX = centerX - (arrowSize - 1 - i);
|
const int startX = centerX - i;
|
||||||
renderer.drawLine(startX, indicatorTop + i, startX + lineWidth - 1,
|
renderer.drawLine(startX, indicatorTop + i, startX + lineWidth - 1,
|
||||||
indicatorTop + i);
|
indicatorTop + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw down arrow at bottom (triangle pointing down - narrow at top, wide at
|
// Draw down arrow at bottom (v) - wide base at top, narrow point at bottom
|
||||||
// bottom)
|
|
||||||
for (int i = 0; i < arrowSize; ++i) {
|
for (int i = 0; i < arrowSize; ++i) {
|
||||||
const int lineWidth = 1 + i * 2;
|
const int lineWidth = 1 + (arrowSize - 1 - i) * 2;
|
||||||
const int startX = centerX - i;
|
const int startX = centerX - (arrowSize - 1 - i);
|
||||||
renderer.drawLine(startX, indicatorBottom - arrowSize + 1 + i,
|
renderer.drawLine(startX, indicatorBottom - arrowSize + 1 + i,
|
||||||
startX + lineWidth - 1,
|
startX + lineWidth - 1,
|
||||||
indicatorBottom - arrowSize + 1 + i);
|
indicatorBottom - arrowSize + 1 + i);
|
||||||
|
|||||||
@ -269,25 +269,23 @@ void MyLibraryActivity::loop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tab switching: Left/Right when selectorIndex == 0
|
// Tab switching: Left/Right always control tabs
|
||||||
if (selectorIndex == 0) {
|
if (leftReleased && currentTab == Tab::Files) {
|
||||||
if (leftReleased && currentTab == Tab::Files) {
|
currentTab = Tab::Recent;
|
||||||
currentTab = Tab::Recent;
|
selectorIndex = 0;
|
||||||
selectorIndex = 0;
|
updateRequired = true;
|
||||||
updateRequired = true;
|
return;
|
||||||
return;
|
}
|
||||||
}
|
if (rightReleased && currentTab == Tab::Recent) {
|
||||||
if (rightReleased && currentTab == Tab::Recent) {
|
currentTab = Tab::Files;
|
||||||
currentTab = Tab::Files;
|
selectorIndex = 0;
|
||||||
selectorIndex = 0;
|
updateRequired = true;
|
||||||
updateRequired = true;
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Navigation: Up/Down moves through items, Left/Right also work as prev/next
|
// Navigation: Up/Down moves through items only
|
||||||
const bool prevReleased = upReleased || leftReleased;
|
const bool prevReleased = upReleased;
|
||||||
const bool nextReleased = downReleased || rightReleased;
|
const bool nextReleased = downReleased;
|
||||||
|
|
||||||
if (prevReleased && itemCount > 0) {
|
if (prevReleased && itemCount > 0) {
|
||||||
if (skipPage) {
|
if (skipPage) {
|
||||||
|
|||||||
@ -10,10 +10,10 @@
|
|||||||
#include "../Activity.h"
|
#include "../Activity.h"
|
||||||
|
|
||||||
class MyLibraryActivity final : public Activity {
|
class MyLibraryActivity final : public Activity {
|
||||||
public:
|
public:
|
||||||
enum class Tab { Recent, Files };
|
enum class Tab { Recent, Files };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TaskHandle_t displayTaskHandle = nullptr;
|
TaskHandle_t displayTaskHandle = nullptr;
|
||||||
SemaphoreHandle_t renderingMutex = nullptr;
|
SemaphoreHandle_t renderingMutex = nullptr;
|
||||||
|
|
||||||
@ -22,8 +22,9 @@ class MyLibraryActivity final : public Activity {
|
|||||||
bool updateRequired = false;
|
bool updateRequired = false;
|
||||||
|
|
||||||
// Recent tab state (from RecentBooksActivity)
|
// Recent tab state (from RecentBooksActivity)
|
||||||
std::vector<std::string> bookTitles; // Display titles for each book
|
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>
|
||||||
|
bookPaths; // Paths for each visible book (excludes missing)
|
||||||
|
|
||||||
// Files tab state (from FileSelectionActivity)
|
// Files tab state (from FileSelectionActivity)
|
||||||
std::string basepath = "/";
|
std::string basepath = "/";
|
||||||
@ -31,7 +32,7 @@ class MyLibraryActivity final : public Activity {
|
|||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
const std::function<void()> onGoHome;
|
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
|
// Number of items that fit on a page
|
||||||
int getPageItems() const;
|
int getPageItems() const;
|
||||||
@ -44,21 +45,20 @@ class MyLibraryActivity final : public Activity {
|
|||||||
void loadFiles();
|
void loadFiles();
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
static void taskTrampoline(void* param);
|
static void taskTrampoline(void *param);
|
||||||
[[noreturn]] void displayTaskLoop();
|
[[noreturn]] void displayTaskLoop();
|
||||||
void render() const;
|
void render() const;
|
||||||
void renderRecentTab() const;
|
void renderRecentTab() const;
|
||||||
void renderFilesTab() const;
|
void renderFilesTab() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MyLibraryActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
|
explicit MyLibraryActivity(
|
||||||
const std::function<void()>& onGoHome,
|
GfxRenderer &renderer, MappedInputManager &mappedInput,
|
||||||
const std::function<void(const std::string& path)>& onSelectBook,
|
const std::function<void()> &onGoHome,
|
||||||
Tab initialTab = Tab::Recent)
|
const std::function<void(const std::string &path)> &onSelectBook,
|
||||||
: Activity("MyLibrary", renderer, mappedInput),
|
Tab initialTab = Tab::Recent)
|
||||||
currentTab(initialTab),
|
: Activity("MyLibrary", renderer, mappedInput), currentTab(initialTab),
|
||||||
onGoHome(onGoHome),
|
onGoHome(onGoHome), onSelectBook(onSelectBook) {}
|
||||||
onSelectBook(onSelectBook) {}
|
|
||||||
void onEnter() override;
|
void onEnter() override;
|
||||||
void onExit() override;
|
void onExit() override;
|
||||||
void loop() override;
|
void loop() override;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user