[Bf-blender-cvs] [debf38840bb] greasepencil-object: Replace Use Dots for a Enum menu

Antonio Vazquez noreply at git.blender.org
Sun Feb 25 11:17:21 CET 2018


Commit: debf38840bb8a36de6e7844f3c1504150c9e80b0
Author: Antonio Vazquez
Date:   Sat Feb 24 21:58:28 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rBdebf38840bb8a36de6e7844f3c1504150c9e80b0

Replace Use Dots for a Enum menu

Instead to define a checkbox, now the dots is a mode.

===================================================================

M	release/scripts/startup/bl_ui/properties_material_gpencil.py
M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesrna/intern/rna_palette.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py
index 2b5a683d964..79bdd57b5e0 100644
--- a/release/scripts/startup/bl_ui/properties_material_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py
@@ -146,6 +146,11 @@ class MATERIAL_PT_gpencil_palette_strokecolor(Panel):
         split.active = not pcolor.lock
 
         col = split.column(align=True)
+        row = col.row(align=True)
+        row.enabled = not pcolor.lock
+        row.prop(pcolor, "mode", expand=True)
+        col.separator()
+
         col.enabled = not pcolor.lock
         col.prop(pcolor, "stroke_style", text="")
 
@@ -162,10 +167,6 @@ class MATERIAL_PT_gpencil_palette_strokecolor(Panel):
             col.prop(pcolor, "color", text="")
             col.prop(pcolor, "alpha", slider=True)
 
