diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-11-29 12:33:00 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-11-29 12:33:00 +0200 |
commit | 7e6e4eb9deb80783e8757fd999819e308e098ab5 (patch) | |
tree | c53a55597c5d130af5912ea01bfab0dc80856171 /src/ui/documentwidget.c | |
parent | 31a5b9499688341353b3946dca208adc67560d2e (diff) |
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.
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r-- | src/ui/documentwidget.c | 15 |
1 files changed, 12 insertions, 3 deletions
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) { | |||
1007 | prependCStr_String(text, escape_Color(uiIcon_ColorId)); | 1007 | prependCStr_String(text, escape_Color(uiIcon_ColorId)); |
1008 | } | 1008 | } |
1009 | const int width = measureRange_Text(font, range_String(text)).advance.x; | 1009 | const int width = measureRange_Text(font, range_String(text)).advance.x; |
1010 | if (width <= avail || | 1010 | const int ellipsisWidth = measure_Text(font, "...").advance.x; |
1011 | isEmpty_StringArray(title)) { | 1011 | setTextColor_LabelWidget(tabButton, none_ColorId); |
1012 | iWidget *tabCloseButton = child_Widget(as_Widget(tabButton), 0); | ||
1013 | setFlags_Widget(tabCloseButton, visibleOnParentHover_WidgetFlag, | ||
1014 | avail > width_Widget(tabCloseButton)); | ||
1015 | if (width <= avail || isEmpty_StringArray(title)) { | ||
1012 | updateText_LabelWidget(tabButton, text); | 1016 | updateText_LabelWidget(tabButton, text); |
1013 | break; | 1017 | break; |
1014 | } | 1018 | } |
1015 | if (size_StringArray(title) == 1) { | 1019 | if (size_StringArray(title) == 1) { |
1016 | /* Just truncate to fit. */ | 1020 | /* Just truncate to fit. */ |
1021 | if (siteIcon && avail <= 4 * ellipsisWidth) { | ||
1022 | updateText_LabelWidget(tabButton, collect_String(newUnicodeN_String(&siteIcon, 1))); | ||
1023 | setTextColor_LabelWidget(tabButton, uiIcon_ColorId); | ||
1024 | break; | ||
1025 | } | ||
1017 | const char *endPos; | 1026 | const char *endPos; |
1018 | tryAdvanceNoWrap_Text(font, | 1027 | tryAdvanceNoWrap_Text(font, |
1019 | range_String(text), | 1028 | range_String(text), |
1020 | avail - measure_Text(font, "...").advance.x, | 1029 | avail - ellipsisWidth, |
1021 | &endPos); | 1030 | &endPos); |
1022 | updateText_LabelWidget( | 1031 | updateText_LabelWidget( |
1023 | tabButton, | 1032 | tabButton, |