Commit eb35c446 authored by Neil Roberts's avatar Neil Roberts Committed by Emmanuele Bassi

clutter-box: Layer new actors on top of all others at the same depth

g_list_insert_sorted inserts the new actor before all others that
compare equal so for the normal case when all actors have depth==0
this has the surprising behaviour of layering the actors in reverse
order. To fix this it now manually inserts the actor in the right
place by searching until it finds an actor at a higher depth and
inserting before that.
parent da0315e4
......@@ -130,12 +130,31 @@ clutter_box_real_add (ClutterContainer *container,
ClutterActor *actor)
ClutterBoxPrivate *priv = CLUTTER_BOX (container)->priv;
GList *l, *prev = NULL;
gfloat actor_depth;
g_object_ref (actor);
priv->children = g_list_insert_sorted (priv->children,
actor_depth = clutter_actor_get_depth (actor);
/* Find the right place to insert the child so that it will still be
sorted and the child will be after all of the actors at the same
depth */
for (l = priv->children;
l && (clutter_actor_get_depth (l->data) <= actor_depth);
l = l->next)
prev = l;
/* Insert the node before the found node */
l = g_list_prepend (l, actor);
/* Fixup the links */
if (prev)
prev->next = l;
l->prev = prev;
priv->children = l;
clutter_actor_set_parent (actor, CLUTTER_ACTOR (container));
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment