[Bf-blender-cvs] [ca4e8b423e8] master: Cleanup: simplify wmEvent tablet data storage and naming

Brecht Van Lommel noreply at git.blender.org
Tue Jan 21 12:30:20 CET 2020


Commit: ca4e8b423e81f2a72cd5409d1c2c0450e12afc78
Author: Brecht Van Lommel
Date:   Fri Jan 10 16:54:17 2020 +0100
Branches: master
https://developer.blender.org/rBca4e8b423e81f2a72cd5409d1c2c0450e12afc78

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.

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

M	source/blender/editors/curve/editcurve_paint.c
M	source/blender/editors/gpencil/annotate_paint.c
M	source/blender/editors/gpencil/gpencil_brush.c
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/space_view3d/view3d_walk.c
M	source/blender/makesrna/intern/rna_wm.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/WM_types.h
M	source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
M	source/blender/windowmanager/intern/wm_cursors.c
M	source/blender/windowmanager/intern/wm_event_query.c
M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_window.c

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

diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 4c4bac6a249..5486d60d5d7 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -460,14 +460,8 @@ static void curve_draw_event_add(wmOperator *op, const wmEvent *event)
 
   ARRAY_SET_ITEMS(selem->mval, event->mval[0], event->mval[1]);
 
-  /* handle pressure sensitivity (which is supplied by tablets) */
-  if (event->tablet_data) {
-    const wmTabletData *wmtab = event->tablet_data;
-    selem->pressure = wmtab->Pressure;
-  }
-  else {
-    selem->pressure = 1.0f;
-  }
+  /* handle pressure sensitivity (which is supplied by tablets or otherwise 1.0) */
+  selem->pressure = event->tablet.pressure;
 
   bool is_depth_found = stroke_elem_project_fallback_elem(
       cdd, cdd->prev.location_world_valid, selem);
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;
     }
   }
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 4948df606ee..690fee61005 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -1976,7 +1976,6 @@ static void gpsculpt_brush_apply_event(bContext *C, wmOperator *op, const wmEven
   GP_Sculpt_Settings *gset = &ts->gp_sculpt;
   PointerRNA itemptr;
   float mouse[2];
-  int tablet = 0;
 
   mouse[0] = event->mval[0] + 1;
   mouse[1] = event->mval[1] + 1;
@@ -1988,24 +1987,14 @@ static void gpsculpt_brush_apply_event(bContext *C, wmOperator *op, const wmEven
   RNA_boolean_set(&itemptr, "pen_flip", event->ctrl != false);
   RNA_boolean_set(&itemptr, "is_start", gso->first);
 
-  /* handle pressure sensitivity (which is supplied by tablets) */
-  if (event->tablet_data) {
-    const wmTabletData *wmtab = event->tablet_data;
-    float pressure = wmtab->Pressure;
-
-    tablet = (wmtab->Active != EVT_TABLET_NONE);
-
-    /* special exception here for too high pressure values on first touch in
-     * windows for some tablets: clamp the values to be sane
-     */
-    if (tablet && (pressure >= 0.99f)) {
-      pressure = 1.0f;
-    }
-    RNA_float_set(&itemptr, "pressure", pressure);
-  }
-  else {
-    RNA_float_set(&itemptr, "pressure", 1.0f);
+  /* handle pressure sensitivity (which is supplied by tablets and otherwise 1.0) */
+  float pressure = event->tablet.pressure;
+  /* special exception here for too high pressure values on first touch in
+   * windows for some tablets: clamp the values to be sane */
+  if (pressure >= 0.99f) {
+    pressure = 1.0f;
   }
+  RNA_float_set(&itemptr, "pressure", pressure);
 
   if (!gso->is_weight_mode) {
     if (event->shift) {
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 6a91417e7f3..09ff24f05fc 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -2553,12 +2553,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);
 }
 
 /* ------------------------------- */
@@ -3020,7 +3015,6 @@ static void gpencil_draw_apply_event(bContext *C,
   GP_Sculpt_Guide *guide = &p->scene->toolsettings->gp_sculpt.guide;
   PointerRNA itemptr;
   float mousef[2];
-  int tablet = 0;
   bool is_speed_guide = ((guide->use_guide) &&
                          (p->brush && (p->brush->gpencil_tool == GPAINT_TOOL_DRAW)));
 
@@ -3055,29 +3049,20 @@ static void gpencil_draw_apply_event(bContext *C,
 
   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 eraser modes */
   if (p->paintmode == GP_PAINTMODE_ERASER) {
@@ -3101,7 +3086,7 @@ static void gpencil_draw_apply_event(bContext *C,
     /* 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;
     }
 
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index 494e7529975..34470896fb9 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -676,7 +676,7 @@ static void walkEvent(bContext *C, WalkInfo *walk, const wmEvent *event)
       return;
     }
 
-    if ((walk->is_cursor_absolute == false) && event->is_motion_absolute) {
+    if ((walk->is_cursor_absolute == false) && event->tablet.is_motion_absolute) {
       walk->is_cursor_absolute = true;
       copy_v2_v2_int(walk->prev_mval, event->mval);
       copy_v2_v2_int(walk->center_mval, event->mval);
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 249581d22bf..532992baa5c 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -2185,7 +2185,7 @@ static void rna_def_event(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Is Tablet", "The event has tablet data");
 
   prop = RNA_def_property(srna, "is_mouse_absolute", PROP_BOOLEAN, PROP_NONE);
-  RNA_def_property_boolean_sdna(prop, NULL, "is_motion_absolute", 1);
+  RNA_def_property_boolean_sdna(prop, NULL, "tablet.is_motion_absolute", 1);
   RNA_def_property_clear_

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list