diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2020-09-22 21:11:02 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2020-09-22 21:11:28 +0300 |
commit | 88970e3900f32d43cadd0f3b6809e71771612379 (patch) | |
tree | 50533757968c7cfd4b9c1bbb2bafcd2ed3fd2ff2 /source/blender/makesrna/intern/rna_brush.c | |
parent | dab50ad7183458aa5ad5b982097da844397be3d9 (diff) |
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
Diffstat (limited to 'source/blender/makesrna/intern/rna_brush.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_brush.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 675a46f48d1..1f5aaabe59f 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -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); |