diff options
author | Henrik Dick <hen-di@web.de> | 2021-05-17 10:28:12 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-05-17 10:33:55 +0300 |
commit | 0447aedb960a1dc514fee8cd99d0eee43fae86ad (patch) | |
tree | 4927b43fca8d05fca891b64f5866248b75b8d81c /source/blender/makesrna/intern/rna_access.c | |
parent | 45863059f7b2335d32631e98632561f4e76b5c61 (diff) |
UI: add non-linear slider support
This patch introduces non linear sliders. That means, that the movement
of the mouse doesn't map linearly to the value of the slider.
The following changes have been made.
- Free logarithmic sliders with maximum range of (`0 <= x < inf`)
- Logarithmic sliders with correct value indication bar.
- Free cubic sliders with maximum range of (`-inf < x < inf`)
- Cubic sliders with correct value indication bar.
Cubic mapping has been added as well, because it's used for brush sizes
in other applications (Krita for e.g.).
To make a slider have a different scale type use following line in RNA:
`RNA_def_property_ui_scale_type(prop, PROP_SCALE_LOGARITHMIC);`
or:
`RNA_def_property_ui_scale_type(prop, PROP_SCALE_CUBIC);`
Test the precision, step size and soft-min if you change the scale type
of a property as it will feel very different and may need tweaking.
Ref D9074
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 9b57096ec19..150a455f1c7 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1189,6 +1189,24 @@ PropertyUnit RNA_property_unit(PropertyRNA *prop) return RNA_SUBTYPE_UNIT(RNA_property_subtype(prop)); } +PropertyScaleType RNA_property_ui_scale(PropertyRNA *prop) +{ + PropertyRNA *rna_prop = rna_ensure_property(prop); + + switch (rna_prop->type) { + case PROP_INT: { + IntPropertyRNA *iprop = (IntPropertyRNA *)rna_prop; + return iprop->ui_scale_type; + } + case PROP_FLOAT: { + FloatPropertyRNA *fprop = (FloatPropertyRNA *)rna_prop; + return fprop->ui_scale_type; + } + default: + return PROP_SCALE_LINEAR; + } +} + int RNA_property_flag(PropertyRNA *prop) { return rna_ensure_property(prop)->flag; |