swipe-action: Use macros for subclassing boilerplate
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3387>
This commit is contained in:
parent
1df56ca77a
commit
57fbc304f5
@ -50,7 +50,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPropertyTransition, g_object_unref)
|
|||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterScrollActor, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterScrollActor, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterShaderEffect, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterShaderEffect, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterStage, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterStage, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterSwipeAction, g_object_unref)
|
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterText, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterText, g_object_unref)
|
||||||
|
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterActorBox, clutter_actor_box_free)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterActorBox, clutter_actor_box_free)
|
||||||
|
@ -44,13 +44,13 @@
|
|||||||
#include "clutter/clutter-marshal.h"
|
#include "clutter/clutter-marshal.h"
|
||||||
#include "clutter/clutter-private.h"
|
#include "clutter/clutter-private.h"
|
||||||
|
|
||||||
struct _ClutterSwipeActionPrivate
|
typedef struct _ClutterSwipeActionPrivate
|
||||||
{
|
{
|
||||||
ClutterSwipeDirection h_direction;
|
ClutterSwipeDirection h_direction;
|
||||||
ClutterSwipeDirection v_direction;
|
ClutterSwipeDirection v_direction;
|
||||||
|
|
||||||
float distance_x, distance_y;
|
float distance_x, distance_y;
|
||||||
};
|
} ClutterSwipeActionPrivate;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -67,7 +67,8 @@ static gboolean
|
|||||||
gesture_begin (ClutterGestureAction *action,
|
gesture_begin (ClutterGestureAction *action,
|
||||||
ClutterActor *actor)
|
ClutterActor *actor)
|
||||||
{
|
{
|
||||||
ClutterSwipeActionPrivate *priv = CLUTTER_SWIPE_ACTION (action)->priv;
|
ClutterSwipeActionPrivate *priv =
|
||||||
|
clutter_swipe_action_get_instance_private (CLUTTER_SWIPE_ACTION (action));
|
||||||
|
|
||||||
/* reset the state at the beginning of a new gesture */
|
/* reset the state at the beginning of a new gesture */
|
||||||
priv->h_direction = 0;
|
priv->h_direction = 0;
|
||||||
@ -85,7 +86,8 @@ static gboolean
|
|||||||
gesture_progress (ClutterGestureAction *action,
|
gesture_progress (ClutterGestureAction *action,
|
||||||
ClutterActor *actor)
|
ClutterActor *actor)
|
||||||
{
|
{
|
||||||
ClutterSwipeActionPrivate *priv = CLUTTER_SWIPE_ACTION (action)->priv;
|
ClutterSwipeActionPrivate *priv =
|
||||||
|
clutter_swipe_action_get_instance_private (CLUTTER_SWIPE_ACTION (action));
|
||||||
gfloat press_x, press_y;
|
gfloat press_x, press_y;
|
||||||
gfloat motion_x, motion_y;
|
gfloat motion_x, motion_y;
|
||||||
gfloat delta_x, delta_y;
|
gfloat delta_x, delta_y;
|
||||||
@ -134,7 +136,8 @@ static void
|
|||||||
gesture_end (ClutterGestureAction *action,
|
gesture_end (ClutterGestureAction *action,
|
||||||
ClutterActor *actor)
|
ClutterActor *actor)
|
||||||
{
|
{
|
||||||
ClutterSwipeActionPrivate *priv = CLUTTER_SWIPE_ACTION (action)->priv;
|
ClutterSwipeActionPrivate *priv =
|
||||||
|
clutter_swipe_action_get_instance_private (CLUTTER_SWIPE_ACTION (action));
|
||||||
gfloat press_x, press_y;
|
gfloat press_x, press_y;
|
||||||
gfloat release_x, release_y;
|
gfloat release_x, release_y;
|
||||||
ClutterSwipeDirection direction = 0;
|
ClutterSwipeDirection direction = 0;
|
||||||
@ -210,7 +213,6 @@ clutter_swipe_action_class_init (ClutterSwipeActionClass *klass)
|
|||||||
static void
|
static void
|
||||||
clutter_swipe_action_init (ClutterSwipeAction *self)
|
clutter_swipe_action_init (ClutterSwipeAction *self)
|
||||||
{
|
{
|
||||||
self->priv = clutter_swipe_action_get_instance_private (self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,23 +37,13 @@
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CLUTTER_TYPE_SWIPE_ACTION (clutter_swipe_action_get_type ())
|
#define CLUTTER_TYPE_SWIPE_ACTION (clutter_swipe_action_get_type ())
|
||||||
#define CLUTTER_SWIPE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_SWIPE_ACTION, ClutterSwipeAction))
|
|
||||||
#define CLUTTER_IS_SWIPE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_SWIPE_ACTION))
|
|
||||||
#define CLUTTER_SWIPE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_SWIPE_ACTION, ClutterSwipeActionClass))
|
|
||||||
#define CLUTTER_IS_SWIPE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_SWIPE_ACTION))
|
|
||||||
#define CLUTTER_SWIPE_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_SWIPE_ACTION, ClutterSwipeActionClass))
|
|
||||||
|
|
||||||
typedef struct _ClutterSwipeAction ClutterSwipeAction;
|
CLUTTER_EXPORT
|
||||||
typedef struct _ClutterSwipeActionPrivate ClutterSwipeActionPrivate;
|
G_DECLARE_DERIVABLE_TYPE (ClutterSwipeAction,
|
||||||
typedef struct _ClutterSwipeActionClass ClutterSwipeActionClass;
|
clutter_swipe_action,
|
||||||
|
CLUTTER,
|
||||||
struct _ClutterSwipeAction
|
SWIPE_ACTION,
|
||||||
{
|
ClutterGestureAction)
|
||||||
/*< private >*/
|
|
||||||
ClutterGestureAction parent_instance;
|
|
||||||
|
|
||||||
ClutterSwipeActionPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterSwipeActionClass:
|
* ClutterSwipeActionClass:
|
||||||
@ -73,9 +63,6 @@ struct _ClutterSwipeActionClass
|
|||||||
ClutterSwipeDirection direction);
|
ClutterSwipeDirection direction);
|
||||||
};
|
};
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
|
||||||
GType clutter_swipe_action_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
ClutterAction * clutter_swipe_action_new (void);
|
ClutterAction * clutter_swipe_action_new (void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user