[Bf-blender-cvs] [0074eac] master: More tweaks to clip middle: * Do not apply margins with MENU (i.e. dropdowns) either. * When middle clipping would remove only a few chars, rather clip right part!

Bastien Montagne noreply at git.blender.org
Sat Jan 4 16:53:35 CET 2014


Commit: 0074eac1ed6a876a951f04b6a017fd7058041558
Author: Bastien Montagne
Date:   Sat Jan 4 16:50:42 2014 +0100
https://developer.blender.org/rB0074eac1ed6a876a951f04b6a017fd7058041558

More tweaks to clip middle:
* Do not apply margins with MENU (i.e. dropdowns) either.
* When middle clipping would remove only a few chars, rather clip right part!

===================================================================

M	source/blender/editors/interface/interface_widgets.c

===================================================================

diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 5e91b5c..c6aabbc 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -973,7 +973,7 @@ static void ui_text_clip_left(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
 static void ui_text_clip_middle(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
 {
 	/* No margin for labels! */
-	const int border = (but->type == LABEL) ? 0 : (int)(UI_TEXT_CLIP_MARGIN + 0.5f);
+	const int border = ELEM(but->type, LABEL, MENU) ? 0 : (int)(UI_TEXT_CLIP_MARGIN + 0.5f);
 	const int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0);
 	float strwidth;
 
@@ -996,8 +996,10 @@ static void ui_text_clip_middle(uiFontStyle *fstyle, uiBut *but, const rcti *rec
 		const float sep_strwidth = BLF_width(fstyle->uifont_id, sep, sep_len + 1);
 		const float parts_strwidth = ((float)okwidth - sep_strwidth) / 2.0f;
 
-		if (parts_strwidth < (float)(UI_DPI_ICON_SIZE) / but->block->aspect * 1.5) {
-			/* If we really have no place, only show start of string. */
+		if (min_ff(parts_strwidth, strwidth - okwidth) < (float)(UI_DPI_ICON_SIZE) / but->block->aspect * 1.5) {
+			/* If we really have no place, or we would clip a very small piece of string in the middle,
+			 * only show start of string.
+			 */
 			l_end = BLF_width_to_strlen(fstyle->uifont_id, but->drawstr, max_len, okwidth, &strwidth);
 			but->drawstr[l_end] = '\0';
 		}




More information about the Bf-blender-cvs mailing list