summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@linux.intel.com>2012-04-20 12:45:54 +0100
committerEmmanuele Bassi <ebassi@linux.intel.com>2012-04-27 12:30:49 +0100
commit78aae84d438587b45ec52d7a28f57e019f04ae23 (patch)
tree2b544948f67fa23bc072f4c899c3ca9b264eedab
parent807d77c0f321a94db960750adb21a231a7a6330a (diff)
downloadclutter-78aae84d438587b45ec52d7a28f57e019f04ae23.tar.gz
actor: Coalesce needs_[xy]_expand() into one method
Use the orientation enumeration instead of a per-axis method.
-rw-r--r--clutter/clutter-actor.c65
-rw-r--r--clutter/clutter-actor.h5
-rw-r--r--clutter/clutter-bin-layout.c4
-rw-r--r--clutter/clutter.symbols3
4 files changed, 30 insertions, 47 deletions
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index 3f388de39..9182fc293 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -18318,7 +18318,7 @@ clutter_actor_set_x_expand (ClutterActor *self,
*
* Retrieves the value set with clutter_actor_set_x_expand().
*
- * See also: clutter_actor_needs_x_expand()
+ * See also: clutter_actor_needs_expand()
*
* Return value: %TRUE if the actor has been set to expand
*
@@ -18377,7 +18377,7 @@ clutter_actor_set_y_expand (ClutterActor *self,
*
* Retrieves the value set with clutter_actor_set_y_expand().
*
- * See also: clutter_actor_needs_y_expand()
+ * See also: clutter_actor_needs_expand()
*
* Return value: %TRUE if the actor has been set to expand
*
@@ -18402,11 +18402,18 @@ clutter_actor_compute_expand_recursive (ClutterActor *self,
x_expand = y_expand = FALSE;
+ /* note that we don't recurse into children if we're already set to expand;
+ * this avoids traversing the whole actor tree, even if it may lead to some
+ * child left with the needs_compute_expand flag set.
+ */
clutter_actor_iter_init (&iter, self);
while (clutter_actor_iter_next (&iter, &child))
{
- x_expand = x_expand || clutter_actor_needs_x_expand (child);
- y_expand = y_expand || clutter_actor_needs_y_expand (child);
+ x_expand = x_expand ||
+ clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_HORIZONTAL);
+
+ y_expand = y_expand ||
+ clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_VERTICAL);
}
*x_expand_p = x_expand;
@@ -18459,24 +18466,26 @@ clutter_actor_compute_expand (ClutterActor *self)
}
/**
- * clutter_actor_needs_x_expand:
+ * clutter_actor_needs_expand:
* @self: a #ClutterActor
+ * @orientation: the direction of expansion
*
* Checks whether an actor, or any of its children, is set to expand
- * horizontally.
+ * horizontally or vertically.
*
* This function should only be called by layout managers that can
* assign extra space to their children.
*
* If you want to know whether the actor was explicitly set to expand,
- * use clutter_actor_get_y_expand().
+ * use clutter_actor_get_x_expand() or clutter_actor_get_y_expand().
*
* Return value: %TRUE if the actor should expand
*
* Since: 1.12
*/
gboolean
-clutter_actor_needs_x_expand (ClutterActor *self)
+clutter_actor_needs_expand (ClutterActor *self,
+ ClutterOrientation orientation)
{
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
@@ -18488,38 +18497,14 @@ clutter_actor_needs_x_expand (ClutterActor *self)
clutter_actor_compute_expand (self);
- return self->priv->needs_x_expand;
-}
-
-/**
- * clutter_actor_needs_y_expand:
- * @self: a #ClutterActor
- *
- * Checks whether an actor, or any of its children, is set to expand
- * vertically.
- *
- * This function should only be called by layout managers that can
- * assign extra space to their children.
- *
- * If you want to know whether the actor was explicitly set to expand,
- * use clutter_actor_get_y_expand().
- *
- * Return value: %TRUE if the actor should expand
- *
- * Since: 1.12
- */
-gboolean
-clutter_actor_needs_y_expand (ClutterActor *self)
-{
- g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
-
- if (!CLUTTER_ACTOR_IS_VISIBLE (self))
- return FALSE;
-
- if (CLUTTER_ACTOR_IN_DESTRUCTION (self))
- return FALSE;
+ switch (orientation)
+ {
+ case CLUTTER_ORIENTATION_HORIZONTAL:
+ return self->priv->needs_x_expand;
- clutter_actor_compute_expand (self);
+ case CLUTTER_ORIENTATION_VERTICAL:
+ return self->priv->needs_y_expand;
+ }
- return self->priv->needs_x_expand;
+ return FALSE;
}
diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h
index 36cda2212..6bac08995 100644
--- a/clutter/clutter-actor.h
+++ b/clutter/clutter-actor.h
@@ -450,9 +450,8 @@ void clutter_actor_set_y_expand
CLUTTER_AVAILABLE_IN_1_12
gboolean clutter_actor_get_y_expand (ClutterActor *self);
CLUTTER_AVAILABLE_IN_1_12
-gboolean clutter_actor_needs_x_expand (ClutterActor *self);
-CLUTTER_AVAILABLE_IN_1_12
-gboolean clutter_actor_needs_y_expand (ClutterActor *self);
+gboolean clutter_actor_needs_expand (ClutterActor *self,
+ ClutterOrientation orientation);
/* Paint */
void clutter_actor_set_clip (ClutterActor *self,
diff --git a/clutter/clutter-bin-layout.c b/clutter/clutter-bin-layout.c
index 45cab4728..f8245b14b 100644
--- a/clutter/clutter-bin-layout.c
+++ b/clutter/clutter-bin-layout.c
@@ -461,7 +461,7 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager,
child_alloc.x2 = available_w;
child_alloc.y2 = available_h;
- if (clutter_actor_needs_x_expand (child))
+ if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_HORIZONTAL))
{
ClutterActorAlign align;
@@ -475,7 +475,7 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager,
x_align = get_bin_alignment_factor (layer->x_align);
}
- if (clutter_actor_needs_y_expand (child))
+ if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_VERTICAL))
{
ClutterActorAlign align;
diff --git a/clutter/clutter.symbols b/clutter/clutter.symbols
index 52ba6c897..553bfc477 100644
--- a/clutter/clutter.symbols
+++ b/clutter/clutter.symbols
@@ -192,8 +192,7 @@ clutter_actor_meta_set_name
clutter_actor_move_anchor_point
clutter_actor_move_anchor_point_from_gravity
clutter_actor_move_by
-clutter_actor_needs_x_expand
-clutter_actor_needs_y_expand
+clutter_actor_needs_expand
clutter_actor_new
clutter_actor_paint
clutter_actor_pop_internal