From 465cc029ffc788c9e110decc156a2c9cbca9264b Mon Sep 17 00:00:00 2001 From: Arthur Tazhitdinov Date: Tue, 3 Feb 2026 17:09:42 +0300 Subject: [PATCH] feat: add screen rotation functionality to Epub reader menu --- src/activities/reader/EpubReaderActivity.cpp | 34 +++++++++++++++++++ .../reader/EpubReaderMenuActivity.h | 3 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index 5ccfb4fe..8afa8205 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -268,6 +268,40 @@ void EpubReaderActivity::onReaderMenuConfirm(EpubReaderMenuActivity::MenuAction xSemaphoreGive(renderingMutex); break; } + case EpubReaderMenuActivity::MenuAction::ROTATE_SCREEN: { + xSemaphoreTake(renderingMutex, portMAX_DELAY); + if (section) { + cachedSpineIndex = currentSpineIndex; + cachedChapterTotalPageCount = section->pageCount; + nextPageNumber = section->currentPage; + } + + SETTINGS.orientation = (SETTINGS.orientation + 1) % CrossPointSettings::ORIENTATION_COUNT; + SETTINGS.saveToFile(); + + switch (SETTINGS.orientation) { + case CrossPointSettings::ORIENTATION::PORTRAIT: + renderer.setOrientation(GfxRenderer::Orientation::Portrait); + break; + case CrossPointSettings::ORIENTATION::LANDSCAPE_CW: + renderer.setOrientation(GfxRenderer::Orientation::LandscapeClockwise); + break; + case CrossPointSettings::ORIENTATION::INVERTED: + renderer.setOrientation(GfxRenderer::Orientation::PortraitInverted); + break; + case CrossPointSettings::ORIENTATION::LANDSCAPE_CCW: + renderer.setOrientation(GfxRenderer::Orientation::LandscapeCounterClockwise); + break; + default: + break; + } + + section.reset(); + exitActivity(); + updateRequired = true; + xSemaphoreGive(renderingMutex); + break; + } case EpubReaderMenuActivity::MenuAction::GO_HOME: { // 2. Trigger the reader's "Go Home" callback if (onGoHome) { diff --git a/src/activities/reader/EpubReaderMenuActivity.h b/src/activities/reader/EpubReaderMenuActivity.h index bd253f81..7f7566f6 100644 --- a/src/activities/reader/EpubReaderMenuActivity.h +++ b/src/activities/reader/EpubReaderMenuActivity.h @@ -13,7 +13,7 @@ class EpubReaderMenuActivity final : public ActivityWithSubactivity { public: - enum class MenuAction { SELECT_CHAPTER, GO_HOME, DELETE_CACHE }; + enum class MenuAction { SELECT_CHAPTER, ROTATE_SCREEN, GO_HOME, DELETE_CACHE }; explicit EpubReaderMenuActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::string& title, const std::function& onBack, const std::function& onAction) @@ -33,6 +33,7 @@ class EpubReaderMenuActivity final : public ActivityWithSubactivity { }; const std::vector menuItems = {{MenuAction::SELECT_CHAPTER, "Go to Chapter"}, + {MenuAction::ROTATE_SCREEN, "Rotate Screen"}, {MenuAction::GO_HOME, "Go Home"}, {MenuAction::DELETE_CACHE, "Delete Book Cache"}};