gp_render/ui.py

63 lines
2.1 KiB
Python
Raw Normal View History

2021-09-07 23:11:42 +02:00
import bpy
from bpy.types import Panel
# from .preferences import get_addon_prefs
# 3D view panel
class GPEXP_PT_gp_node_ui(Panel):
bl_space_type = "NODE_EDITOR" # "VIEW_3D"
bl_region_type = "UI"
bl_category = "Item"
bl_label = "Gpencil Render Manager"
def draw(self, context):
layout = self.layout
layout.operator('gp.clear_render_tree', icon='X', text='Full Clear Render Tree')
# 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')
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
layout.operator('gp.add_object_to_render', icon='RENDERLAYERS', text='Selected Object To Render').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,
)
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)