Files
test2/scripts/startup/bl_ui/properties_data_grease_pencil.py
Falk David b3f3b41d09 GPv3: Initial Layer Tree UI
Adds a new UI template to view the current layer tree of the active Grease Pencil object.

This UI tree view implements the following features (for now):
 - Displaying all the layers with their names and highlighting the active layer.
 - Changing the active layer by clicking on an item.
 - Adding new layers (using a new operator).
 - Removing the active layer (using a new operator).
 - Renaming a layer.

Pull Request: https://projects.blender.org/blender/blender/pulls/109197
2023-06-22 10:51:43 +02:00

57 lines
1.4 KiB
Python

# SPDX-FileCopyrightText: 2023 Blender Foundation
#
# SPDX-License-Identifier: GPL-2.0-or-later
import bpy
from bpy.types import Panel
class DataButtonsPanel:
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"
@classmethod
def poll(cls, context):
return hasattr(context, "grease_pencil") and context.grease_pencil
class DATA_PT_context_grease_pencil(DataButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
def draw(self, context):
layout = self.layout
ob = context.object
grease_pencil = context.grease_pencil
space = context.space_data
if ob:
layout.template_ID(ob, "data")
elif grease_pencil:
layout.template_ID(space, "pin_id")
class DATA_PT_grease_pencil_layers(DataButtonsPanel, Panel):
bl_label = "Layers"
def draw(self, context):
layout = self.layout
row = layout.row()
row.template_grease_pencil_layer_tree()
col = row.column()
col.operator("grease_pencil.layer_add", icon='ADD', text="")
col.operator("grease_pencil.layer_remove", icon='REMOVE', text="")
classes = (
DATA_PT_context_grease_pencil,
DATA_PT_grease_pencil_layers,
)
if __name__ == "__main__": # only for live edit.
from bpy.utils import register_class
for cls in classes:
register_class(cls)