[gtk+/wip/wayland-tablet: 619/632] gtk-demo: Add support for distance in event_axes



commit 651f4ccfd03e70332f6883ec6b31253fd5ae1f5c
Author: Stephen Chandler Paul <thatslyude gmail com>
Date:   Mon Feb 9 22:02:08 2015 -0500

    gtk-demo: Add support for distance in event_axes
    
    Signed-off-by: Stephen Chandler Paul <thatslyude gmail com>

 demos/gtk-demo/event_axes.c |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/demos/gtk-demo/event_axes.c b/demos/gtk-demo/event_axes.c
index 555e299..6659151 100644
--- a/demos/gtk-demo/event_axes.c
+++ b/demos/gtk-demo/event_axes.c
@@ -200,7 +200,7 @@ draw_axes_info (cairo_t       *cr,
                 AxesInfo      *info,
                 GtkAllocation *allocation)
 {
-  gdouble pressure, tilt_x, tilt_y, wheel;
+  gdouble pressure, tilt_x, tilt_y, distance, wheel;
   GdkAxisFlags axes = gdk_device_get_axes (info->last_source);
 
   cairo_save (cr);
@@ -246,6 +246,33 @@ draw_axes_info (cairo_t       *cr,
       render_arrow (cr, tilt_x * 100, tilt_y * 100, "Tilt");
     }
 
+  if (axes & GDK_AXIS_FLAG_DISTANCE)
+    {
+      double dashes[] = { 5.0, 5.0 };
+      cairo_text_extents_t extents;
+
+      gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_DISTANCE,
+                           &distance);
+
+      cairo_save (cr);
+
+      cairo_move_to (cr, distance * 100, 0);
+
+      cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+      cairo_set_dash (cr, dashes, 2, 0.0);
+      cairo_arc (cr, 0, 0, distance * 100, 0, 2 * G_PI);
+      cairo_stroke (cr);
+
+      cairo_move_to (cr, 0, -distance * 100);
+      cairo_text_extents (cr, "Distance", &extents);
+      cairo_rel_move_to (cr, -extents.width / 2, 0);
+      cairo_show_text (cr, "Distance");
+
+      cairo_move_to (cr, 0, 0);
+
+      cairo_restore (cr);
+    }
+
   if (axes & GDK_AXIS_FLAG_WHEEL)
     {
       gdk_device_get_axis (info->last_source, info->axes, GDK_AXIS_WHEEL,


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