Cleanup: style (80-width)
This commit is contained in:
@@ -36,7 +36,8 @@ from bpy.props import (
|
|||||||
class NodeSetting(PropertyGroup):
|
class NodeSetting(PropertyGroup):
|
||||||
value = StringProperty(
|
value = StringProperty(
|
||||||
name="Value",
|
name="Value",
|
||||||
description="Python expression to be evaluated as the initial node setting",
|
description="Python expression to be evaluated "
|
||||||
|
"as the initial node setting",
|
||||||
default="",
|
default="",
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -68,12 +69,15 @@ class NodeAddOperator:
|
|||||||
# convert mouse position to the View2D for later node placement
|
# convert mouse position to the View2D for later node placement
|
||||||
if context.region.type == 'WINDOW':
|
if context.region.type == 'WINDOW':
|
||||||
# convert mouse position to the View2D for later node placement
|
# convert mouse position to the View2D for later node placement
|
||||||
space.cursor_location_from_region(event.mouse_region_x, event.mouse_region_y)
|
space.cursor_location_from_region(
|
||||||
|
event.mouse_region_x, event.mouse_region_y)
|
||||||
else:
|
else:
|
||||||
space.cursor_location = tree.view_center
|
space.cursor_location = tree.view_center
|
||||||
|
|
||||||
# XXX explicit node_type argument is usually not necessary, but required to make search operator work:
|
# XXX explicit node_type argument is usually not necessary,
|
||||||
# add_search has to override the 'type' property since it's hardcoded in bpy_operator_wrap.c ...
|
# but required to make search operator work:
|
||||||
|
# add_search has to override the 'type' property
|
||||||
|
# since it's hardcoded in bpy_operator_wrap.c ...
|
||||||
def create_node(self, context, node_type=None):
|
def create_node(self, context, node_type=None):
|
||||||
space = context.space_data
|
space = context.space_data
|
||||||
tree = space.edit_tree
|
tree = space.edit_tree
|
||||||
@@ -94,7 +98,9 @@ class NodeAddOperator:
|
|||||||
try:
|
try:
|
||||||
setattr(node, setting.name, value)
|
setattr(node, setting.name, value)
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
self.report({'ERROR_INVALID_INPUT'}, "Node has no attribute " + setting.name)
|
self.report(
|
||||||
|
{'ERROR_INVALID_INPUT'},
|
||||||
|
"Node has no attribute " + setting.name)
|
||||||
print(str(e))
|
print(str(e))
|
||||||
# Continue despite invalid attribute
|
# Continue despite invalid attribute
|
||||||
|
|
||||||
@@ -107,7 +113,8 @@ class NodeAddOperator:
|
|||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
space = context.space_data
|
space = context.space_data
|
||||||
# needs active node editor and a tree to add nodes to
|
# needs active node editor and a tree to add nodes to
|
||||||
return (space.type == 'NODE_EDITOR' and space.edit_tree and not space.edit_tree.library)
|
return ((space.type == 'NODE_EDITOR') and
|
||||||
|
space.edit_tree and not space.edit_tree.library)
|
||||||
|
|
||||||
# Default execute simply adds a node
|
# Default execute simply adds a node
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
@@ -187,7 +194,12 @@ class NODE_OT_add_search(NodeAddOperator, Operator):
|
|||||||
if isinstance(item, nodeitems_utils.NodeItem):
|
if isinstance(item, nodeitems_utils.NodeItem):
|
||||||
nodetype = getattr(bpy.types, item.nodetype, None)
|
nodetype = getattr(bpy.types, item.nodetype, None)
|
||||||
if nodetype:
|
if nodetype:
|
||||||
enum_items.append((str(index), item.label, nodetype.bl_rna.description, index))
|
enum_items.append(
|
||||||
|
(str(index),
|
||||||
|
item.label,
|
||||||
|
nodetype.bl_rna.description,
|
||||||
|
index,
|
||||||
|
))
|
||||||
return enum_items
|
return enum_items
|
||||||
|
|
||||||
# Look up the item based on index
|
# Look up the item based on index
|
||||||
@@ -220,7 +232,8 @@ class NODE_OT_add_search(NodeAddOperator, Operator):
|
|||||||
self.create_node(context, item.nodetype)
|
self.create_node(context, item.nodetype)
|
||||||
|
|
||||||
if self.use_transform:
|
if self.use_transform:
|
||||||
bpy.ops.node.translate_attach_remove_on_cancel('INVOKE_DEFAULT')
|
bpy.ops.node.translate_attach_remove_on_cancel(
|
||||||
|
'INVOKE_DEFAULT')
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
else:
|
else:
|
||||||
@@ -243,7 +256,8 @@ class NODE_OT_collapse_hide_unused_toggle(Operator):
|
|||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
space = context.space_data
|
space = context.space_data
|
||||||
# needs active node editor and a tree
|
# needs active node editor and a tree
|
||||||
return (space.type == 'NODE_EDITOR' and space.edit_tree and not space.edit_tree.library)
|
return ((space.type == 'NODE_EDITOR') and
|
||||||
|
(space.edit_tree and not space.edit_tree.library))
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
space = context.space_data
|
space = context.space_data
|
||||||
|
Reference in New Issue
Block a user