[Bf-extensions-cvs] [8d1efc4] master: Amaranth: Passthrough when double click not on node

Greg noreply at git.blender.org
Mon Aug 8 14:55:12 CEST 2016


Commit: 8d1efc4962f137b998ad1fa46231220767d175b9
Author: Greg
Date:   Mon Aug 8 14:45:53 2016 +0200
Branches: master
https://developer.blender.org/rBAC8d1efc4962f137b998ad1fa46231220767d175b9

Amaranth: Passthrough when double click not on node

This allows Node Wrangler's "Viewer Focus" feature to work correctly too.
No functionality changes here except to change only the biggest image editor instead of all of them, which is more in line with Blender's standards
Also, double clicking on a render layer now works too

===================================================================

M	amaranth/node_editor/display_image.py

===================================================================

diff --git a/amaranth/node_editor/display_image.py b/amaranth/node_editor/display_image.py
index 1a84466..322e4d1 100644
--- a/amaranth/node_editor/display_image.py
+++ b/amaranth/node_editor/display_image.py
@@ -27,7 +27,8 @@ import bpy
 
 KEYMAPS = list()
 
-image_nodes = ("CompositorNodeImage",
+image_nodes = ("CompositorNodeRLayers",
+               "CompositorNodeImage",
                "CompositorNodeViewer",
                "CompositorNodeComposite",
                "ShaderNodeTexImage",
@@ -42,27 +43,47 @@ class AMTH_NODE_OT_show_active_node_image(bpy.types.Operator):
     bl_options = {"UNDO"}
 
     def execute(self, context):
-        preferences = context.user_preferences.addons["amaranth"].preferences
-        if preferences.use_image_node_display:
-            if context.active_node:
-                active_node = context.active_node
-
-                if active_node.bl_idname in image_nodes:
-                    for area in context.screen.areas:
-                        if area.type == "IMAGE_EDITOR":
+        return {'FINISHED'}
+
+    def invoke(self, context, event):
+        mlocx = event.mouse_region_x
+        mlocy = event.mouse_region_y
+        select_node = bpy.ops.node.select(mouse_x=mlocx, mouse_y=mlocy, extend=False)
+
+        if 'FINISHED' in select_node:  # Only run if we're clicking on a node
+            preferences = context.user_preferences.addons["amaranth"].preferences
+            if preferences.use_image_node_display:
+                if context.active_node:
+                    active_node = context.active_node
+
+                    if active_node.bl_idname in image_nodes:
+                        # Use largest image editor
+                        area = None
+                        area_size = 0
+                        for a in context.screen.areas:
+                            if a.type == "IMAGE_EDITOR":
+                                size = a.width * a.height
+                                if size > area_size:
+                                    area_size = size
+                                    area = a
+                        if area:
                             for space in area.spaces:
                                 if space.type == "IMAGE_EDITOR":
                                     if active_node.bl_idname == "CompositorNodeViewer":
                                         space.image = bpy.data.images[
                                             "Viewer Node"]
-                                    elif active_node.bl_idname == "CompositorNodeComposite":
+                                    elif active_node.bl_idname in ["CompositorNodeComposite", "CompositorNodeRLayers"]:
                                         space.image = bpy.data.images[
                                             "Render Result"]
                                     elif active_node.image:
                                         space.image = active_node.image
-                            break
+                                break
+                        else:
+                            return {'CANCELLED'}
 
-        return {"FINISHED"}
+            return {"FINISHED"}
+        else:
+            return {"PASS_THROUGH"}
 
 
 def register():



More information about the Bf-extensions-cvs mailing list