mirror of
https://github.com/brl/mutter.git
synced 2024-12-24 20:12:06 +00:00
constraint: Add ClutterConstraint base class
The Constraint base, abstract class should be used to implement Actor modifiers that affect the way an actor is sized or positioned inside a fixed layout manager.
This commit is contained in:
parent
c007b7489b
commit
b842f0ad8e
@ -88,6 +88,7 @@ source_h = \
|
|||||||
$(srcdir)/clutter-child-meta.h \
|
$(srcdir)/clutter-child-meta.h \
|
||||||
$(srcdir)/clutter-clone.h \
|
$(srcdir)/clutter-clone.h \
|
||||||
$(srcdir)/clutter-color.h \
|
$(srcdir)/clutter-color.h \
|
||||||
|
$(srcdir)/clutter-constraint.h \
|
||||||
$(srcdir)/clutter-container.h \
|
$(srcdir)/clutter-container.h \
|
||||||
$(srcdir)/clutter-deprecated.h \
|
$(srcdir)/clutter-deprecated.h \
|
||||||
$(srcdir)/clutter-device-manager.h \
|
$(srcdir)/clutter-device-manager.h \
|
||||||
@ -165,6 +166,7 @@ source_c = \
|
|||||||
$(srcdir)/clutter-child-meta.c \
|
$(srcdir)/clutter-child-meta.c \
|
||||||
$(srcdir)/clutter-clone.c \
|
$(srcdir)/clutter-clone.c \
|
||||||
$(srcdir)/clutter-color.c \
|
$(srcdir)/clutter-color.c \
|
||||||
|
$(srcdir)/clutter-constraint.c \
|
||||||
$(srcdir)/clutter-container.c \
|
$(srcdir)/clutter-container.c \
|
||||||
$(srcdir)/clutter-device-manager.c \
|
$(srcdir)/clutter-device-manager.c \
|
||||||
$(srcdir)/clutter-drag-action.c \
|
$(srcdir)/clutter-drag-action.c \
|
||||||
|
@ -229,6 +229,7 @@
|
|||||||
|
|
||||||
#include "clutter-action.h"
|
#include "clutter-action.h"
|
||||||
#include "clutter-actor-meta-private.h"
|
#include "clutter-actor-meta-private.h"
|
||||||
|
#include "clutter-constraint.h"
|
||||||
#include "clutter-container.h"
|
#include "clutter-container.h"
|
||||||
#include "clutter-debug.h"
|
#include "clutter-debug.h"
|
||||||
#include "clutter-enum-types.h"
|
#include "clutter-enum-types.h"
|
||||||
@ -397,6 +398,7 @@ struct _ClutterActorPrivate
|
|||||||
const ClutterActorBox *oob_queue_redraw_clip;
|
const ClutterActorBox *oob_queue_redraw_clip;
|
||||||
|
|
||||||
ClutterMetaGroup *actions;
|
ClutterMetaGroup *actions;
|
||||||
|
ClutterMetaGroup *constraints;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -479,7 +481,8 @@ enum
|
|||||||
PROP_TEXT_DIRECTION,
|
PROP_TEXT_DIRECTION,
|
||||||
PROP_HAS_POINTER,
|
PROP_HAS_POINTER,
|
||||||
|
|
||||||
PROP_ACTIONS
|
PROP_ACTIONS,
|
||||||
|
PROP_CONSTRAINTS
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -2904,6 +2907,10 @@ clutter_actor_set_property (GObject *object,
|
|||||||
clutter_actor_add_action (actor, g_value_get_object (value));
|
clutter_actor_add_action (actor, g_value_get_object (value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_CONSTRAINTS:
|
||||||
|
clutter_actor_add_constraint (actor, g_value_get_object (value));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -4031,6 +4038,20 @@ clutter_actor_class_init (ClutterActorClass *klass)
|
|||||||
CLUTTER_PARAM_WRITABLE);
|
CLUTTER_PARAM_WRITABLE);
|
||||||
g_object_class_install_property (object_class, PROP_ACTIONS, pspec);
|
g_object_class_install_property (object_class, PROP_ACTIONS, pspec);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClutterActor:constraints:
|
||||||
|
*
|
||||||
|
* Adds a #ClutterConstaint to the actor
|
||||||
|
*
|
||||||
|
* Since: 1.4
|
||||||
|
*/
|
||||||
|
pspec = g_param_spec_object ("constraints",
|
||||||
|
"Constraints",
|
||||||
|
"Adds a constraint to the actor",
|
||||||
|
CLUTTER_TYPE_CONSTRAINT,
|
||||||
|
CLUTTER_PARAM_WRITABLE);
|
||||||
|
g_object_class_install_property (object_class, PROP_CONSTRAINTS, pspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterActor::destroy:
|
* ClutterActor::destroy:
|
||||||
* @actor: the object which received the signal
|
* @actor: the object which received the signal
|
||||||
@ -10318,3 +10339,118 @@ clutter_actor_clear_actions (ClutterActor *self)
|
|||||||
|
|
||||||
_clutter_meta_group_clear_metas (self->priv->actions);
|
_clutter_meta_group_clear_metas (self->priv->actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clutter_actor_add_constraint:
|
||||||
|
* @self: a #ClutterActor
|
||||||
|
* @constraint: a #ClutterConstraint
|
||||||
|
*
|
||||||
|
* Adds @constraint to the list of #ClutterConstraint<!-- -->s applied
|
||||||
|
* to @self
|
||||||
|
*
|
||||||
|
* The #ClutterActor will hold a reference on the @constraint until
|
||||||
|
* either clutter_actor_remove_constraint() or
|
||||||
|
* clutter_actor_clear_constraints() is called.
|
||||||
|
*
|
||||||
|
* Since: 1.4
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
clutter_actor_add_constraint (ClutterActor *self,
|
||||||
|
ClutterConstraint *constraint)
|
||||||
|
{
|
||||||
|
ClutterActorPrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||||
|
g_return_if_fail (CLUTTER_IS_ACTION (constraint));
|
||||||
|
|
||||||
|
priv = self->priv;
|
||||||
|
|
||||||
|
if (priv->constraints == NULL)
|
||||||
|
{
|
||||||
|
priv->constraints = g_object_new (CLUTTER_TYPE_META_GROUP, NULL);
|
||||||
|
priv->constraints->actor = self;
|
||||||
|
}
|
||||||
|
|
||||||
|
_clutter_meta_group_add_meta (priv->constraints,
|
||||||
|
CLUTTER_ACTOR_META (constraint));
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT (self), "constraints");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clutter_actor_remove_constraint:
|
||||||
|
* @self: a #ClutterActor
|
||||||
|
* @constraint: a #ClutterConstraint
|
||||||
|
*
|
||||||
|
* Removes @constraint from the list of constraints applied to @self
|
||||||
|
*
|
||||||
|
* The reference held by @self on the #ClutterConstraint will be released
|
||||||
|
*
|
||||||
|
* Since: 1.4
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
clutter_actor_remove_constraint (ClutterActor *self,
|
||||||
|
ClutterConstraint *constraint)
|
||||||
|
{
|
||||||
|
ClutterActorPrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||||
|
g_return_if_fail (CLUTTER_IS_ACTION (constraint));
|
||||||
|
|
||||||
|
priv = self->priv;
|
||||||
|
|
||||||
|
if (priv->constraints == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_clutter_meta_group_remove_meta (priv->constraints,
|
||||||
|
CLUTTER_ACTOR_META (constraint));
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT (self), "constraints");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clutter_actor_get_constraints:
|
||||||
|
* @self: a #ClutterActor
|
||||||
|
*
|
||||||
|
* Retrieves the list of constraints applied to @self
|
||||||
|
*
|
||||||
|
* Return value: (transfer container) (element-type ClutterConstraint): a copy
|
||||||
|
* of the list of #ClutterConstraint<!-- -->s. The contents of the list are
|
||||||
|
* owned by the #ClutterActor. Use g_list_free() to free the resources
|
||||||
|
* allocated by the returned #GList
|
||||||
|
*
|
||||||
|
* Since: 1.4
|
||||||
|
*/
|
||||||
|
GList *
|
||||||
|
clutter_actor_get_constraints (ClutterActor *self)
|
||||||
|
{
|
||||||
|
const GList *constraints;
|
||||||
|
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), NULL);
|
||||||
|
|
||||||
|
if (self->priv->constraints == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
constraints = _clutter_meta_group_peek_metas (self->priv->constraints);
|
||||||
|
|
||||||
|
return g_list_copy ((GList *) constraints);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clutter_actor_clear_constraints:
|
||||||
|
* @self: a #ClutterActor
|
||||||
|
*
|
||||||
|
* Clears the list of constraints applied to @self
|
||||||
|
*
|
||||||
|
* Since: 1.4
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
clutter_actor_clear_constraints (ClutterActor *self)
|
||||||
|
{
|
||||||
|
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||||
|
|
||||||
|
if (self->priv->constraints == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_clutter_meta_group_clear_metas (self->priv->constraints);
|
||||||
|
}
|
||||||
|
21
clutter/clutter-constraint.c
Normal file
21
clutter/clutter-constraint.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "clutter-constraint.h"
|
||||||
|
|
||||||
|
#include "clutter-actor-meta-private.h"
|
||||||
|
|
||||||
|
G_DEFINE_ABSTRACT_TYPE (ClutterConstraint,
|
||||||
|
clutter_constraint,
|
||||||
|
CLUTTER_TYPE_ACTOR_META);
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_constraint_class_init (ClutterConstraintClass *klass)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_constraint_init (ClutterConstraint *self)
|
||||||
|
{
|
||||||
|
}
|
100
clutter/clutter-constraint.h
Normal file
100
clutter/clutter-constraint.h
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
* Clutter.
|
||||||
|
*
|
||||||
|
* An OpenGL based 'interactive canvas' library.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Intel Corporation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Author:
|
||||||
|
* Emmanuele Bassi <ebassi@linux.intel.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||||
|
#error "Only <clutter/clutter.h> can be included directly."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __CLUTTER_CONSTRAINT_H__
|
||||||
|
#define __CLUTTER_CONSTRAINT_H__
|
||||||
|
|
||||||
|
#include <clutter/clutter-actor-meta.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define CLUTTER_TYPE_CONSTRAINT (clutter_constraint_get_type ())
|
||||||
|
#define CLUTTER_CONSTRAINT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_CONSTRAINT, ClutterConstraint))
|
||||||
|
#define CLUTTER_IS_CONSTRAINT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_CONSTRAINT))
|
||||||
|
#define CLUTTER_CONSTRAINT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_CONSTRAINT, ClutterConstraintClass))
|
||||||
|
#define CLUTTER_IS_CONSTRAINT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_CONSTRAINT))
|
||||||
|
#define CLUTTER_CONSTRAINT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_CONSTRAINT, ClutterConstraintClass))
|
||||||
|
|
||||||
|
typedef struct _ClutterConstraintPrivate ClutterConstraintPrivate;
|
||||||
|
typedef struct _ClutterConstraintClass ClutterConstraintClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClutterConstraint:
|
||||||
|
*
|
||||||
|
* The <structname>ClutterConstraint</structname> structure contains only
|
||||||
|
* private data and should be accessed using the provided API
|
||||||
|
*
|
||||||
|
* Since: 1.4
|
||||||
|
*/
|
||||||
|
struct _ClutterConstraint
|
||||||
|
{
|
||||||
|
/*< private >*/
|
||||||
|
ClutterActorMeta parent_instance;
|
||||||
|
|
||||||
|
ClutterConstraintPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClutterConstraintClass:
|
||||||
|
* @set_actor: virtual function, called when a constraint is applied to
|
||||||
|
* a #ClutterActor
|
||||||
|
*
|
||||||
|
* The <structname>ClutterConstraintClass</structname> structure contains
|
||||||
|
* only private data
|
||||||
|
*
|
||||||
|
* Since: 1.4
|
||||||
|
*/
|
||||||
|
struct _ClutterConstraintClass
|
||||||
|
{
|
||||||
|
/*< private >*/
|
||||||
|
ClutterActorMetaClass parent_class;
|
||||||
|
|
||||||
|
/*< private >*/
|
||||||
|
void (* _clutter_constraint1) (void);
|
||||||
|
void (* _clutter_constraint2) (void);
|
||||||
|
void (* _clutter_constraint3) (void);
|
||||||
|
void (* _clutter_constraint4) (void);
|
||||||
|
void (* _clutter_constraint5) (void);
|
||||||
|
void (* _clutter_constraint6) (void);
|
||||||
|
void (* _clutter_constraint7) (void);
|
||||||
|
void (* _clutter_constraint8) (void);
|
||||||
|
};
|
||||||
|
|
||||||
|
GType clutter_constraint_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
/* ClutterActor API */
|
||||||
|
void clutter_actor_add_constraint (ClutterActor *actor,
|
||||||
|
ClutterConstraint *constraint);
|
||||||
|
void clutter_actor_remove_constraint (ClutterActor *actor,
|
||||||
|
ClutterConstraint *constraint);
|
||||||
|
GList *clutter_actor_get_constraints (ClutterActor *actor);
|
||||||
|
void clutter_actor_clear_constraints (ClutterActor *actor);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __CLUTTER_CONSTRAINT_H__ */
|
@ -45,11 +45,12 @@ typedef struct _ClutterStage ClutterStage;
|
|||||||
typedef struct _ClutterContainer ClutterContainer; /* dummy */
|
typedef struct _ClutterContainer ClutterContainer; /* dummy */
|
||||||
typedef struct _ClutterChildMeta ClutterChildMeta;
|
typedef struct _ClutterChildMeta ClutterChildMeta;
|
||||||
typedef struct _ClutterLayoutMeta ClutterLayoutMeta;
|
typedef struct _ClutterLayoutMeta ClutterLayoutMeta;
|
||||||
|
typedef struct _ClutterActorMeta ClutterActorMeta;
|
||||||
|
|
||||||
typedef struct _ClutterAnimator ClutterAnimator;
|
typedef struct _ClutterAnimator ClutterAnimator;
|
||||||
typedef struct _ClutterAction ClutterAction;
|
|
||||||
|
|
||||||
typedef struct _ClutterActorMeta ClutterActorMeta;
|
typedef struct _ClutterAction ClutterAction;
|
||||||
|
typedef struct _ClutterConstraint ClutterConstraint;
|
||||||
|
|
||||||
typedef union _ClutterEvent ClutterEvent;
|
typedef union _ClutterEvent ClutterEvent;
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
#include "clutter-child-meta.h"
|
#include "clutter-child-meta.h"
|
||||||
#include "clutter-clone.h"
|
#include "clutter-clone.h"
|
||||||
#include "clutter-color.h"
|
#include "clutter-color.h"
|
||||||
|
#include "clutter-constraint.h"
|
||||||
#include "clutter-container.h"
|
#include "clutter-container.h"
|
||||||
#include "clutter-device-manager.h"
|
#include "clutter-device-manager.h"
|
||||||
#include "clutter-drag-action.h"
|
#include "clutter-drag-action.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user