diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index d180282856c6f01c7965d12a4d6511ea9fdaabe5..0aa696042d1e2ac9d47ee85f7aac90efe5a1277d 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -698,7 +698,6 @@ struct _ClutterActorPrivate * allocation */ ClutterActorBox allocation; - ClutterAllocationFlags allocation_flags; /* clip, in actor coordinates */ graphene_rect_t clip; @@ -854,6 +853,7 @@ struct _ClutterActorPrivate guint needs_paint_volume_update : 1; guint had_effects_on_last_paint_volume_update : 1; guint needs_compute_resource_scale : 1; + guint absolute_origin_changed : 1; }; enum @@ -1013,7 +1013,6 @@ enum MOTION_EVENT, ENTER_EVENT, LEAVE_EVENT, - ALLOCATION_CHANGED, TRANSITIONS_COMPLETED, TOUCH_EVENT, TRANSITION_STOPPED, @@ -2577,15 +2576,13 @@ clutter_actor_notify_if_geometry_changed (ClutterActor *self, * Return value: %TRUE if the allocation of the #ClutterActor has been * changed, and %FALSE otherwise */ -static inline gboolean +static inline void clutter_actor_set_allocation_internal (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) + const ClutterActorBox *box) { ClutterActorPrivate *priv = self->priv; GObject *obj; gboolean x1_changed, y1_changed, x2_changed, y2_changed; - gboolean retval; ClutterActorBox old_alloc = { 0, }; obj = G_OBJECT (self); @@ -2600,7 +2597,6 @@ clutter_actor_set_allocation_internal (ClutterActor *self, y2_changed = priv->allocation.y2 != box->y2; priv->allocation = *box; - priv->allocation_flags = flags; /* allocation is authoritative */ priv->needs_width_request = FALSE; @@ -2625,88 +2621,37 @@ clutter_actor_set_allocation_internal (ClutterActor *self, priv->content_box_valid = FALSE; g_object_notify_by_pspec (obj, obj_props[PROP_CONTENT_BOX]); } - - retval = TRUE; } - else - retval = FALSE; clutter_actor_notify_if_geometry_changed (self, &old_alloc); g_object_thaw_notify (obj); - - return retval; } -static void clutter_actor_real_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags); - -static inline void -clutter_actor_maybe_layout_children (ClutterActor *self, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) +static void +clutter_actor_real_allocate (ClutterActor *self, + const ClutterActorBox *box) { ClutterActorPrivate *priv = self->priv; - /* this is going to be a bit hard to follow, so let's put an explanation - * here. - * - * we want ClutterActor to have a default layout manager if the actor was - * created using "g_object_new (CLUTTER_TYPE_ACTOR, NULL)". - * - * we also want any subclass of ClutterActor that does not override the - * ::allocate() virtual function to delegate to a layout manager. - * - * finally, we want to allow people subclassing ClutterActor and overriding - * the ::allocate() vfunc to let Clutter delegate to the layout manager. - * - * on the other hand, we want existing actor subclasses overriding the - * ::allocate() virtual function and chaining up to the parent's - * implementation to continue working without allocating their children - * twice, or without entering an allocation loop. - * - * for the first two points, we check if the class of the actor is - * overridding the ::allocate() virtual function; if it isn't, then we - * follow through with checking whether we have children and a layout - * manager, and eventually calling clutter_layout_manager_allocate(). - * - * for the third point, we check the CLUTTER_DELEGATE_LAYOUT flag in the - * allocation flags that we got passed, and if it is present, we continue - * with the check above. - * - * if neither of these two checks yields a positive result, we just - * assume that the ::allocate() virtual function that resulted in this - * function being called will also allocate the children of the actor. - */ - - if (CLUTTER_ACTOR_GET_CLASS (self)->allocate == clutter_actor_real_allocate) - goto check_layout; - - if ((flags & CLUTTER_DELEGATE_LAYOUT) != 0) - goto check_layout; + g_object_freeze_notify (G_OBJECT (self)); - return; + clutter_actor_set_allocation_internal (self, box); -check_layout: + /* we allocate our children before we notify changes in our geometry, + * so that people connecting to properties will be able to get valid + * data out of the sub-tree of the scene graph that has this actor at + * the root. + */ if (priv->n_children != 0 && priv->layout_manager != NULL) { - ClutterContainer *container = CLUTTER_CONTAINER (self); - ClutterAllocationFlags children_flags; ClutterActorBox children_box; /* normalize the box passed to the layout manager */ children_box.x1 = children_box.y1 = 0.f; - children_box.x2 = (allocation->x2 - allocation->x1); - children_box.y2 = (allocation->y2 - allocation->y1); - - /* remove the DELEGATE_LAYOUT flag; this won't be passed to - * the actor's children, since it refers only to the current - * actor's allocation. - */ - children_flags = flags; - children_flags &= ~CLUTTER_DELEGATE_LAYOUT; + children_box.x2 = box->x2 - box->x1; + children_box.y2 = box->y2 - box->y1; CLUTTER_NOTE (LAYOUT, "Allocating %d children of %s " @@ -2714,46 +2659,15 @@ check_layout: "using %s", priv->n_children, _clutter_actor_get_debug_name (self), - allocation->x1, - allocation->y1, - (allocation->x2 - allocation->x1), - (allocation->y2 - allocation->y1), + box->x1, + box->y1, + (box->x2 - box->x1), + (box->y2 - box->y1), G_OBJECT_TYPE_NAME (priv->layout_manager)); clutter_layout_manager_allocate (priv->layout_manager, - container, - &children_box, - children_flags); - } -} - -static void -clutter_actor_real_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) -{ - ClutterActorPrivate *priv = self->priv; - gboolean changed; - - g_object_freeze_notify (G_OBJECT (self)); - - changed = clutter_actor_set_allocation_internal (self, box, flags); - - /* we allocate our children before we notify changes in our geometry, - * so that people connecting to properties will be able to get valid - * data out of the sub-tree of the scene graph that has this actor at - * the root. - */ - clutter_actor_maybe_layout_children (self, box, flags); - - if (changed) - { - ClutterActorBox signal_box = priv->allocation; - ClutterAllocationFlags signal_flags = priv->allocation_flags; - - g_signal_emit (self, actor_signals[ALLOCATION_CHANGED], 0, - &signal_box, - signal_flags); + CLUTTER_CONTAINER (self), + &children_box); } g_object_thaw_notify (G_OBJECT (self)); @@ -8605,35 +8519,6 @@ clutter_actor_class_init (ClutterActorClass *klass) G_TYPE_NONE, 1, CLUTTER_TYPE_PICK_CONTEXT); - /** - * ClutterActor::allocation-changed: - * @actor: the #ClutterActor that emitted the signal - * @box: a #ClutterActorBox with the new allocation - * @flags: #ClutterAllocationFlags for the allocation - * - * The ::allocation-changed signal is emitted when the - * #ClutterActor:allocation property changes. Usually, application - * code should just use the notifications for the :allocation property - * but if you want to track the allocation flags as well, for instance - * to know whether the absolute origin of @actor changed, then you might - * want use this signal instead. - * - * Since: 1.0 - */ - actor_signals[ALLOCATION_CHANGED] = - g_signal_new (I_("allocation-changed"), - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - _clutter_marshal_VOID__BOXED_FLAGS, - G_TYPE_NONE, 2, - CLUTTER_TYPE_ACTOR_BOX | G_SIGNAL_TYPE_STATIC_SCOPE, - CLUTTER_TYPE_ALLOCATION_FLAGS); - g_signal_set_va_marshaller (actor_signals[ALLOCATION_CHANGED], - G_TYPE_FROM_CLASS (object_class), - _clutter_marshal_VOID__BOXED_FLAGSv); - /** * ClutterActor::transitions-completed: * @actor: a #ClutterActor @@ -10171,8 +10056,7 @@ clutter_actor_adjust_allocation (ClutterActor *self, static void clutter_actor_allocate_internal (ClutterActor *self, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { ClutterActorClass *klass; @@ -10182,7 +10066,7 @@ clutter_actor_allocate_internal (ClutterActor *self, _clutter_actor_get_debug_name (self)); klass = CLUTTER_ACTOR_GET_CLASS (self); - klass->allocate (self, allocation, flags); + klass->allocate (self, allocation); CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_IN_RELAYOUT); @@ -10195,7 +10079,6 @@ clutter_actor_allocate_internal (ClutterActor *self, * clutter_actor_allocate: * @self: A #ClutterActor * @box: new allocation of the actor, in parent-relative coordinates - * @flags: flags that control the allocation * * Assigns the size of a #ClutterActor from the given @box. * @@ -10221,12 +10104,11 @@ clutter_actor_allocate_internal (ClutterActor *self, * Since: 0.8 */ void -clutter_actor_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) +clutter_actor_allocate (ClutterActor *self, + const ClutterActorBox *box) { ClutterActorBox old_allocation, real_allocation; - gboolean origin_changed, child_moved, size_changed; + gboolean origin_changed, size_changed; gboolean stage_allocation_changed; ClutterActorPrivate *priv; @@ -10269,18 +10151,19 @@ clutter_actor_allocate (ClutterActor *self, real_allocation.x2 = MAX (real_allocation.x2, real_allocation.x1); real_allocation.y2 = MAX (real_allocation.y2, real_allocation.y1); - origin_changed = (flags & CLUTTER_ABSOLUTE_ORIGIN_CHANGED); - - child_moved = (real_allocation.x1 != old_allocation.x1 || - real_allocation.y1 != old_allocation.y1); + origin_changed = (real_allocation.x1 != old_allocation.x1 || + real_allocation.y1 != old_allocation.y1); size_changed = (real_allocation.x2 != old_allocation.x2 || real_allocation.y2 != old_allocation.y2); - if (origin_changed || child_moved || size_changed) - stage_allocation_changed = TRUE; - else - stage_allocation_changed = FALSE; + priv->absolute_origin_changed = priv->parent + ? priv->parent->priv->absolute_origin_changed + : FALSE; + + priv->absolute_origin_changed |= origin_changed; + + stage_allocation_changed = priv->absolute_origin_changed || size_changed; /* If we get an allocation "out of the blue" * (we did not queue relayout), then we want to @@ -10310,24 +10193,10 @@ clutter_actor_allocate (ClutterActor *self, { /* If the actor didn't move but needs_allocation is set, we just * need to allocate the children */ - clutter_actor_allocate_internal (self, &real_allocation, flags); + clutter_actor_allocate_internal (self, &real_allocation); return; } - /* When ABSOLUTE_ORIGIN_CHANGED is passed in to - * clutter_actor_allocate(), it indicates whether the parent has its - * absolute origin moved; when passed in to ClutterActor::allocate() - * virtual method though, it indicates whether the child has its - * absolute origin moved. So we set it when child_moved is TRUE - */ - if (child_moved) - flags |= CLUTTER_ABSOLUTE_ORIGIN_CHANGED; - - /* store the flags here, so that they can be propagated by the - * transition code - */ - self->priv->allocation_flags = flags; - _clutter_actor_create_transition (self, obj_props[PROP_ALLOCATION], &priv->allocation, &real_allocation); @@ -10337,20 +10206,14 @@ clutter_actor_allocate (ClutterActor *self, * clutter_actor_set_allocation: * @self: a #ClutterActor * @box: a #ClutterActorBox - * @flags: allocation flags * * Stores the allocation of @self as defined by @box. * * This function can only be called from within the implementation of * the #ClutterActorClass.allocate() virtual function. * - * The allocation should have been adjusted to take into account constraints, - * alignment, and margin properties. If you are implementing a #ClutterActor - * subclass that provides its own layout management policy for its children - * instead of using a #ClutterLayoutManager delegate, you should not call - * this function on the children of @self; instead, you should call - * clutter_actor_allocate(), which will adjust the allocation box for - * you. + * The allocation @box should have been adjusted to take into account + * constraints, alignment, and margin properties. * * This function should only be used by subclasses of #ClutterActor * that wish to store their allocation but cannot chain up to the @@ -10358,69 +10221,12 @@ clutter_actor_allocate (ClutterActor *self, * #ClutterActorClass.allocate() virtual function will call this * function. * - * It is important to note that, while chaining up was the recommended - * behaviour for #ClutterActor subclasses prior to the introduction of - * this function, it is recommended to call clutter_actor_set_allocation() - * instead. - * - * If the #ClutterActor is using a #ClutterLayoutManager delegate object - * to handle the allocation of its children, this function will call - * the clutter_layout_manager_allocate() function only if the - * %CLUTTER_DELEGATE_LAYOUT flag is set on @flags, otherwise it is - * expected that the subclass will call clutter_layout_manager_allocate() - * by itself. For instance, the following code: - * - * |[ - * static void - * my_actor_allocate (ClutterActor *actor, - * const ClutterActorBox *allocation, - * ClutterAllocationFlags flags) - * { - * ClutterActorBox new_alloc; - * ClutterAllocationFlags new_flags; - * - * adjust_allocation (allocation, &new_alloc); - * - * new_flags = flags | CLUTTER_DELEGATE_LAYOUT; - * - * // this will use the layout manager set on the actor - * clutter_actor_set_allocation (actor, &new_alloc, new_flags); - * } - * ]| - * - * is equivalent to this: - * - * |[ - * static void - * my_actor_allocate (ClutterActor *actor, - * const ClutterActorBox *allocation, - * ClutterAllocationFlags flags) - * { - * ClutterLayoutManager *layout; - * ClutterActorBox new_alloc; - * - * adjust_allocation (allocation, &new_alloc); - * - * clutter_actor_set_allocation (actor, &new_alloc, flags); - * - * layout = clutter_actor_get_layout_manager (actor); - * clutter_layout_manager_allocate (layout, - * CLUTTER_CONTAINER (actor), - * &new_alloc, - * flags); - * } - * ]| - * * Since: 1.10 */ void clutter_actor_set_allocation (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) + const ClutterActorBox *box) { - ClutterActorPrivate *priv; - gboolean changed; - g_return_if_fail (CLUTTER_IS_ACTOR (self)); g_return_if_fail (box != NULL); @@ -10432,28 +10238,9 @@ clutter_actor_set_allocation (ClutterActor *self, return; } - priv = self->priv; - g_object_freeze_notify (G_OBJECT (self)); - changed = clutter_actor_set_allocation_internal (self, box, flags); - - /* we allocate our children before we notify changes in our geometry, - * so that people connecting to properties will be able to get valid - * data out of the sub-tree of the scene graph that has this actor at - * the root. - */ - clutter_actor_maybe_layout_children (self, box, flags); - - if (changed) - { - ClutterActorBox signal_box = priv->allocation; - ClutterAllocationFlags signal_flags = priv->allocation_flags; - - g_signal_emit (self, actor_signals[ALLOCATION_CHANGED], 0, - &signal_box, - signal_flags); - } + clutter_actor_set_allocation_internal (self, box); g_object_thaw_notify (G_OBJECT (self)); } @@ -14926,9 +14713,7 @@ clutter_actor_set_animatable_property (ClutterActor *actor, break; case PROP_ALLOCATION: - clutter_actor_allocate_internal (actor, - g_value_get_boxed (value), - actor->priv->allocation_flags); + clutter_actor_allocate_internal (actor, g_value_get_boxed (value)); clutter_actor_queue_redraw (actor); break; @@ -15322,7 +15107,6 @@ clutter_actor_get_stage (ClutterActor *actor) * actor's natural width * @available_height: the maximum available height, or -1 to use the * actor's natural height - * @flags: flags controlling the allocation * * Allocates @self taking into account the #ClutterActor's * preferred size, but limiting it to the maximum available width @@ -15369,7 +15153,7 @@ clutter_actor_get_stage (ClutterActor *actor) * box.x1 = x; box.y1 = y; * box.x2 = box.x1 + available_width; * box.y2 = box.y1 + available_height; - * clutter_actor_allocate (self, &box, flags); + * clutter_actor_allocate (self, &box); * ]| * * This function can be used by fluid layout managers to allocate @@ -15383,8 +15167,7 @@ clutter_actor_allocate_available_size (ClutterActor *self, gfloat x, gfloat y, gfloat available_width, - gfloat available_height, - ClutterAllocationFlags flags) + gfloat available_height) { ClutterActorPrivate *priv; gfloat width, height; @@ -15440,13 +15223,12 @@ clutter_actor_allocate_available_size (ClutterActor *self, box.y1 = y; box.x2 = box.x1 + width; box.y2 = box.y1 + height; - clutter_actor_allocate (self, &box, flags); + clutter_actor_allocate (self, &box); } /** * clutter_actor_allocate_preferred_size: * @self: a #ClutterActor - * @flags: flags controlling the allocation * * Allocates the natural size of @self. * @@ -15464,8 +15246,7 @@ clutter_actor_allocate_available_size (ClutterActor *self, * Since: 0.8 */ void -clutter_actor_allocate_preferred_size (ClutterActor *self, - ClutterAllocationFlags flags) +clutter_actor_allocate_preferred_size (ClutterActor *self) { gfloat actor_x, actor_y; gfloat natural_width, natural_height; @@ -15499,7 +15280,7 @@ clutter_actor_allocate_preferred_size (ClutterActor *self, actor_box.x2 = actor_box.x1 + natural_width; actor_box.y2 = actor_box.y1 + natural_height; - clutter_actor_allocate (self, &actor_box, flags); + clutter_actor_allocate (self, &actor_box); } /** @@ -15510,7 +15291,6 @@ clutter_actor_allocate_preferred_size (ClutterActor *self, * @y_align: the vertical alignment, between 0 and 1 * @x_fill: whether the actor should fill horizontally * @y_fill: whether the actor should fill vertically - * @flags: allocation flags to be passed to clutter_actor_allocate() * * Allocates @self by taking into consideration the available allocation * area; an alignment factor on either axis; and whether the actor should @@ -15537,8 +15317,7 @@ clutter_actor_allocate_align_fill (ClutterActor *self, gdouble x_align, gdouble y_align, gboolean x_fill, - gboolean y_fill, - ClutterAllocationFlags flags) + gboolean y_fill) { ClutterActorPrivate *priv; ClutterActorBox allocation = CLUTTER_ACTOR_BOX_INIT_ZERO; @@ -15654,7 +15433,7 @@ out: allocation.x2 = ceilf (allocation.x1 + MAX (child_width, 0)); allocation.y2 = ceilf (allocation.y1 + MAX (child_height, 0)); - clutter_actor_allocate (self, &allocation, flags); + clutter_actor_allocate (self, &allocation); } /** diff --git a/clutter/clutter/clutter-actor.h b/clutter/clutter/clutter-actor.h index 220289d53641e6253bb7f14a48ce385040208ec3..b5d4b7845e1cd9d444d4066b8da9eb1ff4337f35 100644 --- a/clutter/clutter/clutter-actor.h +++ b/clutter/clutter/clutter-actor.h @@ -175,9 +175,12 @@ struct _ClutterActor * @get_preferred_height: virtual function, used when querying the minimum * and natural heights of an actor for a given width; it is used by * clutter_actor_get_preferred_height() - * @allocate: virtual function, used when settings the coordinates of an - * actor; it is used by clutter_actor_allocate(); it must chain up to - * the parent's implementation, or call clutter_actor_set_allocation() + * @allocate: virtual function, used when setting the coordinates of an + * actor; it is used by clutter_actor_allocate(); when overriding this + * function without chaining up, clutter_actor_set_allocation() must be + * called and children must be allocated by the implementation, when + * chaining up though, those things will be done by the parent's + * implementation. * @apply_transform: virtual function, used when applying the transformations * to an actor before painting it or when transforming coordinates or * the allocation; it must chain up to the parent's implementation @@ -253,8 +256,7 @@ struct _ClutterActorClass gfloat *min_height_p, gfloat *natural_height_p); void (* allocate) (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags); + const ClutterActorBox *box); /* transformations */ void (* apply_transform) (ClutterActor *actor, @@ -415,30 +417,25 @@ void clutter_actor_get_preferred_size gfloat *natural_height_p); CLUTTER_EXPORT void clutter_actor_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags); + const ClutterActorBox *box); CLUTTER_EXPORT -void clutter_actor_allocate_preferred_size (ClutterActor *self, - ClutterAllocationFlags flags); +void clutter_actor_allocate_preferred_size (ClutterActor *self); CLUTTER_EXPORT void clutter_actor_allocate_available_size (ClutterActor *self, gfloat x, gfloat y, gfloat available_width, - gfloat available_height, - ClutterAllocationFlags flags); + gfloat available_height); CLUTTER_EXPORT void clutter_actor_allocate_align_fill (ClutterActor *self, const ClutterActorBox *box, gdouble x_align, gdouble y_align, gboolean x_fill, - gboolean y_fill, - ClutterAllocationFlags flags); + gboolean y_fill); CLUTTER_EXPORT void clutter_actor_set_allocation (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags); + const ClutterActorBox *box); CLUTTER_EXPORT void clutter_actor_get_allocation_box (ClutterActor *self, ClutterActorBox *box); diff --git a/clutter/clutter/clutter-align-constraint.c b/clutter/clutter/clutter-align-constraint.c index a2694aa6386abeec2af2b1176686232f0f4e4d9c..ed10ece2efad07c15473d8a06858436bb8137019 100644 --- a/clutter/clutter/clutter-align-constraint.c +++ b/clutter/clutter/clutter-align-constraint.c @@ -85,8 +85,7 @@ G_DEFINE_TYPE (ClutterAlignConstraint, static void source_position_changed (ClutterActor *actor, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags, + GParamSpec *pspec, ClutterAlignConstraint *align) { if (align->actor != NULL) @@ -410,7 +409,7 @@ clutter_align_constraint_set_source (ClutterAlignConstraint *align, align->source = source; if (align->source != NULL) { - g_signal_connect (align->source, "allocation-changed", + g_signal_connect (align->source, "notify::allocation", G_CALLBACK (source_position_changed), align); g_signal_connect (align->source, "destroy", diff --git a/clutter/clutter/clutter-bin-layout.c b/clutter/clutter/clutter-bin-layout.c index 8c63b802cd764df67b2876e01a3c28a1669dc8ec..a17393c48c576074990896bee6b67043a34ff1f9 100644 --- a/clutter/clutter/clutter-bin-layout.c +++ b/clutter/clutter/clutter-bin-layout.c @@ -406,8 +406,7 @@ get_actor_align_factor (ClutterActorAlign alignment) static void clutter_bin_layout_allocate (ClutterLayoutManager *manager, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { gfloat allocation_x, allocation_y; gfloat available_w, available_h; @@ -515,8 +514,7 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager, clutter_actor_allocate_align_fill (child, &child_alloc, x_align, y_align, - x_fill, y_fill, - flags); + x_fill, y_fill); } } diff --git a/clutter/clutter/clutter-box-layout.c b/clutter/clutter/clutter-box-layout.c index 112200258ec6cd4809c1192a278ef14c0a186a91..74d5d16127a8a330f2a2fa078c751af1f0c22c23 100644 --- a/clutter/clutter/clutter-box-layout.c +++ b/clutter/clutter/clutter-box-layout.c @@ -720,8 +720,7 @@ static void allocate_box_child (ClutterBoxLayout *self, ClutterContainer *container, ClutterActor *child, - ClutterActorBox *child_box, - ClutterAllocationFlags flags) + ClutterActorBox *child_box) { ClutterBoxLayoutPrivate *priv = self->priv; ClutterBoxChild *box_child; @@ -750,14 +749,13 @@ allocate_box_child (ClutterBoxLayout *self, */ if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_HORIZONTAL) || clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_VERTICAL)) - clutter_actor_allocate (child, child_box, flags); + clutter_actor_allocate (child, child_box); else clutter_actor_allocate_align_fill (child, child_box, get_box_alignment_factor (box_child->x_align), get_box_alignment_factor (box_child->y_align), box_child->x_fill, - box_child->y_fill, - flags); + box_child->y_fill); if (priv->use_animations) clutter_actor_restore_easing_state (child); @@ -956,8 +954,7 @@ distribute_natural_allocation (float extra_space, static void clutter_box_layout_allocate (ClutterLayoutManager *layout, ClutterContainer *container, - const ClutterActorBox *box, - ClutterAllocationFlags flags) + const ClutterActorBox *box) { ClutterBoxLayoutPrivate *priv = CLUTTER_BOX_LAYOUT (layout)->priv; ClutterActor *actor, *child; @@ -1224,8 +1221,7 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout, allocate_box_child (CLUTTER_BOX_LAYOUT (layout), container, child, - &child_allocation, - flags); + &child_allocation); i += 1; } diff --git a/clutter/clutter/clutter-clone.c b/clutter/clutter/clutter-clone.c index 8c805725a5cda7d4c053a0f9564ef8bc75bd1559..fb69f6c60bdd86c07b2da9d3ac277b2b46ea135d 100644 --- a/clutter/clutter/clutter-clone.c +++ b/clutter/clutter/clutter-clone.c @@ -240,15 +240,14 @@ clutter_clone_has_overlaps (ClutterActor *actor) static void clutter_clone_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) + const ClutterActorBox *box) { ClutterClonePrivate *priv = CLUTTER_CLONE (self)->priv; ClutterActorClass *parent_class; /* chain up */ parent_class = CLUTTER_ACTOR_CLASS (clutter_clone_parent_class); - parent_class->allocate (self, box, flags); + parent_class->allocate (self, box); if (priv->clone_source == NULL) return; @@ -258,7 +257,7 @@ clutter_clone_allocate (ClutterActor *self, */ if (clutter_actor_get_parent (priv->clone_source) != NULL && !clutter_actor_has_allocation (priv->clone_source)) - clutter_actor_allocate_preferred_size (priv->clone_source, flags); + clutter_actor_allocate_preferred_size (priv->clone_source); #if 0 /* XXX - this is wrong: ClutterClone cannot clone unparented @@ -273,7 +272,7 @@ clutter_clone_allocate (ClutterActor *self, * paint cycle, we can safely give it as much size as it requires */ if (clutter_actor_get_parent (priv->clone_source) == NULL) - clutter_actor_allocate_preferred_size (priv->clone_source, flags); + clutter_actor_allocate_preferred_size (priv->clone_source); #endif } diff --git a/clutter/clutter/clutter-deform-effect.c b/clutter/clutter/clutter-deform-effect.c index 59ef1ff75a9c94c30c2dc5bfd0477d1a3288980d..a1b7c89bb513d7a6d7227e08058848fa9a306078 100644 --- a/clutter/clutter/clutter-deform-effect.c +++ b/clutter/clutter/clutter-deform-effect.c @@ -128,10 +128,9 @@ clutter_deform_effect_deform_vertex (ClutterDeformEffect *effect, } static void -vbo_invalidate (ClutterActor *actor, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags, - ClutterDeformEffect *effect) +vbo_invalidate (ClutterActor *actor, + GParamSpec *pspec, + ClutterDeformEffect *effect) { effect->priv->is_dirty = TRUE; } @@ -156,7 +155,7 @@ clutter_deform_effect_set_actor (ClutterActorMeta *meta, * changes */ if (actor != NULL) - priv->allocation_id = g_signal_connect (actor, "allocation-changed", + priv->allocation_id = g_signal_connect (actor, "notify::allocation", G_CALLBACK (vbo_invalidate), meta); diff --git a/clutter/clutter/clutter-enums.h b/clutter/clutter/clutter-enums.h index 2d4f41c427b4d67d0cf663b64e2074b46672f72c..4b9b62bcf5a8fad432ddecb3fa7bff8f819fa75a 100644 --- a/clutter/clutter/clutter-enums.h +++ b/clutter/clutter/clutter-enums.h @@ -554,32 +554,6 @@ typedef enum /*< prefix=CLUTTER_OFFSCREEN_REDIRECT >*/ CLUTTER_OFFSCREEN_REDIRECT_ON_IDLE = 1 << 2 } ClutterOffscreenRedirect; -/** - * ClutterAllocationFlags: - * @CLUTTER_ALLOCATION_NONE: No flag set - * @CLUTTER_ABSOLUTE_ORIGIN_CHANGED: Whether the absolute origin of the - * actor has changed; this implies that any ancestor of the actor has - * been moved. - * @CLUTTER_DELEGATE_LAYOUT: Whether the allocation should be delegated - * to the #ClutterLayoutManager instance stored inside the - * #ClutterActor:layout-manager property of #ClutterActor. This flag - * should only be used if you are subclassing #ClutterActor and - * overriding the #ClutterActorClass.allocate() virtual function, but - * you wish to use the default implementation of the virtual function - * inside #ClutterActor. Added in Clutter 1.10. - * - * Flags passed to the #ClutterActorClass.allocate() virtual function - * and to the clutter_actor_allocate() function. - * - * Since: 1.0 - */ -typedef enum -{ - CLUTTER_ALLOCATION_NONE = 0, - CLUTTER_ABSOLUTE_ORIGIN_CHANGED = 1 << 1, - CLUTTER_DELEGATE_LAYOUT = 1 << 2 -} ClutterAllocationFlags; - /** * ClutterAlignAxis: * @CLUTTER_ALIGN_X_AXIS: Maintain the alignment on the X axis diff --git a/clutter/clutter/clutter-fixed-layout.c b/clutter/clutter/clutter-fixed-layout.c index 959f7652e9c830fd63b918775c9918ae81d3ae1a..324084809c8dc6ab9823da6b4e0b74170f63f709 100644 --- a/clutter/clutter/clutter-fixed-layout.c +++ b/clutter/clutter/clutter-fixed-layout.c @@ -131,8 +131,7 @@ clutter_fixed_layout_get_preferred_height (ClutterLayoutManager *manager, static void clutter_fixed_layout_allocate (ClutterLayoutManager *manager, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { ClutterActor *child; @@ -140,7 +139,7 @@ clutter_fixed_layout_allocate (ClutterLayoutManager *manager, child != NULL; child = clutter_actor_get_next_sibling (child)) { - clutter_actor_allocate_preferred_size (child, flags); + clutter_actor_allocate_preferred_size (child); } } diff --git a/clutter/clutter/clutter-flow-layout.c b/clutter/clutter/clutter-flow-layout.c index 365c5d9d85525e42625fef041f329a6cd8b1d059..f7ced9837faaa61140dae2e9f855746d326bfcfe 100644 --- a/clutter/clutter/clutter-flow-layout.c +++ b/clutter/clutter/clutter-flow-layout.c @@ -566,8 +566,7 @@ clutter_flow_layout_get_preferred_height (ClutterLayoutManager *manager, static void clutter_flow_layout_allocate (ClutterLayoutManager *manager, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { ClutterFlowLayoutPrivate *priv = CLUTTER_FLOW_LAYOUT (manager)->priv; ClutterActor *actor, *child; @@ -729,7 +728,7 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager, child_alloc.y1 = ceil (item_y); child_alloc.x2 = ceil (child_alloc.x1 + item_width); child_alloc.y2 = ceil (child_alloc.y1 + item_height); - clutter_actor_allocate (child, &child_alloc, flags); + clutter_actor_allocate (child, &child_alloc); if (priv->orientation == CLUTTER_FLOW_HORIZONTAL) item_x = new_x; diff --git a/clutter/clutter/clutter-grid-layout.c b/clutter/clutter/clutter-grid-layout.c index 29ec547591f092416f295ee54bf370efe2600ca1..ebc022eb754b66cebf8556dd53dc279e579b3a85 100644 --- a/clutter/clutter/clutter-grid-layout.c +++ b/clutter/clutter/clutter-grid-layout.c @@ -1391,8 +1391,7 @@ allocate_child (ClutterGridRequest *request, static void clutter_grid_layout_allocate (ClutterLayoutManager *layout, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { ClutterGridLayout *self = CLUTTER_GRID_LAYOUT (layout); ClutterOrientation orientation; @@ -1453,7 +1452,7 @@ clutter_grid_layout_allocate (ClutterLayoutManager *layout, child_allocation.x2 = child_allocation.x1 + width; child_allocation.y2 = child_allocation.y1 + height; - clutter_actor_allocate (child, &child_allocation, flags); + clutter_actor_allocate (child, &child_allocation); } } diff --git a/clutter/clutter/clutter-layout-manager.c b/clutter/clutter/clutter-layout-manager.c index 6fb49b7a5bb57bb2045bfb79a721ec13a47c021b..ad642d8b6a031bee6c4b4b9725501957deed589b 100644 --- a/clutter/clutter/clutter-layout-manager.c +++ b/clutter/clutter/clutter-layout-manager.c @@ -253,8 +253,7 @@ layout_manager_real_get_preferred_height (ClutterLayoutManager *manager, static void layout_manager_real_allocate (ClutterLayoutManager *manager, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { LAYOUT_MANAGER_WARN_NOT_IMPLEMENTED (manager, "allocate"); } @@ -434,7 +433,6 @@ clutter_layout_manager_get_preferred_height (ClutterLayoutManager *manager, * @container: the #ClutterContainer using @manager * @allocation: the #ClutterActorBox containing the allocated area * of @container - * @flags: the allocation flags * * Allocates the children of @container given an area * @@ -445,8 +443,7 @@ clutter_layout_manager_get_preferred_height (ClutterLayoutManager *manager, void clutter_layout_manager_allocate (ClutterLayoutManager *manager, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { ClutterLayoutManagerClass *klass; @@ -455,7 +452,7 @@ clutter_layout_manager_allocate (ClutterLayoutManager *manager, g_return_if_fail (allocation != NULL); klass = CLUTTER_LAYOUT_MANAGER_GET_CLASS (manager); - klass->allocate (manager, container, allocation, flags); + klass->allocate (manager, container, allocation); } /** diff --git a/clutter/clutter/clutter-layout-manager.h b/clutter/clutter/clutter-layout-manager.h index ec87e0ed7f7bf00e05f02531f21814bce14afd0e..6df0cecdf5adc490d9fa8ff445f8361af4284277 100644 --- a/clutter/clutter/clutter-layout-manager.h +++ b/clutter/clutter/clutter-layout-manager.h @@ -115,8 +115,7 @@ struct _ClutterLayoutManagerClass gfloat *nat_height_p); void (* allocate) (ClutterLayoutManager *manager, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags); + const ClutterActorBox *allocation); void (* set_container) (ClutterLayoutManager *manager, ClutterContainer *container); @@ -158,8 +157,7 @@ void clutter_layout_manager_get_preferred_height (ClutterLayoutMa CLUTTER_EXPORT void clutter_layout_manager_allocate (ClutterLayoutManager *manager, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags); + const ClutterActorBox *allocation); CLUTTER_EXPORT void clutter_layout_manager_set_container (ClutterLayoutManager *manager, diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index d656ec2e995d3fd551e55b001b72a11abb066df8..9657dc8b5958436b1cc104ec828380491e350bda 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -613,8 +613,7 @@ stage_is_default (ClutterStage *stage) static void clutter_stage_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) + const ClutterActorBox *box) { ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv; ClutterActorBox alloc = CLUTTER_ACTOR_BOX_INIT_ZERO; @@ -622,6 +621,7 @@ clutter_stage_allocate (ClutterActor *self, float new_width, new_height; float width, height; cairo_rectangle_int_t window_size; + ClutterLayoutManager *layout_manager = clutter_actor_get_layout_manager (self); if (priv->impl == NULL) return; @@ -643,15 +643,21 @@ clutter_stage_allocate (ClutterActor *self, */ if (!clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC)) { + ClutterActorBox children_box; + + children_box.x1 = children_box.y1 = 0.f; + children_box.x2 = box->x2 - box->x1; + children_box.y2 = box->y2 - box->y1; + CLUTTER_NOTE (LAYOUT, - "Following allocation to %.2fx%.2f (absolute origin %s)", - width, height, - (flags & CLUTTER_ABSOLUTE_ORIGIN_CHANGED) - ? "changed" - : "not changed"); + "Following allocation to %.2fx%.2f", + width, height); - clutter_actor_set_allocation (self, box, - flags | CLUTTER_DELEGATE_LAYOUT); + clutter_actor_set_allocation (self, box); + + clutter_layout_manager_allocate (layout_manager, + CLUTTER_CONTAINER (self), + &children_box); /* Ensure the window is sized correctly */ if (priv->min_size_changed) @@ -699,16 +705,16 @@ clutter_stage_allocate (ClutterActor *self, CLUTTER_NOTE (LAYOUT, "Overriding original allocation of %.2fx%.2f " - "with %.2fx%.2f (absolute origin %s)", + "with %.2fx%.2f", width, height, - override.x2, override.y2, - (flags & CLUTTER_ABSOLUTE_ORIGIN_CHANGED) - ? "changed" - : "not changed"); + override.x2, override.y2); /* and store the overridden allocation */ - clutter_actor_set_allocation (self, &override, - flags | CLUTTER_DELEGATE_LAYOUT); + clutter_actor_set_allocation (self, &override); + + clutter_layout_manager_allocate (layout_manager, + CLUTTER_CONTAINER (self), + &override); } /* reset the viewport if the allocation effectively changed */ @@ -1359,8 +1365,7 @@ _clutter_stage_maybe_relayout (ClutterActor *actor) CLUTTER_SET_PRIVATE_FLAGS (queued_actor, CLUTTER_IN_RELAYOUT); old_version = priv->pending_relayouts_version; - clutter_actor_allocate_preferred_size (queued_actor, - CLUTTER_ALLOCATION_NONE); + clutter_actor_allocate_preferred_size (queued_actor); CLUTTER_UNSET_PRIVATE_FLAGS (queued_actor, CLUTTER_IN_RELAYOUT); diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c index a97e94b9232a7236535c4db193b7fe6cc0b54c10..2886016fb63ee2a0e1b0419ee5c9daffd6432860 100644 --- a/clutter/clutter/clutter-text.c +++ b/clutter/clutter/clutter-text.c @@ -3037,8 +3037,7 @@ clutter_text_get_preferred_height (ClutterActor *self, static void clutter_text_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) + const ClutterActorBox *box) { ClutterText *text = CLUTTER_TEXT (self); ClutterActorClass *parent_class; @@ -3058,7 +3057,7 @@ clutter_text_allocate (ClutterActor *self, box->y2 - box->y1); parent_class = CLUTTER_ACTOR_CLASS (clutter_text_parent_class); - parent_class->allocate (self, box, flags); + parent_class->allocate (self, box); } static gboolean diff --git a/clutter/clutter/deprecated/clutter-group.c b/clutter/clutter/deprecated/clutter-group.c index af602fd51ca8ae0b9e799ca72e84327667c7d8c0..dce35cff80ed6b0acc5b9abd28243c893129d096 100644 --- a/clutter/clutter/deprecated/clutter-group.c +++ b/clutter/clutter/deprecated/clutter-group.c @@ -333,21 +333,20 @@ clutter_group_real_get_preferred_height (ClutterActor *actor, static void clutter_group_real_allocate (ClutterActor *actor, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { ClutterGroupPrivate *priv = CLUTTER_GROUP (actor)->priv; ClutterActorClass *klass; klass = CLUTTER_ACTOR_CLASS (clutter_group_parent_class); - klass->allocate (actor, allocation, flags); + klass->allocate (actor, allocation); if (priv->children == NULL) return; clutter_layout_manager_allocate (priv->layout, CLUTTER_CONTAINER (actor), - allocation, flags); + allocation); } static void diff --git a/src/tests/clutter/conform/actor-anchors.c b/src/tests/clutter/conform/actor-anchors.c index 3cf3191f30705a61fd2e46627ab4bc333900c07c..bd934ff1406cb739a316fa0bd0bd9074e06f8a2c 100644 --- a/src/tests/clutter/conform/actor-anchors.c +++ b/src/tests/clutter/conform/actor-anchors.c @@ -716,8 +716,8 @@ actor_pivot (void) clutter_actor_add_child (stage, actor_explicit); /* Fake allocation or pivot-point will not have any effect */ - clutter_actor_allocate (actor_implicit, &allocation, CLUTTER_ALLOCATION_NONE); - clutter_actor_allocate (actor_explicit, &allocation, CLUTTER_ALLOCATION_NONE); + clutter_actor_allocate (actor_implicit, &allocation); + clutter_actor_allocate (actor_explicit, &allocation); clutter_actor_set_pivot_point (actor_implicit, 0.5, 0.5); clutter_actor_set_pivot_point (actor_explicit, 0.5, 0.5); diff --git a/src/tests/clutter/conform/actor-pick.c b/src/tests/clutter/conform/actor-pick.c index dcee96424ed0207f5ee11945b83b66c377f21602..3511be7d2cd2d2bdb0a2ad0f9224087dc1e879e8 100644 --- a/src/tests/clutter/conform/actor-pick.c +++ b/src/tests/clutter/conform/actor-pick.c @@ -82,7 +82,7 @@ on_timeout (gpointer data) /* Only allocated actors can be picked, so force an allocation * of the overlay actor here. */ - clutter_actor_allocate (over_actor, &over_actor_box, 0); + clutter_actor_allocate (over_actor, &over_actor_box); if (g_test_verbose ()) g_print ("Clipped covering actor:\n"); diff --git a/src/tests/clutter/interactive/test-layout.c b/src/tests/clutter/interactive/test-layout.c index 9666f15df99ea105502db46b5259bfe008f29536..5f697c90714a8a78bd6d3e21f115e2fd3a6f9edf 100644 --- a/src/tests/clutter/interactive/test-layout.c +++ b/src/tests/clutter/interactive/test-layout.c @@ -276,15 +276,14 @@ my_thing_get_preferred_height (ClutterActor *self, static void my_thing_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) + const ClutterActorBox *box) { MyThingPrivate *priv; gfloat current_x, current_y, max_row_height; ClutterActorIter iter; ClutterActor *child; - clutter_actor_set_allocation (self, box, flags); + clutter_actor_set_allocation (self, box); priv = MY_THING (self)->priv; @@ -322,7 +321,7 @@ my_thing_allocate (ClutterActor *self, child_box.x2 = child_box.x1 + natural_width; child_box.y2 = child_box.y1 + natural_height; - clutter_actor_allocate (child, &child_box, flags); + clutter_actor_allocate (child, &child_box); /* if we take into account the transformation of the children * then we first check if it's transformed; then we get the @@ -338,17 +337,8 @@ my_thing_allocate (ClutterActor *self, graphene_point3d_t v1 = { 0, }, v2 = { 0, }; ClutterActorBox transformed_box = { 0, }; - /* origin */ - if (!(flags & CLUTTER_ABSOLUTE_ORIGIN_CHANGED)) - { - v1.x = 0; - v1.y = 0; - } - else - { - v1.x = box->x1; - v1.y = box->y1; - } + v1.x = box->x1; + v1.y = box->y1; clutter_actor_apply_transform_to_point (child, &v1, &v2); transformed_box.x1 = v2.x;