From 66968e37fad2108e2d3a16f3f0746ed33ac4f0e4 Mon Sep 17 00:00:00 2001 From: Falk David Date: Thu, 14 Mar 2024 14:05:29 +0100 Subject: [PATCH] GPv3: Add layer blend mode to the UI Adds the `blend_mode` property to RNA and exposes it in the UI. Note: This is not used by the renderer yet. Will be added in a following PR. Pull Request: https://projects.blender.org/blender/blender/pulls/119460 --- .../bl_ui/properties_data_grease_pencil.py | 19 ++++++++++++------- .../makesrna/intern/rna_grease_pencil.cc | 15 +++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/scripts/startup/bl_ui/properties_data_grease_pencil.py b/scripts/startup/bl_ui/properties_data_grease_pencil.py index fcc631171a9..1dc6cd79d0f 100644 --- a/scripts/startup/bl_ui/properties_data_grease_pencil.py +++ b/scripts/startup/bl_ui/properties_data_grease_pencil.py @@ -91,14 +91,19 @@ class DATA_PT_grease_pencil_layers(DataButtonsPanel, Panel): col.operator("grease_pencil.layer_remove", icon='REMOVE', text="") - # Layer main properties - if layer: - layout.use_property_split = True - layout.use_property_decorate = True - col = layout.column(align=True) + if not layer: + return - row = layout.row(align=True) - row.prop(layer, "opacity", text="Opacity", slider=True) + layout.use_property_split = True + layout.use_property_decorate = True + col = layout.column(align=True) + + # Layer main properties + row = layout.row(align=True) + row.prop(layer, "blend_mode", text="Blend Mode") + + row = layout.row(align=True) + row.prop(layer, "opacity", text="Opacity", slider=True) class DATA_PT_grease_pencil_layer_transform(LayerDataButtonsPanel, Panel): diff --git a/source/blender/makesrna/intern/rna_grease_pencil.cc b/source/blender/makesrna/intern/rna_grease_pencil.cc index 6fc7d2f0bf3..cac331333cf 100644 --- a/source/blender/makesrna/intern/rna_grease_pencil.cc +++ b/source/blender/makesrna/intern/rna_grease_pencil.cc @@ -236,6 +236,15 @@ static void rna_def_grease_pencil_layer(BlenderRNA *brna) static const float scale_defaults[3] = {1.0f, 1.0f, 1.0f}; + static const EnumPropertyItem rna_enum_layer_blend_modes_items[] = { + {GP_LAYER_BLEND_NONE, "REGULAR", 0, "Regular", ""}, + {GP_LAYER_BLEND_HARDLIGHT, "HARDLIGHT", 0, "Hard Light", ""}, + {GP_LAYER_BLEND_ADD, "ADD", 0, "Add", ""}, + {GP_LAYER_BLEND_SUBTRACT, "SUBTRACT", 0, "Subtract", ""}, + {GP_LAYER_BLEND_MULTIPLY, "MULTIPLY", 0, "Multiply", ""}, + {GP_LAYER_BLEND_DIVIDE, "DIVIDE", 0, "Divide", ""}, + {0, nullptr, 0, nullptr, nullptr}}; + srna = RNA_def_struct(brna, "GreasePencilLayer", nullptr); RNA_def_struct_sdna(srna, "GreasePencilLayer"); RNA_def_struct_ui_text(srna, "Grease Pencil Layer", "Collection of related drawings"); @@ -332,6 +341,12 @@ static void rna_def_grease_pencil_layer(BlenderRNA *brna) prop, "ViewLayer", "Only include Layer in this View Layer render output (leave blank to include always)"); + + prop = RNA_def_property(srna, "blend_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, nullptr, "blend_mode"); + RNA_def_property_enum_items(prop, rna_enum_layer_blend_modes_items); + RNA_def_property_ui_text(prop, "Blend Mode", "Blend mode"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_grease_pencil_update"); } static void rna_def_grease_pencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop)