GPv3: Opacity modifier #116946

Merged
Lukas Tönne merged 52 commits from LukasTonne/blender:gp3-opacity-modifier into main 2024-01-16 16:56:22 +01:00
2 changed files with 40 additions and 4 deletions
Showing only changes of commit ca2413e91d - Show all commits

View File

@ -7614,6 +7614,14 @@ static void rna_def_modifier_grease_pencil_opacity(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
static const EnumPropertyItem color_mode_items[] = {
{MOD_GREASE_PENCIL_COLOR_BOTH, "BOTH", 0, "Stroke & Fill", "Modify fill and stroke colors"},
{MOD_GREASE_PENCIL_COLOR_STROKE, "STROKE", 0, "Stroke", "Modify stroke color only"},
{MOD_GREASE_PENCIL_COLOR_FILL, "FILL", 0, "Fill", "Modify fill color only"},
{MOD_GREASE_PENCIL_COLOR_HARDNESS, "HARDNESS", 0, "Hardness", "Modify stroke hardness"},
{0, nullptr, 0, nullptr, nullptr},
};
srna = RNA_def_struct(brna, "GreasePencilOpacityModifier", "Modifier");
RNA_def_struct_ui_text(srna, "Grease Pencil Opacity Modifier", "");
RNA_def_struct_sdna(srna, "GreasePencilOpacityModifierData");
@ -7635,6 +7643,11 @@ static void rna_def_modifier_grease_pencil_opacity(BlenderRNA *brna)
RNA_define_lib_overridable(true);
prop = RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, color_mode_items);
RNA_def_property_ui_text(prop, "Color Mode", "Attributes to modify");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, nullptr, "color_factor");
RNA_def_property_ui_range(prop, 0, 2.0, 0.1, 2);

View File

@ -268,6 +268,33 @@ static void panel_draw(const bContext *C, Panel *panel)
PointerRNA ob_ptr;
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
uiLayoutSetPropSep(layout, true);
const GreasePencilModifierColorMode color_mode = GreasePencilModifierColorMode(
RNA_enum_get(ptr, "color_mode"));
uiItemR(layout, ptr, "color_mode", UI_ITEM_NONE, nullptr, ICON_NONE);
if (color_mode == MOD_GREASE_PENCIL_COLOR_HARDNESS) {
uiItemR(layout, ptr, "hardness_factor", UI_ITEM_NONE, nullptr, ICON_NONE);
}
else {
const bool use_uniform_opacity = RNA_boolean_get(ptr, "use_uniform_opacity");
const bool use_weight_as_factor = RNA_boolean_get(ptr, "use_weight_as_factor");
uiItemR(layout, ptr, "use_uniform_opacity", UI_ITEM_NONE, nullptr, ICON_NONE);
const char *text = (use_uniform_opacity) ? IFACE_("Opacity") : IFACE_("Opacity Factor");
uiLayout *row = uiLayoutRow(layout, true);
uiLayoutSetActive(row, !use_weight_as_factor || use_uniform_opacity);
uiItemR(row, ptr, "color_factor", UI_ITEM_NONE, text, ICON_NONE);
if (!use_uniform_opacity) {
uiLayout *sub = uiLayoutRow(row, true);
uiLayoutSetActive(sub, true);
uiItemR(row, ptr, "use_weight_as_factor", UI_ITEM_NONE, "", ICON_MOD_VERTEX_WEIGHT);
}
}
if (uiLayout *influence_panel = uiLayoutPanel(
C, layout, "Influence", ptr, "open_influence_panel"))
{
@ -277,10 +304,6 @@ static void panel_draw(const bContext *C, Panel *panel)
greasepencil::draw_custom_curve_settings(C, influence_panel, ptr);
}
uiLayoutSetPropSep(layout, true);
// TODO
modifier_panel_end(layout, ptr);
}