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() {
const int lineHeight = renderer.getLineHeight(cachedFontId);
auto renderLines = [&]() {
auto renderLines =
[&]() {
int y = cachedOrientedMarginTop;
for (const auto& line : currentPageLines) {
if (line.isHR) {
// Draw horizontal rule as a thin line
int hrY = y + lineHeight / 2;
renderer.drawLine(cachedOrientedMarginLeft + line.indent, hrY, cachedOrientedMarginLeft + viewportWidth, hrY);
renderer.drawLine(cachedOrientedMarginLeft + line.indent, hrY, cachedOrientedMarginLeft + viewportWidth,
hrY);
} else {
if (line.isCodeBlock) {
const int barX = cachedOrientedMarginLeft + std::max(line.indent - 6, 0);
@@ -716,18 +718,19 @@ void MdReaderActivity::renderPage() {
if (SETTINGS.textAntiAliasing) {
ReaderUtils::renderAntiAliased(renderer, [&renderLines]() { renderLines(); });
}
}
}
void MdReaderActivity::renderStatusBar() const {
void
MdReaderActivity::renderStatusBar() const {
const float progress = totalPages > 0 ? (currentPage + 1) * 100.0f / totalPages : 0;
std::string title;
if (SETTINGS.statusBarTitle != CrossPointSettings::STATUS_BAR_TITLE::HIDE_TITLE) {
title = txt->getTitle();
}
GUI.drawStatusBar(renderer, progress, currentPage + 1, totalPages, title);
}
}
void MdReaderActivity::saveProgress() const {
void MdReaderActivity::saveProgress() const {
FsFile f;
if (Storage.openFileForWrite("MDR", txt->getCachePath() + "/progress.bin", f)) {
uint8_t data[4];
@@ -737,9 +740,9 @@ void MdReaderActivity::saveProgress() const {
data[3] = 0;
f.write(data, 4);
}
}
}
void MdReaderActivity::loadProgress() {
void MdReaderActivity::loadProgress() {
FsFile f;
if (Storage.openFileForRead("MDR", txt->getCachePath() + "/progress.bin", f)) {
uint8_t data[4];
@@ -754,9 +757,9 @@ void MdReaderActivity::loadProgress() {
LOG_DBG("MDR", "Loaded progress: page %d/%d", currentPage, totalPages);
}
}
}
}
bool MdReaderActivity::loadPageIndexCache() {
bool MdReaderActivity::loadPageIndexCache() {
std::string cachePath = txt->getCachePath() + "/index.bin";
FsFile f;
if (!Storage.openFileForRead("MDR", cachePath, f)) {
@@ -846,9 +849,9 @@ bool MdReaderActivity::loadPageIndexCache() {
totalPages = pageOffsets.size();
LOG_DBG("MDR", "Loaded page index cache: %d pages", totalPages);
return true;
}
}
void MdReaderActivity::savePageIndexCache() const {
void MdReaderActivity::savePageIndexCache() const {
std::string cachePath = txt->getCachePath() + "/index.bin";
FsFile 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);
}
}