Fix allocation implementations for ShellStack and ShellDrawingArea

In both, using our allocation directly for the child is wrong; we
should create a new allocation that's our width and height.

In ShellDrawingArea, also need to chain up to parent.
This commit is contained in:
Colin Walters 2009-08-26 23:15:47 -04:00
parent ed7881d6c9
commit 3cb54f6707
2 changed files with 23 additions and 3 deletions

View File

@ -40,8 +40,18 @@ shell_drawing_area_allocate (ClutterActor *self,
ShellDrawingArea *area = SHELL_DRAWING_AREA (self);
int width = box->x2 - box->x1;
int height = box->y2 - box->y1;
ClutterActorBox child_box;
clutter_actor_allocate (CLUTTER_ACTOR (area->priv->texture), box, flags);
/* Chain up directly to ClutterActor to set actor->allocation. We explicitly skip our parent class
* ClutterGroup here because we want to override the allocate function. */
(CLUTTER_ACTOR_CLASS (g_type_class_peek (clutter_actor_get_type ())))->allocate (self, box, flags);
child_box.x1 = 0;
child_box.x2 = width;
child_box.y1 = 0;
child_box.y2 = height;
clutter_actor_allocate (CLUTTER_ACTOR (area->priv->texture), &child_box, flags);
if (width > 0 && height > 0)
{
clutter_cairo_texture_set_surface_size (area->priv->texture,

View File

@ -24,15 +24,25 @@ shell_stack_allocate (ClutterActor *self,
ClutterAllocationFlags flags)
{
GList *children, *iter;
float width, height;
/* chain up to set actor->allocation */
width = box->x2 - box->x1;
height = box->y2 - box->y1;
/* Chain up directly to ClutterActor to set actor->allocation. We explicitly skip our parent class
* ClutterGroup here because we want to override the allocate function. */
(CLUTTER_ACTOR_CLASS (g_type_class_peek (clutter_actor_get_type ())))->allocate (self, box, flags);
children = clutter_container_get_children (CLUTTER_CONTAINER (self));
for (iter = children; iter; iter = iter->next)
{
ClutterActor *actor = CLUTTER_ACTOR (iter->data);
clutter_actor_allocate (actor, box, flags);
ClutterActorBox child_box;
child_box.x1 = 0;
child_box.x2 = width;
child_box.y1 = 0;
child_box.y2 = height;
clutter_actor_allocate (actor, &child_box, flags);
}
g_list_free (children);
}