From 7e6e4eb9deb80783e8757fd999819e308e098ab5 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Mon, 29 Nov 2021 12:33:00 +0200 Subject: Fixed issues with tab button labels Fixed issue with very short text not being truncated at all. A short truncated label will now just show the icon, if one is set. The tab close buttons don't appear if the buttons are too small. --- src/ui/documentwidget.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/ui/documentwidget.c') diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index aac77572..746e03e0 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -1007,17 +1007,26 @@ static void updateWindowTitle_DocumentWidget_(const iDocumentWidget *d) { prependCStr_String(text, escape_Color(uiIcon_ColorId)); } const int width = measureRange_Text(font, range_String(text)).advance.x; - if (width <= avail || - isEmpty_StringArray(title)) { + const int ellipsisWidth = measure_Text(font, "...").advance.x; + setTextColor_LabelWidget(tabButton, none_ColorId); + iWidget *tabCloseButton = child_Widget(as_Widget(tabButton), 0); + setFlags_Widget(tabCloseButton, visibleOnParentHover_WidgetFlag, + avail > width_Widget(tabCloseButton)); + if (width <= avail || isEmpty_StringArray(title)) { updateText_LabelWidget(tabButton, text); break; } if (size_StringArray(title) == 1) { /* Just truncate to fit. */ + if (siteIcon && avail <= 4 * ellipsisWidth) { + updateText_LabelWidget(tabButton, collect_String(newUnicodeN_String(&siteIcon, 1))); + setTextColor_LabelWidget(tabButton, uiIcon_ColorId); + break; + } const char *endPos; tryAdvanceNoWrap_Text(font, range_String(text), - avail - measure_Text(font, "...").advance.x, + avail - ellipsisWidth, &endPos); updateText_LabelWidget( tabButton, -- cgit v1.2.3