[clutter/clutter-1.18] Make test-clip friendly for people with only one mouse button



commit 00ef6e29ce68495dc9f10de680f020d7b46d6e6c
Author: Neil Roberts <neil linux intel com>
Date:   Mon Dec 2 19:13:55 2013 +0000

    Make test-clip friendly for people with only one mouse button
    
    The various shapes can now be drawn by holding down modifier keys
    instead of requiring a three-button mouse.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=719716

 tests/interactive/test-clip.c |   32 ++++++++++++++++++++++++++------
 1 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/tests/interactive/test-clip.c b/tests/interactive/test-clip.c
index 8e8d770..1b4401f 100644
--- a/tests/interactive/test-clip.c
+++ b/tests/interactive/test-clip.c
@@ -31,8 +31,9 @@ struct _CallbackData
 
 static const char
 instructions[] =
-  "Press and drag any of the three mouse buttons to add a clip with different "
-  "shapes. Press 'r' to reset or 'u' to undo the last clip.";
+  "Left button and drag to draw a rectangle, control+left to draw a rotated "
+  "rectangle or shift+left to draw a path. Press 'r' to reset or 'u' "
+  "to undo the last clip.";
 
 static void
 path_shapes (gint x, gint y, gint width, gint height)
@@ -231,10 +232,29 @@ on_button_press (ClutterActor *stage, ClutterButtonEvent *event,
   data->current_clip.x1 = data->current_clip.x2 = event->x;
   data->current_clip.y1 = data->current_clip.y2 = event->y;
 
-  data->current_clip.type
-    = event->button == CLUTTER_BUTTON_PRIMARY ? CLIP_RECTANGLE
-    : event->button == CLUTTER_BUTTON_MIDDLE ? CLIP_SHAPES
-    : CLIP_ROTATED_RECTANGLE;
+  switch (event->button)
+    {
+    case CLUTTER_BUTTON_PRIMARY:
+      if (clutter_event_has_shift_modifier ((ClutterEvent *) event))
+        data->current_clip.type = CLIP_SHAPES;
+      else if (clutter_event_has_control_modifier ((ClutterEvent *) event))
+        data->current_clip.type = CLIP_ROTATED_RECTANGLE;
+      else
+        data->current_clip.type = CLIP_RECTANGLE;
+      break;
+
+    case CLUTTER_BUTTON_SECONDARY:
+      data->current_clip.type = CLIP_ROTATED_RECTANGLE;
+      break;
+
+    case CLUTTER_BUTTON_MIDDLE:
+      data->current_clip.type = CLIP_SHAPES;
+      break;
+
+    default:
+      data->current_clip.type = CLIP_NONE;
+      break;
+    }
 
   clutter_actor_queue_redraw (stage);
 


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