diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-04-16 17:26:42 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-04-16 17:34:39 +0300 |
commit | bc1ac160b3ba1ae6dee30219563262dbb5654ec7 (patch) | |
tree | 86394212b08ada35234fadbe5cbc434e3d70939d /rigify | |
parent | fb45e242cd32039710b7aec6b12ed983452ea949 (diff) |
Rigify: change make_property to wrap the official rna_idprop_ui_create.
Also add keyword-only argument markers for clarity.
Diffstat (limited to 'rigify')
-rw-r--r-- | rigify/utils/mechanism.py | 43 |
1 files changed, 11 insertions, 32 deletions
diff --git a/rigify/utils/mechanism.py b/rigify/utils/mechanism.py index 3859c232..62d86154 100644 --- a/rigify/utils/mechanism.py +++ b/rigify/utils/mechanism.py @@ -20,7 +20,7 @@ import bpy -from rna_prop_ui import rna_idprop_ui_prop_get +from rna_prop_ui import rna_idprop_ui_create #============================================= # Constraint creation utilities @@ -33,7 +33,7 @@ _TRACK_AXIS_MAP = { } def make_constraint( - owner, type, target=None, subtarget=None, + owner, type, target=None, subtarget=None, *, space=None, track_axis=None, use_xyz=None, **options): """ @@ -78,42 +78,21 @@ def make_constraint( # Custom property creation utilities #============================================= -def make_property(owner, name, default, min=0.0, max=1.0, soft_min=None, soft_max=None, description=None, overridable=True): +def make_property(owner, name, default, *, min=0.0, max=1.0, soft_min=None, soft_max=None, description=None, overridable=True): """ Creates and initializes a custom property of owner. The soft_min and soft_max parameters default to min and max. Description defaults to the property name. """ - owner[name] = default - prop = rna_idprop_ui_prop_get(owner, name, create=True) - - if soft_min is None: - soft_min = min - if soft_max is None: - soft_max = max - - proptype = type(default) - - if proptype in {int, float}: - prop["min"] = proptype(min) - prop["soft_min"] = proptype(soft_min) - prop["max"] = proptype(max) - prop["soft_max"] = proptype(soft_max) - - if default != 0: - prop["default"] = default - - elif proptype is bool: - prop["min"] = prop["soft_min"] = False - prop["max"] = prop["soft_max"] = True - - prop["description"] = description or name - - owner.property_overridable_static_set('["%s"]' % (name), overridable) - - return prop + # Some keyword argument defaults differ + return rna_idprop_ui_create( + owner, name, default = default, + min = min, max = max, soft_min = soft_min, soft_max = soft_max, + description = description or name, + overridable = overridable, + ) #============================================= # Driver creation utilities @@ -183,7 +162,7 @@ def _add_driver_variable(drv, var_name, var_info, target_id): elif p != 'type': setattr(var, p, v) -def make_driver(owner, prop, index=-1, type='SUM', expression=None, variables={}, polynomial=None, target_id=None): +def make_driver(owner, prop, *, index=-1, type='SUM', expression=None, variables={}, polynomial=None, target_id=None): """ Creates and initializes a driver for the 'prop' property of owner. |