diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-01-10 18:54:17 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-01-21 14:22:24 +0300 |
commit | ca4e8b423e81f2a72cd5409d1c2c0450e12afc78 (patch) | |
tree | f6bcd8f872cb0e9845ef1efc7973ee62ca7d5713 /source/blender/editors/gpencil/annotate_paint.c | |
parent | f10d190240a135f4e26058eb49a787f9178ceb71 (diff) |
Cleanup: simplify wmEvent tablet data storage and naming
Removing meaningless distinction between NULL pointer and EVT_TABLET_NONE,
and initialize pressure and tilt to 1.0 and 0.0 respectively when no tablet
is used.
Diffstat (limited to 'source/blender/editors/gpencil/annotate_paint.c')
-rw-r--r-- | source/blender/editors/gpencil/annotate_paint.c | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index 04b5d8f6d40..5eaf14e361b 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -1461,12 +1461,7 @@ static void gpencil_draw_toggle_eraser_cursor(bContext *C, tGPsdata *p, short en /* Check if tablet eraser is being used (when processing events) */ static bool gpencil_is_tablet_eraser_active(const wmEvent *event) { - if (event->tablet_data) { - const wmTabletData *wmtab = event->tablet_data; - return (wmtab->Active == EVT_TABLET_ERASER); - } - - return false; + return (event->tablet.active == EVT_TABLET_ERASER); } /* ------------------------------- */ @@ -1686,7 +1681,6 @@ static void annotation_draw_apply_event( tGPsdata *p = op->customdata; PointerRNA itemptr; float mousef[2]; - int tablet = 0; /* convert from window-space to area-space mouse coordinates * add any x,y override position for fake events @@ -1720,29 +1714,20 @@ static void annotation_draw_apply_event( p->curtime = PIL_check_seconds_timer(); - /* handle pressure sensitivity (which is supplied by tablets) */ - if (event->tablet_data) { - const wmTabletData *wmtab = event->tablet_data; + /* handle pressure sensitivity (which is supplied by tablets or otherwise 1.0) */ + p->pressure = event->tablet.pressure; - tablet = (wmtab->Active != EVT_TABLET_NONE); - p->pressure = wmtab->Pressure; - - /* Hack for pressure sensitive eraser on D+RMB when using a tablet: - * The pen has to float over the tablet surface, resulting in - * zero pressure (T47101). Ignore pressure values if floating - * (i.e. "effectively zero" pressure), and only when the "active" - * end is the stylus (i.e. the default when not eraser) - */ - if (p->paintmode == GP_PAINTMODE_ERASER) { - if ((wmtab->Active != EVT_TABLET_ERASER) && (p->pressure < 0.001f)) { - p->pressure = 1.0f; - } + /* Hack for pressure sensitive eraser on D+RMB when using a tablet: + * The pen has to float over the tablet surface, resulting in + * zero pressure (T47101). Ignore pressure values if floating + * (i.e. "effectively zero" pressure), and only when the "active" + * end is the stylus (i.e. the default when not eraser) + */ + if (p->paintmode == GP_PAINTMODE_ERASER) { + if ((event->tablet.active != EVT_TABLET_ERASER) && (p->pressure < 0.001f)) { + p->pressure = 1.0f; } } - else { - /* No tablet data -> No pressure info is available */ - p->pressure = 1.0f; - } /* special exception for start of strokes (i.e. maybe for just a dot) */ if (p->flags & GP_PAINTFLAG_FIRSTRUN) { @@ -1758,7 +1743,7 @@ static void annotation_draw_apply_event( /* special exception here for too high pressure values on first touch in * windows for some tablets, then we just skip first touch... */ - if (tablet && (p->pressure >= 0.99f)) { + if ((event->tablet.active != EVT_TABLET_NONE) && (p->pressure >= 0.99f)) { return; } } |