[Bf-blender-cvs] [65648b4] blender-v2.75-release: Fix T45144: Multi-value-edit ignored range
Campbell Barton
noreply at git.blender.org
Mon Jun 29 16:18:01 CEST 2015
Commit: 65648b4883211ffa4447e8b6c3f3ceaaf9e5e30d
Author: Campbell Barton
Date: Mon Jun 22 19:35:00 2015 +1000
Branches: blender-v2.75-release
https://developer.blender.org/rB65648b4883211ffa4447e8b6c3f3ceaaf9e5e30d
Fix T45144: Multi-value-edit ignored range
===================================================================
M source/blender/editors/interface/interface_handlers.c
===================================================================
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 8823cbc..2ddb9a0 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1484,16 +1484,18 @@ static void ui_selectcontext_apply(
bool b;
int i;
float f;
- } delta;
+ } delta, min, max;
const bool is_array = RNA_property_array_check(prop);
const int rna_type = RNA_property_type(prop);
if (rna_type == PROP_FLOAT) {
delta.f = use_delta ? (value - value_orig) : value;
+ RNA_property_float_range(&but->rnapoin, prop, &min.f, &max.f);
}
else if (rna_type == PROP_INT) {
delta.i = use_delta ? ((int)value - (int)value_orig) : (int)value;
+ RNA_property_int_range(&but->rnapoin, prop, &min.i, &max.i);
}
else if (rna_type == PROP_ENUM) {
delta.i = RNA_property_enum_get(&but->rnapoin, prop); /* not a delta infact */
@@ -1543,31 +1545,41 @@ static void ui_selectcontext_apply(
for (i = 0; i < selctx_data->elems_len; i++) {
uiSelectContextElem *other = &selctx_data->elems[i];
PointerRNA lptr = other->ptr;
- if (is_array) {
- if (rna_type == PROP_FLOAT) {
- RNA_property_float_set_index(&lptr, lprop, index, use_delta ? (other->val_f + delta.f) : delta.f);
- }
- else if (rna_type == PROP_INT) {
- RNA_property_int_set_index(&lptr, lprop, index, use_delta ? (other->val_i + delta.i) : delta.i);
+
+ if (rna_type == PROP_FLOAT) {
+ float other_value = use_delta ? (other->val_f + delta.f) : delta.f;
+ CLAMP(other_value, min.f, max.f);
+ if (is_array) {
+ RNA_property_float_set_index(&lptr, lprop, index, other_value);
}
- else if (rna_type == PROP_BOOLEAN) {
- RNA_property_boolean_set_index(&lptr, lprop, index, delta.b);
+ else {
+ RNA_property_float_set(&lptr, lprop, other_value);
}
}
- else {
- if (rna_type == PROP_FLOAT) {
- RNA_property_float_set(&lptr, lprop, use_delta ? (other->val_f + delta.f) : delta.f);
+ else if (rna_type == PROP_INT) {
+ int other_value = use_delta ? (other->val_i + delta.i) : delta.i;
+ CLAMP(other_value, min.i, max.i);
+ if (is_array) {
+ RNA_property_int_set_index(&lptr, lprop, index, other_value);
}
- else if (rna_type == PROP_INT) {
- RNA_property_int_set(&lptr, lprop, use_delta ? (other->val_i + delta.i) : delta.i);
+ else {
+ RNA_property_int_set(&lptr, lprop, other_value);
}
- else if (rna_type == PROP_BOOLEAN) {
- RNA_property_boolean_set(&lptr, lprop, delta.b);
+ }
+ else if (rna_type == PROP_BOOLEAN) {
+ const bool other_value = delta.b;
+ if (is_array) {
+ RNA_property_boolean_set_index(&lptr, lprop, index, other_value);
}
- else if (rna_type == PROP_ENUM) {
- RNA_property_enum_set(&lptr, lprop, delta.i);
+ else {
+ RNA_property_boolean_set(&lptr, lprop, delta.b);
}
}
+ else if (rna_type == PROP_ENUM) {
+ const int other_value = delta.i;
+ BLI_assert(!is_array);
+ RNA_property_enum_set(&lptr, lprop, other_value);
+ }
RNA_property_update(C, &lptr, prop);
}
More information about the Bf-blender-cvs
mailing list