Commit: 5ed5c45e2077e57fb796ccade37e8d2f6665e54f
Author: Antonio Vazquez
Date:   Wed Jun 6 19:57:42 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB5ed5c45e2077e57fb796ccade37e8d2f6665e54f

WIP: Redesign Fill Material Panel and options

- Change the Pattern style as an option inside Texture.
- Define only a gradient type with Linear or Radial modes.

Still the panels are not working with the right options by mode.

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

M       release/scripts/startup/bl_ui/properties_material_gpencil.py
M       source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M       source/blender/draw/engines/gpencil/gpencil_engine.c
M       source/blender/makesdna/DNA_material_types.h
M       source/blender/makesrna/intern/rna_material.c

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

diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py 
b/release/scripts/startup/bl_ui/properties_material_gpencil.py
index 824e181e02a..f18230a85e7 100644
--- a/release/scripts/startup/bl_ui/properties_material_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py
@@ -163,9 +163,9 @@ class 
MATERIAL_PT_gpencil_strokecolor(GPMaterialButtonsPanel, Panel):
                 col = row.column(align=True)
                 col.template_ID(gpcolor, "stroke_image", open="image.open")
                 col.prop(gpcolor, "pixel_size", text="UV Factor")
-                col.prop(gpcolor, "use_pattern", text="Use As Pattern")
+                col.prop(gpcolor, "use_stroke_pattern", text="Use As Pattern")
 
-            if gpcolor.stroke_style == 'SOLID' or gpcolor.use_pattern is True:
+            if gpcolor.stroke_style == 'SOLID' or gpcolor.use_stroke_pattern 
is True:
                 col.prop(gpcolor, "color", text="Color")
 
             # Options
@@ -185,60 +185,50 @@ class 
MATERIAL_PT_gpencil_fillcolor(GPMaterialButtonsPanel, Panel):
             gpcolor = ma.grease_pencil
 
             # color settings
-            split = layout.split(percentage=1.0)
-            split.active = not gpcolor.lock
-
-            row = layout.row()
-            col = row.column(align=True)
-            col.enabled = not gpcolor.lock
+            col = layout.column()
+            col.active = not gpcolor.lock
             col.prop(gpcolor, "fill_style", text="Style")
-
-            row = layout.row()
-            col = row.column(align=True)
+            if gpcolor.fill_style == 'GRADIENT':
+                col.prop(gpcolor, "gradient_type")
 
             if gpcolor.fill_style != 'TEXTURE':
                 col.prop(gpcolor, "fill_color", text="Color")
-                col.separator()
-                if gpcolor.texture_mix is True or gpcolor.fill_style in 
('GRADIENT', 'RADIAL'):
+                if gpcolor.texture_mix is True or gpcolor.fill_style == 
'GRADIENT':
                     col.prop(gpcolor, "mix_factor", text="Mix", slider=True)
 
-            if gpcolor.fill_style in ('GRADIENT', 'RADIAL', 'CHESSBOARD'):
+            if gpcolor.fill_style in ('GRADIENT', 'CHESSBOARD'):
                 if gpcolor.texture_mix is False or gpcolor.fill_style == 
'CHESSBOARD':
                     col.prop(gpcolor, "mix_color", text="Mix Color")
-                split = col.split(percentage=0.5)
-                subcol = split.column(align=True)
-                subcol.prop(gpcolor, "pattern_shift", text="Location")
-                subrow = subcol.row(align=True)
-                if gpcolor.fill_style == 'RADIAL':
+                col.prop(gpcolor, "flip", text="Flip Colors")
+
+                col.prop(gpcolor, "pattern_shift", text="Location")
+
+                subrow = col.row(align=True)
+                if gpcolor.gradient_type == 'RADIAL':
                     subrow.enabled = False
                 subrow.prop(gpcolor, "pattern_angle", text="Angle")
-                subcol.prop(gpcolor, "flip", text="Flip")
 
