From: Emmanuele Bassi Date: Fri, 20 Apr 2012 11:45:54 +0000 (+0100) Subject: actor: Coalesce needs_[xy]_expand() into one method X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=78aae84d438587b45ec52d7a28f57e019f04ae23;p=profile%2Fivi%2Fclutter.git actor: Coalesce needs_[xy]_expand() into one method Use the orientation enumeration instead of a per-axis method. --- diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 3f388de..9182fc2 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 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