mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-07 08:07:40 +03:00
Merge 623bb70158 into 21277e03eb
This commit is contained in:
commit
9a3ec146d7
@ -325,6 +325,10 @@ void HomeActivity::render() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasContinueReading) {
|
if (hasContinueReading) {
|
||||||
|
// Invert text colors based on selection state:
|
||||||
|
// - 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 on white card
|
||||||
|
|
||||||
// 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;
|
||||||
words.reserve(8);
|
words.reserve(8);
|
||||||
@ -407,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
|
||||||
@ -438,14 +442,14 @@ void HomeActivity::render() {
|
|||||||
const int boxX = (pageWidth - boxWidth) / 2;
|
const int boxX = (pageWidth - boxWidth) / 2;
|
||||||
const int boxY = titleYStart - boxPadding;
|
const int boxY = titleYStart - boxPadding;
|
||||||
|
|
||||||
// Draw white filled box
|
// Draw box (inverted when selected: black box instead of white)
|
||||||
renderer.fillRect(boxX, boxY, boxWidth, boxHeight, false);
|
renderer.fillRect(boxX, boxY, boxWidth, boxHeight, bookSelected);
|
||||||
// Draw black border around the box
|
// Draw border around the box (inverted when selected: white border instead of black)
|
||||||
renderer.drawRect(boxX, boxY, boxWidth, boxHeight, true);
|
renderer.drawRect(boxX, boxY, boxWidth, boxHeight, !bookSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& line : lines) {
|
for (const auto& line : lines) {
|
||||||
renderer.drawCenteredText(UI_12_FONT_ID, titleYStart, line.c_str(), !bookSelected || coverRendered);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,13 +470,13 @@ void HomeActivity::render() {
|
|||||||
}
|
}
|
||||||
trimmedAuthor.append("...");
|
trimmedAuthor.append("...");
|
||||||
}
|
}
|
||||||
renderer.drawCenteredText(UI_10_FONT_ID, titleYStart, trimmedAuthor.c_str(), !bookSelected || coverRendered);
|
renderer.drawCenteredText(UI_10_FONT_ID, titleYStart, trimmedAuthor.c_str(), !bookSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Continue Reading" label at the bottom
|
// "Continue Reading" label at the bottom
|
||||||
const int continueY = bookY + bookHeight - renderer.getLineHeight(UI_10_FONT_ID) * 3 / 2;
|
const int continueY = bookY + bookHeight - renderer.getLineHeight(UI_10_FONT_ID) * 3 / 2;
|
||||||
if (coverRendered) {
|
if (coverRendered) {
|
||||||
// Draw white box behind "Continue Reading" text
|
// Draw box behind "Continue Reading" text (inverted when selected: black box instead of white)
|
||||||
const char* continueText = "Continue Reading";
|
const char* continueText = "Continue Reading";
|
||||||
const int continueTextWidth = renderer.getTextWidth(UI_10_FONT_ID, continueText);
|
const int continueTextWidth = renderer.getTextWidth(UI_10_FONT_ID, continueText);
|
||||||
constexpr int continuePadding = 6;
|
constexpr int continuePadding = 6;
|
||||||
@ -480,9 +484,9 @@ void HomeActivity::render() {
|
|||||||
const int continueBoxHeight = renderer.getLineHeight(UI_10_FONT_ID) + continuePadding;
|
const int continueBoxHeight = renderer.getLineHeight(UI_10_FONT_ID) + continuePadding;
|
||||||
const int continueBoxX = (pageWidth - continueBoxWidth) / 2;
|
const int continueBoxX = (pageWidth - continueBoxWidth) / 2;
|
||||||
const int continueBoxY = continueY - continuePadding / 2;
|
const int continueBoxY = continueY - continuePadding / 2;
|
||||||
renderer.fillRect(continueBoxX, continueBoxY, continueBoxWidth, continueBoxHeight, false);
|
renderer.fillRect(continueBoxX, continueBoxY, continueBoxWidth, continueBoxHeight, bookSelected);
|
||||||
renderer.drawRect(continueBoxX, continueBoxY, continueBoxWidth, continueBoxHeight, true);
|
renderer.drawRect(continueBoxX, continueBoxY, continueBoxWidth, continueBoxHeight, !bookSelected);
|
||||||
renderer.drawCenteredText(UI_10_FONT_ID, continueY, continueText, true);
|
renderer.drawCenteredText(UI_10_FONT_ID, continueY, continueText, !bookSelected);
|
||||||
} else {
|
} else {
|
||||||
renderer.drawCenteredText(UI_10_FONT_ID, continueY, "Continue Reading", !bookSelected);
|
renderer.drawCenteredText(UI_10_FONT_ID, continueY, "Continue Reading", !bookSelected);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user