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%.
This commit is contained in:
Dalai Felinto 2018-04-28 11:49:14 +02:00
parent 9b0ea92be7
commit 922ea41395
1 changed files with 7 additions and 1 deletions

View File

@ -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) {