This commit is contained in:
jpirnay
2026-04-23 21:39:27 +02:00
parent cf376df34c
commit c2d51d6772
+16 -13
View File
@@ -657,13 +657,15 @@ void MdReaderActivity::render(RenderLock&&) {
void MdReaderActivity::renderPage() { void MdReaderActivity::renderPage() {
const int lineHeight = renderer.getLineHeight(cachedFontId); const int lineHeight = renderer.getLineHeight(cachedFontId);
auto renderLines = [&]() { auto renderLines =
[&]() {
int y = cachedOrientedMarginTop; int y = cachedOrientedMarginTop;
for (const auto& line : currentPageLines) { for (const auto& line : currentPageLines) {
if (line.isHR) { if (line.isHR) {
// Draw horizontal rule as a thin line // Draw horizontal rule as a thin line
int hrY = y + lineHeight / 2; int hrY = y + lineHeight / 2;
renderer.drawLine(cachedOrientedMarginLeft + line.indent, hrY, cachedOrientedMarginLeft + viewportWidth, hrY); renderer.drawLine(cachedOrientedMarginLeft + line.indent, hrY, cachedOrientedMarginLeft + viewportWidth,
hrY);
} else { } else {
if (line.isCodeBlock) { if (line.isCodeBlock) {
const int barX = cachedOrientedMarginLeft + std::max(line.indent - 6, 0); const int barX = cachedOrientedMarginLeft + std::max(line.indent - 6, 0);
@@ -716,18 +718,19 @@ void MdReaderActivity::renderPage() {
if (SETTINGS.textAntiAliasing) { if (SETTINGS.textAntiAliasing) {
ReaderUtils::renderAntiAliased(renderer, [&renderLines]() { renderLines(); }); ReaderUtils::renderAntiAliased(renderer, [&renderLines]() { renderLines(); });
} }
} }
void MdReaderActivity::renderStatusBar() const { void
MdReaderActivity::renderStatusBar() const {
const float progress = totalPages > 0 ? (currentPage + 1) * 100.0f / totalPages : 0; const float progress = totalPages > 0 ? (currentPage + 1) * 100.0f / totalPages : 0;
std::string title; std::string title;
if (SETTINGS.statusBarTitle != CrossPointSettings::STATUS_BAR_TITLE::HIDE_TITLE) { if (SETTINGS.statusBarTitle != CrossPointSettings::STATUS_BAR_TITLE::HIDE_TITLE) {
title = txt->getTitle(); title = txt->getTitle();
} }
GUI.drawStatusBar(renderer, progress, currentPage + 1, totalPages, title); GUI.drawStatusBar(renderer, progress, currentPage + 1, totalPages, title);
} }
void MdReaderActivity::saveProgress() const { void MdReaderActivity::saveProgress() const {
FsFile f; FsFile f;
if (Storage.openFileForWrite("MDR", txt->getCachePath() + "/progress.bin", f)) { if (Storage.openFileForWrite("MDR", txt->getCachePath() + "/progress.bin", f)) {
uint8_t data[4]; uint8_t data[4];
@@ -737,9 +740,9 @@ void MdReaderActivity::saveProgress() const {
data[3] = 0; data[3] = 0;
f.write(data, 4); f.write(data, 4);
} }
} }
void MdReaderActivity::loadProgress() { void MdReaderActivity::loadProgress() {
FsFile f; FsFile f;
if (Storage.openFileForRead("MDR", txt->getCachePath() + "/progress.bin", f)) { if (Storage.openFileForRead("MDR", txt->getCachePath() + "/progress.bin", f)) {
uint8_t data[4]; uint8_t data[4];
@@ -754,9 +757,9 @@ void MdReaderActivity::loadProgress() {
LOG_DBG("MDR", "Loaded progress: page %d/%d", currentPage, totalPages); LOG_DBG("MDR", "Loaded progress: page %d/%d", currentPage, totalPages);
} }
} }
} }
bool MdReaderActivity::loadPageIndexCache() { bool MdReaderActivity::loadPageIndexCache() {
std::string cachePath = txt->getCachePath() + "/index.bin"; std::string cachePath = txt->getCachePath() + "/index.bin";
FsFile f; FsFile f;
if (!Storage.openFileForRead("MDR", cachePath, f)) { if (!Storage.openFileForRead("MDR", cachePath, f)) {
@@ -846,9 +849,9 @@ bool MdReaderActivity::loadPageIndexCache() {
totalPages = pageOffsets.size(); totalPages = pageOffsets.size();
LOG_DBG("MDR", "Loaded page index cache: %d pages", totalPages); LOG_DBG("MDR", "Loaded page index cache: %d pages", totalPages);
return true; return true;
} }
void MdReaderActivity::savePageIndexCache() const { void MdReaderActivity::savePageIndexCache() const {
std::string cachePath = txt->getCachePath() + "/index.bin"; std::string cachePath = txt->getCachePath() + "/index.bin";
FsFile f; FsFile f;
if (!Storage.openFileForWrite("MDR", cachePath, f)) { if (!Storage.openFileForWrite("MDR", cachePath, f)) {
@@ -872,4 +875,4 @@ void MdReaderActivity::savePageIndexCache() const {
} }
LOG_DBG("MDR", "Saved page index cache: %d pages", totalPages); LOG_DBG("MDR", "Saved page index cache: %d pages", totalPages);
} }