This PR unifies navigation handling & adds system-wide support for continuous navigation. ## Summary Holding down a navigation button now continuously advances through items until the button is released. This removes the need for repeated press-and-release actions and makes navigation faster and smoother, especially in long menus or documents. When page-based navigation is available, it will navigate through pages. If not, it will progress through menu items or similar list-based UI elements. Additionally, this PR fixes inconsistencies in wrap-around behavior and navigation index calculations. Places where the navigation system was updated: - Home Page - Settings Pages - My Library Page - WiFi Selection Page - OPDS Browser Page - Keyboard - File Transfer Page - XTC Chapter Selector Page - EPUB Chapter Selector Page I’ve tested this on the device as much as possible and tried to match the existing behavior. Please let me know if I missed anything. Thanks 🙏  --- Following the request from @osteotek and @daveallie for system-wide support, the old PR (#379) has been closed in favor of this consolidated, system-wide implementation. --- ### AI Usage Did you use AI tools to help write this code? _**PARTIALLY**_ --------- Co-authored-by: Dave Allie <dave@daveallie.com>
64 lines
2.4 KiB
C++
64 lines
2.4 KiB
C++
#pragma once
|
|
#include <freertos/FreeRTOS.h>
|
|
#include <freertos/semphr.h>
|
|
#include <freertos/task.h>
|
|
|
|
#include <functional>
|
|
#include <vector>
|
|
|
|
#include "../Activity.h"
|
|
#include "./MyLibraryActivity.h"
|
|
#include "util/ButtonNavigator.h"
|
|
|
|
struct RecentBook;
|
|
struct Rect;
|
|
|
|
class HomeActivity final : public Activity {
|
|
TaskHandle_t displayTaskHandle = nullptr;
|
|
SemaphoreHandle_t renderingMutex = nullptr;
|
|
ButtonNavigator buttonNavigator;
|
|
int selectorIndex = 0;
|
|
bool updateRequired = false;
|
|
bool recentsLoading = false;
|
|
bool recentsLoaded = false;
|
|
bool firstRenderDone = false;
|
|
bool hasOpdsUrl = false;
|
|
bool coverRendered = false; // Track if cover has been rendered once
|
|
bool coverBufferStored = false; // Track if cover buffer is stored
|
|
uint8_t* coverBuffer = nullptr; // HomeActivity's own buffer for cover image
|
|
std::vector<RecentBook> recentBooks;
|
|
const std::function<void(const std::string& path)> onSelectBook;
|
|
const std::function<void()> onMyLibraryOpen;
|
|
const std::function<void()> onRecentsOpen;
|
|
const std::function<void()> onSettingsOpen;
|
|
const std::function<void()> onFileTransferOpen;
|
|
const std::function<void()> onOpdsBrowserOpen;
|
|
|
|
static void taskTrampoline(void* param);
|
|
[[noreturn]] void displayTaskLoop();
|
|
void render();
|
|
int getMenuItemCount() const;
|
|
bool storeCoverBuffer(); // Store frame buffer for cover image
|
|
bool restoreCoverBuffer(); // Restore frame buffer from stored cover
|
|
void freeCoverBuffer(); // Free the stored cover buffer
|
|
void loadRecentBooks(int maxBooks);
|
|
void loadRecentCovers(int coverHeight);
|
|
|
|
public:
|
|
explicit HomeActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
|
|
const std::function<void(const std::string& path)>& onSelectBook,
|
|
const std::function<void()>& onMyLibraryOpen, const std::function<void()>& onRecentsOpen,
|
|
const std::function<void()>& onSettingsOpen, const std::function<void()>& onFileTransferOpen,
|
|
const std::function<void()>& onOpdsBrowserOpen)
|
|
: Activity("Home", renderer, mappedInput),
|
|
onSelectBook(onSelectBook),
|
|
onMyLibraryOpen(onMyLibraryOpen),
|
|
onRecentsOpen(onRecentsOpen),
|
|
onSettingsOpen(onSettingsOpen),
|
|
onFileTransferOpen(onFileTransferOpen),
|
|
onOpdsBrowserOpen(onOpdsBrowserOpen) {}
|
|
void onEnter() override;
|
|
void onExit() override;
|
|
void loop() override;
|
|
};
|