[Bf-blender-cvs] [81d1840d7c7] greasepencil-object: GPencil: Fisrt steps to create new Tint Brush type

Antonio Vazquez noreply at git.blender.org
Sat Nov 2 17:24:48 CET 2019


Commit: 81d1840d7c70fbe7abcae73c261071faec8c6024
Author: Antonio Vazquez
Date:   Sat Nov 2 12:20:31 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB81d1840d7c70fbe7abcae73c261071faec8c6024

GPencil: Fisrt steps to create new Tint Brush type

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

M	release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py
M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
M	source/blender/editors/gpencil/gpencil_ops.c
M	source/blender/editors/screen/area.c
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesrna/intern/rna_brush.c

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

diff --git a/release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py b/release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py
index a98fa2c1fa8..211059bd850 100644
--- a/release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py
+++ b/release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py
@@ -194,6 +194,7 @@ _km_hierarchy = [
         ('Grease Pencil Stroke Paint (Draw brush)', 'EMPTY', 'WINDOW', []),
         ('Grease Pencil Stroke Paint (Fill)', 'EMPTY', 'WINDOW', []),
         ('Grease Pencil Stroke Paint (Erase)', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Paint (Tint)', 'EMPTY', 'WINDOW', []),
         ('Grease Pencil Stroke Paint Mode', 'EMPTY', 'WINDOW', []),
         ('Grease Pencil Stroke Sculpt Mode', 'EMPTY', 'WINDOW', []),
         ('Grease Pencil Stroke Weight Mode', 'EMPTY', 'WINDOW', []),
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 54ae00ba1b6..aeefd710337 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -3272,6 +3272,22 @@ def km_grease_pencil_stroke_paint_fill(_params):
     return keymap
 
 
+def km_grease_pencil_stroke_paint_tint(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Paint (Tint)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        # Tint
+        ("gpencil.tint", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+    ])
+
+    return keymap
+
+
 def km_grease_pencil_stroke_sculpt_mode(params):
     items = []
     keymap = (
@@ -6123,6 +6139,7 @@ def generate_keymaps(params=None):
         km_grease_pencil_stroke_paint_draw_brush(params),
         km_grease_pencil_stroke_paint_erase(params),
         km_grease_pencil_stroke_paint_fill(params),
+        km_grease_pencil_stroke_paint_tint(params),
         km_grease_pencil_stroke_sculpt_mode(params),
         km_grease_pencil_stroke_weight_mode(params),
         km_face_mask(params),
diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
index 49a394b478d..7d5250b85fe 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -2461,6 +2461,22 @@ def km_grease_pencil_stroke_paint_fill(params):
     return keymap
 
 
+def km_grease_pencil_stroke_paint_tint(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Paint (Tint)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        # Tint
+        ("gpencil.tint", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+    ])
+
+    return keymap
+
+
 def km_grease_pencil_stroke_sculpt_mode(params):
     items = []
     keymap = (
@@ -3790,6 +3806,7 @@ def generate_keymaps(params=None):
         km_grease_pencil_stroke_paint_draw_brush(params),
         km_grease_pencil_stroke_paint_erase(params),
         km_grease_pencil_stroke_paint_fill(params),
+        km_grease_pencil_stroke_paint_tint(params),
         km_grease_pencil_stroke_sculpt_mode(params),
         km_grease_pencil_stroke_weight_mode(params),
         km_face_mask(params),
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index 69b2d00aa68..2c8a1b2192f 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -113,6 +113,12 @@ static bool gp_stroke_paintmode_fill_poll(bContext *C)
   return gp_stroke_paintmode_poll_with_tool(C, GPAINT_TOOL_FILL);
 }
 
+/* Poll callback for stroke painting (tint) */
+static bool gp_stroke_paintmode_tint_poll(bContext *C)
+{
+  return gp_stroke_paintmode_poll_with_tool(C, GPAINT_TOOL_TINT);
+}
+
 /* Poll callback for stroke sculpting mode */
 static bool gp_stroke_sculptmode_poll(bContext *C)
 {
@@ -177,6 +183,13 @@ static void ed_keymap_gpencil_painting_fill(wmKeyConfig *keyconf)
   keymap->poll = gp_stroke_paintmode_fill_poll;
 }
 
+/* keys for draw with a tint brush */
+static void ed_keymap_gpencil_painting_tint(wmKeyConfig *keyconf)
+{
+  wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Stroke Paint (Tint)", 0, 0);
+  keymap->poll = gp_stroke_paintmode_tint_poll;
+}
+
 /* Stroke Painting Keymap - Only when paintmode is enabled */
 static void ed_keymap_gpencil_painting(wmKeyConfig *keyconf)
 {
@@ -210,6 +223,7 @@ void ED_keymap_gpencil(wmKeyConfig *keyconf)
   ed_keymap_gpencil_painting_draw(keyconf);
   ed_keymap_gpencil_painting_erase(keyconf);
   ed_keymap_gpencil_painting_fill(keyconf);
+  ed_keymap_gpencil_painting_tint(keyconf);
   ed_keymap_gpencil_sculpting(keyconf);
   ed_keymap_gpencil_weightpainting(keyconf);
 }
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 41c3a2ca285..705aab4eabb 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1669,6 +1669,10 @@ static void ed_default_handlers(
         wm->defaultconf, "Grease Pencil Stroke Paint (Fill)", 0, 0);
     WM_event_add_keymap_handler(handlers, keymap_paint_fill);
 
+    wmKeyMap *keymap_paint_tint = WM_keymap_ensure(
+        wm->defaultconf, "Grease Pencil Stroke Paint (Tint)", 0, 0);
+    WM_event_add_keymap_handler(handlers, keymap_paint_tint);
+
     wmKeyMap *keymap_sculpt = WM_keymap_ensure(
         wm->defaultconf, "Grease Pencil Stroke Sculpt Mode", 0, 0);
     WM_event_add_keymap_handler(handlers, keymap_sculpt);
@@ -2869,7 +2873,7 @@ void ED_region_info_draw(ARegion *ar,
                          float fill_color[4],
                          const bool full_redraw)
 {
-  ED_region_info_draw_multiline(ar, (const char *[2]){text, NULL}, fill_color, full_redraw);
+  ED_region_info_draw_multiline(ar, (const char * [2]){text, NULL}, fill_color, full_redraw);
 }
 
 #define MAX_METADATA_STR 1024
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index b4923694e86..f349062bb26 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -518,7 +518,7 @@ typedef enum eBrushUVSculptTool {
         SCULPT_TOOL_ELASTIC_DEFORM, \
         SCULPT_TOOL_POSE, \
 \
-        /* These brushes could handle dynamic topology, \ \ \ \ \ \ \ \
+        /* These brushes could handle dynamic topology, \ \ \ \ \ \ \ \ \
          * but user feedback indicates it's better not to */ \
         SCULPT_TOOL_SMOOTH, \
         SCULPT_TOOL_MASK) == 0)
@@ -560,6 +560,7 @@ typedef enum eBrushGPaintTool {
   GPAINT_TOOL_DRAW = 0,
   GPAINT_TOOL_FILL = 1,
   GPAINT_TOOL_ERASE = 2,
+  GPAINT_TOOL_TINT = 3,
 } eBrushGPaintTool;
 
 /* direction that the brush displaces along */
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 187fadb398a..a7b8f729a6e 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -142,6 +142,11 @@ const EnumPropertyItem rna_enum_brush_gpencil_types_items[] = {
      ICON_PANEL_CLOSE,
      "Erase",
      "The brush is used for erasing strokes"},
+    {GPAINT_TOOL_TINT,
+     "TINT",
+     ICON_STROKE,
+     "Tint",
+     "The brush is of type used for tinting strokes"},
     {0, NULL, 0, NULL, NULL},
 };



More information about the Bf-blender-cvs mailing list