[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57741] trunk/blender/intern/cycles/ blender/addon/ui.py: Fix #35546: clicking cycles "Use Nodes" did not do a proper undo push, due to

Brecht Van Lommel brechtvanlommel at pandora.be
Tue Jun 25 18:38:40 CEST 2013


Revision: 57741
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57741
Author:   blendix
Date:     2013-06-25 16:38:40 +0000 (Tue, 25 Jun 2013)
Log Message:
-----------
Fix #35546: clicking cycles "Use Nodes" did not do a proper undo push, due to
button disappearing as soon as it's clicked. Workaround now is to make this an
operator. Thanks to Lukas and Campbell for tracking this down.

Modified Paths:
--------------
    trunk/blender/intern/cycles/blender/addon/ui.py

Modified: trunk/blender/intern/cycles/blender/addon/ui.py
===================================================================
--- trunk/blender/intern/cycles/blender/addon/ui.py	2013-06-25 14:57:45 UTC (rev 57740)
+++ trunk/blender/intern/cycles/blender/addon/ui.py	2013-06-25 16:38:40 UTC (rev 57741)
@@ -20,7 +20,7 @@
 
 import bpy
 
-from bpy.types import Panel, Menu
+from bpy.types import Panel, Menu, Operator
 
 
 class CYCLES_MT_integrator_presets(Menu):
@@ -547,6 +547,26 @@
             flow.prop(visibility, "shadow")
 
 
+class CYCLES_OT_use_shading_nodes(Operator):
+    """Enable nodes on a material, world or lamp"""
+    bl_idname = "cycles.use_shading_nodes"
+    bl_label = "Use Nodes"
+
+    @classmethod
+    def poll(cls, context):
+        return context.material or context.world or context.lamp
+
+    def execute(self, context):
+        if context.material:
+            context.material.use_nodes = True
+        elif context.world:
+            context.world.use_nodes = True
+        elif context.lamp:
+            context.lamp.use_nodes = True
+
+        return {'FINISHED'}
+
+
 def find_node(material, nodetype):
     if material and material.node_tree:
         ntree = material.node_tree
@@ -568,7 +588,7 @@
 
 def panel_node_draw(layout, id_data, output_type, input_name):
     if not id_data.use_nodes:
-        layout.prop(id_data, "use_nodes", icon='NODETREE')
+        layout.operator("cycles.use_shading_nodes", icon='NODETREE')
         return False
 
     ntree = id_data.node_tree




More information about the Bf-blender-cvs mailing list