[gtk+] gtk-demo: Add support for distance in event_axes



commit 505dac94be3de6623e8e1dc9adf00050f40046e6
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 a12168a..f5929e8 100644
--- a/demos/gtk-demo/event_axes.c
+++ b/demos/gtk-demo/event_axes.c
@@ -206,7 +206,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);
@@ -258,6 +258,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]