diff options
author | Stephen Chandler Paul <thatslyude@gmail.com> | 2015-02-09 22:02:08 -0500 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2016-04-06 15:43:29 +0200 |
commit | 505dac94be3de6623e8e1dc9adf00050f40046e6 (patch) | |
tree | 6595946d145243e7fd23e6851c7feb3f4f781b7b /demos | |
parent | 6c2a078bf2110d41c8f4d96d74c5dbf6d17eaf92 (diff) | |
download | gtk+-505dac94be3de6623e8e1dc9adf00050f40046e6.tar.gz |
gtk-demo: Add support for distance in event_axes
Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
Diffstat (limited to 'demos')
-rw-r--r-- | 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 a12168a70b..f5929e8d49 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, |