diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-06-26 08:57:14 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-06-26 09:38:04 +0300 |
commit | 28b2f1c30504ce0e437b21f7964282fcd6894421 (patch) | |
tree | 8653eeeb0edb90cf41a93bc2b196ac55739f2a32 /release/scripts/modules | |
parent | c9e33b36de25d272a9896ad0a85dcc69ee0692ba (diff) |
Manipulator: Python API
Initial support for Python/Manipulator integration
from 'custom-manipulators' branch.
Supports:
- Registering custom manipulators & manipulator-groups.
- Modifying RNA properties, custom values via get/set callbacks,
or invoking an operator.
- Drawing shape presets for Python defined manipulators (arrow, circle, face-maps)
Limitations:
- Only float properties supported.
- Drawing only supported via shape presets.
(we'll likely want a way to define custom geometry or draw directly).
- When to refresh, recalculate manipulators will likely need
integration with notifier system.
Development will be continued in the 2.8 branch
Diffstat (limited to 'release/scripts/modules')
-rw-r--r-- | release/scripts/modules/bpy_types.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 600b29a6b2b..89d8e0746a6 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -592,6 +592,35 @@ class OrderedMeta(RNAMeta): return OrderedDictMini() # collections.OrderedDict() +# Same as 'Operator' +# only without 'as_keywords' +class Manipulator(StructRNA, metaclass=OrderedMeta): + __slots__ = () + + def __getattribute__(self, attr): + properties = StructRNA.path_resolve(self, "properties") + bl_rna = getattr(properties, "bl_rna", None) + if (bl_rna is not None) and (attr in bl_rna.properties): + return getattr(properties, attr) + return super().__getattribute__(attr) + + def __setattr__(self, attr, value): + properties = StructRNA.path_resolve(self, "properties") + bl_rna = getattr(properties, "bl_rna", None) + if (bl_rna is not None) and (attr in bl_rna.properties): + return setattr(properties, attr, value) + return super().__setattr__(attr, value) + + def __delattr__(self, attr): + properties = StructRNA.path_resolve(self, "properties") + bl_rna = getattr(properties, "bl_rna", None) + if (bl_rna is not None) and (attr in bl_rna.properties): + return delattr(properties, attr) + return super().__delattr__(attr) + + target_set_handler = _bpy._rna_manipulator_target_set_handler + + # Only defined so operators members can be used by accessing self.order # with doc generation 'self.properties.bl_rna.properties' can fail class Operator(StructRNA, metaclass=OrderedMeta): |