diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-04-28 12:49:14 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-04-28 17:55:17 +0300 |
commit | 922ea41395d2dc8afc045ee606ad55d506517a55 (patch) | |
tree | a4a05a83208aac3f5c17f32a05adff6b4e9cf8ba /source | |
parent | 9b0ea92be75c67567e05a091d0593b87564e0ad1 (diff) |
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%.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 8 |
1 files changed, 7 insertions, 1 deletions
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) { |