feat: Go To Position for epubs (#666)

## Summary

* Adds Go To % action in Epub Reader menu with slider style percent
selector

<img width="860" height="1147" alt="image"
src="https://github.com/user-attachments/assets/a38ecc71-429e-40e8-94ac-37fb1509dbd9"
/>

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**< PARTIALLY >**_

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Arthur Tazhitdinov
2026-02-05 15:17:51 +03:00
committed by GitHub
parent 17fedd2a69
commit ddbe49f536
6 changed files with 332 additions and 5 deletions

View File

@@ -0,0 +1,46 @@
#pragma once
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
#include <freertos/task.h>
#include <functional>
#include "MappedInputManager.h"
#include "activities/ActivityWithSubactivity.h"
class EpubReaderPercentSelectionActivity final : public ActivityWithSubactivity {
public:
// Slider-style percent selector for jumping within a book.
explicit EpubReaderPercentSelectionActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
const int initialPercent, const std::function<void(int)>& onSelect,
const std::function<void()>& onCancel)
: ActivityWithSubactivity("EpubReaderPercentSelection", renderer, mappedInput),
percent(initialPercent),
onSelect(onSelect),
onCancel(onCancel) {}
void onEnter() override;
void onExit() override;
void loop() override;
private:
// Current percent value (0-100) shown on the slider.
int percent = 0;
// Render dirty flag for the task loop.
bool updateRequired = false;
// FreeRTOS task and mutex for rendering.
TaskHandle_t displayTaskHandle = nullptr;
SemaphoreHandle_t renderingMutex = nullptr;
// Callback invoked when the user confirms a percent.
const std::function<void(int)> onSelect;
// Callback invoked when the user cancels the slider.
const std::function<void()> onCancel;
static void taskTrampoline(void* param);
[[noreturn]] void displayTaskLoop();
// Render the slider UI.
void renderScreen();
// Change the current percent by a delta and clamp within bounds.
void adjustPercent(int delta);
};