From 523bab0868255e3f2b2910a60a868bffeb5bf64a Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 11 Feb 2010 11:45:36 +0000 Subject: [PATCH] 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. --- clutter/clutter-fixed-layout.c | 17 +++++++++++++++++ clutter/clutter-group.c | 8 +++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/clutter/clutter-fixed-layout.c b/clutter/clutter-fixed-layout.c index 5ec56fa3d..d87d29216 100644 --- a/clutter/clutter-fixed-layout.c +++ b/clutter/clutter-fixed-layout.c @@ -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 diff --git a/clutter/clutter-group.c b/clutter/clutter-group.c index d2a352c13..0d8d01eae 100644 --- a/clutter/clutter-group.c +++ b/clutter/clutter-group.c @@ -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)); } /**