[Bf-blender-cvs] [a412f49e758] master: GPencil: Create new CURSOR for paint modes

Antonio Vazquez noreply at git.blender.org
Fri Jun 7 13:01:18 CEST 2019


Commit: a412f49e7580a96ff3088dd2f763efe3a814c131
Author: Antonio Vazquez
Date:   Fri Jun 7 12:59:47 2019 +0200
Branches: master
https://developer.blender.org/rBa412f49e7580a96ff3088dd2f763efe3a814c131

GPencil: Create new CURSOR for paint modes

This new cursor is used instead of the ARROW because it was too disruptive while you are drawing.

The change affects all paint modes that are used Brushes.

See D5036 for details.

Reviewers: @brecht @billreynish @mendio
Cursor designed by:  @billreynish

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

M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/makesrna/intern/rna_wm_api.c
M	source/blender/windowmanager/intern/wm_cursors.c
M	source/blender/windowmanager/wm_cursors.h

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

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index a2b96c9d6c7..4ed0d5b1bbb 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -60,6 +60,7 @@ def generate_from_enum_ex(
                     idname=idname_prefix + name,
                     label=name,
                     icon=icon_prefix + idname.lower(),
+					cursor='PAINT_CROSSHAIR',
                     data_block=idname,
                     **tooldef_keywords,
                 )
@@ -199,7 +200,7 @@ class _defs_annotate:
             idname="builtin.annotate_line",
             label="Annotate Line",
             icon="ops.gpencil.draw.line",
-            cursor='CROSSHAIR',
+            cursor='PAINT_CROSSHAIR',
             keymap="Generic Tool: Annotate Line",
             draw_settings=draw_settings,
         )
@@ -210,7 +211,7 @@ class _defs_annotate:
             idname="builtin.annotate_polygon",
             label="Annotate Polygon",
             icon="ops.gpencil.draw.poly",
-            cursor='CROSSHAIR',
+            cursor='PAINT_CROSSHAIR',
             keymap="Generic Tool: Annotate Polygon",
             draw_settings=draw_settings,
         )
@@ -225,7 +226,7 @@ class _defs_annotate:
             idname="builtin.annotate_eraser",
             label="Annotate Eraser",
             icon="ops.gpencil.draw.eraser",
-            cursor='CROSSHAIR',  # XXX: Always show brush circle when enabled
+            cursor='PAINT_CROSSHAIR',  # XXX: Always show brush circle when enabled
             keymap="Generic Tool: Annotate Eraser",
             draw_settings=draw_settings,
         )
@@ -1286,7 +1287,7 @@ class _defs_gpencil_paint:
             idname="builtin.line",
             label="Line",
             icon="ops.gpencil.primitive_line",
-            cursor='CROSSHAIR',
+            cursor='PAINT_CROSSHAIR',
             widget=None,
             keymap=(),
         )
@@ -1297,7 +1298,7 @@ class _defs_gpencil_paint:
             idname="builtin.box",
             label="Box",
             icon="ops.gpencil.primitive_box",
-            cursor='CROSSHAIR',
+            cursor='PAINT_CROSSHAIR',
             widget=None,
             keymap=(),
         )
@@ -1308,7 +1309,7 @@ class _defs_gpencil_paint:
             idname="builtin.circle",
             label="Circle",
             icon="ops.gpencil.primitive_circle",
-            cursor='CROSSHAIR',
+            cursor='PAINT_CROSSHAIR',
             widget=None,
             keymap=(),
         )
@@ -1319,7 +1320,7 @@ class _defs_gpencil_paint:
             idname="builtin.arc",
             label="Arc",
             icon="ops.gpencil.primitive_arc",
-            cursor='CROSSHAIR',
+            cursor='PAINT_CROSSHAIR',
             widget=None,
             keymap=(),
         )
@@ -1330,7 +1331,7 @@ class _defs_gpencil_paint:
             idname="builtin.curve",
             label="Curve",
             icon="ops.gpencil.primitive_curve",
