mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 20:32:16 +00:00
rotate-action: Use macros for subclassing boilerplate
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3387>
This commit is contained in:
parent
aa8ef78b17
commit
64ad3abded
@ -47,7 +47,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterKeyframeTransition, g_object_unref)
|
|||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterOffscreenEffect, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterOffscreenEffect, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPageTurnEffect, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPageTurnEffect, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPropertyTransition, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPropertyTransition, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterRotateAction, 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)
|
||||||
|
@ -42,12 +42,12 @@
|
|||||||
#include "clutter/clutter-marshal.h"
|
#include "clutter/clutter-marshal.h"
|
||||||
#include "clutter/clutter-private.h"
|
#include "clutter/clutter-private.h"
|
||||||
|
|
||||||
struct _ClutterRotateActionPrivate
|
typedef struct _ClutterRotateActionPrivate
|
||||||
{
|
{
|
||||||
gfloat initial_vector[2];
|
gfloat initial_vector[2];
|
||||||
gdouble initial_vector_norm;
|
gdouble initial_vector_norm;
|
||||||
gdouble initial_rotation;
|
gdouble initial_rotation;
|
||||||
};
|
} ClutterRotateActionPrivate;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -64,7 +64,8 @@ static gboolean
|
|||||||
clutter_rotate_action_gesture_begin (ClutterGestureAction *action,
|
clutter_rotate_action_gesture_begin (ClutterGestureAction *action,
|
||||||
ClutterActor *actor)
|
ClutterActor *actor)
|
||||||
{
|
{
|
||||||
ClutterRotateActionPrivate *priv = CLUTTER_ROTATE_ACTION (action)->priv;
|
ClutterRotateActionPrivate *priv =
|
||||||
|
clutter_rotate_action_get_instance_private (CLUTTER_ROTATE_ACTION (action));
|
||||||
gfloat p1[2], p2[2];
|
gfloat p1[2], p2[2];
|
||||||
|
|
||||||
/* capture initial vector */
|
/* capture initial vector */
|
||||||
@ -87,7 +88,8 @@ static gboolean
|
|||||||
clutter_rotate_action_gesture_progress (ClutterGestureAction *action,
|
clutter_rotate_action_gesture_progress (ClutterGestureAction *action,
|
||||||
ClutterActor *actor)
|
ClutterActor *actor)
|
||||||
{
|
{
|
||||||
ClutterRotateActionPrivate *priv = CLUTTER_ROTATE_ACTION (action)->priv;
|
ClutterRotateActionPrivate *priv =
|
||||||
|
clutter_rotate_action_get_instance_private (CLUTTER_ROTATE_ACTION (action));
|
||||||
gfloat p1[2], p2[2];
|
gfloat p1[2], p2[2];
|
||||||
gfloat vector[2];
|
gfloat vector[2];
|
||||||
gboolean retval;
|
gboolean retval;
|
||||||
@ -126,9 +128,9 @@ clutter_rotate_action_gesture_progress (ClutterGestureAction *action,
|
|||||||
/* The angle given is comprise between 0 and 180 degrees, we
|
/* The angle given is comprise between 0 and 180 degrees, we
|
||||||
need some logic on top to get a value between 0 and 360. */
|
need some logic on top to get a value between 0 and 360. */
|
||||||
mult[0] = priv->initial_vector[0] * vector[1] -
|
mult[0] = priv->initial_vector[0] * vector[1] -
|
||||||
priv->initial_vector[1] * vector[0];
|
priv->initial_vector[1] * vector[0];
|
||||||
mult[1] = priv->initial_vector[1] * vector[0] -
|
mult[1] = priv->initial_vector[1] * vector[0] -
|
||||||
priv->initial_vector[0] * vector[1];
|
priv->initial_vector[0] * vector[1];
|
||||||
|
|
||||||
if (mult[0] < 0)
|
if (mult[0] < 0)
|
||||||
angle = -angle;
|
angle = -angle;
|
||||||
@ -206,12 +208,8 @@ clutter_rotate_action_class_init (ClutterRotateActionClass *klass)
|
|||||||
static void
|
static void
|
||||||
clutter_rotate_action_init (ClutterRotateAction *self)
|
clutter_rotate_action_init (ClutterRotateAction *self)
|
||||||
{
|
{
|
||||||
ClutterGestureAction *gesture;
|
clutter_gesture_action_set_n_touch_points (CLUTTER_GESTURE_ACTION (self),
|
||||||
|
2);
|
||||||
self->priv = clutter_rotate_action_get_instance_private (self);
|
|
||||||
|
|
||||||
gesture = CLUTTER_GESTURE_ACTION (self);
|
|
||||||
clutter_gesture_action_set_n_touch_points (gesture, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,23 +33,13 @@
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CLUTTER_TYPE_ROTATE_ACTION (clutter_rotate_action_get_type ())
|
#define CLUTTER_TYPE_ROTATE_ACTION (clutter_rotate_action_get_type ())
|
||||||
#define CLUTTER_ROTATE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ROTATE_ACTION, ClutterRotateAction))
|
|
||||||
#define CLUTTER_IS_ROTATE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_ROTATE_ACTION))
|
|
||||||
#define CLUTTER_ROTATE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_ROTATE_ACTION, ClutterRotateActionClass))
|
|
||||||
#define CLUTTER_IS_ROTATE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_ROTATE_ACTION))
|
|
||||||
#define CLUTTER_ROTATE_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_ROTATE_ACTION, ClutterRotateActionClass))
|
|
||||||
|
|
||||||
typedef struct _ClutterRotateAction ClutterRotateAction;
|
CLUTTER_EXPORT
|
||||||
typedef struct _ClutterRotateActionPrivate ClutterRotateActionPrivate;
|
G_DECLARE_DERIVABLE_TYPE (ClutterRotateAction,
|
||||||
typedef struct _ClutterRotateActionClass ClutterRotateActionClass;
|
clutter_rotate_action,
|
||||||
|
CLUTTER,
|
||||||
struct _ClutterRotateAction
|
ROTATE_ACTION,
|
||||||
{
|
ClutterGestureAction)
|
||||||
/*< private >*/
|
|
||||||
ClutterGestureAction parent_instance;
|
|
||||||
|
|
||||||
ClutterRotateActionPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterRotateActionClass:
|
* ClutterRotateActionClass:
|
||||||
@ -64,9 +54,6 @@ struct _ClutterRotateActionClass
|
|||||||
ClutterGestureActionClass parent_class;
|
ClutterGestureActionClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
|
||||||
GType clutter_rotate_action_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
ClutterAction *clutter_rotate_action_new (void);
|
ClutterAction *clutter_rotate_action_new (void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user