mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
Port ClutterVBox to the new ClutterBox implementation
Like ClutterHBox, ClutterVBox now takes into account the per-child padding and the per-box margin.
This commit is contained in:
parent
6005c0849d
commit
fb6d01cd76
@ -40,12 +40,21 @@ clutter_vbox_query_coords (ClutterActor *actor,
|
|||||||
ClutterActorBox *coords)
|
ClutterActorBox *coords)
|
||||||
{
|
{
|
||||||
ClutterBox *box = CLUTTER_BOX (actor);
|
ClutterBox *box = CLUTTER_BOX (actor);
|
||||||
|
ClutterMargin box_margin;
|
||||||
GList *l;
|
GList *l;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
guint spacing;
|
|
||||||
|
|
||||||
spacing = clutter_box_get_spacing (box);
|
if (box->allocation.x2 != -1 && box->allocation.y2 != -1)
|
||||||
width = height = 0;
|
{
|
||||||
|
coords->x2 = box->allocation.x2;
|
||||||
|
coords->y2 = box->allocation.y2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clutter_box_get_margin (box, &box_margin);
|
||||||
|
|
||||||
|
width = CLUTTER_UNITS_TO_INT (box_margin.left);
|
||||||
|
height = CLUTTER_UNITS_TO_INT (box_margin.top);
|
||||||
|
|
||||||
for (l = box->children; l; l = l->next)
|
for (l = box->children; l; l = l->next)
|
||||||
{
|
{
|
||||||
@ -57,20 +66,38 @@ clutter_vbox_query_coords (ClutterActor *actor,
|
|||||||
|
|
||||||
clutter_actor_get_size (child->actor, &child_width, &child_height);
|
clutter_actor_get_size (child->actor, &child_width, &child_height);
|
||||||
|
|
||||||
width = MAX (child_width, width);
|
height = height
|
||||||
height += child_height + (spacing * 2);
|
+ CLUTTER_UNITS_TO_INT (child->padding.top)
|
||||||
|
+ child_height
|
||||||
|
+ CLUTTER_UNITS_TO_INT (child->padding.bottom);
|
||||||
|
|
||||||
|
width = MAX ((child_width
|
||||||
|
+ CLUTTER_UNITS_TO_INT (child->padding.left)
|
||||||
|
+ CLUTTER_UNITS_TO_INT (child->padding.right)),
|
||||||
|
width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
coords->x2 = coords->x1 + CLUTTER_UNITS_FROM_INT (width);
|
width += CLUTTER_UNITS_TO_INT (box_margin.right);
|
||||||
coords->y2 = coords->y1 + CLUTTER_UNITS_FROM_INT (height);
|
height += CLUTTER_UNITS_TO_INT (box_margin.bottom);
|
||||||
|
|
||||||
|
box->allocation.x2 = coords->x2 =
|
||||||
|
coords->x1 + CLUTTER_UNITS_FROM_INT (width);
|
||||||
|
box->allocation.y2 = coords->y2 =
|
||||||
|
coords->y1 + CLUTTER_UNITS_FROM_INT (height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_vbox_request_coords (ClutterActor *actor,
|
clutter_vbox_request_coords (ClutterActor *actor,
|
||||||
ClutterActorBox *coords)
|
ClutterActorBox *coords)
|
||||||
{
|
{
|
||||||
/* FIXME */
|
ClutterBox *box = CLUTTER_BOX (actor);
|
||||||
|
|
||||||
|
/* we reset the allocation here */
|
||||||
|
box->allocation.x1 = coords->x1;
|
||||||
|
box->allocation.y1 = coords->y1;
|
||||||
|
box->allocation.x2 = -1;
|
||||||
|
box->allocation.y2 = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -78,15 +105,35 @@ clutter_vbox_pack_child (ClutterBox *box,
|
|||||||
ClutterBoxChild *child)
|
ClutterBoxChild *child)
|
||||||
{
|
{
|
||||||
ClutterGeometry box_geom, child_geom;
|
ClutterGeometry box_geom, child_geom;
|
||||||
guint spacing;
|
ClutterMargin box_margin;
|
||||||
|
|
||||||
spacing = clutter_box_get_spacing (box);
|
/* reset the saved allocation */
|
||||||
|
box->allocation.x2 = box->allocation.y2 = -1;
|
||||||
|
|
||||||
clutter_actor_get_geometry (CLUTTER_ACTOR (box), &box_geom);
|
clutter_actor_get_geometry (CLUTTER_ACTOR (box), &box_geom);
|
||||||
clutter_actor_get_geometry (child->actor, &child_geom);
|
clutter_actor_get_geometry (child->actor, &child_geom);
|
||||||
|
|
||||||
child_geom.x = 0;
|
clutter_box_get_margin (box, &box_margin);
|
||||||
child_geom.y = box_geom.height + spacing;
|
|
||||||
|
if (child->pack_type == CLUTTER_PACK_START)
|
||||||
|
{
|
||||||
|
child_geom.x = CLUTTER_UNITS_TO_INT (child->padding.left);
|
||||||
|
child_geom.y = box_geom.height
|
||||||
|
+ CLUTTER_UNITS_TO_INT (child->padding.top);
|
||||||
|
}
|
||||||
|
else if (child->pack_type == CLUTTER_PACK_END)
|
||||||
|
{
|
||||||
|
child_geom.x = CLUTTER_UNITS_TO_INT (child->padding.left);
|
||||||
|
child_geom.y = box_geom.height - child_geom.height
|
||||||
|
- CLUTTER_UNITS_TO_INT (child->padding.bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
child->child_coords.x1 = CLUTTER_UNITS_FROM_INT (child_geom.x);
|
||||||
|
child->child_coords.y1 = CLUTTER_UNITS_FROM_INT (child_geom.y);
|
||||||
|
child->child_coords.x2 = CLUTTER_UNITS_FROM_INT (child_geom.x)
|
||||||
|
+ CLUTTER_UNITS_FROM_INT (child_geom.width);
|
||||||
|
child->child_coords.y2 = CLUTTER_UNITS_FROM_INT (child_geom.y)
|
||||||
|
+ CLUTTER_UNITS_FROM_INT (child_geom.height);
|
||||||
|
|
||||||
clutter_actor_set_geometry (child->actor, &child_geom);
|
clutter_actor_set_geometry (child->actor, &child_geom);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user