GPencil: New Brush option to define Caps type

This is used to set the default caps type for the stroke. Before always was rounded and only could be changed later in Edit mode

Two new buttons has been added to topbar.

NOTE: New icons are been designed (T90414)

The buttons are expanded to list in Properties panel.

Reviewed By: mendio, HooglyBoogly

Differential Revision: https://developer.blender.org/D11999
This commit is contained in:
Antonio Vazquez 2021-08-04 15:54:54 +02:00
parent 145270d8d7
commit c1730ed165
6 changed files with 30 additions and 1 deletions

View File

@ -1252,6 +1252,12 @@ def brush_basic_gpencil_paint_settings(layout, context, brush, *, compact=False)
if brush.gpencil_tool == 'TINT':
row = layout.row(align=True)
row.prop(gp_settings, "vertex_mode", text="Mode")
else:
row = layout.row(align=True)
if context.region.type == 'TOOL_HEADER':
row.prop(gp_settings, "caps_type", text="", expand=True)
else:
row.prop(gp_settings, "caps_type", text="Caps Type")
# FIXME: tools must use their own UI drawing!
if tool.idname in {

View File

@ -552,6 +552,9 @@ bGPDstroke *DRW_cache_gpencil_sbuffer_stroke_data_get(Object *ob)
gps->caps[0] = gps->caps[1] = GP_STROKE_CAP_ROUND;
gps->runtime.stroke_start = 1; /* Add one for the adjacency index. */
copy_v4_v4(gps->vert_color_fill, gpd->runtime.vert_color_fill);
/* Caps. */
gps->caps[0] = gps->caps[1] = brush->gpencil_settings->caps_type;
gpd->runtime.sbuffer_gps = gps;
}
return gpd->runtime.sbuffer_gps;

View File

@ -996,6 +996,9 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
gps->inittime = p->inittime;
gps->uv_scale = 1.0f;
/* Set stroke caps. */
gps->caps[0] = gps->caps[1] = brush->gpencil_settings->caps_type;
/* allocate enough memory for a continuous array for storage points */
const int subdivide = brush->gpencil_settings->draw_subdivide;

View File

@ -335,6 +335,9 @@ static void gpencil_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi)
gps->uv_scale = 1.0f;
gps->inittime = 0.0f;
/* Set stroke caps. */
gps->caps[0] = gps->caps[1] = brush->gpencil_settings->caps_type;
/* Apply the vertex color to fill. */
ED_gpencil_fill_vertex_color_set(ts, brush, gps);

View File

@ -76,7 +76,9 @@ typedef struct BrushGpencilSettings {
float fill_threshold;
/** Number of pixel to consider the leak is too small (x 2). */
short fill_leak;
char _pad2[2];
/* Type of caps: eGPDstroke_Caps. */
int8_t caps_type;
char _pad;
int flag2;

View File

@ -1281,6 +1281,12 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
static EnumPropertyItem rna_enum_gpencil_brush_caps_types_items[] = {
{GP_STROKE_CAP_ROUND, "ROUND", ICON_HANDLETYPE_AUTO_CLAMP_VEC, "Round", ""},
{GP_STROKE_CAP_FLAT, "FLAT", ICON_HANDLETYPE_VECTOR_VEC, "Flat", ""},
{0, NULL, 0, NULL, NULL},
};
srna = RNA_def_struct(brna, "BrushGpencilSettings", NULL);
RNA_def_struct_sdna(srna, "BrushGpencilSettings");
RNA_def_struct_path_func(srna, "rna_BrushGpencilSettings_path");
@ -1750,6 +1756,12 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_update(
prop, NC_GPENCIL | ND_DATA, "rna_BrushGpencilSettings_eraser_mode_update");
prop = RNA_def_property(srna, "caps_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "caps_type");
RNA_def_property_enum_items(prop, rna_enum_gpencil_brush_caps_types_items);
RNA_def_property_ui_text(prop, "Caps Type", "The shape of the start and end of the stroke");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "fill_draw_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "fill_draw_mode");
RNA_def_property_enum_items(prop, rna_enum_gpencil_fill_draw_modes_items);