mirror of
https://github.com/crosspoint-reader/crosspoint-reader.git
synced 2026-04-29 10:26:52 -07:00
feat: add orientation-aware popups for reader activities (#1428)
## Summary Make popups (like "Going to sleep") respect the current screen orientation when shown from reader activities. **What changes are included?** - Apply reader orientation in SleepActivity before showing popup when `lastSleepFromReader` is true - Make popup Y-position proportional to screen height (7.5% for BaseTheme, 16.5% for LyraTheme) instead of hardcoded pixel values, ensuring correct positioning in both portrait and landscape modes. - Add `isReaderActivity()` override to all reader sub-screens (menu, chapter selection, percent selection, footnotes, QR display, KOReader sync), so sleep popups rotate correctly when entering sleep from any reader context. ## Additional Context <img src="https://github.com/user-attachments/assets/47d88c2c-ffc5-41a7-b3f2-af272ea0150e" width="400" height="240"> --- ### 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? _**YES**_ (Claude Opus 4.5)
This commit is contained in:
@@ -10,13 +10,22 @@
|
||||
|
||||
#include "CrossPointSettings.h"
|
||||
#include "CrossPointState.h"
|
||||
#include "activities/reader/ReaderUtils.h"
|
||||
#include "components/UITheme.h"
|
||||
#include "fontIds.h"
|
||||
#include "images/Logo120.h"
|
||||
|
||||
void SleepActivity::onEnter() {
|
||||
Activity::onEnter();
|
||||
GUI.drawPopup(renderer, tr(STR_ENTERING_SLEEP));
|
||||
|
||||
// Show popup with reader orientation only when going to sleep from reader
|
||||
if (APP_STATE.lastSleepFromReader) {
|
||||
ReaderUtils::applyOrientation(renderer, SETTINGS.orientation);
|
||||
GUI.drawPopup(renderer, tr(STR_ENTERING_SLEEP));
|
||||
renderer.setOrientation(GfxRenderer::Orientation::Portrait);
|
||||
} else {
|
||||
GUI.drawPopup(renderer, tr(STR_ENTERING_SLEEP));
|
||||
}
|
||||
|
||||
switch (SETTINGS.sleepScreen) {
|
||||
case (CrossPointSettings::SLEEP_SCREEN_MODE::BLANK):
|
||||
|
||||
@@ -32,4 +32,5 @@ class EpubReaderChapterSelectionActivity final : public Activity {
|
||||
void onExit() override;
|
||||
void loop() override;
|
||||
void render(RenderLock&&) override;
|
||||
bool isReaderActivity() const override { return true; }
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@ class EpubReaderFootnotesActivity final : public Activity {
|
||||
void onExit() override;
|
||||
void loop() override;
|
||||
void render(RenderLock&&) override;
|
||||
bool isReaderActivity() const override { return true; }
|
||||
|
||||
private:
|
||||
const std::vector<FootnoteEntry>& footnotes;
|
||||
|
||||
@@ -32,6 +32,7 @@ class EpubReaderMenuActivity final : public Activity {
|
||||
void onExit() override;
|
||||
void loop() override;
|
||||
void render(RenderLock&&) override;
|
||||
bool isReaderActivity() const override { return true; }
|
||||
|
||||
private:
|
||||
struct MenuItem {
|
||||
|
||||
@@ -15,6 +15,7 @@ class EpubReaderPercentSelectionActivity final : public Activity {
|
||||
void onExit() override;
|
||||
void loop() override;
|
||||
void render(RenderLock&&) override;
|
||||
bool isReaderActivity() const override { return true; }
|
||||
|
||||
private:
|
||||
// Current percent value (0-100) shown on the slider.
|
||||
|
||||
@@ -38,6 +38,7 @@ class KOReaderSyncActivity final : public Activity {
|
||||
void loop() override;
|
||||
void render(RenderLock&&) override;
|
||||
bool preventAutoSleep() override { return state == CONNECTING || state == SYNCING; }
|
||||
bool isReaderActivity() const override { return true; }
|
||||
|
||||
private:
|
||||
enum State {
|
||||
|
||||
@@ -14,6 +14,7 @@ class QrDisplayActivity final : public Activity {
|
||||
void onExit() override;
|
||||
void loop() override;
|
||||
void render(RenderLock&&) override;
|
||||
bool isReaderActivity() const override { return true; }
|
||||
|
||||
private:
|
||||
std::string textPayload;
|
||||
|
||||
@@ -648,7 +648,8 @@ void BaseTheme::drawButtonMenu(GfxRenderer& renderer, Rect rect, int buttonCount
|
||||
|
||||
Rect BaseTheme::drawPopup(const GfxRenderer& renderer, const char* message) const {
|
||||
constexpr int margin = 15;
|
||||
constexpr int y = 60;
|
||||
// Scale y position proportionally to screen height (7.5% from top)
|
||||
const int y = static_cast<int>(renderer.getScreenHeight() * 0.075f);
|
||||
const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, message, EpdFontFamily::BOLD);
|
||||
const int textHeight = renderer.getLineHeight(UI_12_FONT_ID);
|
||||
const int w = textWidth + margin * 2;
|
||||
|
||||
@@ -541,7 +541,8 @@ void LyraTheme::drawButtonMenu(GfxRenderer& renderer, Rect rect, int buttonCount
|
||||
}
|
||||
|
||||
Rect LyraTheme::drawPopup(const GfxRenderer& renderer, const char* message) const {
|
||||
constexpr int y = 132;
|
||||
// Scale y position proportionally to screen height (16.5% from top)
|
||||
const int y = static_cast<int>(renderer.getScreenHeight() * 0.165f);
|
||||
constexpr int outline = 2;
|
||||
const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, message, EpdFontFamily::REGULAR);
|
||||
const int textHeight = renderer.getLineHeight(UI_12_FONT_ID);
|
||||
|
||||
Reference in New Issue
Block a user