mirror of
https://github.com/brl/mutter.git
synced 2025-01-11 12:12:25 +00:00
[actor] Add the ::allocation-changed signal
Sometimes it is useful to be able to track changes in the allocation flags, like the absolute origin, inside children of a container. Using the notify::allocation signal is not enough, in these cases, so we need a specific signal that gives us both the allocation box and the allocation flags.
This commit is contained in:
parent
0187bb3965
commit
5ebb59e6b0
@ -273,6 +273,7 @@ struct _ClutterActorPrivate
|
||||
gfloat request_natural_height;
|
||||
|
||||
ClutterActorBox allocation;
|
||||
ClutterAllocationFlags allocation_flags;
|
||||
|
||||
guint position_set : 1;
|
||||
guint min_width_set : 1;
|
||||
@ -434,6 +435,7 @@ enum
|
||||
MOTION_EVENT,
|
||||
ENTER_EVENT,
|
||||
LEAVE_EVENT,
|
||||
ALLOCATION_CHANGED,
|
||||
|
||||
LAST_SIGNAL
|
||||
};
|
||||
@ -1547,6 +1549,7 @@ clutter_actor_real_allocate (ClutterActor *self,
|
||||
{
|
||||
ClutterActorPrivate *priv = self->priv;
|
||||
gboolean x1_changed, y1_changed, x2_changed, y2_changed;
|
||||
gboolean flags_changed;
|
||||
ClutterActorBox old = { 0, };
|
||||
|
||||
clutter_actor_store_old_geometry (self, &old);
|
||||
@ -1556,13 +1559,25 @@ clutter_actor_real_allocate (ClutterActor *self,
|
||||
x2_changed = priv->allocation.x2 != box->x2;
|
||||
y2_changed = priv->allocation.y2 != box->y2;
|
||||
|
||||
flags_changed = priv->allocation_flags != flags;
|
||||
|
||||
priv->allocation = *box;
|
||||
priv->allocation_flags = flags;
|
||||
priv->needs_allocation = FALSE;
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (self));
|
||||
|
||||
if (x1_changed || y1_changed || x2_changed || y2_changed)
|
||||
g_object_notify (G_OBJECT (self), "allocation");
|
||||
{
|
||||
g_object_notify (G_OBJECT (self), "allocation");
|
||||
|
||||
/* we also emit the ::allocation-changed signal for people
|
||||
* that wish to track the allocation flags
|
||||
*/
|
||||
g_signal_emit (self, actor_signals[ALLOCATION_CHANGED], 0,
|
||||
box,
|
||||
flags);
|
||||
}
|
||||
|
||||
clutter_actor_notify_if_geometry_changed (self, &old);
|
||||
|
||||
@ -4200,6 +4215,32 @@ clutter_actor_class_init (ClutterActorClass *klass)
|
||||
G_TYPE_NONE, 1,
|
||||
CLUTTER_TYPE_COLOR);
|
||||
|
||||
/**
|
||||
* ClutterActor::allocation-changed:
|
||||
* @actor: the #ClutterActor that emitted the signal
|
||||
* @box: a #ClutterActorBox with the new allocation
|
||||
* @flags: #ClutterAllocationFlags for the allocation
|
||||
*
|
||||
* The ::allocation-changed signal is emitted when the
|
||||
* #ClutterActor:allocation property changes. Usually, application
|
||||
* code should just use the notifications for the :allocation property
|
||||
* but if you want to track the allocation flags as well, for instance
|
||||
* to know whether the absolute origin of @actor changed, then you might
|
||||
* want use this signal instead.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
actor_signals[ALLOCATION_CHANGED] =
|
||||
g_signal_new (I_("allocation-changed"),
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL, NULL,
|
||||
clutter_marshal_VOID__BOXED_FLAGS,
|
||||
G_TYPE_NONE, 2,
|
||||
CLUTTER_TYPE_ACTOR_BOX,
|
||||
CLUTTER_TYPE_ALLOCATION_FLAGS);
|
||||
|
||||
klass->show = clutter_actor_real_show;
|
||||
klass->show_all = clutter_actor_show;
|
||||
klass->hide = clutter_actor_real_hide;
|
||||
|
@ -3,6 +3,7 @@ BOOLEAN:STRING,UINT,ENUM
|
||||
DOUBLE:VOID
|
||||
UINT:VOID
|
||||
VOID:BOXED
|
||||
VOID:BOXED,FLAGS
|
||||
VOID:INT
|
||||
VOID:INT64,INT64,FLOAT,BOOLEAN
|
||||
VOID:INT,INT
|
||||
|
Loading…
Reference in New Issue
Block a user