GPv3: Make the Remove button work with groups.

This makes the `remove` delete groups when active.
The items inside of the group will not be deleted (i.e. `ungroup`)

Pull Request: https://projects.blender.org/blender/blender/pulls/128002
This commit is contained in:
casey bianco-davis
2024-09-27 16:39:59 +02:00
committed by Falk David
parent 85e4bd19f6
commit a75259fa14

View File

@@ -219,6 +219,8 @@ class DATA_PT_grease_pencil_layers(DataButtonsPanel, Panel):
@classmethod
def draw_settings(cls, layout, grease_pencil):
layer = grease_pencil.layers.active
is_layer_active = layer is not None
is_group_active = grease_pencil.layer_groups.active is not None
row = layout.row()
row.template_grease_pencil_layer_tree()
@@ -230,7 +232,10 @@ class DATA_PT_grease_pencil_layers(DataButtonsPanel, Panel):
sub.operator("grease_pencil.layer_group_add", icon='NEWFOLDER', text="")
sub.separator()
sub.operator("grease_pencil.layer_remove", icon='REMOVE', text="")
if is_layer_active:
sub.operator("grease_pencil.layer_remove", icon='REMOVE', text="")
if is_group_active:
sub.operator("grease_pencil.layer_group_remove", icon='REMOVE', text="").keep_children = True
sub.separator()
@@ -242,7 +247,9 @@ class DATA_PT_grease_pencil_layers(DataButtonsPanel, Panel):
sub.operator("grease_pencil.layer_move", icon='TRIA_UP', text="").direction = 'UP'
sub.operator("grease_pencil.layer_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
if not layer:
sub.menu("GREASE_PENCIL_MT_grease_pencil_add_layer_extra", icon='DOWNARROW_HLT', text="")
if not is_layer_active:
return
layout.use_property_split = True