Fix sleep overlay rendering conditions
This commit is contained in:
@@ -101,11 +101,12 @@ bool renderPngSleepScreen(const std::string& filename, GfxRenderer& renderer, co
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!overlayInfo.title.empty() || !overlayInfo.author.empty() || !overlayInfo.progressText.empty()) {
|
if (!overlayInfo.progressText.empty()) {
|
||||||
const int lineHeight12 = renderer.getLineHeight(BOOKERLY_12_FONT_ID);
|
const int lineHeight12 = renderer.getLineHeight(BOOKERLY_12_FONT_ID);
|
||||||
const int lineHeight10 = renderer.getLineHeight(UI_10_FONT_ID);
|
const int lineHeight10 = renderer.getLineHeight(UI_10_FONT_ID);
|
||||||
constexpr int lineSpacing = 3;
|
constexpr int lineSpacing = 3;
|
||||||
constexpr int sectionSpacing = 10;
|
constexpr int sectionSpacing = 10;
|
||||||
|
const int maxTextWidth = pageWidth - 20;
|
||||||
|
|
||||||
int textBlockHeight = 0;
|
int textBlockHeight = 0;
|
||||||
if (!overlayInfo.title.empty()) {
|
if (!overlayInfo.title.empty()) {
|
||||||
@@ -129,7 +130,8 @@ bool renderPngSleepScreen(const std::string& filename, GfxRenderer& renderer, co
|
|||||||
const int overlayY = pageHeight - textBlockHeight - (lineHeight12 / 3) - (lineHeight10 * 2 / 3);
|
const int overlayY = pageHeight - textBlockHeight - (lineHeight12 / 3) - (lineHeight10 * 2 / 3);
|
||||||
int y = overlayY + (lineHeight12 / 3);
|
int y = overlayY + (lineHeight12 / 3);
|
||||||
if (!overlayInfo.title.empty()) {
|
if (!overlayInfo.title.empty()) {
|
||||||
renderer.drawText(BOOKERLY_12_FONT_ID, 10, y, overlayInfo.title.c_str(), true);
|
const std::string title = renderer.truncatedText(BOOKERLY_12_FONT_ID, overlayInfo.title.c_str(), maxTextWidth);
|
||||||
|
renderer.drawText(BOOKERLY_12_FONT_ID, 10, y, title.c_str(), true);
|
||||||
y += lineHeight12;
|
y += lineHeight12;
|
||||||
if (!overlayInfo.author.empty()) {
|
if (!overlayInfo.author.empty()) {
|
||||||
y += lineSpacing;
|
y += lineSpacing;
|
||||||
@@ -138,14 +140,17 @@ bool renderPngSleepScreen(const std::string& filename, GfxRenderer& renderer, co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!overlayInfo.author.empty()) {
|
if (!overlayInfo.author.empty()) {
|
||||||
renderer.drawText(UI_10_FONT_ID, 10, y, overlayInfo.author.c_str(), true);
|
const std::string author = renderer.truncatedText(UI_10_FONT_ID, overlayInfo.author.c_str(), maxTextWidth);
|
||||||
|
renderer.drawText(UI_10_FONT_ID, 10, y, author.c_str(), true);
|
||||||
y += lineHeight10;
|
y += lineHeight10;
|
||||||
if (!overlayInfo.progressText.empty()) {
|
if (!overlayInfo.progressText.empty()) {
|
||||||
y += sectionSpacing;
|
y += sectionSpacing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!overlayInfo.progressText.empty()) {
|
if (!overlayInfo.progressText.empty()) {
|
||||||
renderer.drawText(UI_10_FONT_ID, 10, y, overlayInfo.progressText.c_str(), true);
|
const std::string progress =
|
||||||
|
renderer.truncatedText(UI_10_FONT_ID, overlayInfo.progressText.c_str(), maxTextWidth);
|
||||||
|
renderer.drawText(UI_10_FONT_ID, 10, y, progress.c_str(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,8 +358,8 @@ void SleepActivity::renderCustomSleepScreen() const {
|
|||||||
explicitSleepFile.close();
|
explicitSleepFile.close();
|
||||||
const BookOverlayInfo resolvedOverlayInfo =
|
const BookOverlayInfo resolvedOverlayInfo =
|
||||||
shouldLoadOverlayInfo ? getBookOverlayInfo(APP_STATE.openEpubPath) : overlayInfo;
|
shouldLoadOverlayInfo ? getBookOverlayInfo(APP_STATE.openEpubPath) : overlayInfo;
|
||||||
if (renderPngSleepScreen("/sleep.png", renderer, resolvedOverlayInfo)) {
|
|
||||||
LOG_DBG("SLP", "Loading explicit custom sleep image: /sleep.png");
|
LOG_DBG("SLP", "Loading explicit custom sleep image: /sleep.png");
|
||||||
|
if (renderPngSleepScreen("/sleep.png", renderer, resolvedOverlayInfo)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -585,7 +590,8 @@ void SleepActivity::renderBitmapSleepScreen(const Bitmap& bitmap, const BookOver
|
|||||||
const bool hasTitle = !overlayInfo.title.empty();
|
const bool hasTitle = !overlayInfo.title.empty();
|
||||||
const bool hasProgress = !overlayInfo.progressText.empty();
|
const bool hasProgress = !overlayInfo.progressText.empty();
|
||||||
const bool hasAuthor = !overlayInfo.author.empty();
|
const bool hasAuthor = !overlayInfo.author.empty();
|
||||||
if (!hasTitle && !hasAuthor && !hasProgress) {
|
// If there is no overlay progress text, do not draw the overlay background block.
|
||||||
|
if (!hasProgress) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user