[gimp/gtk3-port] app: add the new distance, rotation and slider axes to GimpCoords



commit f14ad3c3339e1f958193538050fe9ef2899d5d05
Author: Michael Natterer <mitch gimp org>
Date:   Fri May 18 18:38:45 2018 +0200

    app: add the new distance, rotation and slider axes to GimpCoords
    
    and add code to get them from events and devices.

 app/core/core-types.h               |   15 ++++++++
 app/core/gimpcoords.c               |   28 ++++++++++++---
 app/widgets/gimpdeviceinfo-coords.c |   69 +++++++++++++++++++++++++++++++++++
 3 files changed, 107 insertions(+), 5 deletions(-)
---
diff --git a/app/core/core-types.h b/app/core/core-types.h
index d687c9e..fb1680e 100644
--- a/app/core/core-types.h
+++ b/app/core/core-types.h
@@ -60,6 +60,10 @@
 #define GIMP_COORDS_MAX_WHEEL         1.0
 #define GIMP_COORDS_DEFAULT_WHEEL     0.5
 
+#define GIMP_COORDS_DEFAULT_DISTANCE  0.0
+#define GIMP_COORDS_DEFAULT_ROTATION  0.0
+#define GIMP_COORDS_DEFAULT_SLIDER    0.0
+
 #define GIMP_COORDS_DEFAULT_VELOCITY  0.0
 
 #define GIMP_COORDS_DEFAULT_DIRECTION 0.0
@@ -72,6 +76,9 @@
                                         GIMP_COORDS_DEFAULT_TILT,     \
                                         GIMP_COORDS_DEFAULT_TILT,     \
                                         GIMP_COORDS_DEFAULT_WHEEL,    \
+                                        GIMP_COORDS_DEFAULT_DISTANCE, \
+                                        GIMP_COORDS_DEFAULT_ROTATION, \
+                                        GIMP_COORDS_DEFAULT_SLIDER,   \
                                         GIMP_COORDS_DEFAULT_VELOCITY, \
                                         GIMP_COORDS_DEFAULT_DIRECTION,\
                                         GIMP_COORDS_DEFAULT_XSCALE,   \
