/** * clutter_pan_action_get_motion_coords: * @self: A #ClutterPanAction * @point: the touch point index, with 0 being the first touch * point received by the action * @motion_x: (out) (allow-none): return location for the X coordinate * @motion_y: (out) (allow-none): return location for the Y coordinate * * Retrieves the coordinates, in stage space, dependent on the current state * of the #ClutterPanAction. If it is inactive, both fields will be * set to 0. If it is panning by user action, the values will be equivalent * to those returned by clutter_gesture_action_get_motion_coords(). * If it is interpolating with some form of kinetic scrolling, the values * will be equivalent to those returned by * clutter_pan_action_get_interpolated_coords(). This is a convenience * method designed to be used in replacement "pan" signal handlers. */ void clutter_pan_action_get_motion_coords (ClutterPanAction *self, guint point, gfloat *motion_x, gfloat *motion_y) { ClutterPanActionPrivate *priv; g_return_if_fail (CLUTTER_IS_PAN_ACTION (self)); priv = self->priv; switch (priv->state) { case PAN_STATE_INACTIVE: if (motion_x) *motion_x = 0; if (motion_y) *motion_y = 0; break; case PAN_STATE_PANNING: clutter_gesture_action_get_motion_coords (CLUTTER_GESTURE_ACTION (self), point, motion_x, motion_y); break; case PAN_STATE_INTERPOLATING: clutter_pan_action_get_interpolated_coords (self, motion_x, motion_y); break; default: g_assert_not_reached (); } }
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; }
static void capture_point_update_position (ClutterGestureAction *action, ClutterActor *actor, gint index, ZoomPoint *point) { clutter_gesture_action_get_motion_coords (action, index, &point->update_x, &point->update_y); point->transformed_update_x = point->update_x; point->transformed_update_y = point->update_y; clutter_actor_transform_stage_point (actor, point->update_x, point->update_y, &point->transformed_update_x, &point->transformed_update_y); }
static void on_gesture_progress(ClutterGestureAction *action, ClutterActor *stage, gpointer data) { gfloat x, y; gint dx, dy; clutter_gesture_action_get_motion_coords(action, 0, &x, &y); dx = (guint)x - (guint)x_0; dy = (guint)y - (guint)y_0; if (dx < 0 && dy > 0){ clutter_actor_set_position(tmpRect, x, y_0); } if (dy < 0 && dx > 0){ clutter_actor_set_position(tmpRect, x_0, y); } if (dx < 0 && dy < 0){ clutter_actor_set_position(tmpRect, x, y); } clutter_actor_set_size(tmpRect, ABS(dx), ABS(dy)); }