GPv3: Layer properties in dopesheet n-panel
Display layer properties in n-panel of dopesheet (grease pencil mode). Draw code is moved inside separate classes then inherit them in actual panel drawing class to avoid copy pasting the code in two places (in layer properties panel and dopesheet side panel). Part of #110056 Pull Request: https://projects.blender.org/blender/blender/pulls/120606
This commit is contained in:
committed by
Falk David
parent
9041eef0b8
commit
6e137f957f
@@ -40,6 +40,94 @@ class GREASE_PENCIL_UL_masks(UIList):
|
||||
layout.prop(mask, "name", text="", emboss=False, icon_value=icon)
|
||||
|
||||
|
||||
class GreasePencil_LayerMaskPanel:
|
||||
def draw_header(self, context):
|
||||
ob = context.object
|
||||
grease_pencil = ob.data
|
||||
layer = grease_pencil.layers.active
|
||||
|
||||
self.layout.prop(layer, "use_masks", text="")
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
ob = context.object
|
||||
grease_pencil = ob.data
|
||||
layer = grease_pencil.layers.active
|
||||
|
||||
layout = self.layout
|
||||
layout.enabled = layer.use_masks
|
||||
|
||||
if not layer:
|
||||
return
|
||||
|
||||
rows = 4
|
||||
row = layout.row()
|
||||
col = row.column()
|
||||
col.template_list("GREASE_PENCIL_UL_masks", "", layer, "mask_layers", layer.mask_layers,
|
||||
"active_mask_index", rows=rows, sort_lock=True)
|
||||
|
||||
col = row.column(align=True)
|
||||
col.menu("GREASE_PENCIL_MT_layer_mask_add", icon='ADD', text="")
|
||||
col.operator("grease_pencil.layer_mask_remove", icon='REMOVE', text="")
|
||||
|
||||
col.separator()
|
||||
|
||||
sub = col.column(align=True)
|
||||
sub.operator("grease_pencil.layer_mask_reorder", icon='TRIA_UP', text="").direction = 'UP'
|
||||
sub.operator("grease_pencil.layer_mask_reorder", icon='TRIA_DOWN', text="").direction = 'DOWN'
|
||||
|
||||
|
||||
class GreasePencil_LayerTransformPanel:
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
|
||||
ob = context.object
|
||||
grease_pencil = ob.data
|
||||
layer = grease_pencil.layers.active
|
||||
layout.active = not layer.lock
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(layer, "translation")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(layer, "rotation")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(layer, "scale")
|
||||
|
||||
|
||||
class GreasPencil_LayerRelationsPanel:
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
|
||||
ob = context.object
|
||||
grease_pencil = ob.data
|
||||
layer = grease_pencil.layers.active
|
||||
layout.active = not layer.lock
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(layer, "parent", text="Parent")
|
||||
|
||||
if layer.parent and layer.parent.type == 'ARMATURE':
|
||||
row = layout.row(align=True)
|
||||
row.prop_search(layer, "parent_bone", layer.parent.data, "bones", text="Bone")
|
||||
|
||||
layout.separator()
|
||||
|
||||
col = layout.row(align=True)
|
||||
col.prop(layer, "pass_index")
|
||||
|
||||
col = layout.row(align=True)
|
||||
col.prop_search(layer, "viewlayer_render", context.scene, "view_layers", text="View Layer")
|
||||
|
||||
col = layout.row(align=True)
|
||||
# Only enable this property when a view layer is selected.
|
||||
col.enabled = bool(layer.viewlayer_render)
|
||||
col.prop(layer, "use_viewlayer_masks")
|
||||
|
||||
|
||||
class GREASE_PENCIL_MT_layer_mask_add(Menu):
|
||||
bl_label = "Add Mask"
|
||||
|
||||
@@ -143,101 +231,23 @@ class DATA_PT_grease_pencil_layers(DataButtonsPanel, Panel):
|
||||
row.prop(layer, "use_lights", text="Lights")
|
||||
|
||||
|
||||
class DATA_PT_grease_pencil_layer_masks(LayerDataButtonsPanel, Panel):
|
||||
class DATA_PT_grease_pencil_layer_masks(LayerDataButtonsPanel, GreasePencil_LayerMaskPanel, Panel):
|
||||
bl_label = "Masks"
|
||||
bl_parent_id = "DATA_PT_grease_pencil_layers"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
def draw_header(self, context):
|
||||
grease_pencil = context.grease_pencil
|
||||
layer = grease_pencil.layers.active
|
||||
|
||||
self.layout.prop(layer, "use_masks", text="")
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
grease_pencil = context.grease_pencil
|
||||
layer = grease_pencil.layers.active
|
||||
|
||||
layout = self.layout
|
||||
layout.enabled = layer.use_masks
|
||||
|
||||
if not layer:
|
||||
return
|
||||
|
||||
rows = 4
|
||||
row = layout.row()
|
||||
col = row.column()
|
||||
col.template_list("GREASE_PENCIL_UL_masks", "", layer, "mask_layers", layer.mask_layers,
|
||||
"active_mask_index", rows=rows, sort_lock=True)
|
||||
|
||||
col = row.column(align=True)
|
||||
col.menu("GREASE_PENCIL_MT_layer_mask_add", icon='ADD', text="")
|
||||
col.operator("grease_pencil.layer_mask_remove", icon='REMOVE', text="")
|
||||
|
||||
col.separator()
|
||||
|
||||
sub = col.column(align=True)
|
||||
sub.operator("grease_pencil.layer_mask_reorder", icon='TRIA_UP', text="").direction = 'UP'
|
||||
sub.operator("grease_pencil.layer_mask_reorder", icon='TRIA_DOWN', text="").direction = 'DOWN'
|
||||
|
||||
|
||||
class DATA_PT_grease_pencil_layer_transform(LayerDataButtonsPanel, Panel):
|
||||
class DATA_PT_grease_pencil_layer_transform(LayerDataButtonsPanel, GreasePencil_LayerTransformPanel, Panel):
|
||||
bl_label = "Transform"
|
||||
bl_parent_id = "DATA_PT_grease_pencil_layers"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
|
||||
grease_pencil = context.grease_pencil
|
||||
layer = grease_pencil.layers.active
|
||||
layout.active = not layer.lock
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(layer, "translation")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(layer, "rotation")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(layer, "scale")
|
||||
|
||||
|
||||
class DATA_PT_grease_pencil_layer_relations(LayerDataButtonsPanel, Panel):
|
||||
class DATA_PT_grease_pencil_layer_relations(LayerDataButtonsPanel, GreasPencil_LayerRelationsPanel, Panel):
|
||||
bl_label = "Relations"
|
||||
bl_parent_id = "DATA_PT_grease_pencil_layers"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
|
||||
grease_pencil = context.grease_pencil
|
||||
layer = grease_pencil.layers.active
|
||||
layout.active = not layer.lock
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(layer, "parent", text="Parent")
|
||||
|
||||
if layer.parent and layer.parent.type == 'ARMATURE':
|
||||
row = layout.row(align=True)
|
||||
row.prop_search(layer, "parent_bone", layer.parent.data, "bones", text="Bone")
|
||||
|
||||
layout.separator()
|
||||
|
||||
col = layout.row(align=True)
|
||||
col.prop(layer, "pass_index")
|
||||
|
||||
col = layout.row(align=True)
|
||||
col.prop_search(layer, "viewlayer_render", context.scene, "view_layers", text="View Layer")
|
||||
|
||||
col = layout.row(align=True)
|
||||
# Only enable this property when a view layer is selected.
|
||||
col.enabled = bool(layer.viewlayer_render)
|
||||
col.prop(layer, "use_viewlayer_masks")
|
||||
|
||||
|
||||
class DATA_PT_grease_pencil_onion_skinning(DataButtonsPanel, Panel):
|
||||
bl_label = "Onion Skinning"
|
||||
|
||||
@@ -17,6 +17,12 @@ from bl_ui.properties_grease_pencil_common import (
|
||||
GreasePencilLayerDisplayPanel,
|
||||
)
|
||||
|
||||
from bl_ui.properties_data_grease_pencil import (
|
||||
GreasePencil_LayerMaskPanel,
|
||||
GreasePencil_LayerTransformPanel,
|
||||
GreasPencil_LayerRelationsPanel,
|
||||
)
|
||||
|
||||
from rna_prop_ui import PropertyPanel
|
||||
|
||||
#######################################
|
||||
@@ -834,6 +840,26 @@ class LayersDopeSheetPanel:
|
||||
return False
|
||||
|
||||
|
||||
class GreasePencilLayersDopeSheetPanel:
|
||||
bl_space_type = 'DOPESHEET_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
bl_category = "View"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
st = context.space_data
|
||||
ob = context.object
|
||||
if st.mode != 'GPENCIL' or ob is None or ob.type != 'GREASEPENCIL':
|
||||
return False
|
||||
|
||||
grease_pencil = ob.data
|
||||
active_layer = grease_pencil.layers.active
|
||||
if active_layer:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
class DOPESHEET_PT_gpencil_mode(LayersDopeSheetPanel, Panel):
|
||||
# bl_space_type = 'DOPESHEET_EDITOR'
|
||||
# bl_region_type = 'UI'
|
||||
@@ -889,6 +915,53 @@ class DOPESHEET_PT_gpencil_layer_display(LayersDopeSheetPanel, GreasePencilLayer
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
|
||||
class DOPESHEET_PT_grease_pencil_mode(GreasePencilLayersDopeSheetPanel, Panel):
|
||||
bl_label = "Layer"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
layout.use_property_decorate = False
|
||||
|
||||
ob = context.object
|
||||
grease_pencil = ob.data
|
||||
active_layer = grease_pencil.layers.active
|
||||
|
||||
if active_layer:
|
||||
row = layout.row(align=True)
|
||||
row.prop(active_layer, "blend_mode", text="Blend")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(active_layer, "opacity", text="Opacity", slider=True)
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(active_layer, "use_lights", text="Lights")
|
||||
|
||||
|
||||
class DOPESHEET_PT_grease_pencil_layer_masks(GreasePencilLayersDopeSheetPanel, GreasePencil_LayerMaskPanel, Panel):
|
||||
bl_label = "Masks"
|
||||
bl_parent_id = "DOPESHEET_PT_grease_pencil_mode"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
|
||||
class DOPESHEET_PT_grease_pencil_layer_transform(
|
||||
GreasePencilLayersDopeSheetPanel,
|
||||
GreasePencil_LayerTransformPanel,
|
||||
Panel):
|
||||
bl_label = "Transform"
|
||||
bl_parent_id = "DOPESHEET_PT_grease_pencil_mode"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
|
||||
class DOPESHEET_PT_grease_pencil_layer_relations(
|
||||
GreasePencilLayersDopeSheetPanel,
|
||||
GreasPencil_LayerRelationsPanel,
|
||||
Panel):
|
||||
bl_label = "Relations"
|
||||
bl_parent_id = "DOPESHEET_PT_grease_pencil_mode"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
|
||||
classes = (
|
||||
DOPESHEET_HT_header,
|
||||
DOPESHEET_PT_proportional_edit,
|
||||
@@ -915,7 +988,11 @@ classes = (
|
||||
DOPESHEET_PT_gpencil_layer_relations,
|
||||
DOPESHEET_PT_gpencil_layer_display,
|
||||
DOPESHEET_PT_custom_props_action,
|
||||
DOPESHEET_PT_snapping
|
||||
DOPESHEET_PT_snapping,
|
||||
DOPESHEET_PT_grease_pencil_mode,
|
||||
DOPESHEET_PT_grease_pencil_layer_masks,
|
||||
DOPESHEET_PT_grease_pencil_layer_transform,
|
||||
DOPESHEET_PT_grease_pencil_layer_relations,
|
||||
)
|
||||
|
||||
if __name__ == "__main__": # only for live edit.
|
||||
|
||||
Reference in New Issue
Block a user