test-flow-layout: Use BindConstraints

If we want to fit the FlowLayout to the Stage size we should use the
BindConstraint API instead of a watcher on ::allocation-changed.
This commit is contained in:
Emmanuele Bassi 2010-08-10 17:43:56 +01:00
parent bfa10f629f
commit 02b7bf3635

View File

@ -67,22 +67,6 @@ static GOptionEntry entries[] = {
{ NULL }
};
static void
on_stage_resize (ClutterActor *stage,
const ClutterActorBox *allocation,
ClutterAllocationFlags flags,
ClutterActor *box)
{
gfloat width, height;
clutter_actor_box_get_size (allocation, &width, &height);
if (vertical)
clutter_actor_set_height (box, height);
else
clutter_actor_set_width (box, width);
}
G_MODULE_EXPORT int
test_flow_layout_main (int argc, char *argv[])
{
@ -124,6 +108,13 @@ test_flow_layout_main (int argc, char *argv[])
box = clutter_box_new (layout);
clutter_box_set_color (CLUTTER_BOX (box), &box_color);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);
if (fit_to_stage)
{
clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_WIDTH, 0.0));
clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_HEIGHT, 0.0));
}
clutter_actor_set_position (box, 0, 0);
clutter_actor_set_name (box, "box");
@ -161,11 +152,6 @@ test_flow_layout_main (int argc, char *argv[])
g_free (name);
}
if (fit_to_stage)
g_signal_connect (stage,
"allocation-changed", G_CALLBACK (on_stage_resize),
box);
clutter_actor_show_all (stage);
clutter_main ();