From ab1698730db8205ab11226fb18942e9d86e93b6b Mon Sep 17 00:00:00 2001 From: Pullusb Date: Fri, 8 Oct 2021 17:01:33 +0200 Subject: [PATCH] viewlayer panel popup 0.5.4 - feat: button to popup a floating panel with viewlayer list for easy check/toggle --- CHANGELOG.md | 4 ++++ __init__.py | 2 +- ui.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fec207e..5e9429c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ Activate / deactivate layer opaticty according to prefix Activate / deactivate all masks using MA layers --> +0.5.4 + +- feat: button to popup a floating panel with viewlayer list for easy check/toggle + 0.5.3 - fix: manage output : activate only some viewlayer take context.scene instead of render.scene diff --git a/__init__.py b/__init__.py index db8040c..2f8e5a8 100644 --- a/__init__.py +++ b/__init__.py @@ -2,7 +2,7 @@ bl_info = { "name": "GP Render", "description": "Organise export of gp layers through compositor output", "author": "Samuel Bernou", - "version": (0, 5, 3), + "version": (0, 5, 4), "blender": (2, 93, 0), "location": "View3D", "warning": "", diff --git a/ui.py b/ui.py index 77a8a3a..4e08877 100644 --- a/ui.py +++ b/ui.py @@ -53,10 +53,19 @@ class GPEXP_PT_gp_node_ui(Panel): layout.label(text='View layers:') ct = len([n for n in context.scene.node_tree.nodes if n.type == 'R_LAYERS' and n.select]) - col = layout.column(align=True) - col.operator('gp.activate_only_selected_layers', text=f'Activate Only {ct} Layer Nodes') - col.enabled = ct > 0 + # col = layout.column(align=True) + # row=col.row(align=True) + row=layout.row(align=True) + + row1 = row.row(align=True) + row1.operator('gp.activate_only_selected_layers', text=f'Activate Only {ct} Layer Nodes') + row1.enabled = ct > 0 + + row2=row.row(align=True) + row2.operator("wm.call_panel", text="", icon='RENDERLAYERS').name = "GPEXP_PT_viewlayers_ui" + # row2.operator("gp.viewlayer_popup", text="", icon='RENDERLAYERS') # Ops invoke hack + # row2.operator("wm.call_menu", text="", icon='RENDERLAYERS').name = "GPEXP_MT_viewlayers_popup" # Bad menu if advanced: col = layout.column(align=True) @@ -199,7 +208,6 @@ class GPEXP_PT_gp_dopesheet_ui(Panel): class GPEXP_MT_multi_user_doc(bpy.types.Menu): - # bl_idname = "OBJECT_MT_custom_menu" bl_label = "Case of multiuser objects" def draw(self, context): @@ -218,6 +226,45 @@ class GPEXP_MT_multi_user_doc(bpy.types.Menu): col.label(text='- search "Make single user"') col.label(text='- tick only "object data"') + +def viewlayer_layout(layout, context): + for vl in context.scene.view_layers: + row = layout.row() + row.prop(vl, 'use', text=vl.name, icon='RESTRICT_RENDER_OFF' if vl.use else 'RESTRICT_RENDER_ON', emboss=False, toggle=0) + # row.prop(vl, 'use', text=vl.name, icon='RESTRICT_RENDER_OFF', emboss=False) + +## Can only toggle one with a menu +# class GPEXP_MT_viewlayers_popup(bpy.types.Menu): +# bl_label = "View Layers" +# def draw(self, context): +# layout = self.layout +# viewlayer_layout(layout, context) + +class GPEXP_PT_viewlayers_ui(Panel): + bl_space_type = "NODE_EDITOR" + bl_region_type = "UI" + bl_label = "View Layers" + def draw(self, context): + layout = self.layout + viewlayer_layout(layout, context) + +class GPEXP_OT_viewlayer_popup_invoke(bpy.types.Operator): + bl_idname = "gp.viewlayer_popup" + bl_label = "Viewlayer Popup" + bl_description = "Pop up menu for toggling viewlayers" + bl_options = {"REGISTER",} + + def invoke(self, context, event): + return context.window_manager.invoke_props_dialog(self) + + def draw(self, context): + layout = self.layout + viewlayer_layout(layout, context) + + def execute(self, context): + return {"FINISHED"} + + ## not registered for now (better to place render menu in GP dopesheet) def manager_ui(self, context): '''appended to DATA_PT_gpencil_layers''' @@ -253,6 +300,8 @@ def manager_ui(self, context): #-# REGISTER classes=( +GPEXP_PT_viewlayers_ui, +GPEXP_OT_viewlayer_popup_invoke, GPEXP_MT_multi_user_doc, GPEXP_PT_gp_node_ui, GPEXP_PT_gp_dopesheet_ui,