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
This commit is contained in:
Antonio Vazquez 2019-06-07 12:59:47 +02:00
parent 1f93f9e982
commit a412f49e75
Notes: blender-bot 2023-10-18 15:23:11 +02:00
Referenced by commit 40a8c49088, Revert new grease pencil cursor for paint modes
Referenced by issue #62446, Mouse cursor disappears on Grease Pencil stroke
5 changed files with 76 additions and 14 deletions

View 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=(),
)

View 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 */

View 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},
};

View 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 ***********************/
}

View File

@ -92,6 +92,7 @@ enum {
BC_E_ARROWCURSOR,
BC_W_ARROWCURSOR,
BC_STOPCURSOR,
BC_PAINTCROSSCURSOR,
/* --- ALWAYS LAST ----- */
BC_NUMCURSORS,
};