-                subcol = split.column(align=True)
-                subcol.prop(gpcolor, "pattern_scale", text="Scale")
-                subrow = subcol.row(align=True)
-                if gpcolor.fill_style != 'RADIAL':
-                    subrow.enabled = False
-                subrow.prop(gpcolor, "pattern_radius", text="Radius")
-                subrow = subcol.row(align=True)
+                col.prop(gpcolor, "pattern_scale", text="Scale")
+                if gpcolor.gradient_type != 'RADIAL':
+                    col.prop(gpcolor, "pattern_radius", text="Radius")
+
+                subrow = col.row(align=True)
                 if gpcolor.fill_style != 'CHESSBOARD':
                     subrow.enabled = False
                 subrow.prop(gpcolor, "pattern_boxsize", text="Box")
 
-            col.separator()
-            col.label("Texture")
-            if gpcolor.fill_style not in ('TEXTURE', 'PATTERN'):
+            if gpcolor.fill_style == 'SOLID':
                 col.prop(gpcolor, "texture_mix", text="Mix Texture")
-            if gpcolor.fill_style in ('TEXTURE', 'PATTERN') or 
gpcolor.texture_mix is True:
+
+            if gpcolor.fill_style == 'TEXTURE' or gpcolor.texture_mix is True:
                 col.template_ID(gpcolor, "fill_image", open="image.open")
