From 7a792a5384d193a5757060fc1e856b3de71d1240 Mon Sep 17 00:00:00 2001 From: Luke Stein <44452336+lukestein@users.noreply.github.com> Date: Mon, 19 Jan 2026 06:57:39 -0500 Subject: [PATCH] fix: Invert colors on home screen cover overlay when recent book is selected (#390) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary * Fixes #388 ## Additional Context * Tested on my own device * See images at #388 for what home screen looked like before. * With this PR the home screen shows the following (selected and unselected recent book × cover image rendered or not) ![Picsew_20260115153419](https://github.com/user-attachments/assets/44193f9d-76b7-4c77-b890-72b0dbae01c4) --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? **YES** --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- src/activities/home/HomeActivity.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/activities/home/HomeActivity.cpp b/src/activities/home/HomeActivity.cpp index 3a97e13..6f27e39 100644 --- a/src/activities/home/HomeActivity.cpp +++ b/src/activities/home/HomeActivity.cpp @@ -325,6 +325,10 @@ void HomeActivity::render() { } 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) std::vector words; words.reserve(8); @@ -407,7 +411,7 @@ void HomeActivity::render() { // Vertically center the title block within the card 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) { constexpr int boxPadding = 8; // Calculate the max text width for the box @@ -438,14 +442,14 @@ void HomeActivity::render() { const int boxX = (pageWidth - boxWidth) / 2; const int boxY = titleYStart - boxPadding; - // Draw white filled box - renderer.fillRect(boxX, boxY, boxWidth, boxHeight, false); - // Draw black border around the box - renderer.drawRect(boxX, boxY, boxWidth, boxHeight, true); + // Draw box (inverted when selected: black box instead of white) + renderer.fillRect(boxX, boxY, boxWidth, boxHeight, bookSelected); + // Draw border around the box (inverted when selected: white border instead of black) + renderer.drawRect(boxX, boxY, boxWidth, boxHeight, !bookSelected); } 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); } @@ -466,13 +470,13 @@ void HomeActivity::render() { } 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 const int continueY = bookY + bookHeight - renderer.getLineHeight(UI_10_FONT_ID) * 3 / 2; 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 int continueTextWidth = renderer.getTextWidth(UI_10_FONT_ID, continueText); constexpr int continuePadding = 6; @@ -480,9 +484,9 @@ void HomeActivity::render() { const int continueBoxHeight = renderer.getLineHeight(UI_10_FONT_ID) + continuePadding; const int continueBoxX = (pageWidth - continueBoxWidth) / 2; const int continueBoxY = continueY - continuePadding / 2; - renderer.fillRect(continueBoxX, continueBoxY, continueBoxWidth, continueBoxHeight, false); - renderer.drawRect(continueBoxX, continueBoxY, continueBoxWidth, continueBoxHeight, true); - renderer.drawCenteredText(UI_10_FONT_ID, continueY, continueText, true); + renderer.fillRect(continueBoxX, continueBoxY, continueBoxWidth, continueBoxHeight, bookSelected); + renderer.drawRect(continueBoxX, continueBoxY, continueBoxWidth, continueBoxHeight, !bookSelected); + renderer.drawCenteredText(UI_10_FONT_ID, continueY, continueText, !bookSelected); } else { renderer.drawCenteredText(UI_10_FONT_ID, continueY, "Continue Reading", !bookSelected); }