Review changes

This commit is contained in:
jpirnay
2026-03-24 09:46:55 +01:00
parent dea0503040
commit 4dff52b83e
+11 -3
View File
@@ -318,7 +318,11 @@ void SleepActivity::renderBitmapSleepScreen(const Bitmap& bitmap) const {
// Draw overlay text if provided // Draw overlay text if provided
const std::string overlayText = SETTINGS.sleepCoverOverlay ? getBookOverlayText(APP_STATE.openEpubPath) : ""; const std::string overlayText = SETTINGS.sleepCoverOverlay ? getBookOverlayText(APP_STATE.openEpubPath) : "";
if (!overlayText.empty()) { const auto drawOverlay = [&]() {
if (overlayText.empty()) {
return;
}
// Split text into lines // Split text into lines
size_t newlinePos = overlayText.find('\n'); size_t newlinePos = overlayText.find('\n');
std::string line1 = (newlinePos != std::string::npos) ? overlayText.substr(0, newlinePos) : overlayText; std::string line1 = (newlinePos != std::string::npos) ? overlayText.substr(0, newlinePos) : overlayText;
@@ -330,7 +334,7 @@ void SleepActivity::renderBitmapSleepScreen(const Bitmap& bitmap) const {
line1 = renderer.truncatedText(UI_10_FONT_ID, line1.c_str(), pageWidth - 20); line1 = renderer.truncatedText(UI_10_FONT_ID, line1.c_str(), pageWidth - 20);
line2 = renderer.truncatedText(UI_10_FONT_ID, line2.c_str(), pageWidth - 20); line2 = renderer.truncatedText(UI_10_FONT_ID, line2.c_str(), pageWidth - 20);
// Draw semi-transparent background rectangle at the bottom (taller for two lines) // Draw white background rectangle at the bottom (taller for two lines)
const int overlayHeight = 50; const int overlayHeight = 50;
const int overlayY = pageHeight - overlayHeight - 20; // Position 20 pixels higher from bottom const int overlayY = pageHeight - overlayHeight - 20; // Position 20 pixels higher from bottom
renderer.fillRect(0, overlayY, pageWidth, overlayHeight, false); // White background renderer.fillRect(0, overlayY, pageWidth, overlayHeight, false); // White background
@@ -346,7 +350,9 @@ void SleepActivity::renderBitmapSleepScreen(const Bitmap& bitmap) const {
const int textX2 = (pageWidth - renderer.getTextWidth(UI_10_FONT_ID, line2.c_str())) / 2; const int textX2 = (pageWidth - renderer.getTextWidth(UI_10_FONT_ID, line2.c_str())) / 2;
renderer.drawText(UI_10_FONT_ID, textX2, line2Y, line2.c_str(), true); // Black text renderer.drawText(UI_10_FONT_ID, textX2, line2Y, line2.c_str(), true); // Black text
} }
} };
drawOverlay();
renderer.displayBuffer(HalDisplay::HALF_REFRESH); renderer.displayBuffer(HalDisplay::HALF_REFRESH);
@@ -355,12 +361,14 @@ void SleepActivity::renderBitmapSleepScreen(const Bitmap& bitmap) const {
renderer.clearScreen(0x00); renderer.clearScreen(0x00);
renderer.setRenderMode(GfxRenderer::GRAYSCALE_LSB); renderer.setRenderMode(GfxRenderer::GRAYSCALE_LSB);
renderer.drawBitmap(bitmap, x, y, pageWidth, pageHeight, cropX, cropY); renderer.drawBitmap(bitmap, x, y, pageWidth, pageHeight, cropX, cropY);
drawOverlay();
renderer.copyGrayscaleLsbBuffers(); renderer.copyGrayscaleLsbBuffers();
bitmap.rewindToData(); bitmap.rewindToData();
renderer.clearScreen(0x00); renderer.clearScreen(0x00);
renderer.setRenderMode(GfxRenderer::GRAYSCALE_MSB); renderer.setRenderMode(GfxRenderer::GRAYSCALE_MSB);
renderer.drawBitmap(bitmap, x, y, pageWidth, pageHeight, cropX, cropY); renderer.drawBitmap(bitmap, x, y, pageWidth, pageHeight, cropX, cropY);
drawOverlay();
renderer.copyGrayscaleMsbBuffers(); renderer.copyGrayscaleMsbBuffers();
renderer.displayGrayBuffer(); renderer.displayGrayBuffer();