From 0d68162a07225900ee996670bad37e0a9f840000 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Thu, 23 Apr 2026 09:33:50 +0200 Subject: [PATCH] show long branch names (#1727) --- 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 d51b633e..f65a6c1e 100644 --- a/src/components/themes/lyra/LyraTheme.cpp +++ b/src/components/themes/lyra/LyraTheme.cpp @@ -44,7 +44,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; @@ -307,8 +306,27 @@ void LyraTheme::drawHeader(const GfxRenderer& renderer, Rect rect, const char* t renderer.drawText(SMALL_FONT_ID, rect.x + LyraMetrics::values.contentSidePadding, rect.y + 5, clockStr); } - 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);