[Bf-blender-cvs] [922ea41395d] blender2.8: UI: Number Slider - treat percentage as a special case

Dalai Felinto noreply at git.blender.org
Sat Apr 28 16:57:27 CEST 2018


Commit: 922ea41395d2dc8afc045ee606ad55d506517a55
Author: Dalai Felinto
Date:   Sat Apr 28 11:49:14 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB922ea41395d2dc8afc045ee606ad55d506517a55

UI: Number Slider - treat percentage as a special case

This is to address things like a percentage slider with a fixed soft mininum.

For example, the render resolution ranges from 1% to 100% and it is really
strange to have the slider showing nothing filled when the ui shows 1%.

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

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 6b50279d6d3..d745c9b4207 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -3605,7 +3605,13 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
 		float factor_discard = 1.0f; /* No discard. */
 		float value = (float)ui_but_value_get(but);
 
-		factor = (value - but->softmin) / (but->softmax - but->softmin);
+		if (but->rnaprop && (RNA_property_subtype(but->rnaprop) == PROP_PERCENTAGE)) {
+			factor = value / but->softmax;
+		}
+		else {
+			factor = (value - but->softmin) / (but->softmax - but->softmin);
+		}
+
 		factor_ui = factor * (float)BLI_rcti_size_x(rect);
 
 		if (factor_ui <= offs) {



More information about the Bf-blender-cvs mailing list