From 56d3ab929c3fd5ab54dc8acada3da954b1f0b8dd Mon Sep 17 00:00:00 2001 From: Stefan Blixten Karlsson Date: Tue, 21 Apr 2026 17:33:33 +0200 Subject: [PATCH] feat: show long branch names (#1727) ## Summary * This change will make better use of the space available for Title and Subtitle in the Settings (Theme: Lyra). Instead of having a fixed maxwidth in pixels for subtitle, it will use the whole line and shorten the longest one if needed. So instead of: image It will now show: image --- ### 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? _**NO**_ --- src/components/themes/lyra/LyraTheme.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/components/themes/lyra/LyraTheme.cpp b/src/components/themes/lyra/LyraTheme.cpp index 73a898b9a..994b047e9 100644 --- a/src/components/themes/lyra/LyraTheme.cpp +++ b/src/components/themes/lyra/LyraTheme.cpp @@ -35,7 +35,6 @@ constexpr int cornerRadius = 6; constexpr int topHintButtonY = 345; constexpr int popupMarginX = 16; constexpr int popupMarginY = 12; -constexpr int maxSubtitleWidth = 100; constexpr int maxListValueWidth = 200; constexpr int mainMenuIconSize = 32; constexpr int listIconSize = 24; @@ -150,8 +149,27 @@ void LyraTheme::drawHeader(const GfxRenderer& renderer, Rect rect, const char* t Rect{batteryX, rect.y + 5, LyraMetrics::values.batteryWidth, LyraMetrics::values.batteryHeight}, showBatteryPercentage); - int maxTitleWidth = - rect.width - LyraMetrics::values.contentSidePadding * 2 - (subtitle != nullptr ? maxSubtitleWidth : 0); + int maxTitleWidth = title != nullptr ? renderer.getTextWidth(UI_12_FONT_ID, title, EpdFontFamily::BOLD) : 0; + int maxSubtitleWidth = + subtitle != nullptr ? renderer.getTextWidth(SMALL_FONT_ID, subtitle, EpdFontFamily::REGULAR) : 0; + + // Available space is the distance between the side paddings, and a with side padding between title and subtitle. + const int availableSpace = rect.width - LyraMetrics::values.contentSidePadding * 3; + + if (maxTitleWidth + maxSubtitleWidth > availableSpace) { + if ((maxTitleWidth > availableSpace / 2) && (maxSubtitleWidth > availableSpace / 2)) { + // Both are wider then half the space, truncate both. + maxTitleWidth = availableSpace / 2; + maxSubtitleWidth = availableSpace / 2; + } else { + // Truncate the the longest one + if (maxTitleWidth > maxSubtitleWidth) { + maxTitleWidth = availableSpace - maxSubtitleWidth; + } else { + maxSubtitleWidth = availableSpace - maxTitleWidth; + } + } + } if (title) { auto truncatedTitle = renderer.truncatedText(UI_12_FONT_ID, title, maxTitleWidth, EpdFontFamily::BOLD);