mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-06 23:57:39 +03:00
Correctly invert text color for books missing cover image
This commit is contained in:
parent
1b9ba15486
commit
623bb70158
@ -327,8 +327,7 @@ void HomeActivity::render() {
|
|||||||
if (hasContinueReading) {
|
if (hasContinueReading) {
|
||||||
// Invert text colors based on selection state:
|
// Invert text colors based on selection state:
|
||||||
// - With cover: selected = white text on black box, unselected = black text on white box
|
// - With cover: selected = white text on black box, unselected = black text on white box
|
||||||
// - Without cover: selected = white text on black card, unselected = black text
|
// - Without cover: selected = white text on black card, unselected = black text on white card
|
||||||
const bool invertText = coverRendered ? bookSelected : !bookSelected;
|
|
||||||
|
|
||||||
// Split into words (avoid stringstream to keep this light on the MCU)
|
// Split into words (avoid stringstream to keep this light on the MCU)
|
||||||
std::vector<std::string> words;
|
std::vector<std::string> words;
|
||||||
@ -412,7 +411,7 @@ void HomeActivity::render() {
|
|||||||
// Vertically center the title block within the card
|
// Vertically center the title block within the card
|
||||||
int titleYStart = bookY + (bookHeight - totalTextHeight) / 2;
|
int titleYStart = bookY + (bookHeight - totalTextHeight) / 2;
|
||||||
|
|
||||||
// If cover image was rendered, draw white box behind title and author
|
// If cover image was rendered, draw box behind title and author
|
||||||
if (coverRendered) {
|
if (coverRendered) {
|
||||||
constexpr int boxPadding = 8;
|
constexpr int boxPadding = 8;
|
||||||
// Calculate the max text width for the box
|
// Calculate the max text width for the box
|
||||||
@ -450,7 +449,7 @@ void HomeActivity::render() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& line : lines) {
|
for (const auto& line : lines) {
|
||||||
renderer.drawCenteredText(UI_12_FONT_ID, titleYStart, line.c_str(), !invertText);
|
renderer.drawCenteredText(UI_12_FONT_ID, titleYStart, line.c_str(), !bookSelected);
|
||||||
titleYStart += renderer.getLineHeight(UI_12_FONT_ID);
|
titleYStart += renderer.getLineHeight(UI_12_FONT_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,7 +470,7 @@ void HomeActivity::render() {
|
|||||||
}
|
}
|
||||||
trimmedAuthor.append("...");
|
trimmedAuthor.append("...");
|
||||||
}
|
}
|
||||||
renderer.drawCenteredText(UI_10_FONT_ID, titleYStart, trimmedAuthor.c_str(), !invertText);
|
renderer.drawCenteredText(UI_10_FONT_ID, titleYStart, trimmedAuthor.c_str(), !bookSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Continue Reading" label at the bottom
|
// "Continue Reading" label at the bottom
|
||||||
@ -487,9 +486,9 @@ void HomeActivity::render() {
|
|||||||
const int continueBoxY = continueY - continuePadding / 2;
|
const int continueBoxY = continueY - continuePadding / 2;
|
||||||
renderer.fillRect(continueBoxX, continueBoxY, continueBoxWidth, continueBoxHeight, bookSelected);
|
renderer.fillRect(continueBoxX, continueBoxY, continueBoxWidth, continueBoxHeight, bookSelected);
|
||||||
renderer.drawRect(continueBoxX, continueBoxY, continueBoxWidth, continueBoxHeight, !bookSelected);
|
renderer.drawRect(continueBoxX, continueBoxY, continueBoxWidth, continueBoxHeight, !bookSelected);
|
||||||
renderer.drawCenteredText(UI_10_FONT_ID, continueY, continueText, !invertText);
|
renderer.drawCenteredText(UI_10_FONT_ID, continueY, continueText, !bookSelected);
|
||||||
} else {
|
} else {
|
||||||
renderer.drawCenteredText(UI_10_FONT_ID, continueY, "Continue Reading", !invertText);
|
renderer.drawCenteredText(UI_10_FONT_ID, continueY, "Continue Reading", !bookSelected);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No book to continue reading
|
// No book to continue reading
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user