Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Oeser <info@graphics-engineer.com>2020-07-31 11:51:00 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2020-07-31 11:51:00 +0300
commit585c9c2f23d76ffe29997f2beb149fb363ef35fa (patch)
tree59b05cfe26b41b4f2a5e56cf0c76efd93e70de76 /source/blender/editors/interface/interface.c
parentf3e8326453ae856d7914e45e832a2ed80aa9a9b9 (diff)
parent298d5eb66916c6379f2a4203dd7502dae7db8939 (diff)
Merge branch 'blender-v2.90-release'
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r--source/blender/editors/interface/interface.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index b28a6f530f6..5dfecacf81b 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3092,8 +3092,38 @@ static double soft_range_round_down(double value, double max)
return newmax;
}
+void ui_but_range_set_hard(uiBut *but)
+{
+ if (but->rnaprop) {
+ const PropertyType type = RNA_property_type(but->rnaprop);
+ double hardmin, hardmax;
+
+ /* clamp button range to something reasonable in case
+ * we get -inf/inf from RNA properties */
+ if (type == PROP_INT) {
+ int imin, imax;
+
+ RNA_property_int_range(&but->rnapoin, but->rnaprop, &imin, &imax);
+ hardmin = (imin == INT_MIN) ? -1e4 : imin;
+ hardmax = (imin == INT_MAX) ? 1e4 : imax;
+ }
+ else if (type == PROP_FLOAT) {
+ float fmin, fmax;
+
+ RNA_property_float_range(&but->rnapoin, but->rnaprop, &fmin, &fmax);
+ hardmin = (fmin == -FLT_MAX) ? (float)-1e4 : fmin;
+ hardmax = (fmax == FLT_MAX) ? (float)1e4 : fmax;
+ }
+ else {
+ return;
+ }
+ but->hardmin = hardmin;
+ but->hardmax = hardmax;
+ }
+}
+
/* note: this could be split up into functions which handle arrays and not */
-static void ui_set_but_soft_range(uiBut *but)
+void ui_but_range_set_soft(uiBut *but)
{
/* ideally we would not limit this but practically, its more than
* enough worst case is very long vectors wont use a smart soft-range
@@ -3497,7 +3527,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
/* only update soft range while not editing */
if (!ui_but_is_editing(but)) {
if ((but->rnaprop != NULL) || (but->poin && (but->pointype & UI_BUT_POIN_TYPES))) {
- ui_set_but_soft_range(but);
+ ui_but_range_set_soft(but);
}
}