zoom-action: Use macros for subclassing boilerplate
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3387>
This commit is contained in:
parent
09b7cd9f4a
commit
5fb78dfbad
@ -67,7 +67,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterText, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterTimeline, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterTransitionGroup, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterTransition, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterZoomAction, g_object_unref)
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterActorBox, clutter_actor_box_free)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterColor, clutter_color_free)
|
||||
|
@ -69,7 +69,7 @@ typedef struct
|
||||
gfloat transformed_update_y;
|
||||
} ZoomPoint;
|
||||
|
||||
struct _ClutterZoomActionPrivate
|
||||
typedef struct _ClutterZoomActionPrivate
|
||||
{
|
||||
ClutterStage *stage;
|
||||
|
||||
@ -87,7 +87,7 @@ struct _ClutterZoomActionPrivate
|
||||
gdouble initial_scale_y;
|
||||
|
||||
gdouble zoom_initial_distance;
|
||||
};
|
||||
} ClutterZoomActionPrivate;
|
||||
|
||||
enum
|
||||
{
|
||||
@ -142,7 +142,8 @@ static gboolean
|
||||
clutter_zoom_action_gesture_begin (ClutterGestureAction *action,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
ClutterZoomActionPrivate *priv = ((ClutterZoomAction *) action)->priv;
|
||||
ClutterZoomActionPrivate *priv =
|
||||
clutter_zoom_action_get_instance_private (CLUTTER_ZOOM_ACTION (action));
|
||||
gfloat dx, dy;
|
||||
|
||||
capture_point_initial_position (action, actor, 0, &priv->points[0]);
|
||||
@ -179,7 +180,8 @@ static gboolean
|
||||
clutter_zoom_action_gesture_progress (ClutterGestureAction *action,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
ClutterZoomActionPrivate *priv = ((ClutterZoomAction *) action)->priv;
|
||||
ClutterZoomActionPrivate *priv =
|
||||
clutter_zoom_action_get_instance_private (CLUTTER_ZOOM_ACTION (action));
|
||||
gdouble distance, new_scale;
|
||||
gfloat dx, dy;
|
||||
gboolean retval;
|
||||
@ -210,7 +212,8 @@ static void
|
||||
clutter_zoom_action_gesture_cancel (ClutterGestureAction *action,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
ClutterZoomActionPrivate *priv = ((ClutterZoomAction *) action)->priv;
|
||||
ClutterZoomActionPrivate *priv =
|
||||
clutter_zoom_action_get_instance_private (CLUTTER_ZOOM_ACTION (action));
|
||||
|
||||
clutter_actor_set_translation (actor,
|
||||
priv->initial_x,
|
||||
@ -275,12 +278,8 @@ clutter_zoom_action_class_init (ClutterZoomActionClass *klass)
|
||||
static void
|
||||
clutter_zoom_action_init (ClutterZoomAction *self)
|
||||
{
|
||||
ClutterGestureAction *gesture;
|
||||
|
||||
self->priv = clutter_zoom_action_get_instance_private (self);
|
||||
|
||||
gesture = CLUTTER_GESTURE_ACTION (self);
|
||||
clutter_gesture_action_set_n_touch_points (gesture, 2);
|
||||
clutter_gesture_action_set_n_touch_points (CLUTTER_GESTURE_ACTION (self),
|
||||
2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -307,10 +306,14 @@ void
|
||||
clutter_zoom_action_get_focal_point (ClutterZoomAction *action,
|
||||
graphene_point_t *point)
|
||||
{
|
||||
ClutterZoomActionPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_ZOOM_ACTION (action));
|
||||
g_return_if_fail (point != NULL);
|
||||
|
||||
*point = action->priv->focal_point;
|
||||
priv = clutter_zoom_action_get_instance_private (action);
|
||||
|
||||
*point = priv->focal_point;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -325,8 +328,12 @@ void
|
||||
clutter_zoom_action_get_transformed_focal_point (ClutterZoomAction *action,
|
||||
graphene_point_t *point)
|
||||
{
|
||||
ClutterZoomActionPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_ZOOM_ACTION (action));
|
||||
g_return_if_fail (point != NULL);
|
||||
|
||||
*point = action->priv->transformed_focal_point;
|
||||
priv = clutter_zoom_action_get_instance_private (action);
|
||||
|
||||
*point = priv->transformed_focal_point;
|
||||
}
|
||||
|
@ -35,23 +35,13 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_TYPE_ZOOM_ACTION (clutter_zoom_action_get_type ())
|
||||
#define CLUTTER_ZOOM_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ZOOM_ACTION, ClutterZoomAction))
|
||||
#define CLUTTER_IS_ZOOM_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_ZOOM_ACTION))
|
||||
#define CLUTTER_ZOOM_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_ZOOM_ACTION, ClutterZoomActionClass))
|
||||
#define CLUTTER_IS_ZOOM_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_ZOOM_ACTION))
|
||||
#define CLUTTER_ZOOM_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_ZOOM_ACTION, ClutterZoomActionClass))
|
||||
|
||||
typedef struct _ClutterZoomAction ClutterZoomAction;
|
||||
typedef struct _ClutterZoomActionPrivate ClutterZoomActionPrivate;
|
||||
typedef struct _ClutterZoomActionClass ClutterZoomActionClass;
|
||||
|
||||
struct _ClutterZoomAction
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterGestureAction parent_instance;
|
||||
|
||||
ClutterZoomActionPrivate *priv;
|
||||
};
|
||||
CLUTTER_EXPORT
|
||||
G_DECLARE_DERIVABLE_TYPE (ClutterZoomAction,
|
||||
clutter_zoom_action,
|
||||
CLUTTER,
|
||||
ZOOM_ACTION,
|
||||
ClutterGestureAction)
|
||||
|
||||
/**
|
||||
* ClutterZoomActionClass:
|
||||
@ -66,9 +56,6 @@ struct _ClutterZoomActionClass
|
||||
ClutterGestureActionClass parent_class;
|
||||
};
|
||||
|
||||
CLUTTER_EXPORT
|
||||
GType clutter_zoom_action_get_type (void) G_GNUC_CONST;
|
||||
|
||||
CLUTTER_EXPORT
|
||||
ClutterAction * clutter_zoom_action_new (void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user