132 lines
4.8 KiB
Python
132 lines
4.8 KiB
Python
import bpy
|
|
from bpy.types import Panel
|
|
# from .preferences import get_addon_prefs
|
|
|
|
|
|
# Node view panel
|
|
class GPEXP_PT_gp_node_ui(Panel):
|
|
bl_space_type = "NODE_EDITOR" # "VIEW_3D"
|
|
bl_region_type = "UI"
|
|
bl_category = "View"
|
|
bl_label = "Gpencil Render Manager"
|
|
|
|
def draw(self, context):
|
|
if not context.scene.use_nodes or not context.scene.node_tree:
|
|
return
|
|
|
|
# TODO : add advanced bool checkbox to hide some options from the user
|
|
|
|
layout = self.layout
|
|
col = layout.column(align=True)
|
|
ct = len([n for n in context.scene.node_tree.nodes if n.type == 'R_LAYERS' and n.select])
|
|
txt = f'Merge {ct} Layer Nodes'
|
|
col.operator('gp.merge_selected_viewlayer_nodes', icon='NODETREE', text=txt).disconnect = True
|
|
col.operator('gp.merge_selected_viewlayer_nodes', icon='NODETREE', text='Merge (keep connect)').disconnect = False
|
|
col.enabled = ct > 1
|
|
|
|
layout.separator()
|
|
|
|
layout.label(text='All Outputs:')
|
|
row=layout.row()
|
|
row.operator('gp.mute_toggle_output_nodes', icon='NODE_INSERT_ON', text='Mute').mute = True
|
|
row.operator('gp.mute_toggle_output_nodes', icon='NODE_INSERT_OFF', text='Unmute').mute = False
|
|
|
|
layout.separator()
|
|
|
|
col=layout.column()
|
|
col.label(text='Clean and updates:')
|
|
|
|
row = col.row()
|
|
n = context.scene.node_tree.nodes.active
|
|
row.enabled = n and n.type == 'R_LAYERS' and not n.outputs[0].is_linked
|
|
row.operator('gp.reconnect_render_layer', icon='ANIM', text='Reconnect')
|
|
|
|
col.operator('gp.clean_compo_tree', icon='BRUSHES_ALL', text='Clean Nodes') # NODE_CORNER
|
|
|
|
col.separator()
|
|
col.operator('gp.number_outputs', icon='LINENUMBERS_ON', text='Renumber outputs')
|
|
## maybe get only this one...
|
|
col.operator('gp.number_outputs', icon='LINENUMBERS_ON', text='Renumber Selected outputs').mode = 'SELECTED'
|
|
|
|
layout.separator()
|
|
|
|
col=layout.column()
|
|
col.label(text='Delete Options:')
|
|
col.operator('gp.clear_render_tree', icon='X', text='Clear Render Tree')
|
|
col.operator('gp.clear_render_tree', icon='X', text='Clear Delete Render Scene').mode = "COMPLETE"
|
|
|
|
|
|
# layout.operator('gp.add_object_to_render', icon='RENDERLAYERS', text='Layer To Render').mode = 'ALL'
|
|
# layout.operator('gp.add_object_to_render', icon='RENDERLAYERS', text='Layer To Render').mode = 'SELECTED'
|
|
|
|
# layout.operator('gp.merge_layers', icon='X', text='Merge selected nodes')
|
|
|
|
class GPEXP_PT_gp_dopesheet_ui(Panel):
|
|
bl_space_type = 'DOPESHEET_EDITOR'
|
|
bl_region_type = 'UI'
|
|
# bl_category = "Item"
|
|
bl_parent_id='DOPESHEET_PT_gpencil_mode'
|
|
bl_label = "Gpencil Render Manager"
|
|
|
|
@classmethod
|
|
def poll(cls, context):
|
|
return context.object and context.object.type == 'GPENCIL'
|
|
|
|
def draw(self, context):
|
|
layout = self.layout
|
|
layout.label(text=context.object.name)
|
|
|
|
ct = len([l for l in context.object.data.layers if l.select])
|
|
txt = f'Merge {ct} layers'
|
|
|
|
# merge layers from dopesheet
|
|
layout.operator('gp.merge_selected_dopesheet_layers', text=txt, )
|
|
layout.enabled= ct > 1
|
|
|
|
def manager_ui(self, context):
|
|
'''appended to DATA_PT_gpencil_layers'''
|
|
|
|
layout = self.layout
|
|
|
|
## On layers
|
|
if context.object and context.object.type == 'GPENCIL':
|
|
txt = f'{len([l for l in context.object.data.layers if l.select])} Layer(s) To Render'
|
|
else:
|
|
txt = 'Layer To Render'
|
|
layout.operator('gp.add_layer_to_render', icon='RENDERLAYERS', text=txt)
|
|
|
|
## On objects
|
|
# txt = 'Selected Object To Render'
|
|
if context.scene.name != 'Render':
|
|
txt = f'{len([o for o in context.selected_objects if o.type == "GPENCIL" and o.select_get()])} Selected Object(s) To Render'
|
|
layout.operator('gp.add_object_to_render', icon='RENDERLAYERS', text=txt).mode='SELECTED'
|
|
layout.operator('gp.add_object_to_render', icon='RENDERLAYERS', text='All GP at once').mode='ALL'
|
|
|
|
|
|
# ## function to append in a menu
|
|
# def palette_manager_menu(self, context):
|
|
# """Palette menu to append in existing menu"""
|
|
# # GPENCIL_MT_material_context_menu
|
|
# layout = self.layout
|
|
# # {'EDIT_GPENCIL', 'PAINT_GPENCIL','SCULPT_GPENCIL','WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}
|
|
# layout.separator()
|
|
# prefs = get_addon_prefs()
|
|
|
|
# layout.operator("", text='do stuff from material submenu', icon='MATERIAL')
|
|
|
|
#-# REGISTER
|
|
|
|
classes=(
|
|
GPEXP_PT_gp_node_ui,
|
|
GPEXP_PT_gp_dopesheet_ui,
|
|
)
|
|
|
|
def register():
|
|
for cls in classes:
|
|
bpy.utils.register_class(cls)
|
|
bpy.types.DATA_PT_gpencil_layers.prepend(manager_ui)
|
|
|
|
def unregister():
|
|
bpy.types.DATA_PT_gpencil_layers.remove(manager_ui)
|
|
for cls in reversed(classes):
|
|
bpy.utils.unregister_class(cls) |