diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-12-29 12:46:27 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-12-29 12:46:27 +0400 |
commit | ed713803f5ef4f0ad13e99e595556857d397f26d (patch) | |
tree | 2395b49e176e2615588c46c4498ae0784b5eac44 /release/scripts | |
parent | 0cb07bcabcad6a8090750470cd834210cce08318 (diff) |
Fix for the NODE_OT_add_node operator. The way python classes were subclassed does not work with the registration mechanism. Combined both node_add and node_add_move operators into a single general operator with a flag. When use_transform is set, the operator will start transform on the new nodes after inserting.
Diffstat (limited to 'release/scripts')
-rw-r--r-- | release/scripts/startup/bl_operators/node.py | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/release/scripts/startup/bl_operators/node.py b/release/scripts/startup/bl_operators/node.py index 071eb2e75f9..39e00f94953 100644 --- a/release/scripts/startup/bl_operators/node.py +++ b/release/scripts/startup/bl_operators/node.py @@ -20,7 +20,7 @@ import bpy from bpy.types import Operator -from bpy.props import EnumProperty, StringProperty +from bpy.props import BoolProperty, EnumProperty, StringProperty # Base class for node 'Add' operators class NodeAddOperator(): @@ -75,6 +75,11 @@ class NODE_OT_add_node(NodeAddOperator, Operator): name="Group tree", description="Group node tree name", ) + use_transform = BoolProperty( + name="Use Transform", + description="Start transform operator after inserting the node", + default = False, + ) def execute(self, context): node = self.create_node(context, self.type) @@ -84,27 +89,13 @@ class NODE_OT_add_node(NodeAddOperator, Operator): return {'FINISHED'} - -# Adds a node and immediately starts the transform operator for inserting in a tree -class NODE_OT_add_node_move(NODE_OT_add_node): - '''Add a node to the active tree and start transform''' - bl_idname = "node.add_node_move" - bl_label = "Add Node and Move" - - type = StringProperty( - name="Node Type", - description="Node type", - ) - # optional group tree parameter for group nodes - group_tree = StringProperty( - name="Group tree", - description="Group node tree name", - ) - def invoke(self, context, event): self.store_mouse_cursor(context, event) - self.execute(context) - return bpy.ops.transform.translate('INVOKE_DEFAULT') + result = self.execute(context) + if self.use_transform and ('FINISHED' in result): + return bpy.ops.transform.translate('INVOKE_DEFAULT') + else: + return result # XXX These node item lists should actually be generated by a callback at |