-            cursor='CROSSHAIR',
+            cursor='PAINT_CROSSHAIR',
             widget=None,
             keymap=(),
         )
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index cd1ebc91fbb..fc888ba95f4 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -2392,10 +2392,6 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op)
       WM_cursor_modal_restore(CTX_wm_window(C));
     }
     else {
-      /* or restore paint if 3D view */
-      if ((p) && (p->paintmode == GP_PAINTMODE_ERASER)) {
-        WM_cursor_modal_set(p->win, CURSOR_STD);
-      }
 
       /* drawing batch cache is dirty now */
       bGPdata *gpd = CTX_data_gpencil_data(C);
@@ -2409,8 +2405,6 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op)
     gpencil_undo_finish();
 
     /* cleanup */
-    WM_cursor_modal_set(p->win, CURSOR_STD);
-
     gp_paint_cleanup(p);
     gp_session_cleanup(p);
     ED_gpencil_toggle_brush_cursor(C, true, NULL);
@@ -2478,6 +2472,9 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event)
 /* ensure that the correct cursor icon is set */
 static void gpencil_draw_cursor_set(tGPsdata *p)
 {
+  return;
+  /* Disable while we get a better cursor handling for direct input devices (Cintiq/Ipad)*/
+#if 0
   Brush *brush = p->brush;
   if ((p->paintmode == GP_PAINTMODE_ERASER) || (brush->gpencil_tool == GPAINT_TOOL_ERASE)) {
     WM_cursor_modal_set(p->win, BC_CROSSCURSOR); /* XXX need a better cursor */
@@ -2485,6 +2482,7 @@ static void gpencil_draw_cursor_set(tGPsdata *p)
   else {
     WM_cursor_modal_set(p->win, CURSOR_NONE);
   }
+#endif
 }
 
 /* update UI indicators of status, including cursor and header prints */
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index 1fea87df10c..3748a2fdbb6 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -59,6 +59,7 @@ const EnumPropertyItem rna_enum_window_cursor_items[] = {
     {BC_NS_SCROLLCURSOR, "SCROLL_Y", 0, "Scroll-Y", ""},
     {BC_NSEW_SCROLLCURSOR, "SCROLL_XY", 0, "Scroll-XY", ""},
     {BC_EYEDROPPER_CURSOR, "EYEDROPPER", 0, "Eyedropper", ""},
+    {BC_PAINTCROSSCURSOR, "PAINT_CROSSHAIR", 0, "Paint Crosshair", ""},
     {0, NULL, 0, NULL, NULL},
 };
 
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index 490a05a40d6..44395b0b201 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -1571,5 +1571,66 @@ void wm_init_cursor_data(void)
 
   END_CURSOR_BLOCK;
 
+  /********************** PaintCross Cursor ***********************/
+  BEGIN_CURSOR_BLOCK;
+  static char paintcross_sbm[] = {
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  };
+
+  static char paintcross_smsk[] = {
+      0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x0e, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+      0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
+  };
+
+  static char paintcross_sbm_large[] = {
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  };
+
+  static char paintcross_smsk_large[] = {
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00,
+      0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0,
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0xc0, 0x0f,
+      0xfc, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
+      0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00,
+      0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  };
+
+  static BCursor PaintCrossCursor = {
+      /*small*/
+      paintcross_sbm,
+      paintcross_smsk,
+      16,
+      16,
+      7,
+      7,
+      /*big*/
+      paintcross_sbm_large,
+      paintcross_smsk_large,
+      32,
+      32,
+      15,
+      15,
+      /*color*/
+      BC_BLACK,
+      BC_WHITE,
+  };
+
+  BlenderCursor[BC_PAINTCROSSCURSOR] = &PaintCrossCursor;
+  END_CURSOR_BLOCK;
+
   /********************** Put the cursors in the array ***********************/
 }
diff --git a/source/blender/windowmanager/wm_cursors.h b/source/blender/windowmanager/wm_cursors.h
index b4b0bcf0149..46fdb4baa5b 100644
--- a/source/blender/windowmanager/wm_cursors.h
+++ b/source/blender/windowmanager/wm_cursors.h
@@ -92,6 +92,7 @@ enum {
   BC_E_ARROWCURSOR,
   BC_W_ARROWCURSOR,
   BC_STOPCURSOR,
+  BC_PAINTCROSSCURSOR,
   /* --- ALWAYS LAST ----- */
   BC_NUMCURSORS,
 };



More information about the Bf-blender-cvs mailing list