static void gesture_end (ClutterGestureAction *action, ClutterActor *actor) { ClutterSwipeActionPrivate *priv = CLUTTER_SWIPE_ACTION (action)->priv; gfloat press_x, press_y; gfloat release_x, release_y; ClutterSwipeDirection direction = 0; gboolean can_emit_swipe; clutter_gesture_action_get_press_coords (action, 0, &press_x, &press_y); clutter_gesture_action_get_release_coords (action, 0, &release_x, &release_y); if (release_x - press_x > priv->threshold) direction |= CLUTTER_SWIPE_DIRECTION_RIGHT; else if (press_x - release_x > priv->threshold) direction |= CLUTTER_SWIPE_DIRECTION_LEFT; if (release_y - press_y > priv->threshold) direction |= CLUTTER_SWIPE_DIRECTION_DOWN; else if (press_y - release_y > priv->threshold) direction |= CLUTTER_SWIPE_DIRECTION_UP; /* XXX:2.0 remove */ g_signal_emit (action, swipe_signals[SWIPE], 0, actor, direction, &can_emit_swipe); if (can_emit_swipe) g_signal_emit (action, swipe_signals[SWEPT], 0, actor, direction); }
static void on_gesture_begin(ClutterGestureAction *action, ClutterActor *stage, gpointer data) { gfloat x, y; ClutterColor transp = {0, 0, 0, 0}; ClutterColor grey = {30, 30, 30, 128}; switch (tool){ case TOOL_RECTANGLE: clutter_gesture_action_get_press_coords(action, 0, &x, &y); tmpRect = clutter_rectangle_new_with_color(&transp); clutter_rectangle_set_border_width(CLUTTER_RECTANGLE(tmpRect), 1); clutter_rectangle_set_border_color(CLUTTER_RECTANGLE(tmpRect), &grey); clutter_actor_set_position(tmpRect, x, y); clutter_actor_set_size(tmpRect, 0, 0); clutter_actor_add_child(CLUTTER_ACTOR(stage), tmpRect); clutter_actor_show(tmpRect); x_0 = x; y_0 = y; break; default: break; } }
static gboolean gesture_progress (ClutterGestureAction *action, ClutterActor *actor) { ClutterSwipeActionPrivate *priv = CLUTTER_SWIPE_ACTION (action)->priv; gfloat press_x, press_y; gfloat motion_x, motion_y; gfloat delta_x, delta_y; ClutterSwipeDirection h_direction = 0, v_direction = 0; clutter_gesture_action_get_press_coords (action, 0, &press_x, &press_y); clutter_gesture_action_get_motion_coords (action, 0, &motion_x, &motion_y); delta_x = press_x - motion_x; delta_y = press_y - motion_y; if (delta_x >= priv->threshold) h_direction = CLUTTER_SWIPE_DIRECTION_RIGHT; else if (delta_x < -priv->threshold) h_direction = CLUTTER_SWIPE_DIRECTION_LEFT; if (delta_y >= priv->threshold) v_direction = CLUTTER_SWIPE_DIRECTION_DOWN; else if (delta_y < -priv->threshold) v_direction = CLUTTER_SWIPE_DIRECTION_UP; /* cancel gesture on direction reversal */ if (priv->h_direction == 0) priv->h_direction = h_direction; if (priv->v_direction == 0) priv->v_direction = v_direction; if (priv->h_direction != h_direction) return FALSE; if (priv->v_direction != v_direction) return FALSE; return TRUE; }