[clutter/master-next: 38/43] actor: Coalesce needs_[xy]_expand() into one method
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/master-next: 38/43] actor: Coalesce needs_[xy]_expand() into one method
- Date: Fri, 20 Apr 2012 17:34:51 +0000 (UTC)
commit 602b8efacab2ede10176ffd229f15daefa574ebc
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Fri Apr 20 12:45:54 2012 +0100
actor: Coalesce needs_[xy]_expand() into one method
Use the orientation enumeration instead of a per-axis method.
clutter/clutter-actor.c | 65 ++++++++++++++++-------------------------
clutter/clutter-actor.h | 5 +--
clutter/clutter-bin-layout.c | 4 +-
clutter/clutter.symbols | 3 +-
4 files changed, 30 insertions(+), 47 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index 7f6d020..7a33158 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -18313,7 +18313,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
*
@@ -18372,7 +18372,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
*
@@ -18397,11 +18397,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;
@@ -18454,24 +18461,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);
@@ -18483,38 +18492,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 36cda22..6bac089 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 45cab47..f8245b1 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 52ba6c8..553bfc4 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]