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
This commit is contained in:
Neil Roberts 2013-12-02 19:13:55 +00:00
parent 992f2ca7b5
commit 00ef6e29ce

View File

@ -31,8 +31,9 @@ struct _CallbackData
static const char static const char
instructions[] = instructions[] =
"Press and drag any of the three mouse buttons to add a clip with different " "Left button and drag to draw a rectangle, control+left to draw a rotated "
"shapes. Press 'r' to reset or 'u' to undo the last clip."; "rectangle or shift+left to draw a path. Press 'r' to reset or 'u' "
"to undo the last clip.";
static void static void
path_shapes (gint x, gint y, gint width, gint height) 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.x1 = data->current_clip.x2 = event->x;
data->current_clip.y1 = data->current_clip.y2 = event->y; data->current_clip.y1 = data->current_clip.y2 = event->y;
data->current_clip.type switch (event->button)
= event->button == CLUTTER_BUTTON_PRIMARY ? CLIP_RECTANGLE {
: event->button == CLUTTER_BUTTON_MIDDLE ? CLIP_SHAPES case CLUTTER_BUTTON_PRIMARY:
: CLIP_ROTATED_RECTANGLE; 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); clutter_actor_queue_redraw (stage);