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:
authorAlexander Gavrilov <angavrilov@gmail.com>2018-12-15 22:37:12 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2018-12-19 14:20:35 +0300
commit61c941f040d367d18fcaa57c9e8e0c2078193d97 (patch)
tree9cf843e4f19fffda991afb77595ec4d287a0b142 /release/scripts/modules/rna_prop_ui.py
parent908a2742403b279cd6dfa5c27acb76d68d3f1523 (diff)
RNA: support setting default values for custom properties.
NLA requires a usable default value for all properties that are to be animated via it, without any exceptions. This is the real cause of T36496: using the default of 0 for a scale related custom property obviously doesn't work. Thus, to really fix this it is necessary to support configurable default values for custom properties, which are very frequently used in rigs for auxiliary settings. For common use it is enough to support this for scalar float and integer properties. The default can be set via the custom property configuration popup, or a right click menu option. In addition, to help in updating old rigs, an operator that saves current values as defaults for all object and bone properties is added. Reviewers: campbellbarton, brecht Differential Revision: https://developer.blender.org/D4084
Diffstat (limited to 'release/scripts/modules/rna_prop_ui.py')
-rw-r--r--release/scripts/modules/rna_prop_ui.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py
index fc17cc60c6c..f08390cfd6d 100644
--- a/release/scripts/modules/rna_prop_ui.py
+++ b/release/scripts/modules/rna_prop_ui.py
@@ -96,6 +96,25 @@ def rna_idprop_has_properties(rna_item):
return (nbr_props > 1) or (nbr_props and '_RNA_UI' not in keys)
+def rna_idprop_ui_prop_default_set(item, prop, value):
+ defvalue = None
+ try:
+ prop_type = type(item[prop])
+
+ if prop_type in {int, float}:
+ defvalue = prop_type(value)
+ except KeyError:
+ pass
+
+ if defvalue:
+ rna_ui = rna_idprop_ui_prop_get(item, prop, True)
+ rna_ui["default"] = defvalue
+ else:
+ rna_ui = rna_idprop_ui_prop_get(item, prop)
+ if rna_ui and "default" in rna_ui:
+ del rna_ui["default"]
+
+
def draw(layout, context, context_member, property_type, use_edit=True):
def assign_props(prop, val, key):