Recover parts of the regression fiasco
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -26,6 +26,7 @@ struct MenuResult {
|
||||
int8_t embeddedStyleOverride = -1;
|
||||
int8_t imageRenderingOverride = -1;
|
||||
int8_t fontFamilyOverride = -1;
|
||||
std::string sdFontFamilyOverride;
|
||||
int8_t fontSizeOverride = -1;
|
||||
uint8_t textDarkness = 1;
|
||||
uint8_t bionicReadingOverride = 0;
|
||||
|
||||
@@ -190,6 +190,7 @@ void EpubReaderActivity::onEnter() {
|
||||
bookEmbeddedStyleOverride = currentBook.embeddedStyleOverride;
|
||||
bookImageRenderingOverride = currentBook.imageRenderingOverride;
|
||||
bookFontFamilyOverride = currentBook.fontFamilyOverride;
|
||||
bookSdFontFamilyOverride = currentBook.sdFontFamilyOverride;
|
||||
bookFontSizeOverride = currentBook.fontSizeOverride;
|
||||
bookBionicReadingOverride = (currentBook.bionicReadingOverride >= 0)
|
||||
? static_cast<bool>(currentBook.bionicReadingOverride)
|
||||
@@ -1036,24 +1037,27 @@ void EpubReaderActivity::toggleAutoPageTurn(const uint8_t selectedPageTurnOption
|
||||
|
||||
void EpubReaderActivity::applyBookReaderOverrides(const int8_t embeddedStyleOverride,
|
||||
const int8_t imageRenderingOverride, const int8_t fontFamilyOverride,
|
||||
const std::string& sdFontFamilyOverride,
|
||||
const int8_t fontSizeOverride, const bool bionicReadingOverride) {
|
||||
if (!epub) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (bookEmbeddedStyleOverride == embeddedStyleOverride && bookImageRenderingOverride == imageRenderingOverride &&
|
||||
bookFontFamilyOverride == fontFamilyOverride && bookFontSizeOverride == fontSizeOverride &&
|
||||
bookBionicReadingOverride == bionicReadingOverride) {
|
||||
bookFontFamilyOverride == fontFamilyOverride && bookSdFontFamilyOverride == sdFontFamilyOverride &&
|
||||
bookFontSizeOverride == fontSizeOverride && bookBionicReadingOverride == bionicReadingOverride) {
|
||||
return;
|
||||
}
|
||||
|
||||
bookEmbeddedStyleOverride = embeddedStyleOverride;
|
||||
bookImageRenderingOverride = imageRenderingOverride;
|
||||
bookFontFamilyOverride = fontFamilyOverride;
|
||||
bookSdFontFamilyOverride = sdFontFamilyOverride;
|
||||
bookFontSizeOverride = fontSizeOverride;
|
||||
bookBionicReadingOverride = bionicReadingOverride;
|
||||
RECENT_BOOKS.setReaderOverrides(epub->getPath(), bookEmbeddedStyleOverride, bookImageRenderingOverride,
|
||||
bookFontFamilyOverride, bookFontSizeOverride, bookBionicReadingOverride);
|
||||
bookFontFamilyOverride, bookSdFontFamilyOverride, bookFontSizeOverride,
|
||||
bookBionicReadingOverride);
|
||||
|
||||
RenderLock lock(*this);
|
||||
if (section) {
|
||||
@@ -1081,9 +1085,7 @@ uint8_t EpubReaderActivity::getEffectiveImageRendering() const {
|
||||
float EpubReaderActivity::getEffectiveReaderLineCompression() const {
|
||||
const uint8_t fontSize = (bookFontSizeOverride >= 0) ? static_cast<uint8_t>(bookFontSizeOverride) : SETTINGS.fontSize;
|
||||
const int effectiveFontId = getEffectiveReaderFontId();
|
||||
const int bookerlyId = CrossPointSettings::getBuiltinReaderFontId(CrossPointSettings::BOOKERLY, fontSize);
|
||||
const int notosansId = CrossPointSettings::getBuiltinReaderFontId(CrossPointSettings::NOTOSANS, fontSize);
|
||||
const int opendyslexicId = CrossPointSettings::getBuiltinReaderFontId(CrossPointSettings::OPENDYSLEXIC, fontSize);
|
||||
|
||||
if (effectiveFontId == notosansId) {
|
||||
switch (SETTINGS.lineSpacing) {
|
||||
@@ -1097,18 +1099,6 @@ float EpubReaderActivity::getEffectiveReaderLineCompression() const {
|
||||
}
|
||||
}
|
||||
|
||||
if (effectiveFontId == opendyslexicId) {
|
||||
switch (SETTINGS.lineSpacing) {
|
||||
case CrossPointSettings::TIGHT:
|
||||
return 0.90f;
|
||||
case CrossPointSettings::NORMAL:
|
||||
default:
|
||||
return 0.95f;
|
||||
case CrossPointSettings::WIDE:
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
switch (SETTINGS.lineSpacing) {
|
||||
case CrossPointSettings::TIGHT:
|
||||
return 0.95f;
|
||||
@@ -1129,6 +1119,10 @@ int EpubReaderActivity::getEffectiveReaderFontId() const {
|
||||
if (bookFontFamilyOverride >= 0) {
|
||||
return CrossPointSettings::getBuiltinReaderFontId(static_cast<uint8_t>(bookFontFamilyOverride), fontSize);
|
||||
}
|
||||
if (!bookSdFontFamilyOverride.empty()) {
|
||||
const int id = resolveSdCardFontId(bookSdFontFamilyOverride.c_str(), fontSize);
|
||||
if (id != 0) return id;
|
||||
}
|
||||
// No override: defer to global resolution (which honors SD card font selection).
|
||||
// We synthesize a temporary lookup using the override fontSize if it's set; otherwise
|
||||
// SETTINGS.getReaderFontId() is the canonical answer.
|
||||
@@ -1747,59 +1741,25 @@ bool EpubReaderActivity::drawCurrentPageToBuffer(const std::string& filePath, Gf
|
||||
// Load or rebuild the section cache. Rebuilding is needed when the cache is missing or stale
|
||||
// (e.g. after a firmware update). A no-op popup callback avoids any UI during sleep preparation.
|
||||
const RecentBook currentBook = RECENT_BOOKS.getBookByPath(filePath);
|
||||
const bool hasLocalSdOverride = !currentBook.sdFontFamilyOverride.empty();
|
||||
const uint8_t effectiveFontFamily =
|
||||
currentBook.fontFamilyOverride >= 0 ? static_cast<uint8_t>(currentBook.fontFamilyOverride) : SETTINGS.fontFamily;
|
||||
const uint8_t effectiveFontSize =
|
||||
currentBook.fontSizeOverride >= 0 ? static_cast<uint8_t>(currentBook.fontSizeOverride) : SETTINGS.fontSize;
|
||||
auto getEffectiveFontId = [&](uint8_t family, uint8_t size) {
|
||||
switch (family) {
|
||||
case CrossPointSettings::NOTOSANS:
|
||||
switch (size) {
|
||||
case CrossPointSettings::SMALL:
|
||||
return NOTOSANS_12_FONT_ID;
|
||||
case CrossPointSettings::LARGE:
|
||||
return NOTOSANS_16_FONT_ID;
|
||||
case CrossPointSettings::EXTRA_LARGE:
|
||||
return NOTOSANS_18_FONT_ID;
|
||||
case CrossPointSettings::MEDIUM:
|
||||
default:
|
||||
return NOTOSANS_14_FONT_ID;
|
||||
}
|
||||
case CrossPointSettings::OPENDYSLEXIC:
|
||||
switch (size) {
|
||||
case CrossPointSettings::SMALL:
|
||||
return OPENDYSLEXIC_8_FONT_ID;
|
||||
case CrossPointSettings::LARGE:
|
||||
return OPENDYSLEXIC_12_FONT_ID;
|
||||
case CrossPointSettings::EXTRA_LARGE:
|
||||
return OPENDYSLEXIC_14_FONT_ID;
|
||||
case CrossPointSettings::MEDIUM:
|
||||
default:
|
||||
return OPENDYSLEXIC_10_FONT_ID;
|
||||
}
|
||||
case CrossPointSettings::BOOKERLY:
|
||||
default:
|
||||
switch (size) {
|
||||
case CrossPointSettings::SMALL:
|
||||
return BOOKERLY_12_FONT_ID;
|
||||
case CrossPointSettings::LARGE:
|
||||
return BOOKERLY_16_FONT_ID;
|
||||
case CrossPointSettings::EXTRA_LARGE:
|
||||
return BOOKERLY_18_FONT_ID;
|
||||
case CrossPointSettings::MEDIUM:
|
||||
default:
|
||||
return BOOKERLY_14_FONT_ID;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const int effectiveFontId = getEffectiveFontId(effectiveFontFamily, effectiveFontSize);
|
||||
int effectiveFontId = 0;
|
||||
if (hasLocalSdOverride) {
|
||||
effectiveFontId = resolveSdCardFontId(currentBook.sdFontFamilyOverride.c_str(), effectiveFontSize);
|
||||
}
|
||||
if (effectiveFontId == 0 && currentBook.fontFamilyOverride >= 0) {
|
||||
effectiveFontId = CrossPointSettings::getBuiltinReaderFontId(effectiveFontFamily, effectiveFontSize);
|
||||
}
|
||||
if (effectiveFontId == 0) {
|
||||
effectiveFontId = SETTINGS.getReaderFontId();
|
||||
}
|
||||
const auto getEffectiveLineCompression = [&](int fontId) {
|
||||
const int notosansId = CrossPointSettings::getBuiltinReaderFontId(CrossPointSettings::NOTOSANS, effectiveFontSize);
|
||||
const int opendyslexicId =
|
||||
CrossPointSettings::getBuiltinReaderFontId(CrossPointSettings::OPENDYSLEXIC, effectiveFontSize);
|
||||
|
||||
if (fontId == notosansId || fontId == opendyslexicId) {
|
||||
if (fontId == notosansId) {
|
||||
switch (SETTINGS.lineSpacing) {
|
||||
case CrossPointSettings::TIGHT:
|
||||
return 0.90f;
|
||||
@@ -1824,13 +1784,12 @@ bool EpubReaderActivity::drawCurrentPageToBuffer(const std::string& filePath, Gf
|
||||
|
||||
const float effectiveLineCompression = getEffectiveLineCompression(effectiveFontId);
|
||||
auto section = std::make_unique<Section>(epub, spineIndex, renderer);
|
||||
if (!section->loadSectionFile(getEffectiveFontId(effectiveFontFamily, effectiveFontSize), effectiveLineCompression,
|
||||
SETTINGS.extraParagraphSpacing, SETTINGS.paragraphAlignment, viewportWidth,
|
||||
viewportHeight, SETTINGS.hyphenationEnabled, SETTINGS.embeddedStyle,
|
||||
static_cast<bool>(SETTINGS.bionicReading), SETTINGS.imageRendering)) {
|
||||
if (!section->loadSectionFile(effectiveFontId, effectiveLineCompression, SETTINGS.extraParagraphSpacing,
|
||||
SETTINGS.paragraphAlignment, viewportWidth, viewportHeight, SETTINGS.hyphenationEnabled,
|
||||
SETTINGS.embeddedStyle, static_cast<bool>(SETTINGS.bionicReading),
|
||||
SETTINGS.imageRendering)) {
|
||||
LOG_DBG("SLP", "EPUB: section cache not found for spine %d, rebuilding", spineIndex);
|
||||
if (!section->createSectionFile(getEffectiveFontId(effectiveFontFamily, effectiveFontSize),
|
||||
effectiveLineCompression, SETTINGS.extraParagraphSpacing,
|
||||
if (!section->createSectionFile(effectiveFontId, effectiveLineCompression, SETTINGS.extraParagraphSpacing,
|
||||
SETTINGS.paragraphAlignment, viewportWidth, viewportHeight,
|
||||
SETTINGS.hyphenationEnabled, SETTINGS.embeddedStyle,
|
||||
static_cast<bool>(SETTINGS.bionicReading), SETTINGS.imageRendering)) {
|
||||
@@ -1849,7 +1808,7 @@ bool EpubReaderActivity::drawCurrentPageToBuffer(const std::string& filePath, Gf
|
||||
}
|
||||
|
||||
renderer.clearScreen();
|
||||
page->render(renderer, getEffectiveFontId(effectiveFontFamily, effectiveFontSize), marginLeft, marginTop);
|
||||
page->render(renderer, effectiveFontId, marginLeft, marginTop);
|
||||
// No displayBuffer call — caller (SleepActivity) handles that after compositing the overlay
|
||||
return true;
|
||||
}
|
||||
@@ -1870,15 +1829,16 @@ void EpubReaderActivity::openReaderMenu() {
|
||||
std::make_unique<EpubReaderMenuActivity>(
|
||||
renderer, mappedInput, epub->getTitle(), currentPage, totalPages, bookProgressPercent, SETTINGS.orientation,
|
||||
!currentPageFootnotes.empty(), bookEmbeddedStyleOverride, bookImageRenderingOverride, bookFontFamilyOverride,
|
||||
bookFontSizeOverride, SETTINGS.textDarkness, bookBionicReadingOverride, !bookmarkStore.isEmpty(),
|
||||
isCurrentPageStarred),
|
||||
bookSdFontFamilyOverride, bookFontSizeOverride, SETTINGS.textDarkness, bookBionicReadingOverride,
|
||||
!bookmarkStore.isEmpty(), isCurrentPageStarred),
|
||||
[this](const ActivityResult& result) {
|
||||
const auto& menu = std::get<MenuResult>(result.data);
|
||||
applyOrientation(menu.orientation);
|
||||
applyTextDarkness(menu.textDarkness);
|
||||
toggleAutoPageTurn(menu.pageTurnOption);
|
||||
applyBookReaderOverrides(menu.embeddedStyleOverride, menu.imageRenderingOverride, menu.fontFamilyOverride,
|
||||
menu.fontSizeOverride, static_cast<bool>(menu.bionicReadingOverride));
|
||||
menu.sdFontFamilyOverride, menu.fontSizeOverride,
|
||||
static_cast<bool>(menu.bionicReadingOverride));
|
||||
if (!result.isCancelled) {
|
||||
onReaderMenuConfirm(static_cast<EpubReaderMenuActivity::MenuAction>(menu.action));
|
||||
}
|
||||
@@ -2010,7 +1970,7 @@ void EpubReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION
|
||||
case BA::BTN_TOGGLE_BIONIC_READING:
|
||||
if (epub) {
|
||||
applyBookReaderOverrides(bookEmbeddedStyleOverride, bookImageRenderingOverride, bookFontFamilyOverride,
|
||||
bookFontSizeOverride, !bookBionicReadingOverride);
|
||||
bookSdFontFamilyOverride, bookFontSizeOverride, !bookBionicReadingOverride);
|
||||
requestUpdate();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -134,6 +134,7 @@ class EpubReaderActivity final : public Activity {
|
||||
int8_t bookEmbeddedStyleOverride = -1;
|
||||
int8_t bookImageRenderingOverride = -1;
|
||||
int8_t bookFontFamilyOverride = -1;
|
||||
std::string bookSdFontFamilyOverride;
|
||||
int8_t bookFontSizeOverride = -1;
|
||||
bool bookBionicReadingOverride = false;
|
||||
|
||||
@@ -177,7 +178,8 @@ class EpubReaderActivity final : public Activity {
|
||||
void applyTextDarkness(uint8_t textDarkness);
|
||||
void toggleAutoPageTurn(uint8_t selectedPageTurnOption);
|
||||
void applyBookReaderOverrides(int8_t embeddedStyleOverride, int8_t imageRenderingOverride, int8_t fontFamilyOverride,
|
||||
int8_t fontSizeOverride, bool bionicReadingOverride);
|
||||
const std::string& sdFontFamilyOverride, int8_t fontSizeOverride,
|
||||
bool bionicReadingOverride);
|
||||
void openReaderMenu();
|
||||
bool getEffectiveEmbeddedStyle() const;
|
||||
uint8_t getEffectiveImageRendering() const;
|
||||
|
||||
@@ -19,9 +19,8 @@ std::string defaultFontFamilyLabel(const SettingInfo& item) {
|
||||
if (SETTINGS.sdFontFamilyName[0] != '\0') {
|
||||
return std::string(SETTINGS.sdFontFamilyName);
|
||||
}
|
||||
// Built-in: enumValues[0] is STR_DEFAULT_VALUE, [1..3] are the three families
|
||||
// in the same order as CrossPointSettings::FONT_FAMILY (BOOKERLY, NOTOSANS,
|
||||
// OPENDYSLEXIC).
|
||||
// Built-in: enumValues[0] is STR_DEFAULT_VALUE, [1..] are built-in families
|
||||
// in CrossPointSettings::FONT_FAMILY order.
|
||||
const auto idx = static_cast<size_t>(SETTINGS.fontFamily + 1);
|
||||
if (idx < item.enumValues.size()) {
|
||||
return I18N.get(item.enumValues[idx]);
|
||||
@@ -34,14 +33,16 @@ EpubReaderMenuActivity::EpubReaderMenuActivity(
|
||||
GfxRenderer& renderer, MappedInputManager& mappedInput, const std::string& title, const int currentPage,
|
||||
const int totalPages, const int bookProgressPercent, const uint8_t currentOrientation, const bool hasFootnotes,
|
||||
const int8_t initialEmbeddedStyleOverride, const int8_t initialImageRenderingOverride,
|
||||
const int8_t initialFontFamilyOverride, const int8_t initialFontSizeOverride, const uint8_t initialTextDarkness,
|
||||
const bool initialBionicReadingOverride, const bool hasStarredPages, const bool isCurrentPageStarred)
|
||||
const int8_t initialFontFamilyOverride, const std::string& initialSdFontFamilyOverride,
|
||||
const int8_t initialFontSizeOverride, const uint8_t initialTextDarkness, const bool initialBionicReadingOverride,
|
||||
const bool hasStarredPages, const bool isCurrentPageStarred)
|
||||
: MenuListActivity("EpubReaderMenu", renderer, mappedInput),
|
||||
currentPageStarred(isCurrentPageStarred),
|
||||
pendingOrientation(currentOrientation),
|
||||
pendingEmbeddedStyleOverride(initialEmbeddedStyleOverride),
|
||||
pendingImageRenderingOverride(initialImageRenderingOverride),
|
||||
pendingFontFamilyOverride(initialFontFamilyOverride),
|
||||
pendingSdFontFamilyOverride(initialSdFontFamilyOverride),
|
||||
pendingFontSizeOverride(initialFontSizeOverride),
|
||||
pendingTextDarkness(initialTextDarkness),
|
||||
pendingBionicReading(initialBionicReadingOverride),
|
||||
@@ -119,35 +120,79 @@ void EpubReaderMenuActivity::buildMenuItems(bool hasFootnotes, bool hasStarredPa
|
||||
})
|
||||
.withSubmenu(StrId::STR_READER_OVERRIDES));
|
||||
|
||||
// Reader font family: cycles default(-1) -> Bookerly(0) -> Noto Sans(1) -> Open Dyslexic(2)
|
||||
menuItems.push_back(
|
||||
SettingInfo::DynamicEnumCtx(
|
||||
StrId::STR_FONT_FAMILY,
|
||||
{StrId::STR_DEFAULT_VALUE, StrId::STR_BOOKERLY, StrId::STR_NOTO_SANS, StrId::STR_OPEN_DYSLEXIC}, self,
|
||||
[](const void* ctx) -> uint8_t {
|
||||
const auto* s = static_cast<const EpubReaderMenuActivity*>(ctx);
|
||||
return (s->pendingFontFamilyOverride < 0) ? 0 : static_cast<uint8_t>(s->pendingFontFamilyOverride + 1);
|
||||
},
|
||||
[](void* ctx, uint8_t v) {
|
||||
auto* s = static_cast<EpubReaderMenuActivity*>(ctx);
|
||||
s->pendingFontFamilyOverride = (v == 0) ? -1 : static_cast<int8_t>(v - 1);
|
||||
})
|
||||
.withSubmenu(StrId::STR_READER_OVERRIDES));
|
||||
// Reader font family: default + built-ins + discovered SD families.
|
||||
{
|
||||
std::vector<StrId> values = {StrId::STR_DEFAULT_VALUE, StrId::STR_BOOKERLY, StrId::STR_NOTO_SANS};
|
||||
const auto& families = sdFontSystem.registry().getFamilies();
|
||||
values.insert(values.end(), families.size(), StrId::STR_NONE_OPT);
|
||||
|
||||
// Reader font size: cycles default(-1) -> Small(0) -> Medium(1) -> Large(2) -> X Large(3)
|
||||
menuItems.push_back(
|
||||
SettingInfo::DynamicEnumCtx(
|
||||
StrId::STR_FONT_SIZE,
|
||||
{StrId::STR_DEFAULT_VALUE, StrId::STR_SMALL, StrId::STR_MEDIUM, StrId::STR_LARGE, StrId::STR_X_LARGE}, self,
|
||||
[](const void* ctx) -> uint8_t {
|
||||
const auto* s = static_cast<const EpubReaderMenuActivity*>(ctx);
|
||||
return (s->pendingFontSizeOverride < 0) ? 0 : static_cast<uint8_t>(s->pendingFontSizeOverride + 1);
|
||||
},
|
||||
[](void* ctx, uint8_t v) {
|
||||
auto* s = static_cast<EpubReaderMenuActivity*>(ctx);
|
||||
s->pendingFontSizeOverride = (v == 0) ? -1 : static_cast<int8_t>(v - 1);
|
||||
})
|
||||
.withSubmenu(StrId::STR_READER_OVERRIDES));
|
||||
auto familySetting = SettingInfo::DynamicEnumCtx(
|
||||
StrId::STR_FONT_FAMILY, std::move(values), self,
|
||||
[](const void* ctx) -> uint8_t {
|
||||
const auto* s = static_cast<const EpubReaderMenuActivity*>(ctx);
|
||||
if (s->pendingFontFamilyOverride >= 0) {
|
||||
return static_cast<uint8_t>(s->pendingFontFamilyOverride + 1);
|
||||
}
|
||||
if (!s->pendingSdFontFamilyOverride.empty()) {
|
||||
const auto& fs = sdFontSystem.registry().getFamilies();
|
||||
for (size_t i = 0; i < fs.size(); i++) {
|
||||
if (fs[i].name == s->pendingSdFontFamilyOverride) {
|
||||
return static_cast<uint8_t>(CrossPointSettings::BUILTIN_FONT_COUNT + 1 + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
[](void* ctx, uint8_t v) {
|
||||
auto* s = static_cast<EpubReaderMenuActivity*>(ctx);
|
||||
if (v == 0) {
|
||||
s->pendingFontFamilyOverride = -1;
|
||||
s->pendingSdFontFamilyOverride.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8_t builtinCount = CrossPointSettings::BUILTIN_FONT_COUNT;
|
||||
if (v <= builtinCount) {
|
||||
s->pendingFontFamilyOverride = static_cast<int8_t>(v - 1);
|
||||
s->pendingSdFontFamilyOverride.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
const size_t sdIdx = static_cast<size_t>(v - (builtinCount + 1));
|
||||
const auto& fs = sdFontSystem.registry().getFamilies();
|
||||
s->pendingFontFamilyOverride = -1;
|
||||
if (sdIdx < fs.size()) {
|
||||
s->pendingSdFontFamilyOverride = fs[sdIdx].name;
|
||||
} else {
|
||||
s->pendingSdFontFamilyOverride.clear();
|
||||
}
|
||||
})
|
||||
.withSubmenu(StrId::STR_READER_OVERRIDES);
|
||||
|
||||
familySetting.enumLabels = {tr(STR_DEFAULT_VALUE), tr(STR_BOOKERLY), tr(STR_NOTO_SANS)};
|
||||
for (const auto& fam : families) {
|
||||
familySetting.enumLabels.push_back(fam.name);
|
||||
}
|
||||
menuItems.push_back(std::move(familySetting));
|
||||
}
|
||||
|
||||
// Reader font size: cycles default(-1) -> Small(0) -> Medium(1) -> Large(2) -> X Large(3) -> Tiny(4)
|
||||
menuItems.push_back(SettingInfo::DynamicEnumCtx(
|
||||
StrId::STR_FONT_SIZE,
|
||||
{StrId::STR_DEFAULT_VALUE, StrId::STR_SMALL, StrId::STR_MEDIUM, StrId::STR_LARGE,
|
||||
StrId::STR_X_LARGE, StrId::STR_TINY},
|
||||
self,
|
||||
[](const void* ctx) -> uint8_t {
|
||||
const auto* s = static_cast<const EpubReaderMenuActivity*>(ctx);
|
||||
return (s->pendingFontSizeOverride < 0)
|
||||
? 0
|
||||
: static_cast<uint8_t>(s->pendingFontSizeOverride + 1);
|
||||
},
|
||||
[](void* ctx, uint8_t v) {
|
||||
auto* s = static_cast<EpubReaderMenuActivity*>(ctx);
|
||||
s->pendingFontSizeOverride = (v == 0) ? -1 : static_cast<int8_t>(v - 1);
|
||||
})
|
||||
.withSubmenu(StrId::STR_READER_OVERRIDES));
|
||||
|
||||
// Text darkness: straightforward 0-3 cycle
|
||||
menuItems.push_back(
|
||||
@@ -248,7 +293,8 @@ EpubReaderMenuActivity::MenuAction EpubReaderMenuActivity::actionForSettingActio
|
||||
void EpubReaderMenuActivity::finishWithAction(MenuAction action) {
|
||||
setResult(MenuResult{static_cast<int>(action), -1, pendingOrientation, selectedPageTurnOption,
|
||||
pendingEmbeddedStyleOverride, pendingImageRenderingOverride, pendingFontFamilyOverride,
|
||||
pendingFontSizeOverride, pendingTextDarkness, static_cast<uint8_t>(pendingBionicReading)});
|
||||
pendingSdFontFamilyOverride, pendingFontSizeOverride, pendingTextDarkness,
|
||||
static_cast<uint8_t>(pendingBionicReading)});
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -280,6 +326,7 @@ void EpubReaderMenuActivity::onBackPressed() {
|
||||
pendingEmbeddedStyleOverride,
|
||||
pendingImageRenderingOverride,
|
||||
pendingFontFamilyOverride,
|
||||
pendingSdFontFamilyOverride,
|
||||
pendingFontSizeOverride,
|
||||
pendingTextDarkness,
|
||||
static_cast<uint8_t>(pendingBionicReading)};
|
||||
@@ -319,7 +366,7 @@ std::string EpubReaderMenuActivity::getItemValueString(int index) const {
|
||||
return std::string(tr(STR_DEFAULT_VALUE)) + " (" + I18N.get(item.enumValues[defaultIndex]) + ")";
|
||||
}
|
||||
}
|
||||
if (item.nameId == StrId::STR_FONT_FAMILY && pendingFontFamilyOverride < 0) {
|
||||
if (item.nameId == StrId::STR_FONT_FAMILY && pendingFontFamilyOverride < 0 && pendingSdFontFamilyOverride.empty()) {
|
||||
const auto label = defaultFontFamilyLabel(item);
|
||||
if (!label.empty()) {
|
||||
return std::string(tr(STR_DEFAULT_VALUE)) + " (" + label + ")";
|
||||
@@ -353,7 +400,7 @@ void EpubReaderMenuActivity::openSubmenu(const SettingInfo& submenuEntry) {
|
||||
return std::string(tr(STR_DEFAULT_VALUE)) + " (" + I18N.get(item.enumValues[valueIndex]) + ")";
|
||||
}
|
||||
}
|
||||
if (item.nameId == StrId::STR_FONT_FAMILY && pendingFontFamilyOverride < 0) {
|
||||
if (item.nameId == StrId::STR_FONT_FAMILY && pendingFontFamilyOverride < 0 && pendingSdFontFamilyOverride.empty()) {
|
||||
const auto label = defaultFontFamilyLabel(item);
|
||||
if (!label.empty()) {
|
||||
return std::string(tr(STR_DEFAULT_VALUE)) + " (" + label + ")";
|
||||
|
||||
@@ -36,7 +36,8 @@ class EpubReaderMenuActivity final : public MenuListActivity {
|
||||
const int currentPage, const int totalPages, const int bookProgressPercent,
|
||||
const uint8_t currentOrientation, const bool hasFootnotes,
|
||||
const int8_t initialEmbeddedStyleOverride, const int8_t initialImageRenderingOverride,
|
||||
const int8_t initialFontFamilyOverride, const int8_t initialFontSizeOverride,
|
||||
const int8_t initialFontFamilyOverride,
|
||||
const std::string& initialSdFontFamilyOverride, const int8_t initialFontSizeOverride,
|
||||
const uint8_t initialTextDarkness, const bool initialBionicReadingOverride,
|
||||
const bool hasStarredPages, const bool isCurrentPageStarred);
|
||||
|
||||
@@ -67,6 +68,7 @@ class EpubReaderMenuActivity final : public MenuListActivity {
|
||||
int8_t pendingEmbeddedStyleOverride = -1;
|
||||
int8_t pendingImageRenderingOverride = -1;
|
||||
int8_t pendingFontFamilyOverride = -1;
|
||||
std::string pendingSdFontFamilyOverride;
|
||||
int8_t pendingFontSizeOverride = -1;
|
||||
uint8_t pendingTextDarkness = 1;
|
||||
bool pendingBionicReading = false;
|
||||
|
||||
Reference in New Issue
Block a user