Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/interface/interface_widgets.c')
-rw-r--r--source/blender/editors/interface/interface_widgets.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 868f62c89c9..0c3448b987d 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1533,25 +1533,22 @@ static void ui_text_clip_right_ex(const uiFontStyle *fstyle,
{
BLI_assert(str[0]);
- /* If the trailing ellipsis takes more than 20% of all available width, just cut the string
- * (as using the ellipsis would remove even more useful chars, and we cannot show much
- * already!).
- */
- if (sep_strwidth / okwidth > 0.2f) {
- float tmp;
- const int l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, okwidth, &tmp);
- str[l_end] = '\0';
+ /* How many BYTES (not characters) of this utf-8 string can fit, along with appended ellipsis. */
+ int l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, okwidth - sep_strwidth, NULL);
+
+ if (l_end > 0) {
+ /* At least one character, so clip and add the ellipsis. */
+ memcpy(str + l_end, sep, sep_len + 1); /* +1 for trailing '\0'. */
if (r_final_len) {
- *r_final_len = (size_t)l_end;
+ *r_final_len = (size_t)(l_end) + sep_len;
}
}
else {
- float tmp;
- const int l_end = BLF_width_to_strlen(
- fstyle->uifont_id, str, max_len, okwidth - sep_strwidth, &tmp);
- memcpy(str + l_end, sep, sep_len + 1); /* +1 for trailing '\0'. */
+ /* Otherwise fit as much as we can without adding an ellipsis. */
+ l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, okwidth, NULL);
+ str[l_end] = '\0';
if (r_final_len) {
- *r_final_len = (size_t)(l_end) + sep_len;
+ *r_final_len = (size_t)l_end;
}
}
}
@@ -5224,8 +5221,7 @@ void ui_draw_tooltip_background(const uiStyle *UNUSED(style), uiBlock *UNUSED(bl
*
* \param state: The state of the button,
* typically #UI_ACTIVE, #UI_BUT_DISABLED, #UI_BUT_INACTIVE.
- * \param use_sep: When true, characters after the last #UI_SEP_CHAR are right aligned,
- * use for displaying key shortcuts.
+ * \param separator_type: The kind of separator which controls if and how the string is clipped.
* \param r_xmax: The right hand position of the text, this takes into the icon,
* padding and text clipping when there is not enough room to display the full text.
*/
@@ -5273,7 +5269,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
rect->xmax -= BLF_width(fstyle->uifont_id, cpoin + 1, INT_MAX) + UI_DPI_ICON_SIZE;
}
else if (separator_type == UI_MENU_ITEM_SEPARATOR_HINT) {
- /* Deterimine max-width for the hint string to leave the name string un-clipped (if there's
+ /* Determine max-width for the hint string to leave the name string un-clipped (if there's
* enough space to display it). */
const int available_width = BLI_rcti_size_x(rect) - padding;