1
0
Fork 0

layout: allow wider use of the CLUTTER_ACTOR_NO_LAYOUT flag

Previously only ClutterGroup was able to set the CLUTTER_ACTOR_NO_LAYOUT
flag which allows clutter-actor.c to avoid a relayout when showing or
hiding fixed layout containers. Instead of it being the responsibility
of the container to set this flag this patch makes the layout manager
itself decide in the ::set_container method. This way both ClutterBox
and ClutterGroup can take advantage of the optimization.
This commit is contained in:
Robert Bragg 2010-02-11 11:45:36 +00:00
parent f21e649c80
commit 523bab0868
2 changed files with 20 additions and 5 deletions

View file

@ -152,6 +152,22 @@ clutter_fixed_layout_allocate (ClutterLayoutManager *manager,
g_list_free (children);
}
void
clutter_fixed_layout_set_container (ClutterLayoutManager *manager,
ClutterContainer *container)
{
if (container)
{
/* signal Clutter that we don't impose any layout on
* our children, so we can shave off some relayout
* operations
*/
CLUTTER_ACTOR_SET_FLAGS (container, CLUTTER_ACTOR_NO_LAYOUT);
}
else
CLUTTER_ACTOR_UNSET_FLAGS (container, CLUTTER_ACTOR_NO_LAYOUT);
}
static void
clutter_fixed_layout_class_init (ClutterFixedLayoutClass *klass)
{
@ -163,6 +179,7 @@ clutter_fixed_layout_class_init (ClutterFixedLayoutClass *klass)
manager_class->get_preferred_height =
clutter_fixed_layout_get_preferred_height;
manager_class->allocate = clutter_fixed_layout_allocate;
manager_class->set_container = clutter_fixed_layout_set_container;
}
static void

View file

@ -360,6 +360,7 @@ clutter_group_dispose (GObject *object)
if (priv->layout)
{
clutter_layout_manager_set_container (priv->layout, NULL);
g_object_unref (priv->layout);
priv->layout = NULL;
}
@ -416,11 +417,8 @@ clutter_group_init (ClutterGroup *self)
self->priv->layout = clutter_fixed_layout_new ();
g_object_ref_sink (self->priv->layout);
/* signal Clutter that we don't impose any layout on
* our children, so we can shave off some relayout
* operations
*/
CLUTTER_ACTOR_SET_FLAGS (self, CLUTTER_ACTOR_NO_LAYOUT);
clutter_layout_manager_set_container (self->priv->layout,
CLUTTER_CONTAINER (self));
}
/**