[Bf-blender-cvs] [fd2c48726fd] master: UI: center align number buttons w/o text

Campbell Barton noreply at git.blender.org
Sun May 27 21:10:00 CEST 2018


Commit: fd2c48726fd27ff1335c4adbe251fb1e076d8266
Author: Campbell Barton
Date:   Sun May 27 21:06:38 2018 +0200
Branches: master
https://developer.blender.org/rBfd2c48726fd27ff1335c4adbe251fb1e076d8266

UI: center align number buttons w/o text

This makes supporting split properties and text possible, see T54951

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

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

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

diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 1d798c7baad..20ad6f00c5b 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3238,7 +3238,9 @@ static uiBut *ui_def_but(
 	}
 #ifdef USE_NUMBUTS_LR_ALIGN
 	else if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER)) {
-		but->drawflag |= UI_BUT_TEXT_LEFT;
+		if (slen != 0) {
+			but->drawflag |= UI_BUT_TEXT_LEFT;
+		}
 	}
 #endif
 
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index c476c12ce2b..e3230d39ae2 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1475,7 +1475,9 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
 	}
 
 #ifdef USE_NUMBUTS_LR_ALIGN
-	if (!drawstr_right && ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) &&
+	if (!drawstr_right &&
+	    (but->drawflag & UI_BUT_TEXT_LEFT) &&
+	    ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) &&
 	    /* if we're editing or multi-drag (fake editing), then use left alignment */
 	    (but->editstr == NULL) && (drawstr == but->drawstr))
 	{



More information about the Bf-blender-cvs mailing list