[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;
|
gfloat request_natural_height;
|
||||||
|
|
||||||
ClutterActorBox allocation;
|
ClutterActorBox allocation;
|
||||||
|
ClutterAllocationFlags allocation_flags;
|
||||||
|
|
||||||
guint position_set : 1;
|
guint position_set : 1;
|
||||||
guint min_width_set : 1;
|
guint min_width_set : 1;
|
||||||
@ -434,6 +435,7 @@ enum
|
|||||||
MOTION_EVENT,
|
MOTION_EVENT,
|
||||||
ENTER_EVENT,
|
ENTER_EVENT,
|
||||||
LEAVE_EVENT,
|
LEAVE_EVENT,
|
||||||
|
ALLOCATION_CHANGED,
|
||||||
|
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
@ -1547,6 +1549,7 @@ clutter_actor_real_allocate (ClutterActor *self,
|
|||||||
{
|
{
|
||||||
ClutterActorPrivate *priv = self->priv;
|
ClutterActorPrivate *priv = self->priv;
|
||||||
gboolean x1_changed, y1_changed, x2_changed, y2_changed;
|
gboolean x1_changed, y1_changed, x2_changed, y2_changed;
|
||||||
|
gboolean flags_changed;
|
||||||
ClutterActorBox old = { 0, };
|
ClutterActorBox old = { 0, };
|
||||||
|
|
||||||
clutter_actor_store_old_geometry (self, &old);
|
clutter_actor_store_old_geometry (self, &old);
|
||||||
@ -1556,14 +1559,26 @@ clutter_actor_real_allocate (ClutterActor *self,
|
|||||||
x2_changed = priv->allocation.x2 != box->x2;
|
x2_changed = priv->allocation.x2 != box->x2;
|
||||||
y2_changed = priv->allocation.y2 != box->y2;
|
y2_changed = priv->allocation.y2 != box->y2;
|
||||||
|
|
||||||
|
flags_changed = priv->allocation_flags != flags;
|
||||||
|
|
||||||
priv->allocation = *box;
|
priv->allocation = *box;
|
||||||
|
priv->allocation_flags = flags;
|
||||||
priv->needs_allocation = FALSE;
|
priv->needs_allocation = FALSE;
|
||||||
|
|
||||||
g_object_freeze_notify (G_OBJECT (self));
|
g_object_freeze_notify (G_OBJECT (self));
|
||||||
|
|
||||||
if (x1_changed || y1_changed || x2_changed || y2_changed)
|
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);
|
clutter_actor_notify_if_geometry_changed (self, &old);
|
||||||
|
|
||||||
g_object_thaw_notify (G_OBJECT (self));
|
g_object_thaw_notify (G_OBJECT (self));
|
||||||
@ -4200,6 +4215,32 @@ clutter_actor_class_init (ClutterActorClass *klass)
|
|||||||
G_TYPE_NONE, 1,
|
G_TYPE_NONE, 1,
|
||||||
CLUTTER_TYPE_COLOR);
|
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 = clutter_actor_real_show;
|
||||||
klass->show_all = clutter_actor_show;
|
klass->show_all = clutter_actor_show;
|
||||||
klass->hide = clutter_actor_real_hide;
|
klass->hide = clutter_actor_real_hide;
|
||||||
|
@ -3,6 +3,7 @@ BOOLEAN:STRING,UINT,ENUM
|
|||||||
DOUBLE:VOID
|
DOUBLE:VOID
|
||||||
UINT:VOID
|
UINT:VOID
|
||||||
VOID:BOXED
|
VOID:BOXED
|
||||||
|
VOID:BOXED,FLAGS
|
||||||
VOID:INT
|
VOID:INT
|
||||||
VOID:INT64,INT64,FLOAT,BOOLEAN
|
VOID:INT64,INT64,FLOAT,BOOLEAN
|
||||||
VOID:INT,INT
|
VOID:INT,INT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user