[St] share common ClutterContainer implementation code

https://bugzilla.gnome.org/show_bug.cgi?id=611647
This commit is contained in:
Dan Winship
2010-03-02 15:05:14 -05:00
parent fbb88da134
commit f6b4fa6e7e
5 changed files with 323 additions and 289 deletions

View File

@ -74,13 +74,7 @@ st_overflow_box_add_actor (ClutterContainer *container,
{
StOverflowBoxPrivate *priv = ST_OVERFLOW_BOX (container)->priv;
clutter_actor_set_parent (actor, CLUTTER_ACTOR (container));
priv->children = g_list_append (priv->children, actor);
clutter_actor_queue_relayout (CLUTTER_ACTOR (container));
g_signal_emit_by_name (container, "actor-added", actor);
_st_container_add_actor (container, actor, &priv->children);
}
static void
@ -89,28 +83,7 @@ st_overflow_box_remove_actor (ClutterContainer *container,
{
StOverflowBoxPrivate *priv = ST_OVERFLOW_BOX (container)->priv;
GList *item = NULL;
item = g_list_find (priv->children, actor);
if (item == NULL)
{
g_warning ("Actor of type '%s' is not a child of container of type '%s'",
g_type_name (G_OBJECT_TYPE (actor)),
g_type_name (G_OBJECT_TYPE (container)));
return;
}
g_object_ref (actor);
priv->children = g_list_delete_link (priv->children, item);
clutter_actor_unparent (actor);
g_signal_emit_by_name (container, "actor-removed", actor);
g_object_unref (actor);
clutter_actor_queue_relayout ((ClutterActor*) container);
_st_container_remove_actor (container, actor, &priv->children);
}
static void
@ -120,7 +93,8 @@ st_overflow_box_foreach (ClutterContainer *container,
{
StOverflowBoxPrivate *priv = ST_OVERFLOW_BOX (container)->priv;
g_list_foreach (priv->children, (GFunc) callback, callback_data);
_st_container_foreach (container, callback, callback_data,
&priv->children);
}
static void
@ -130,40 +104,7 @@ st_overflow_box_lower (ClutterContainer *container,
{
StOverflowBoxPrivate *priv = ST_OVERFLOW_BOX (container)->priv;
/* copied from clutter/clutter/clutter-group.c */
priv->children = g_list_remove (priv->children, actor);
/* Push to bottom */
if (!sibling)
{
GList *last_item;
last_item = g_list_first (priv->children);
if (last_item)
sibling = last_item->data;
priv->children = g_list_prepend (priv->children, actor);
}
else
{
gint pos;
pos = g_list_index (priv->children, sibling);
priv->children = g_list_insert (priv->children, actor, pos);
}
/* See comment in group_raise for this */
if (sibling &&
clutter_actor_get_depth (sibling) != clutter_actor_get_depth (actor))
{
clutter_actor_set_depth (actor, clutter_actor_get_depth (sibling));
}
if (CLUTTER_ACTOR_IS_VISIBLE (container))
clutter_actor_queue_redraw (CLUTTER_ACTOR (container));
_st_container_lower (container, actor, sibling, &priv->children);
}
static void
@ -173,52 +114,15 @@ st_overflow_box_raise (ClutterContainer *container,
{
StOverflowBoxPrivate *priv = ST_OVERFLOW_BOX (container)->priv;
priv->children = g_list_remove (priv->children, actor);
/* copied from clutter/clutter/clutter-group.c */
/* Raise at the top */
if (!sibling)
{
GList *last_item;
last_item = g_list_last (priv->children);
if (last_item)
sibling = last_item->data;
priv->children = g_list_append (priv->children, actor);
}
else
{
gint pos;
pos = g_list_index (priv->children, sibling) + 1;
priv->children = g_list_insert (priv->children, actor, pos);
}
/* set Z ordering a value below, this will then call sort
* as values are equal ordering shouldn't change but Z
* values will be correct.
*
* FIXME: optimise
*/
if (sibling &&
clutter_actor_get_depth (sibling) != clutter_actor_get_depth (actor))
{
clutter_actor_set_depth (actor, clutter_actor_get_depth (sibling));
}
if (CLUTTER_ACTOR_IS_VISIBLE (container))
clutter_actor_queue_redraw (CLUTTER_ACTOR (container));
_st_container_raise (container, actor, sibling, &priv->children);
}
static void
st_overflow_box_sort_depth_order (ClutterContainer *container)
{
/* XXX: not yet implemented */
g_warning ("%s() not yet implemented", __FUNCTION__);
StOverflowBoxPrivate *priv = ST_OVERFLOW_BOX (container)->priv;
_st_container_sort_depth_order (container, &priv->children);
}
static void