mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
clutter: Use G_DECLARE_DERIVABLE_TYPE for ClutterAction and subclasses
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/788
This commit is contained in:
parent
8c131b32b1
commit
c42c11583d
@ -33,28 +33,11 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_TYPE_ACTION (clutter_action_get_type ())
|
||||
#define CLUTTER_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ACTION, ClutterAction))
|
||||
#define CLUTTER_IS_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_ACTION))
|
||||
#define CLUTTER_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_ACTION, ClutterActionClass))
|
||||
#define CLUTTER_IS_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_ACTION))
|
||||
#define CLUTTER_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_ACTION, ClutterActionClass))
|
||||
#define CLUTTER_TYPE_ACTION (clutter_action_get_type ())
|
||||
|
||||
typedef struct _ClutterActionClass ClutterActionClass;
|
||||
|
||||
/**
|
||||
* ClutterAction:
|
||||
*
|
||||
* The #ClutterAction structure contains only private data and
|
||||
* should be accessed using the provided API.
|
||||
*
|
||||
* Since: 1.4
|
||||
*/
|
||||
struct _ClutterAction
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterActorMeta parent_instance;
|
||||
};
|
||||
CLUTTER_EXPORT
|
||||
G_DECLARE_DERIVABLE_TYPE (ClutterAction, clutter_action,
|
||||
CLUTTER, ACTION, ClutterActorMeta);
|
||||
|
||||
/**
|
||||
* ClutterActionClass:
|
||||
@ -78,9 +61,6 @@ struct _ClutterActionClass
|
||||
void (* _clutter_action8) (void);
|
||||
};
|
||||
|
||||
CLUTTER_EXPORT
|
||||
GType clutter_action_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/* ClutterActor API */
|
||||
CLUTTER_EXPORT
|
||||
void clutter_actor_add_action (ClutterActor *self,
|
||||
|
@ -30,7 +30,6 @@
|
||||
|
||||
#ifndef __GI_SCANNER__
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterAction, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterActor, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterAlignConstraint, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBackend, g_object_unref)
|
||||
@ -42,7 +41,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBoxLayout, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBrightnessContrastEffect, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterCanvas, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterChildMeta, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterClickAction, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterClone, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterColorizeEffect, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterConstraint, g_object_unref)
|
||||
@ -52,7 +50,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDesaturateEffect, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterEffect, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterFixedLayout, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterFlowLayout, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterGestureAction, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterGridLayout, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterImage, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterInputDevice, g_object_unref)
|
||||
|
@ -159,7 +159,8 @@ static inline void
|
||||
click_action_set_pressed (ClutterClickAction *action,
|
||||
gboolean is_pressed)
|
||||
{
|
||||
ClutterClickActionPrivate *priv = action->priv;
|
||||
ClutterClickActionPrivate *priv =
|
||||
clutter_click_action_get_instance_private (action);
|
||||
|
||||
is_pressed = !!is_pressed;
|
||||
|
||||
@ -174,7 +175,8 @@ static inline void
|
||||
click_action_set_held (ClutterClickAction *action,
|
||||
gboolean is_held)
|
||||
{
|
||||
ClutterClickActionPrivate *priv = action->priv;
|
||||
ClutterClickActionPrivate *priv =
|
||||
clutter_click_action_get_instance_private (action);
|
||||
|
||||
is_held = !!is_held;
|
||||
|
||||
@ -189,7 +191,8 @@ static gboolean
|
||||
click_action_emit_long_press (gpointer data)
|
||||
{
|
||||
ClutterClickAction *action = data;
|
||||
ClutterClickActionPrivate *priv = action->priv;
|
||||
ClutterClickActionPrivate *priv =
|
||||
clutter_click_action_get_instance_private (action);
|
||||
ClutterActor *actor;
|
||||
gboolean result;
|
||||
|
||||
@ -213,7 +216,8 @@ click_action_emit_long_press (gpointer data)
|
||||
static inline void
|
||||
click_action_query_long_press (ClutterClickAction *action)
|
||||
{
|
||||
ClutterClickActionPrivate *priv = action->priv;
|
||||
ClutterClickActionPrivate *priv =
|
||||
clutter_click_action_get_instance_private (action);
|
||||
ClutterActor *actor;
|
||||
gboolean result = FALSE;
|
||||
gint timeout;
|
||||
@ -249,7 +253,8 @@ click_action_query_long_press (ClutterClickAction *action)
|
||||
static inline void
|
||||
click_action_cancel_long_press (ClutterClickAction *action)
|
||||
{
|
||||
ClutterClickActionPrivate *priv = action->priv;
|
||||
ClutterClickActionPrivate *priv =
|
||||
clutter_click_action_get_instance_private (action);
|
||||
|
||||
if (priv->long_press_id != 0)
|
||||
{
|
||||
@ -272,7 +277,8 @@ on_event (ClutterActor *actor,
|
||||
ClutterEvent *event,
|
||||
ClutterClickAction *action)
|
||||
{
|
||||
ClutterClickActionPrivate *priv = action->priv;
|
||||
ClutterClickActionPrivate *priv =
|
||||
clutter_click_action_get_instance_private (action);
|
||||
gboolean has_button = TRUE;
|
||||
|
||||
if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (action)))
|
||||
@ -342,7 +348,8 @@ on_captured_event (ClutterActor *stage,
|
||||
ClutterEvent *event,
|
||||
ClutterClickAction *action)
|
||||
{
|
||||
ClutterClickActionPrivate *priv = action->priv;
|
||||
ClutterClickActionPrivate *priv =
|
||||
clutter_click_action_get_instance_private (action);
|
||||
ClutterActor *actor;
|
||||
ClutterModifierType modifier_state;
|
||||
gboolean has_button = TRUE;
|
||||
@ -434,7 +441,8 @@ clutter_click_action_set_actor (ClutterActorMeta *meta,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
ClutterClickAction *action = CLUTTER_CLICK_ACTION (meta);
|
||||
ClutterClickActionPrivate *priv = action->priv;
|
||||
ClutterClickActionPrivate *priv =
|
||||
clutter_click_action_get_instance_private (action);
|
||||
|
||||
if (priv->event_id != 0)
|
||||
{
|
||||
@ -488,7 +496,8 @@ clutter_click_action_set_property (GObject *gobject,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterClickActionPrivate *priv = CLUTTER_CLICK_ACTION (gobject)->priv;
|
||||
ClutterClickActionPrivate *priv =
|
||||
clutter_click_action_get_instance_private (CLUTTER_CLICK_ACTION (gobject));
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -512,7 +521,8 @@ clutter_click_action_get_property (GObject *gobject,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterClickActionPrivate *priv = CLUTTER_CLICK_ACTION (gobject)->priv;
|
||||
ClutterClickActionPrivate *priv =
|
||||
clutter_click_action_get_instance_private (CLUTTER_CLICK_ACTION (gobject));
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -541,7 +551,8 @@ clutter_click_action_get_property (GObject *gobject,
|
||||
static void
|
||||
clutter_click_action_dispose (GObject *gobject)
|
||||
{
|
||||
ClutterClickActionPrivate *priv = CLUTTER_CLICK_ACTION (gobject)->priv;
|
||||
ClutterClickActionPrivate *priv =
|
||||
clutter_click_action_get_instance_private (CLUTTER_CLICK_ACTION (gobject));
|
||||
|
||||
g_clear_signal_handler (&priv->event_id,
|
||||
clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (gobject)));
|
||||
@ -699,9 +710,11 @@ clutter_click_action_class_init (ClutterClickActionClass *klass)
|
||||
static void
|
||||
clutter_click_action_init (ClutterClickAction *self)
|
||||
{
|
||||
self->priv = clutter_click_action_get_instance_private (self);
|
||||
self->priv->long_press_threshold = -1;
|
||||
self->priv->long_press_duration = -1;
|
||||
ClutterClickActionPrivate *priv =
|
||||
clutter_click_action_get_instance_private (self);
|
||||
|
||||
priv->long_press_threshold = -1;
|
||||
priv->long_press_duration = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -741,7 +754,7 @@ clutter_click_action_release (ClutterClickAction *action)
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_CLICK_ACTION (action));
|
||||
|
||||
priv = action->priv;
|
||||
priv = clutter_click_action_get_instance_private (action);
|
||||
|
||||
if (!priv->is_held)
|
||||
return;
|
||||
@ -767,9 +780,13 @@ clutter_click_action_release (ClutterClickAction *action)
|
||||
guint
|
||||
clutter_click_action_get_button (ClutterClickAction *action)
|
||||
{
|
||||
ClutterClickActionPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_CLICK_ACTION (action), 0);
|
||||
|
||||
return action->priv->press_button;
|
||||
priv = clutter_click_action_get_instance_private (action);
|
||||
|
||||
return priv->press_button;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -785,9 +802,13 @@ clutter_click_action_get_button (ClutterClickAction *action)
|
||||
ClutterModifierType
|
||||
clutter_click_action_get_state (ClutterClickAction *action)
|
||||
{
|
||||
ClutterClickActionPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_CLICK_ACTION (action), 0);
|
||||
|
||||
return action->priv->modifier_state;
|
||||
priv = clutter_click_action_get_instance_private (action);
|
||||
|
||||
return priv->modifier_state;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -805,11 +826,15 @@ clutter_click_action_get_coords (ClutterClickAction *action,
|
||||
gfloat *press_x,
|
||||
gfloat *press_y)
|
||||
{
|
||||
ClutterClickActionPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_ACTION (action));
|
||||
|
||||
priv = clutter_click_action_get_instance_private (action);
|
||||
|
||||
if (press_x != NULL)
|
||||
*press_x = action->priv->press_x;
|
||||
*press_x = priv->press_x;
|
||||
|
||||
if (press_y != NULL)
|
||||
*press_y = action->priv->press_y;
|
||||
*press_y = priv->press_y;
|
||||
}
|
||||
|
@ -37,32 +37,13 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_TYPE_CLICK_ACTION (clutter_click_action_get_type ())
|
||||
#define CLUTTER_CLICK_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_CLICK_ACTION, ClutterClickAction))
|
||||
#define CLUTTER_IS_CLICK_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_CLICK_ACTION))
|
||||
#define CLUTTER_CLICK_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_CLICK_ACTION, ClutterClickActionClass))
|
||||
#define CLUTTER_IS_CLICK_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_CLICK_ACTION))
|
||||
#define CLUTTER_CLICK_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_CLICK_ACTION, ClutterClickActionClass))
|
||||
#define CLUTTER_TYPE_CLICK_ACTION (clutter_click_action_get_type ())
|
||||
|
||||
typedef struct _ClutterClickAction ClutterClickAction;
|
||||
typedef struct _ClutterClickActionPrivate ClutterClickActionPrivate;
|
||||
typedef struct _ClutterClickActionClass ClutterClickActionClass;
|
||||
CLUTTER_EXPORT
|
||||
G_DECLARE_DERIVABLE_TYPE (ClutterClickAction, clutter_click_action,
|
||||
CLUTTER, CLICK_ACTION, ClutterAction);
|
||||
|
||||
/**
|
||||
* ClutterClickAction:
|
||||
*
|
||||
* The #ClutterClickAction structure contains
|
||||
* only private data and should be accessed using the provided API
|
||||
*
|
||||
* Since: 1.4
|
||||
*/
|
||||
struct _ClutterClickAction
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterAction parent_instance;
|
||||
|
||||
ClutterClickActionPrivate *priv;
|
||||
};
|
||||
typedef struct _ClutterClickActionPrivate ClutterClickActionPrivate;
|
||||
|
||||
/**
|
||||
* ClutterClickActionClass:
|
||||
@ -97,9 +78,6 @@ struct _ClutterClickActionClass
|
||||
void (* _clutter_click_action7) (void);
|
||||
};
|
||||
|
||||
CLUTTER_EXPORT
|
||||
GType clutter_click_action_get_type (void) G_GNUC_CONST;
|
||||
|
||||
CLUTTER_EXPORT
|
||||
ClutterAction * clutter_click_action_new (void);
|
||||
|
||||
|
@ -157,7 +157,8 @@ G_DEFINE_TYPE_WITH_PRIVATE (ClutterGestureAction, clutter_gesture_action, CLUTTE
|
||||
static GesturePoint *
|
||||
gesture_register_point (ClutterGestureAction *action, ClutterEvent *event)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv = action->priv;
|
||||
ClutterGestureActionPrivate *priv =
|
||||
clutter_gesture_action_get_instance_private (action);
|
||||
GesturePoint *point = NULL;
|
||||
|
||||
if (priv->points->len >= MAX_GESTURE_POINTS)
|
||||
@ -190,7 +191,8 @@ gesture_find_point (ClutterGestureAction *action,
|
||||
ClutterEvent *event,
|
||||
gint *position)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv = action->priv;
|
||||
ClutterGestureActionPrivate *priv =
|
||||
clutter_gesture_action_get_instance_private (action);
|
||||
GesturePoint *point = NULL;
|
||||
ClutterEventType type = clutter_event_type (event);
|
||||
ClutterInputDevice *device = clutter_event_get_device (event);
|
||||
@ -220,9 +222,10 @@ gesture_find_point (ClutterGestureAction *action,
|
||||
static void
|
||||
gesture_unregister_point (ClutterGestureAction *action, gint position)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv = action->priv;
|
||||
ClutterGestureActionPrivate *priv =
|
||||
clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
if (action->priv->points->len == 0)
|
||||
if (priv->points->len == 0)
|
||||
return;
|
||||
|
||||
g_array_remove_index (priv->points, position);
|
||||
@ -303,7 +306,8 @@ gesture_point_unset (GesturePoint *point)
|
||||
static void
|
||||
cancel_gesture (ClutterGestureAction *action)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv = action->priv;
|
||||
ClutterGestureActionPrivate *priv =
|
||||
clutter_gesture_action_get_instance_private (action);
|
||||
ClutterActor *actor;
|
||||
|
||||
priv->in_gesture = FALSE;
|
||||
@ -313,14 +317,15 @@ cancel_gesture (ClutterGestureAction *action)
|
||||
actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (action));
|
||||
g_signal_emit (action, gesture_signals[GESTURE_CANCEL], 0, actor);
|
||||
|
||||
g_array_set_size (action->priv->points, 0);
|
||||
g_array_set_size (priv->points, 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
begin_gesture (ClutterGestureAction *action,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv = action->priv;
|
||||
ClutterGestureActionPrivate *priv =
|
||||
clutter_gesture_action_get_instance_private (action);
|
||||
gboolean return_value;
|
||||
|
||||
priv->in_gesture = TRUE;
|
||||
@ -353,7 +358,8 @@ stage_captured_event_cb (ClutterActor *stage,
|
||||
ClutterEvent *event,
|
||||
ClutterGestureAction *action)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv = action->priv;
|
||||
ClutterGestureActionPrivate *priv =
|
||||
clutter_gesture_action_get_instance_private (action);
|
||||
ClutterActor *actor;
|
||||
gint position;
|
||||
float threshold_x, threshold_y;
|
||||
@ -488,7 +494,8 @@ actor_captured_event_cb (ClutterActor *actor,
|
||||
ClutterEvent *event,
|
||||
ClutterGestureAction *action)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv = action->priv;
|
||||
ClutterGestureActionPrivate *priv =
|
||||
clutter_gesture_action_get_instance_private (action);
|
||||
GesturePoint *point G_GNUC_UNUSED;
|
||||
|
||||
if ((clutter_event_type (event) != CLUTTER_BUTTON_PRESS) &&
|
||||
@ -522,7 +529,8 @@ static void
|
||||
clutter_gesture_action_set_actor (ClutterActorMeta *meta,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv = CLUTTER_GESTURE_ACTION (meta)->priv;
|
||||
ClutterGestureActionPrivate *priv =
|
||||
clutter_gesture_action_get_instance_private (CLUTTER_GESTURE_ACTION (meta));
|
||||
ClutterActorMetaClass *meta_class =
|
||||
CLUTTER_ACTOR_META_CLASS (clutter_gesture_action_parent_class);
|
||||
|
||||
@ -563,7 +571,8 @@ clutter_gesture_action_set_enabled (ClutterActorMeta *meta,
|
||||
ClutterActorMetaClass *meta_class =
|
||||
CLUTTER_ACTOR_META_CLASS (clutter_gesture_action_parent_class);
|
||||
ClutterGestureAction *gesture_action = CLUTTER_GESTURE_ACTION (meta);
|
||||
ClutterGestureActionPrivate *priv = gesture_action->priv;
|
||||
ClutterGestureActionPrivate *priv =
|
||||
clutter_gesture_action_get_instance_private (gesture_action);
|
||||
|
||||
if (!is_enabled && priv->in_gesture)
|
||||
cancel_gesture (gesture_action);
|
||||
@ -585,6 +594,8 @@ clutter_gesture_action_set_property (GObject *gobject,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterGestureAction *self = CLUTTER_GESTURE_ACTION (gobject);
|
||||
ClutterGestureActionPrivate *priv =
|
||||
clutter_gesture_action_get_instance_private (self);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -597,11 +608,15 @@ clutter_gesture_action_set_property (GObject *gobject,
|
||||
break;
|
||||
|
||||
case PROP_THRESHOLD_TRIGGER_DISTANCE_X:
|
||||
clutter_gesture_action_set_threshold_trigger_distance (self, g_value_get_float (value), self->priv->distance_y);
|
||||
clutter_gesture_action_set_threshold_trigger_distance (self,
|
||||
g_value_get_float (value),
|
||||
priv->distance_y);
|
||||
break;
|
||||
|
||||
case PROP_THRESHOLD_TRIGGER_DISTANCE_Y:
|
||||
clutter_gesture_action_set_threshold_trigger_distance (self, self->priv->distance_x, g_value_get_float (value));
|
||||
clutter_gesture_action_set_threshold_trigger_distance (self,
|
||||
priv->distance_x,
|
||||
g_value_get_float (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -616,28 +631,29 @@ clutter_gesture_action_get_property (GObject *gobject,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterGestureAction *self = CLUTTER_GESTURE_ACTION (gobject);
|
||||
ClutterGestureActionPrivate *priv =
|
||||
clutter_gesture_action_get_instance_private (CLUTTER_GESTURE_ACTION (gobject));
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_N_TOUCH_POINTS:
|
||||
g_value_set_int (value, self->priv->requested_nb_points);
|
||||
g_value_set_int (value, priv->requested_nb_points);
|
||||
break;
|
||||
|
||||
case PROP_THRESHOLD_TRIGGER_EDGE:
|
||||
g_value_set_enum (value, self->priv->edge);
|
||||
g_value_set_enum (value, priv->edge);
|
||||
break;
|
||||
|
||||
case PROP_THRESHOLD_TRIGGER_DISTANCE_X:
|
||||
if (self->priv->distance_x > 0.0)
|
||||
g_value_set_float (value, self->priv->distance_x);
|
||||
if (priv->distance_x > 0.0)
|
||||
g_value_set_float (value, priv->distance_x);
|
||||
else
|
||||
g_value_set_float (value, gesture_get_default_threshold ());
|
||||
break;
|
||||
|
||||
case PROP_THRESHOLD_TRIGGER_DISTANCE_Y:
|
||||
if (self->priv->distance_y > 0.0)
|
||||
g_value_set_float (value, self->priv->distance_y);
|
||||
if (priv->distance_y > 0.0)
|
||||
g_value_set_float (value, priv->distance_y);
|
||||
else
|
||||
g_value_set_float (value, gesture_get_default_threshold ());
|
||||
break;
|
||||
@ -651,7 +667,8 @@ clutter_gesture_action_get_property (GObject *gobject,
|
||||
static void
|
||||
clutter_gesture_action_finalize (GObject *gobject)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv = CLUTTER_GESTURE_ACTION (gobject)->priv;
|
||||
ClutterGestureActionPrivate *priv =
|
||||
clutter_gesture_action_get_instance_private (CLUTTER_GESTURE_ACTION (gobject));
|
||||
|
||||
g_array_unref (priv->points);
|
||||
|
||||
@ -843,13 +860,14 @@ clutter_gesture_action_class_init (ClutterGestureActionClass *klass)
|
||||
static void
|
||||
clutter_gesture_action_init (ClutterGestureAction *self)
|
||||
{
|
||||
self->priv = clutter_gesture_action_get_instance_private (self);
|
||||
ClutterGestureActionPrivate *priv =
|
||||
clutter_gesture_action_get_instance_private (self);
|
||||
|
||||
self->priv->points = g_array_sized_new (FALSE, TRUE, sizeof (GesturePoint), 3);
|
||||
g_array_set_clear_func (self->priv->points, (GDestroyNotify) gesture_point_unset);
|
||||
priv->points = g_array_sized_new (FALSE, TRUE, sizeof (GesturePoint), 3);
|
||||
g_array_set_clear_func (priv->points, (GDestroyNotify) gesture_point_unset);
|
||||
|
||||
self->priv->requested_nb_points = 1;
|
||||
self->priv->edge = CLUTTER_GESTURE_TRIGGER_EDGE_NONE;
|
||||
priv->requested_nb_points = 1;
|
||||
priv->edge = CLUTTER_GESTURE_TRIGGER_EDGE_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -888,16 +906,21 @@ clutter_gesture_action_get_press_coords (ClutterGestureAction *action,
|
||||
gfloat *press_x,
|
||||
gfloat *press_y)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
|
||||
g_return_if_fail (action->priv->points->len > point);
|
||||
|
||||
priv = clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
g_return_if_fail (priv->points->len > point);
|
||||
|
||||
if (press_x)
|
||||
*press_x = g_array_index (action->priv->points,
|
||||
*press_x = g_array_index (priv->points,
|
||||
GesturePoint,
|
||||
point).press_x;
|
||||
|
||||
if (press_y)
|
||||
*press_y = g_array_index (action->priv->points,
|
||||
*press_y = g_array_index (priv->points,
|
||||
GesturePoint,
|
||||
point).press_y;
|
||||
}
|
||||
@ -923,16 +946,21 @@ clutter_gesture_action_get_motion_coords (ClutterGestureAction *action,
|
||||
gfloat *motion_x,
|
||||
gfloat *motion_y)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
|
||||
g_return_if_fail (action->priv->points->len > point);
|
||||
|
||||
priv = clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
g_return_if_fail (priv->points->len > point);
|
||||
|
||||
if (motion_x)
|
||||
*motion_x = g_array_index (action->priv->points,
|
||||
*motion_x = g_array_index (priv->points,
|
||||
GesturePoint,
|
||||
point).last_motion_x;
|
||||
|
||||
if (motion_y)
|
||||
*motion_y = g_array_index (action->priv->points,
|
||||
*motion_y = g_array_index (priv->points,
|
||||
GesturePoint,
|
||||
point).last_motion_y;
|
||||
}
|
||||
@ -960,15 +988,19 @@ clutter_gesture_action_get_motion_delta (ClutterGestureAction *action,
|
||||
gfloat *delta_x,
|
||||
gfloat *delta_y)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv;
|
||||
gfloat d_x, d_y;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), 0);
|
||||
g_return_val_if_fail (action->priv->points->len > point, 0);
|
||||
|
||||
d_x = g_array_index (action->priv->points,
|
||||
priv = clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
g_return_val_if_fail (priv->points->len > point, 0);
|
||||
|
||||
d_x = g_array_index (priv->points,
|
||||
GesturePoint,
|
||||
point).last_delta_x;
|
||||
d_y = g_array_index (action->priv->points,
|
||||
d_y = g_array_index (priv->points,
|
||||
GesturePoint,
|
||||
point).last_delta_y;
|
||||
|
||||
@ -1002,16 +1034,21 @@ clutter_gesture_action_get_release_coords (ClutterGestureAction *action,
|
||||
gfloat *release_x,
|
||||
gfloat *release_y)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
|
||||
g_return_if_fail (action->priv->points->len > point);
|
||||
|
||||
priv = clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
g_return_if_fail (priv->points->len > point);
|
||||
|
||||
if (release_x)
|
||||
*release_x = g_array_index (action->priv->points,
|
||||
*release_x = g_array_index (priv->points,
|
||||
GesturePoint,
|
||||
point).release_x;
|
||||
|
||||
if (release_y)
|
||||
*release_y = g_array_index (action->priv->points,
|
||||
*release_y = g_array_index (priv->points,
|
||||
GesturePoint,
|
||||
point).release_y;
|
||||
}
|
||||
@ -1037,16 +1074,20 @@ clutter_gesture_action_get_velocity (ClutterGestureAction *action,
|
||||
gfloat *velocity_x,
|
||||
gfloat *velocity_y)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv;
|
||||
gfloat d_x, d_y, distance, velocity;
|
||||
gint64 d_t;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), 0);
|
||||
g_return_val_if_fail (action->priv->points->len > point, 0);
|
||||
|
||||
priv = clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
g_return_val_if_fail (priv->points->len > point, 0);
|
||||
|
||||
distance = clutter_gesture_action_get_motion_delta (action, point,
|
||||
&d_x, &d_y);
|
||||
|
||||
d_t = g_array_index (action->priv->points,
|
||||
d_t = g_array_index (priv->points,
|
||||
GesturePoint,
|
||||
point).last_delta_time;
|
||||
|
||||
@ -1073,9 +1114,13 @@ clutter_gesture_action_get_velocity (ClutterGestureAction *action,
|
||||
gint
|
||||
clutter_gesture_action_get_n_touch_points (ClutterGestureAction *action)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), 0);
|
||||
|
||||
return action->priv->requested_nb_points;
|
||||
priv = clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
return priv->requested_nb_points;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1096,7 +1141,7 @@ clutter_gesture_action_set_n_touch_points (ClutterGestureAction *action,
|
||||
g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
|
||||
g_return_if_fail (nb_points >= 1);
|
||||
|
||||
priv = action->priv;
|
||||
priv = clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
if (priv->requested_nb_points == nb_points)
|
||||
return;
|
||||
@ -1150,9 +1195,13 @@ clutter_gesture_action_set_n_touch_points (ClutterGestureAction *action,
|
||||
guint
|
||||
clutter_gesture_action_get_n_current_points (ClutterGestureAction *action)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), 0);
|
||||
|
||||
return action->priv->points->len;
|
||||
priv = clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
return priv->points->len;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1170,10 +1219,15 @@ ClutterEventSequence *
|
||||
clutter_gesture_action_get_sequence (ClutterGestureAction *action,
|
||||
guint point)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), NULL);
|
||||
g_return_val_if_fail (action->priv->points->len > point, NULL);
|
||||
ClutterGestureActionPrivate *priv;
|
||||
|
||||
return g_array_index (action->priv->points, GesturePoint, point).sequence;
|
||||
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), NULL);
|
||||
|
||||
priv = clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
g_return_val_if_fail (priv->points->len > point, NULL);
|
||||
|
||||
return g_array_index (priv->points, GesturePoint, point).sequence;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1192,10 +1246,15 @@ ClutterInputDevice *
|
||||
clutter_gesture_action_get_device (ClutterGestureAction *action,
|
||||
guint point)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), NULL);
|
||||
g_return_val_if_fail (action->priv->points->len > point, NULL);
|
||||
ClutterGestureActionPrivate *priv;
|
||||
|
||||
return g_array_index (action->priv->points, GesturePoint, point).device;
|
||||
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), NULL);
|
||||
|
||||
priv = clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
g_return_val_if_fail (priv->points->len > point, NULL);
|
||||
|
||||
return g_array_index (priv->points, GesturePoint, point).device;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1215,11 +1274,15 @@ clutter_gesture_action_get_last_event (ClutterGestureAction *action,
|
||||
guint point)
|
||||
{
|
||||
GesturePoint *gesture_point;
|
||||
ClutterGestureActionPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), NULL);
|
||||
g_return_val_if_fail (action->priv->points->len > point, NULL);
|
||||
|
||||
gesture_point = &g_array_index (action->priv->points, GesturePoint, point);
|
||||
priv = clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
g_return_val_if_fail (priv->points->len > point, NULL);
|
||||
|
||||
gesture_point = &g_array_index (priv->points, GesturePoint, point);
|
||||
|
||||
return gesture_point->last_event;
|
||||
}
|
||||
@ -1256,12 +1319,16 @@ void
|
||||
clutter_gesture_action_set_threshold_trigger_edge (ClutterGestureAction *action,
|
||||
ClutterGestureTriggerEdge edge)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
|
||||
|
||||
if (action->priv->edge == edge)
|
||||
priv = clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
if (priv->edge == edge)
|
||||
return;
|
||||
|
||||
action->priv->edge = edge;
|
||||
priv->edge = edge;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (action), gesture_props[PROP_THRESHOLD_TRIGGER_EDGE]);
|
||||
}
|
||||
@ -1280,10 +1347,14 @@ clutter_gesture_action_set_threshold_trigger_edge (ClutterGestureAction *ac
|
||||
ClutterGestureTriggerEdge
|
||||
clutter_gesture_action_get_threshold_trigger_edge (ClutterGestureAction *action)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action),
|
||||
CLUTTER_GESTURE_TRIGGER_EDGE_NONE);
|
||||
|
||||
return action->priv->edge;
|
||||
priv = clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
return priv->edge;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1323,17 +1394,21 @@ clutter_gesture_action_set_threshold_trigger_distance (ClutterGestureAction
|
||||
float x,
|
||||
float y)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
|
||||
|
||||
if (fabsf (x - action->priv->distance_x) > FLOAT_EPSILON)
|
||||
priv = clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
if (fabsf (x - priv->distance_x) > FLOAT_EPSILON)
|
||||
{
|
||||
action->priv->distance_x = x;
|
||||
priv->distance_x = x;
|
||||
g_object_notify_by_pspec (G_OBJECT (action), gesture_props[PROP_THRESHOLD_TRIGGER_DISTANCE_X]);
|
||||
}
|
||||
|
||||
if (fabsf (y - action->priv->distance_y) > FLOAT_EPSILON)
|
||||
if (fabsf (y - priv->distance_y) > FLOAT_EPSILON)
|
||||
{
|
||||
action->priv->distance_y = y;
|
||||
priv->distance_y = y;
|
||||
g_object_notify_by_pspec (G_OBJECT (action), gesture_props[PROP_THRESHOLD_TRIGGER_DISTANCE_Y]);
|
||||
}
|
||||
}
|
||||
@ -1354,19 +1429,23 @@ clutter_gesture_action_get_threshold_trigger_distance (ClutterGestureAction *act
|
||||
float *x,
|
||||
float *y)
|
||||
{
|
||||
ClutterGestureActionPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
|
||||
|
||||
priv = clutter_gesture_action_get_instance_private (action);
|
||||
|
||||
if (x != NULL)
|
||||
{
|
||||
if (action->priv->distance_x > 0.0)
|
||||
*x = action->priv->distance_x;
|
||||
if (priv->distance_x > 0.0)
|
||||
*x = priv->distance_x;
|
||||
else
|
||||
*x = gesture_get_default_threshold ();
|
||||
}
|
||||
if (y != NULL)
|
||||
{
|
||||
if (action->priv->distance_y > 0.0)
|
||||
*y = action->priv->distance_y;
|
||||
if (priv->distance_y > 0.0)
|
||||
*y = priv->distance_y;
|
||||
else
|
||||
*y = gesture_get_default_threshold ();
|
||||
}
|
||||
|
@ -34,32 +34,13 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_TYPE_GESTURE_ACTION (clutter_gesture_action_get_type ())
|
||||
#define CLUTTER_GESTURE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_GESTURE_ACTION, ClutterGestureAction))
|
||||
#define CLUTTER_IS_GESTURE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_GESTURE_ACTION))
|
||||
#define CLUTTER_GESTURE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_GESTURE_ACTION, ClutterGestureActionClass))
|
||||
#define CLUTTER_IS_GESTURE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_GESTURE_ACTION))
|
||||
#define CLUTTER_GESTURE_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_GESTURE_ACTION, ClutterGestureActionClass))
|
||||
#define CLUTTER_TYPE_GESTURE_ACTION (clutter_gesture_action_get_type ())
|
||||
|
||||
typedef struct _ClutterGestureAction ClutterGestureAction;
|
||||
typedef struct _ClutterGestureActionPrivate ClutterGestureActionPrivate;
|
||||
typedef struct _ClutterGestureActionClass ClutterGestureActionClass;
|
||||
CLUTTER_EXPORT
|
||||
G_DECLARE_DERIVABLE_TYPE (ClutterGestureAction, clutter_gesture_action,
|
||||
CLUTTER, GESTURE_ACTION, ClutterAction);
|
||||
|
||||
/**
|
||||
* ClutterGestureAction:
|
||||
*
|
||||
* The #ClutterGestureAction structure contains
|
||||
* only private data and should be accessed using the provided API
|
||||
*
|
||||
* Since: 1.8
|
||||
*/
|
||||
struct _ClutterGestureAction
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterAction parent_instance;
|
||||
|
||||
ClutterGestureActionPrivate *priv;
|
||||
};
|
||||
typedef struct _ClutterGestureActionPrivate ClutterGestureActionPrivate;
|
||||
|
||||
/**
|
||||
* ClutterGestureActionClass:
|
||||
@ -101,9 +82,6 @@ struct _ClutterGestureActionClass
|
||||
void (* _clutter_gesture_action6) (void);
|
||||
};
|
||||
|
||||
CLUTTER_EXPORT
|
||||
GType clutter_gesture_action_get_type (void) G_GNUC_CONST;
|
||||
|
||||
CLUTTER_EXPORT
|
||||
ClutterAction * clutter_gesture_action_new (void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user