@@ -243,14 +250,22 @@ typedef gint64   (* GimpMemsizeFunc)       (gpointer     instance,
 
 struct _GimpCoords
 {
+  /* axes as reported by the device */
   gdouble  x;
   gdouble  y;
   gdouble  pressure;
   gdouble  xtilt;
   gdouble  ytilt;
   gdouble  wheel;
+  gdouble  distance;
+  gdouble  rotation;
+  gdouble  slider;
+
+  /* synthetic axes */
   gdouble  velocity;
   gdouble  direction;
+
+  /* view transform */
   gdouble  xscale;  /* the view scale                */
   gdouble  yscale;
   gdouble  angle;   /* the view rotation angle       */
diff --git a/app/core/gimpcoords.c b/app/core/gimpcoords.c
index 038af89..e55c038 100644
--- a/app/core/gimpcoords.c
+++ b/app/core/gimpcoords.c
@@ -49,6 +49,9 @@ gimp_coords_mix (const gdouble     amul,
       ret_val->xtilt     = amul * a->xtilt     + bmul * b->xtilt;
       ret_val->ytilt     = amul * a->ytilt     + bmul * b->ytilt;
       ret_val->wheel     = amul * a->wheel     + bmul * b->wheel;
+      ret_val->distance  = amul * a->distance  + bmul * b->distance;
+      ret_val->rotation  = amul * a->rotation  + bmul * b->rotation;
+      ret_val->slider    = amul * a->slider    + bmul * b->slider;
       ret_val->velocity  = amul * a->velocity  + bmul * b->velocity;
       ret_val->direction = amul * a->direction + bmul * b->direction;
     }
@@ -60,6 +63,9 @@ gimp_coords_mix (const gdouble     amul,
       ret_val->xtilt     = amul * a->xtilt;
       ret_val->ytilt     = amul * a->ytilt;
       ret_val->wheel     = amul * a->wheel;
+      ret_val->distance  = amul * a->distance;
+      ret_val->rotation  = amul * a->rotation;
+      ret_val->slider    = amul * a->slider;
       ret_val->velocity  = amul * a->velocity;
       ret_val->direction = amul * a->direction;
     }
@@ -122,6 +128,9 @@ gimp_coords_scalarprod (const GimpCoords *a,
           a->xtilt     * b->xtilt    +
           a->ytilt     * b->ytilt    +
           a->wheel     * b->wheel    +
+          a->distance  * b->distance +
+          a->rotation  * b->rotation +
+          a->slider    * b->slider   +
           a->velocity  * b->velocity +
           a->direction * b->direction);
 }
@@ -144,6 +153,9 @@ gimp_coords_length_squared (const GimpCoords *a)
   upscaled_a.xtilt     = a->xtilt     * INPUT_RESOLUTION;
   upscaled_a.ytilt     = a->ytilt     * INPUT_RESOLUTION;
   upscaled_a.wheel     = a->wheel     * INPUT_RESOLUTION;
+  upscaled_a.distance  = a->distance  * INPUT_RESOLUTION;
+  upscaled_a.rotation  = a->rotation  * INPUT_RESOLUTION;
+  upscaled_a.slider    = a->slider    * INPUT_RESOLUTION;
   upscaled_a.velocity  = a->velocity  * INPUT_RESOLUTION;
   upscaled_a.direction = a->direction * INPUT_RESOLUTION;
 
@@ -168,11 +180,14 @@ gimp_coords_manhattan_dist (const GimpCoords *a,
 {
   gdouble dist = 0;
 
-  dist += ABS (a->pressure - b->pressure);
-  dist += ABS (a->xtilt - b->xtilt);
-  dist += ABS (a->ytilt - b->ytilt);
-  dist += ABS (a->wheel - b->wheel);
-  dist += ABS (a->velocity - b->velocity);
+  dist += ABS (a->pressure  - b->pressure);
+  dist += ABS (a->xtilt     - b->xtilt);
+  dist += ABS (a->ytilt     - b->ytilt);
+  dist += ABS (a->wheel     - b->wheel);
+  dist += ABS (a->distance  - b->distance);
+  dist += ABS (a->rotation  - b->rotation);
+  dist += ABS (a->slider    - b->slider);
+  dist += ABS (a->velocity  - b->velocity);
   dist += ABS (a->direction - b->direction);
 
   dist *= INPUT_RESOLUTION;
@@ -193,6 +208,9 @@ gimp_coords_equal (const GimpCoords *a,
           a->xtilt     == b->xtilt    &&
           a->ytilt     == b->ytilt    &&
           a->wheel     == b->wheel    &&
+          a->distance  == b->distance &&
+          a->rotation  == b->rotation &&
+          a->slider    == b->slider   &&
           a->velocity  == b->velocity &&
           a->direction == b->direction);
 
diff --git a/app/widgets/gimpdeviceinfo-coords.c b/app/widgets/gimpdeviceinfo-coords.c
index eb5595b..2a15abb 100644
--- a/app/widgets/gimpdeviceinfo-coords.c
+++ b/app/widgets/gimpdeviceinfo-coords.c
@@ -101,6 +101,27 @@ gimp_device_info_get_event_coords (GimpDeviceInfo *info,
                                                      coords->wheel);
         }
 
+      if (gdk_event_get_axis (event, GDK_AXIS_DISTANCE, &coords->distance))
+        {
+          coords->distance = gimp_device_info_map_axis (info,
+                                                        GDK_AXIS_DISTANCE,
+                                                        coords->distance);
+        }
+
+      if (gdk_event_get_axis (event, GDK_AXIS_ROTATION, &coords->rotation))
+        {
+          coords->rotation = gimp_device_info_map_axis (info,
+                                                        GDK_AXIS_ROTATION,
+                                                        coords->rotation);
+        }
+
+      if (gdk_event_get_axis (event, GDK_AXIS_SLIDER, &coords->slider))
+        {
+          coords->slider = gimp_device_info_map_axis (info,
+                                                      GDK_AXIS_SLIDER,
+                                                      coords->slider);
+        }
+
       return TRUE;
     }
 
@@ -172,6 +193,30 @@ gimp_device_info_get_device_coords (GimpDeviceInfo *info,
                                                  GDK_AXIS_WHEEL,
                                                  coords->wheel);
     }
+
+  if (gdk_device_get_axis (info->device,
+                           axes, GDK_AXIS_DISTANCE, &coords->distance))
+    {
+      coords->distance = gimp_device_info_map_axis (info,
+                                                    GDK_AXIS_DISTANCE,
+                                                    coords->distance);
+    }
+
+  if (gdk_device_get_axis (info->device,
+                           axes, GDK_AXIS_ROTATION, &coords->rotation))
+    {
+      coords->rotation = gimp_device_info_map_axis (info,
+                                                    GDK_AXIS_ROTATION,
+                                                    coords->rotation);
+    }
+
+  if (gdk_device_get_axis (info->device,
+                           axes, GDK_AXIS_SLIDER, &coords->slider))
+    {
+      coords->slider = gimp_device_info_map_axis (info,
+                                                  GDK_AXIS_SLIDER,
+                                                  coords->slider);
+    }
 }
 
 void
@@ -219,6 +264,30 @@ gimp_device_info_get_time_coords (GimpDeviceInfo *info,
                                                  GDK_AXIS_WHEEL,
                                                  coords->wheel);
     }
+
+  if (gdk_device_get_axis (info->device,
+                           event->axes, GDK_AXIS_DISTANCE, &coords->distance))
+    {
+      coords->distance = gimp_device_info_map_axis (info,
+                                                    GDK_AXIS_DISTANCE,
+                                                    coords->distance);
+    }
+
+  if (gdk_device_get_axis (info->device,
+                           event->axes, GDK_AXIS_ROTATION, &coords->rotation))
+    {
+      coords->rotation = gimp_device_info_map_axis (info,
+                                                    GDK_AXIS_ROTATION,
+                                                    coords->rotation);
+    }
+
+  if (gdk_device_get_axis (info->device,
+                           event->axes, GDK_AXIS_SLIDER, &coords->slider))
+    {
+      coords->slider = gimp_device_info_map_axis (info,
+                                                  GDK_AXIS_SLIDER,
+                                                  coords->slider);
+    }
 }
 
 gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]