-        row = layout.row(align=True)
-        row.enabled = not pcolor.lock
-        row.prop(pcolor, "use_dot", text="Dots")
-
         # Options
         row = layout.row()
         row.active = not pcolor.lock
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 9cb8758a17e..2c41f947112 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -589,7 +589,7 @@ static void gpencil_add_stroke_shgroup(GpencilBatchCache *cache, DRWShadingGroup
 	CLAMP_MIN(sthickness, 1);
 	if (cache->is_dirty) {
 		gpencil_batch_cache_check_free_slots(ob);
-		if ((gps->totpoints > 1) && ((gps->palcolor->flag & PAC_COLOR_DOT) == 0)) {
+		if ((gps->totpoints > 1) && (gps->palcolor->mode  == PAC_MODE_LINE)) {
 			cache->batch_stroke[cache->cache_idx] = DRW_gpencil_get_stroke_geom(gpf, gps, sthickness, ink);
 		}
 		else {
@@ -664,7 +664,7 @@ static void gpencil_draw_onion_strokes(GpencilBatchCache *cache, GPENCIL_e_data
 		}
 
 		stl->shgroups[id].shgrps_fill = NULL;
-		if ((gps->totpoints > 1) && ((gps->palcolor->flag & PAC_COLOR_DOT) == 0)) {
+		if ((gps->totpoints > 1) && (gps->palcolor->mode == PAC_MODE_LINE)) {
 			stl->shgroups[id].shgrps_stroke = DRW_gpencil_shgroup_stroke_create(e_data, vedata, psl->stroke_pass, e_data->gpencil_stroke_sh, ob, gpd, gps->palcolor, id);
 		}
 		else {
@@ -780,7 +780,7 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
 #endif
 		if ((gpl->actframe->framenum == derived_gpf->framenum) || (!is_multiedit) || ((gpd->flag & GP_DATA_STROKE_MULTIEDIT_LINES) == 0)) {
 			int id = stl->storage->shgroup_id;
-			if ((gps->totpoints > 1) && ((gps->palcolor->flag & PAC_COLOR_DOT) == 0)) {
+			if ((gps->totpoints > 1) && (gps->palcolor->mode == PAC_MODE_LINE)) {
 				if ((gps->totpoints > 2) && (!GP_SIMPLIFY_FILL(ts, playing)) && 
 					((gps->palcolor->fill[3] > GPENCIL_ALPHA_OPACITY_THRESH) || (gps->palcolor->fill_style > 0)) &&
 					((gps->flag & GP_STROKE_NOFILL) == 0))
@@ -871,7 +871,7 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
 			short lthick = brush->thickness * obscale;
 			/* if only one point, don't need to draw buffer because the user has no time to see it */
 			if (gpd->sbuffer_size > 1) {
-				if ((palcolor) && (palcolor->flag & PAC_COLOR_DOT) == 0) {
+				if ((palcolor) && (palcolor->mode == PAC_MODE_LINE)) {
 					stl->g_data->shgrps_drawing_stroke = DRW_gpencil_shgroup_stroke_create(e_data, vedata, psl->drawing_pass, e_data->gpencil_stroke_sh, NULL, gpd, palcolor, -1);
 				}
 				else {
@@ -879,7 +879,7 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
 				}
 
 				/* use unit matrix because the buffer is in screen space and does not need conversion */
-				if ((gpd->sflag & PAC_COLOR_DOT) == 0) {
+				if (gpd->mode == PAC_MODE_LINE) {
 					stl->g_data->batch_buffer_stroke = DRW_gpencil_get_buffer_stroke_geom(gpd, stl->storage->unit_matrix, lthick);
 				}
 				else {
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 796a956d69d..548e27f5fc7 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -1099,7 +1099,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
 					copy_v4_v4(ink, tcolor);
 				}
 			}
-			if (palcolor->flag & PAC_COLOR_DOT) {
+			if (palcolor->mode == PAC_MODE_DOTS) {
 				/* volumetric stroke drawing */
 				if (tgpw->disable_fill != 1) {
 					gp_draw_stroke_volumetric_3d(gps->points, gps->totpoints, sthickness, ink);
@@ -1167,7 +1167,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
 					copy_v4_v4(ink, tcolor);
 				}
 			}
-			if (palcolor->flag & PAC_COLOR_DOT) {
+			if (palcolor->mode == PAC_MODE_DOTS) {
 				/* blob/disk-based "volumetric" drawing */
 				gp_draw_stroke_volumetric_2d(gps->points, gps->totpoints, sthickness, tgpw->dflag, gps->flag,
 					tgpw->offsx, tgpw->offsy, tgpw->winx, tgpw->winy, tgpw->diff_mat, ink);
@@ -1663,7 +1663,7 @@ static void gp_draw_data_layers(RegionView3D *rv3d,
 			 * It should also be noted that sbuffer contains temporary point types
 			 * i.e. tGPspoints NOT bGPDspoints
 			 */
-			if (gpd->sflag & PAC_COLOR_DOT) {
+			if (gpd->mode == PAC_MODE_DOTS) {
 				gp_draw_stroke_volumetric_buffer(gpd->sbuffer, gpd->sbuffer_size, lthick,
 				                                 dflag, gpd->scolor);
 			}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 59dd2823d2b..b76155a2544 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1453,7 +1453,7 @@ static void gp_init_palette(tGPsdata *p)
 			gpd->sfill[3] = 0.8f;
 		}
 
-		gpd->sflag = palcolor->flag;
+		gpd->mode = palcolor->mode;
 		gpd->bstroke_style = palcolor->stroke_style;
 		gpd->bfill_style = palcolor->fill_style;
 	}
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 53ede5e99f5..df0d8808af9 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -167,6 +167,8 @@ typedef struct PaletteColor {
 	float t_offset[2];       /* factor to shift texture in 2d space */
 	float t_opacity;         /* texture opacity */
 	float t_pixsize;         /* pixel size for uv along the stroke */
+	int mode;                /* drawing mode (line or dots) */
+	char pad[4];
 } PaletteColor;
 
 /* PaletteColor->flag (mainly used by grease pencil) */
@@ -184,11 +186,16 @@ typedef enum ePaletteColor_Flag {
 	/* Flip fill colors */
 	PAC_COLOR_FLIP_FILL = (1 << 6),
 	/* Stroke use Dots */
-	PAC_COLOR_DOT = (1 << 7),
+	/* PAC_COLOR_DOT = (1 << 7), DEPRECATED*
 	/* Texture is a pattern */
 	PAC_COLOR_PATTERN = (1 << 8)
 } ePaletteColor_Flag;
 
+typedef enum ePaletteColor_Mode {
+	PAC_MODE_LINE = 0, /* line */
+	PAC_MODE_DOTS = 1, /* dots */
+} ePaletteColor_Mode;
+
 typedef struct Palette {
 	ID id;
 	struct AnimData *adt;   /* animation data - for animating draw settings */
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 640aaac3fc5..76a85b3c5b7 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -419,7 +419,7 @@ typedef struct bGPdata {
 	void *sbuffer;				/* stroke buffer (can hold GP_STROKE_BUFFER_MAX) */
 	float scolor[4];            /* buffer color using palettes */
 	float sfill[4];             /* buffer fill color */
-	short sflag;                /* settings for palette color */
+	short mode;                 /* settings for palette color */
 	short bstroke_style;        /* buffer style for drawing strokes (used to select shader type) */
 	short bfill_style;          /* buffer style for filling areas (used to select shader type) */
 
diff --git a/source/blender/makesrna/intern/rna_palette.c b/source/blender/makesrna/intern/rna_palette.c
index bbe4298f7a3..4212418a114 100644
--- a/source/blender/makesrna/intern/rna_palette.c
+++ b/source/blender/makesrna/intern/rna_palette.c
@@ -232,6 +232,13 @@ static void rna_def_palettecolor(BlenderRNA *brna)
 	StructRNA *srna;
 	PropertyRNA *prop;
 
+	/* mode type styles */
+	static EnumPropertyItem palettecolor_mode_types_items[] = {
+		{ PAC_MODE_LINE, "LINE", 0, "Line", "Draw strokes using a continuous line" },
+		{ PAC_MODE_DOTS, "DOTS", 0, "Dots", "Draw strokes using separated dots" },
+		{ 0, NULL, 0, NULL, NULL }
+	};
+
 	/* stroke styles */
 	static EnumPropertyItem stroke_style_items[] = {
 		{ STROKE_STYLE_SOLID, "SOLID", 0, "Solid", "Draw strokes with solid color" },
@@ -433,11 +440,6 @@ static void rna_def_palettecolor(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Flip", "Flip filling colors");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_Palette_dependency_update");
 
-	prop = RNA_def_property(srna, "use_dot", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "flag", PAC_COLOR_DOT);
-	RNA_def_property_ui_text(prop, "Use Dots", "Draw stroke using dots instead of lines");
-	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_Palette_dependency_update");
-
 	prop = RNA_def_property(srna, "use_pattern", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", PAC_COLOR_PATTERN);
 	RNA_def_property_ui_text(prop, "Pattern", "Texture is a pattern to apply color");
@@ -449,6 +451,13 @@ static void rna_def_palettecolor(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Pass Index", "Index number for the \"Color Index\" pass");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_Palette_dependency_update");
 
+	/* mode type */
+	prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
+	RNA_def_property_enum_items(prop, palettecolor_mode_types_items);
+	RNA_def_property_ui_text(prop, "Mode Type", "Select draw mode for stroke");
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_Palette_dependency_update");
+
 	/* stroke style */
 	prop = RNA_def_property(srna, "stroke_style", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_bitflag_sdna(prop, NU

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list