diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-03-17 19:52:05 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-03-17 23:53:13 +0300 |
commit | df96455c55110da00f0543c5895376ffbc66313b (patch) | |
tree | d1fc0a55f44d4b931362d84eea77a7662c1955a6 /release | |
parent | f79ad428085edd8289f37027ba3d5ed3a52bce67 (diff) |
UI: add light/world settings in shader node editor.
Material was already there. Implementation was changed so it's just a
single line of code to adapt a panel to the node editor.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/startup/bl_ui/properties_data_light.py | 18 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/properties_material.py | 16 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_node.py | 65 |
3 files changed, 44 insertions, 55 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_light.py b/release/scripts/startup/bl_ui/properties_data_light.py index d6f37245d96..acda015f8d4 100644 --- a/release/scripts/startup/bl_ui/properties_data_light.py +++ b/release/scripts/startup/bl_ui/properties_data_light.py @@ -69,7 +69,13 @@ class DATA_PT_light(DataButtonsPanel, Panel): light = context.light - layout.row().prop(light, "type", expand=True) + # Compact layout for node editor. + if self.bl_space_type == 'PROPERTIES': + layout.row().prop(light, "type", expand=True) + layout.use_property_split = True + else: + layout.use_property_split = True + layout.row().prop(light, "type") class DATA_PT_EEVEE_light(DataButtonsPanel, Panel): @@ -80,9 +86,13 @@ class DATA_PT_EEVEE_light(DataButtonsPanel, Panel): layout = self.layout light = context.light - layout.row().prop(light, "type", expand=True) - - layout.use_property_split = True + # Compact layout for node editor. + if self.bl_space_type == 'PROPERTIES': + layout.row().prop(light, "type", expand=True) + layout.use_property_split = True + else: + layout.use_property_split = True + layout.row().prop(light, "type") col = layout.column() col.prop(light, "color") diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index 6e21fba51f2..260e57c4b1c 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -206,11 +206,12 @@ class EEVEE_MATERIAL_PT_settings(MaterialButtonsPanel, Panel): bl_context = "material" COMPAT_ENGINES = {'BLENDER_EEVEE'} - @staticmethod - def draw_shared(self, mat): + def draw(self, context): layout = self.layout layout.use_property_split = True + mat = context.material + layout.prop(mat, "blend_method") if mat.blend_method != 'OPAQUE': @@ -228,9 +229,6 @@ class EEVEE_MATERIAL_PT_settings(MaterialButtonsPanel, Panel): layout.prop(mat, "use_sss_translucency") layout.prop(mat, "pass_index") - def draw(self, context): - self.draw_shared(self, context.material) - class MATERIAL_PT_viewport(MaterialButtonsPanel, Panel): bl_label = "Viewport Display" @@ -242,19 +240,17 @@ class MATERIAL_PT_viewport(MaterialButtonsPanel, Panel): mat = context.material return mat and not mat.grease_pencil - @staticmethod - def draw_shared(self, mat): + def draw(self, context): layout = self.layout layout.use_property_split = True + mat = context.material + col = layout.column() col.prop(mat, "diffuse_color", text="Color") col.prop(mat, "metallic") col.prop(mat, "roughness") - def draw(self, context): - self.draw_shared(self, context.material) - classes = ( MATERIAL_MT_context_menu, diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index e6765d59723..31451d7eedf 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -30,6 +30,13 @@ from .properties_material import ( EEVEE_MATERIAL_PT_settings, MATERIAL_PT_viewport ) +from .properties_world import ( + WORLD_PT_viewport_display +) +from .properties_data_light import ( + DATA_PT_light, + DATA_PT_EEVEE_light, +) class NODE_HT_header(Header): @@ -569,49 +576,22 @@ class NODE_PT_grease_pencil_tools(GreasePencilToolsPanel, Panel): # toolbar, but which may not necessarily be open -class EEVEE_NODE_PT_material_settings(Panel): - bl_space_type = 'NODE_EDITOR' - bl_region_type = 'UI' - bl_category = "Node" - bl_label = "Settings" - COMPAT_ENGINES = {'BLENDER_EEVEE'} - - @classmethod - def poll(cls, context): - snode = context.space_data - return ( - (context.engine in cls.COMPAT_ENGINES) and - (snode.tree_type == 'ShaderNodeTree' and snode.id) and - (snode.id.bl_rna.identifier == 'Material') - ) - - def draw(self, context): - material = context.space_data.id - EEVEE_MATERIAL_PT_settings.draw_shared(self, material) - - -class NODE_PT_material_viewport(Panel): - bl_space_type = 'NODE_EDITOR' - bl_region_type = 'UI' - bl_category = "Node" - bl_label = "Viewport Display" - bl_options = {'DEFAULT_CLOSED'} +def node_draw_tree_view(layout, context): + pass - @classmethod - def poll(cls, context): - snode = context.space_data - return ( - (snode.tree_type == 'ShaderNodeTree' and snode.id) and - (snode.id.bl_rna.identifier == "Material") - ) - def draw(self, context): - material = context.space_data.id - MATERIAL_PT_viewport.draw_shared(self, material) +# Adapt properties editor panel to display in node editor. We have to +# copy the class rather than inherit due to the way bpy registration works. +def node_panel(cls): + node_cls = type('NODE_' + cls.__name__, cls.__bases__, dict(cls.__dict__)) + node_cls.bl_space_type = 'NODE_EDITOR' + node_cls.bl_region_type = 'UI' + node_cls.bl_category = "Node" + if hasattr(node_cls, 'bl_parent_id'): + node_cls.bl_parent_id = 'NODE_' + node_cls.bl_parent_id -def node_draw_tree_view(layout, context): - pass + return node_cls classes = ( @@ -632,8 +612,11 @@ classes = ( NODE_UL_interface_sockets, NODE_PT_grease_pencil, NODE_PT_grease_pencil_tools, - EEVEE_NODE_PT_material_settings, - NODE_PT_material_viewport, + node_panel(EEVEE_MATERIAL_PT_settings), + node_panel(MATERIAL_PT_viewport), + node_panel(WORLD_PT_viewport_display), + node_panel(DATA_PT_light), + node_panel(DATA_PT_EEVEE_light), ) |