GPencil: Create new CURSOR for paint modes
authorAntonio Vazquez <blendergit@gmail.com>
Fri, 7 Jun 2019 10:59:47 +0000 (12:59 +0200)
committerAntonio Vazquez <blendergit@gmail.com>
Fri, 7 Jun 2019 10:59:47 +0000 (12:59 +0200)
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

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

index a2b96c9d6c75c744fbb53ffdee71c29fdbcdc92f..4ed0d5b1bbb2c64e1dd88e6c28f9e8284c3a5a46 100644 (file)
@@ -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=(),
         )
index cd1ebc91fbb2f53fe919dcadfe0f73b2b558e179..fc888ba95f435c8fe0e03df7ffa9c7f26e1e6ee4 100644 (file)
@@ -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 */
index 1fea87df10cd69d00cc928da8f956d29f3b1bf17..3748a2fdbb60126d3af2a3c29040dce2472a6545 100644 (file)
@@ -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},
 };
 
index 490a05a40d62400d4fe019b83769b2d7f4bfe41f..44395b0b2015899e5664306309dd1a8e7d828d4e 100644 (file)
@@ -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 ***********************/
 }
index b4b0bcf0149b3346343bfc484efb18cf2d18c213..46fdb4baa5b58f5aa7a9f799d875f8dea7027919 100644 (file)
@@ -92,6 +92,7 @@ enum {
   BC_E_ARROWCURSOR,
   BC_W_ARROWCURSOR,
   BC_STOPCURSOR,
+  BC_PAINTCROSSCURSOR,
   /* --- ALWAYS LAST ----- */
   BC_NUMCURSORS,
 };