GPencil: Improve default brush draw mode
Mainly a UI adjustment, no functional changes To have the default mode in the advanced panel as separated option is not the best solution. Now, there is a pin option and when it is enabled, the brush keeps this mode. Differential Revision: https://developer.blender.org/D8974
This commit is contained in:
parent
dab50ad718
commit
88970e3900
|
@ -1148,11 +1148,19 @@ def brush_basic__draw_color_selector(context, layout, brush, gp_settings, props)
|
|||
|
||||
if brush.gpencil_tool in {'DRAW', 'FILL'}:
|
||||
row.separator(factor=1.0)
|
||||
row.prop_enum(settings, "color_mode", 'MATERIAL', text="", icon='MATERIAL')
|
||||
row.prop_enum(settings, "color_mode", 'VERTEXCOLOR', text="", icon='VPAINT_HLT')
|
||||
sub_row = row.row(align=True)
|
||||
sub_row.enabled = settings.color_mode == 'VERTEXCOLOR'
|
||||
sub_row.enabled = not gp_settings.pin_draw_mode
|
||||
if gp_settings.pin_draw_mode:
|
||||
sub_row.prop_enum(gp_settings, "brush_draw_mode", 'MATERIAL', text="", icon='MATERIAL')
|
||||
sub_row.prop_enum(gp_settings, "brush_draw_mode", 'VERTEXCOLOR', text="", icon='VPAINT_HLT')
|
||||
else:
|
||||
sub_row.prop_enum(settings, "color_mode", 'MATERIAL', text="", icon='MATERIAL')
|
||||
sub_row.prop_enum(settings, "color_mode", 'VERTEXCOLOR', text="", icon='VPAINT_HLT')
|
||||
|
||||
sub_row = row.row(align=True)
|
||||
sub_row.enabled = settings.color_mode == 'VERTEXCOLOR' or gp_settings.brush_draw_mode == 'VERTEXCOLOR'
|
||||
sub_row.prop_with_popover(brush, "color", text="", panel="TOPBAR_PT_gpencil_vertexcolor")
|
||||
row.prop(gp_settings, "pin_draw_mode", text="")
|
||||
|
||||
if props:
|
||||
row = layout.row(align=True)
|
||||
|
|
|
@ -1405,9 +1405,6 @@ class VIEW3D_PT_tools_grease_pencil_brush_advanced(View3DPanel, Panel):
|
|||
|
||||
col = layout.column(align=True)
|
||||
if brush is not None:
|
||||
col.prop(gp_settings, "brush_draw_mode")
|
||||
col.separator()
|
||||
|
||||
if brush.gpencil_tool != 'FILL':
|
||||
col.prop(gp_settings, "input_samples")
|
||||
col.separator()
|
||||
|
|
|
@ -971,6 +971,38 @@ static bool rna_BrushGpencilSettings_material_poll(PointerRNA *UNUSED(ptr), Poin
|
|||
return (ma->gp_style != NULL);
|
||||
}
|
||||
|
||||
static bool rna_GPencilBrush_pin_mode_get(PointerRNA *ptr)
|
||||
{
|
||||
Brush *brush = (Brush *)ptr->owner_id;
|
||||
if ((brush != NULL) && (brush->gpencil_settings != NULL)) {
|
||||
return (brush->gpencil_settings->brush_draw_mode != GP_BRUSH_MODE_ACTIVE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void rna_GPencilBrush_pin_mode_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
/* All data is set in update. Keep this function only to avoid RNA compilation errors. */
|
||||
return;
|
||||
}
|
||||
|
||||
static void rna_GPencilBrush_pin_mode_update(bContext *C, PointerRNA *ptr)
|
||||
{
|
||||
Brush *brush = (Brush *)ptr->owner_id;
|
||||
if ((brush != NULL) && (brush->gpencil_settings != NULL)) {
|
||||
if (brush->gpencil_settings->brush_draw_mode != GP_BRUSH_MODE_ACTIVE) {
|
||||
/* If not active, means that must be set to off. */
|
||||
brush->gpencil_settings->brush_draw_mode = GP_BRUSH_MODE_ACTIVE;
|
||||
}
|
||||
else {
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
brush->gpencil_settings->brush_draw_mode = GPENCIL_USE_VERTEX_COLOR(ts) ?
|
||||
GP_BRUSH_MODE_VERTEXCOLOR :
|
||||
GP_BRUSH_MODE_MATERIAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void rna_def_brush_texture_slot(BlenderRNA *brna)
|
||||
|
@ -1689,6 +1721,15 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Direction", "Direction of the fill");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
|
||||
prop = RNA_def_property(srna, "pin_draw_mode", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_funcs(
|
||||
prop, "rna_GPencilBrush_pin_mode_get", "rna_GPencilBrush_pin_mode_set");
|
||||
RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencilBrush_pin_mode_update");
|
||||
RNA_def_property_ui_text(prop, "Pin Mode", "Pin the mode to the brush");
|
||||
|
||||
prop = RNA_def_property(srna, "brush_draw_mode", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "brush_draw_mode");
|
||||
RNA_def_property_enum_items(prop, rna_enum_gpencil_brush_modes_items);
|
||||
|
|
Loading…
Reference in New Issue