Use and populate metadata

This commit is contained in:
jpirnay
2026-03-07 18:02:21 +01:00
parent 87e5cc4fe1
commit 3ed96a7e49
8 changed files with 43 additions and 13 deletions
+19 -1
View File
@@ -482,6 +482,7 @@ void BaseTheme::drawRecentBookCover(GfxRenderer& renderer, Rect rect, const std:
if (hasContinueReading) {
const std::string& lastBookTitle = recentBooks[0].title;
const std::string& lastBookAuthor = recentBooks[0].author;
const std::string& lastBookSeries = recentBooks[0].series;
// Invert text colors based on selection state:
// - With cover: selected = white text on black box, unselected = black text on white box
@@ -494,6 +495,9 @@ void BaseTheme::drawRecentBookCover(GfxRenderer& renderer, Rect rect, const std:
if (!lastBookAuthor.empty()) {
totalTextHeight += renderer.getLineHeight(UI_10_FONT_ID) * 3 / 2;
}
if (!lastBookSeries.empty()) {
totalTextHeight += renderer.getLineHeight(UI_12_FONT_ID);
}
// Vertically center the title block within the card
int titleYStart = bookY + (bookHeight - totalTextHeight) / 2;
@@ -501,8 +505,11 @@ void BaseTheme::drawRecentBookCover(GfxRenderer& renderer, Rect rect, const std:
const auto truncatedAuthor = lastBookAuthor.empty()
? std::string{}
: renderer.truncatedText(UI_10_FONT_ID, lastBookAuthor.c_str(), bookWidth - 40);
const auto truncatedSeries = lastBookSeries.empty()
? std::string{}
: renderer.truncatedText(UI_12_FONT_ID, lastBookSeries.c_str(), bookWidth - 40);
// If cover image was rendered, draw box behind title and author
// If cover image was rendered, draw box behind title, author, and series
if (coverRendered) {
constexpr int boxPadding = 8;
// Calculate the max text width for the box
@@ -519,6 +526,12 @@ void BaseTheme::drawRecentBookCover(GfxRenderer& renderer, Rect rect, const std:
maxTextWidth = authorWidth;
}
}
if (!truncatedSeries.empty()) {
const int seriesWidth = renderer.getTextWidth(UI_12_FONT_ID, truncatedSeries.c_str());
if (seriesWidth > maxTextWidth) {
maxTextWidth = seriesWidth;
}
}
const int boxWidth = maxTextWidth + boxPadding * 2;
const int boxHeight = totalTextHeight + boxPadding * 2;
@@ -539,6 +552,11 @@ void BaseTheme::drawRecentBookCover(GfxRenderer& renderer, Rect rect, const std:
if (!truncatedAuthor.empty()) {
titleYStart += renderer.getLineHeight(UI_10_FONT_ID) / 2;
renderer.drawCenteredText(UI_10_FONT_ID, titleYStart, truncatedAuthor.c_str(), !bookSelected);
titleYStart += renderer.getLineHeight(UI_10_FONT_ID);
}
if (!truncatedSeries.empty()) {
renderer.drawCenteredText(UI_12_FONT_ID, titleYStart, truncatedSeries.c_str(), !bookSelected);
}
// "Continue Reading" label at the bottom