[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55463] trunk/blender/source/blender/ editors/interface: Fix for extra string width padding in ui_text_icon_width , causing labels in right-aligned layouts show an annoying gap.

Lukas Toenne lukas.toenne at googlemail.com
Thu Mar 21 13:58:32 CET 2013


Revision: 55463
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55463
Author:   lukastoenne
Date:     2013-03-21 12:58:31 +0000 (Thu, 21 Mar 2013)
Log Message:
-----------
Fix for extra string width padding in ui_text_icon_width, causing labels in right-aligned layouts show an annoying gap. If the layout is right-aligned, make the text button align right as well, so text is drawn at the right side of the alloted rect.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_layout.c
    trunk/blender/source/blender/editors/interface/interface_widgets.c

Modified: trunk/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_layout.c	2013-03-21 11:48:13 UTC (rev 55462)
+++ trunk/blender/source/blender/editors/interface/interface_layout.c	2013-03-21 12:58:31 UTC (rev 55463)
@@ -1599,6 +1599,14 @@
 	else
 		but = uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
 	
+	/* to compensate for string size padding in ui_text_icon_width,
+	 * make text aligned right if the layout is aligned right.
+	 */
+	if (uiLayoutGetAlignment(layout) == UI_LAYOUT_ALIGN_RIGHT) {
+		but->flag &= ~UI_TEXT_LEFT;	/* default, needs to be unset */
+		but->flag |= UI_TEXT_RIGHT;
+	}
+	
 	return but;
 }
 

Modified: trunk/blender/source/blender/editors/interface/interface_widgets.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_widgets.c	2013-03-21 11:48:13 UTC (rev 55462)
+++ trunk/blender/source/blender/editors/interface/interface_widgets.c	2013-03-21 12:58:31 UTC (rev 55463)
@@ -1147,6 +1147,8 @@
 	
 	if (but->editstr || (but->flag & UI_TEXT_LEFT))
 		fstyle->align = UI_STYLE_TEXT_LEFT;
+	else if (but->flag & UI_TEXT_RIGHT)
+		fstyle->align = UI_STYLE_TEXT_RIGHT;
 	else
 		fstyle->align = UI_STYLE_TEXT_CENTER;
 	
@@ -1333,10 +1335,16 @@
 			if (but->editstr || (but->flag & UI_TEXT_LEFT)) {
 				rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
 			}
+			else if ((but->flag & UI_TEXT_RIGHT)) {
+				rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
+			}
 		}
 		else if ((but->flag & UI_TEXT_LEFT)) {
 			rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
 		}
+		else if ((but->flag & UI_TEXT_RIGHT)) {
+			rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
+		}
 		
 		/* unlink icon for this button type */
 		if (but->type == SEARCH_MENU_UNLINK && but->drawstr[0]) {




More information about the Bf-blender-cvs mailing list