[Bf-blender-cvs] [89b30af4b2d] greasepencil-object: GPencil: Replace Vertex Color ON/OFF by Enum
Antonio Vazquez
noreply at git.blender.org
Wed Feb 26 19:46:59 CET 2020
Commit: 89b30af4b2d9cf50dafe90752573d4a1d445a225
Author: Antonio Vazquez
Date: Wed Feb 26 19:46:51 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rB89b30af4b2d9cf50dafe90752573d4a1d445a225
GPencil: Replace Vertex Color ON/OFF by Enum
The old switch looked that disable the colors instead to change of mode.
===================================================================
M release/scripts/startup/bl_ui/space_view3d.py
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/blenkernel/BKE_gpencil.h
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index ff2a4eb264d..084329e2950 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -433,12 +433,10 @@ class _draw_tool_settings_context_mode:
row.prop(gp_settings, "use_material_pin", text="")
if brush.gpencil_tool in {'DRAW', 'FILL'} and ma:
- gp_style = ma.grease_pencil
- row.separator(factor=0.4)
- row.prop(settings, "use_vertex_color", text="",
- icon='CHECKBOX_HLT' if settings.use_vertex_color else 'CHECKBOX_DEHLT')
+ row.separator(factor=1.0)
+ row.prop(settings, "use_vertex_color", text="", expand=True)
sub_row = row.row(align=True)
- sub_row.enabled = settings.use_vertex_color
+ sub_row.enabled = settings.use_vertex_color == 'VERTEXCOLOR'
sub_row.prop(brush, "color", text="")
sub_row.popover(
panel="TOPBAR_PT_gpencil_vertexcolor",
@@ -6864,7 +6862,7 @@ class VIEW3D_PT_gpencil_draw_context_menu(Panel):
layout = self.layout
- if brush.gpencil_tool not in {'ERASE', 'CUTTER', 'EYEDROPPER'} and settings.use_vertex_color:
+ if brush.gpencil_tool not in {'ERASE', 'CUTTER', 'EYEDROPPER'} and settings.use_vertex_color == 'VERTEXCOLOR':
split = layout.split(factor=0.1)
split.prop(brush, "color", text="")
split.template_color_picker(brush, "color", value_slider=True)
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index b3c4204fda8..3bf17fc1cdd 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -2110,6 +2110,9 @@ class VIEW3D_PT_tools_grease_pencil_brush_mixcolor(View3DPanel, Panel):
if ob is None or brush is None:
return False
+ if settings.use_vertex_color != 'VERTEXCOLOR':
+ return False
+
if context.region.type == 'TOOL_HEADER':
return False
@@ -2129,15 +2132,6 @@ class VIEW3D_PT_tools_grease_pencil_brush_mixcolor(View3DPanel, Panel):
return True
- def draw_header(self, context):
- ts = context.tool_settings
- settings = ts.gpencil_paint
- brush = settings.brush
-
- if brush.gpencil_tool != 'TINT':
- self.layout.prop(settings, "use_vertex_color", text="",
- toggle=False)
-
def draw(self, context):
layout = self.layout
layout.use_property_split = True
@@ -2148,7 +2142,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_mixcolor(View3DPanel, Panel):
gp_settings = brush.gpencil_settings
col = layout.column()
- col.enabled = settings.use_vertex_color or brush.gpencil_tool == 'TINT'
+ col.enabled = settings.use_vertex_color == 'VERTEXCOLOR' or brush.gpencil_tool == 'TINT'
if brush.gpencil_tool in {'DRAW', 'FILL'}:
col.prop(gp_settings, "vertex_mode", text="Mode")
@@ -2208,7 +2202,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_mix_palette(View3DPanel, Panel):
brush = settings.brush
col = layout.column()
- col.enabled = settings.use_vertex_color or brush.gpencil_tool == 'TINT'
+ col.enabled = settings.use_vertex_color == 'VERTEXCOLOR' or brush.gpencil_tool == 'TINT'
row = col.row(align=True)
row.template_ID(settings, "palette", new="palette.new")
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 646ab481f92..78b414bdd32 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -65,7 +65,7 @@ struct MDeformVert;
/* Vertex Color macros. */
#define GPENCIL_USE_VERTEX_COLOR(toolsettings) \
- ((toolsettings->gp_paint->flag & GPPAINT_FLAG_USE_VERTEXCOLOR))
+ ((toolsettings->gp_paint->mode == GPPAINT_FLAG_USE_VERTEXCOLOR))
#define GPENCIL_USE_VERTEX_COLOR_STROKE(toolsettings, brush) \
((GPENCIL_USE_VERTEX_COLOR(toolsettings) && \
((brush->gpencil_settings->vertex_mode == GPPAINT_MODE_STROKE) || \
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 95a45aa231b..890faa45e01 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1000,13 +1000,14 @@ typedef struct UvSculpt {
typedef struct GpPaint {
Paint paint;
int flag;
- char _pad[4];
+ /* Mode of paint (Materials or Vertex Color). */
+ int mode;
} GpPaint;
/* GpPaint.flag */
enum {
- /* weight paint only */
- GPPAINT_FLAG_USE_VERTEXCOLOR = (1 << 0),
+ GPPAINT_FLAG_USE_MATERIAL = 0,
+ GPPAINT_FLAG_USE_VERTEXCOLOR = 1,
};
/* Grease pencil vertex paint. */
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 3edb060071f..bca9d997fdf 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -82,6 +82,20 @@ static const EnumPropertyItem rna_enum_gpencil_lock_axis_items[] = {
"Align strokes to current 3D cursor orientation"},
{0, NULL, 0, NULL, NULL},
};
+
+static const EnumPropertyItem rna_enum_gpencil_paint_mode[] = {
+ {GPPAINT_FLAG_USE_MATERIAL,
+ "MATERIAL",
+ ICON_MATERIAL,
+ "Material",
+ "Paint using the active material base color"},
+ {GPPAINT_FLAG_USE_VERTEXCOLOR,
+ "VERTEXCOLOR",
+ ICON_VPAINT_HLT,
+ "Vertex Color",
+ "Paint the material with custom vertex color"},
+ {0, NULL, 0, NULL, NULL},
+};
#endif
const EnumPropertyItem rna_enum_symmetrize_direction_items[] = {
@@ -846,9 +860,10 @@ static void rna_def_gp_paint(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Grease Pencil Paint", "");
/* Use vertex color (main swith). */
- prop = RNA_def_property(srna, "use_vertex_color", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GPPAINT_FLAG_USE_VERTEXCOLOR);
- RNA_def_property_ui_text(prop, "Use Vertex Color", "Use Vertex Color to manage colors");
+ prop = RNA_def_property(srna, "use_vertex_color", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "mode");
+ RNA_def_property_enum_items(prop, rna_enum_gpencil_paint_mode);
+ RNA_def_property_ui_text(prop, "Mode", "Paint Mode");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
}
More information about the Bf-blender-cvs
mailing list