Top | ![]() |
![]() |
![]() |
![]() |
ClutterDragAction is a sub-class of ClutterAction that implements all the necessary logic for dragging actors.
The simplest usage of ClutterDragAction consists in adding it to a ClutterActor and setting it as reactive; for instance, the following code:
1 2 |
clutter_actor_add_action (actor, clutter_drag_action_new ()); clutter_actor_set_reactive (actor, TRUE); |
will automatically result in the actor moving to follow the pointer whenever the pointer's button is pressed over the actor and moved across the stage.
The ClutterDragAction will signal the begin and the end of a dragging through the “drag-begin” and “drag-end” signals, respectively. Each pointer motion during a drag will also result in the “drag-motion” signal to be emitted.
It is also possible to set another ClutterActor as the dragged actor
by calling clutter_drag_action_set_drag_handle()
from within a handle
of the “drag-begin” signal. The drag handle must be
parented and exist between the emission of “drag-begin”
and “drag-end”.
The drag-action example
allows dragging the rectangle around the stage using a ClutterDragAction.
When pressing the Shift
key the actor that is being dragged will be a
separate rectangle, and when the drag ends, the original rectangle will be
animated to the final drop coordinates.
ClutterDragAction is available since Clutter 1.4
ClutterAction *
clutter_drag_action_new (void
);
Creates a new ClutterDragAction instance
Since: 1.4
void clutter_drag_action_set_drag_threshold (ClutterDragAction *action
,gint x_threshold
,gint y_threshold
);
Sets the horizontal and vertical drag thresholds that must be
cleared by the pointer before action
can begin the dragging.
If x_threshold
or y_threshold
are set to -1 then the default
drag threshold stored in the “dnd-drag-threshold”
property of ClutterSettings will be used.
action |
||
x_threshold |
a distance on the horizontal axis, in pixels, or -1 to use the default drag threshold from ClutterSettings |
|
y_threshold |
a distance on the vertical axis, in pixels, or -1 to use the default drag threshold from ClutterSettings |
Since: 1.4
void clutter_drag_action_get_drag_threshold (ClutterDragAction *action
,guint *x_threshold
,guint *y_threshold
);
Retrieves the values set by clutter_drag_action_set_drag_threshold()
.
If the “x-drag-threshold” property or the “y-drag-threshold” property have been set to -1 then this function will return the default drag threshold value as stored by the “dnd-drag-threshold” property of ClutterSettings.
action |
||
x_threshold |
return location for the horizontal drag threshold value, in pixels. |
[out] |
y_threshold |
return location for the vertical drag threshold value, in pixels. |
[out] |
Since: 1.4
void clutter_drag_action_set_drag_handle (ClutterDragAction *action
,ClutterActor *handle
);
Sets the actor to be used as the drag handle.
Since: 1.4
ClutterActor *
clutter_drag_action_get_drag_handle (ClutterDragAction *action
);
Retrieves the drag handle set by clutter_drag_action_set_drag_handle()
Since: 1.4
void clutter_drag_action_set_drag_axis (ClutterDragAction *action
,ClutterDragAxis axis
);
Restricts the dragging action to a specific axis
Since: 1.4
ClutterDragAxis
clutter_drag_action_get_drag_axis (ClutterDragAction *action
);
Retrieves the axis constraint set by clutter_drag_action_set_drag_axis()
Since: 1.4
void clutter_drag_action_set_drag_area (ClutterDragAction *action
,const ClutterRect *drag_area
);
Sets drag_area
to constrain the dragging of the actor associated
with action
, so that it position is always within drag_area
, expressed
in parent's coordinates.
If drag_area
is NULL
, the actor is not constrained.
gboolean clutter_drag_action_get_drag_area (ClutterDragAction *action
,ClutterRect *drag_area
);
Retrieves the "drag area" associated with action
, that
is a ClutterRect that constrains the actor movements,
in parents coordinates.
void clutter_drag_action_get_press_coords (ClutterDragAction *action
,gfloat *press_x
,gfloat *press_y
);
Retrieves the coordinates, in stage space, of the press event that started the dragging
action |
||
press_x |
return location for the press event's X coordinate. |
[out] |
press_y |
return location for the press event's Y coordinate. |
[out] |
Since: 1.4
void clutter_drag_action_get_motion_coords (ClutterDragAction *action
,gfloat *motion_x
,gfloat *motion_y
);
Retrieves the coordinates, in stage space, of the latest motion event during the dragging
action |
||
motion_x |
return location for the latest motion event's X coordinate. |
[out] |
motion_y |
return location for the latest motion event's Y coordinate. |
[out] |
Since: 1.4
struct ClutterDragAction { };
The ClutterDragAction structure contains only private data and should be accessed using the provided API
Since: 1.4
struct ClutterDragActionClass { void (* drag_begin) (ClutterDragAction *action, ClutterActor *actor, gfloat event_x, gfloat event_y, ClutterModifierType modifiers); void (* drag_motion) (ClutterDragAction *action, ClutterActor *actor, gfloat delta_x, gfloat delta_y); void (* drag_end) (ClutterDragAction *action, ClutterActor *actor, gfloat event_x, gfloat event_y, ClutterModifierType modifiers); gboolean (* drag_progress) (ClutterDragAction *action, ClutterActor *actor, gfloat delta_x, gfloat delta_y); };
The ClutterDragActionClass structure contains only private data
Since: 1.4
The axis of the constraint that should be applied on the dragging action
Since: 1.4