-                split = col.split(percentage=0.5)
-                subcol = split.column(align=True)
-                subcol.prop(gpcolor, "texture_offset", text="Offset")
-                subcol.prop(gpcolor, "texture_angle")
-                subcol.prop(gpcolor, "texture_clamp", text="Clip Image")
-                subcol = split.column(align=True)
-                subcol.prop(gpcolor, "texture_scale", text="Scale")
-                subcol.prop(gpcolor, "texture_opacity")
+                col.prop(gpcolor, "use_fill_pattern", text="Use As Pattern")
+
+                col.prop(gpcolor, "texture_offset", text="Offset")
+                col.prop(gpcolor, "texture_scale", text="Scale")
+                col.prop(gpcolor, "texture_angle")
+                col.prop(gpcolor, "texture_opacity")
+                col.prop(gpcolor, "texture_clamp", text="Clip Image")
 
 
 classes = (
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index b33fcf42564..73287b564ea 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -53,6 +53,14 @@
 
 #include "gpencil_engine.h"
 
+/* fill type to communicate to shader */
+#define SOLID 0
+#define GRADIENT 1
+#define RADIAL 2
+#define CHESS 3
+#define TEXTURE 4
+#define PATTERN 5
+
 /* Helper for doing all the checks on whether a stroke can be drawn */
 static bool gpencil_can_draw_stroke(struct MaterialGPencilStyle *gp_style, 
const bGPDstroke *gps, const bool onion)
 {
@@ -261,8 +269,37 @@ static DRWShadingGroup *DRW_gpencil_shgroup_fill_create(
        DRWShadingGroup *grp = DRW_shgroup_create(shader, pass);
 
        DRW_shgroup_uniform_vec4(grp, "color2", gp_style->mix_rgba, 1);
-       stl->shgroups[id].fill_style = gp_style->fill_style;
+
+       /* set styil�e type */
+       switch (gp_style->fill_style) {
+               case GP_STYLE_FILL_STYLE_SOLID:
+                       stl->shgroups[id].fill_style = SOLID;
+                       break;
+               case GP_STYLE_FILL_STYLE_GRADIENT:
+                       if (gp_style->gradient_type == 
GP_STYLE_GRADIENT_LINEAR) {
+                               stl->shgroups[id].fill_style = GRADIENT;
+                       }
+                       else {
+                               stl->shgroups[id].fill_style = RADIAL;
+                       }
+                       break;
+               case GP_STYLE_FILL_STYLE_CHESSBOARD:
+                       stl->shgroups[id].fill_style = CHESS;
+                       break;
+               case GP_STYLE_FILL_STYLE_TEXTURE:
+                       if (gp_style->flag & GP_STYLE_FILL_PATTERN) {
+                               stl->shgroups[id].fill_style = PATTERN;
+                       }
+                       else {
+                               stl->shgroups[id].fill_style = TEXTURE;
+                       }
+                       break;
+               default:
+                       stl->shgroups[id].fill_style = 
GP_STYLE_FILL_STYLE_SOLID;
+                       break;
+       }
        DRW_shgroup_uniform_int(grp, "fill_type", 
&stl->shgroups[id].fill_style, 1);
+
        DRW_shgroup_uniform_float(grp, "mix_factor", &gp_style->mix_factor, 1);
 
        DRW_shgroup_uniform_float(grp, "gradient_angle", 
&gp_style->gradient_angle, 1);
@@ -285,7 +322,7 @@ static DRWShadingGroup *DRW_gpencil_shgroup_fill_create(
        DRW_shgroup_uniform_int(grp, "xraymode", (const int *) &gpd->xray_mode, 
1);
        /* image texture */
        if ((gp_style->flag & GP_STYLE_COLOR_TEX_MIX) ||
-           ELEM(gp_style->fill_style, GP_STYLE_FILL_STYLE_TEXTURE, 
GP_STYLE_FILL_STYLE_PATTERN))
+           (gp_style->fill_style & GP_STYLE_FILL_STYLE_TEXTURE))
        {
                ImBuf *ibuf;
                Image *image = gp_style->ima;
@@ -351,7 +388,7 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
                stl->shgroups[id].color_type = GPENCIL_COLOR_SOLID;
                if ((gp_style->stroke_style == GP_STYLE_STROKE_STYLE_TEXTURE) 
&& (!onion)) {
                        stl->shgroups[id].color_type = GPENCIL_COLOR_TEXTURE;
-                       if (gp_style->flag & GP_STYLE_COLOR_PATTERN) {
+                       if (gp_style->flag & GP_STYLE_STROKE_PATTERN) {
                                stl->shgroups[id].color_type = 
GPENCIL_COLOR_PATTERN;
                        }
                }
@@ -442,7 +479,7 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create(
                stl->shgroups[id].color_type = GPENCIL_COLOR_SOLID;
                if ((gp_style->stroke_style == GP_STYLE_STROKE_STYLE_TEXTURE) 
&& (!onion)) {
                        stl->shgroups[id].color_type = GPENCIL_COLOR_TEXTURE;
-                       if (gp_style->flag & GP_STYLE_COLOR_PATTERN) {
+                       if (gp_style->flag & GP_STYLE_STROKE_PATTERN) {
                                stl->shgroups[id].color_type = 
GPENCIL_COLOR_PATTERN;
                        }
                }
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 7f632f7c23f..6fe2f68aba8 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -312,7 +312,7 @@ void GPENCIL_cache_init(void *vedata)
                        stl->storage->color_type = GPENCIL_COLOR_SOLID;
                        if (gp_style->stroke_style == 
GP_STYLE_STROKE_STYLE_TEXTURE) {
                                stl->storage->color_type = 
GPENCIL_COLOR_TEXTURE;
-                               if (gp_style->flag & GP_STYLE_COLOR_PATTERN) {
+                               if (gp_style->flag & GP_STYLE_STROKE_PATTERN) {
                                        stl->storage->color_type = 
GPENCIL_COLOR_PATTERN;
                                }
                        }
diff --git a/source/blender/makesdna/DNA_material_types.h 
b/source/blender/makesdna/DNA_material_types.h
index 711a95df46e..0e5e154585a 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -86,10 +86,15 @@ typedef struct MaterialGPencilStyle {
        float texture_opacity;   /* texture opacity */
        float texture_pixsize;   /* pixel size for uv along the stroke */
        int mode;                /* drawing mode (line or dots) */
+
+       int gradient_type;       /* type of gradient */
+       char pad[4];
 } MaterialGPencilStyle;
 
 /* MaterialGPencilStyle->flag */
 typedef enum eMaterialGPencilStyle_Flag {
+       /* Fill Texture is a pattern */
+       GP_STYLE_FILL_PATTERN = (1 << 0),
        /* don't display color */
        GP_STYLE_COLOR_HIDE = (1 << 1),
        /* protected from further editing */
@@ -102,8 +107,8 @@ typedef enum eMaterialGPencilStyle_Flag {
        GP_STYLE_COLOR_TEX_MIX = (1 << 5),
        /* Flip fill colors */
        GP_STYLE_COLOR_FLIP_FILL = (1 << 6),
-       /* Texture is a pattern */
-       GP_STYL

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to