From: Owen W. Taylor Date: Fri, 26 Mar 2010 00:35:36 +0000 (+0000) Subject: actor: Add has_allocation() method X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8df4a0b8fdbbff580aab4377dec9878c693d2440;p=profile%2Fivi%2Fclutter.git actor: Add has_allocation() method Add clutter_actor_has_allocation(), a method meant to be used when deciding whether to call clutter_actor_get_allocation_box() or any of its wrappers. The get_allocation_box() method will, in case the allocation is invalid, perform a costly re-allocation cycle to ensure that the returned box is valid. The has_allocation() method is meant to be used if we have an actor calling get_allocation_box() from outside the place where the allocation is always guaranteed to be valid. Signed-off-by: Emmanuele Bassi --- diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 7b80469..0dc201a 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -10112,3 +10112,35 @@ _clutter_actor_set_queue_redraw_clip (ClutterActor *self, self->priv->oob_queue_redraw_clip = clip; } +/** + * clutter_actor_has_allocation: + * @self: a #ClutterActor + * + * Checks if the actor has an up-to-date allocation assigned to + * it. This means that the actor should have an allocation: it's + * visible and has a parent. It also means that there is no + * outstanding relayout request in progress for the actor or its + * children (There might be other outstanding layout requests in + * progress that will cause the actor to get a new allocation + * when the stage is laid out, however). + * + * If this function returns %FALSE, then the actor will normally + * be allocated before it is next drawn on the screen. + * + * Return value: %TRUE if the actor has an up-to-date allocation + * + * Since: 1.4 + */ +gboolean +clutter_actor_has_allocation (ClutterActor *self) +{ + ClutterActorPrivate *priv; + + g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE); + + priv = self->priv; + + return priv->parent_actor != NULL && + CLUTTER_ACTOR_IS_VISIBLE (self) && + !priv->needs_allocation; +} diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h index 4bb46cd..b7ae817 100644 --- a/clutter/clutter-actor.h +++ b/clutter/clutter-actor.h @@ -562,6 +562,8 @@ ClutterTextDirection clutter_actor_get_text_direction (ClutterActor *sel void clutter_actor_push_internal (ClutterActor *self); void clutter_actor_pop_internal (ClutterActor *self); +gboolean clutter_actor_has_allocation (ClutterActor *self); + G_END_DECLS #endif /* __CLUTTER_ACTOR_H__ */ diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index ea2b494..7c65d53 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -314,6 +314,7 @@ clutter_actor_set_fixed_position_set clutter_actor_get_fixed_position_set clutter_actor_set_request_mode clutter_actor_get_request_mode +clutter_actor_has_allocation clutter_actor_set_geometry