[Bf-blender-cvs] [d41b2bb] master: Fix issue with right aligned number buttons overlapping the label

Campbell Barton noreply at git.blender.org
Tue Dec 17 21:21:41 CET 2013


Commit: d41b2bb25f5caf88e8f41a1f37297cd555ae158c
Author: Campbell Barton
Date:   Wed Dec 18 07:15:25 2013 +1100
http://developer.blender.org/rBd41b2bb25f5caf88e8f41a1f37297cd555ae158c

Fix issue with right aligned number buttons overlapping the label

This also simplifies button clipping which was attempting to detect
offsets that were applied afterwards,
Now apply text clipping after adjusting the button rect margins.

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

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 9382a3b..af55203 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1046,8 +1046,8 @@ static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rec
  */
 static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
 {
-	int border = (but->drawflag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
-	int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0);
+	const int border = 4;
+	const int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0);
 	char *cpoin = NULL;
 	int drawstr_len = strlen(but->drawstr);
 	char *cpend = but->drawstr + drawstr_len;
@@ -1256,7 +1256,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
 	/* part text right aligned */
 	if (drawstr_right) {
 		fstyle->align = UI_STYLE_TEXT_RIGHT;
-		rect->xmax -= ui_but_draw_menu_icon(but) ? UI_DPI_ICON_SIZE : 0.25f * U.widget_unit;
+		rect->xmax -= 0.25f * U.widget_unit / but->block->aspect;
 		uiStyleFontDraw(fstyle, rect, drawstr_right);
 	}
 }
@@ -1272,29 +1272,11 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
 
 	ui_button_text_password_hide(password_str, but, FALSE);
 
-	/* clip but->drawstr to fit in available space */
-	if (but->editstr && but->pos >= 0) {
-		ui_text_clip_cursor(fstyle, but, rect);
-	}
-	else if (ELEM(but->type, NUM, NUMSLI)) {
-		ui_text_clip_right_label(fstyle, but, rect);
-	}
-	else if (ELEM3(but->type, TEX, SEARCH_MENU, SEARCH_MENU_UNLINK)) {
-		ui_text_clip_left(fstyle, but, rect);
-	}
-	else if ((but->block->flag & UI_BLOCK_LOOP) && (but->type == BUT)) {
-		ui_text_clip_left(fstyle, but, rect);
-	}
-	else {
-		but->ofs = 0;
-	}
-
 	/* check for button text label */
 	if (but->type == MENU && (but->flag & UI_BUT_NODE_LINK)) {
-		int tmp = rect->xmin;
-		rect->xmin = rect->xmax - BLI_rcti_size_y(rect) - 1;
-		widget_draw_icon(but, ICON_LAYER_USED, alpha, rect);
-		rect->xmin = tmp;
+		rcti temp = *rect;
+		temp.xmin = rect->xmax - BLI_rcti_size_y(rect) - 1;
+		widget_draw_icon(but, ICON_LAYER_USED, alpha, &temp);
 	}
 
 	/* If there's an icon too (made with uiDefIconTextBut) then draw the icon
@@ -1302,23 +1284,11 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
 
 	if (but->flag & UI_HAS_ICON) {
 		widget_draw_icon(but, but->icon + but->iconadd, alpha, rect);
-		
-		/* icons default draw 0.8f x height */
-		rect->xmin += (int)(0.8f * BLI_rcti_size_y(rect));
-
-		if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) {
-			if (but->editstr || but->ofs == 0) {
-				rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
-			}
-		}
-		else if ((but->drawflag & UI_BUT_TEXT_RIGHT)) {
-			rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
-		}
+		rect->xmin += 0.8f * BLI_rcti_size_y(rect);
 	}
-	else if ((but->drawflag & UI_BUT_TEXT_LEFT)) {
-		if (but->ofs == 0) {
-			rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
-		}
+
+	if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) {
+		rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
 	}
 	else if ((but->drawflag & UI_BUT_TEXT_RIGHT)) {
 		rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
@@ -1332,6 +1302,23 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
 		widget_draw_icon(but, ICON_X, alpha, &temp);
 	}
 
+	/* clip but->drawstr to fit in available space */
+	if (but->editstr && but->pos >= 0) {
+		ui_text_clip_cursor(fstyle, but, rect);
+	}
+	else if (ELEM(but->type, NUM, NUMSLI)) {
+		ui_text_clip_right_label(fstyle, but, rect);
+	}
+	else if (ELEM3(but->type, TEX, SEARCH_MENU, SEARCH_MENU_UNLINK)) {
+		ui_text_clip_left(fstyle, but, rect);
+	}
+	else if ((but->block->flag & UI_BLOCK_LOOP) && (but->type == BUT)) {
+		ui_text_clip_left(fstyle, but, rect);
+	}
+	else {
+		but->ofs = 0;
+	}
+
 	/* always draw text for textbutton cursor */
 	widget_draw_text(fstyle, wcol, but, rect);




More information about the Bf-blender-cvs mailing list