From 922ea41395d2dc8afc045ee606ad55d506517a55 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sat, 28 Apr 2018 11:49:14 +0200 Subject: 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%. --- source/blender/editors/interface/interface_widgets.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to '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) { -- cgit v1.2.3