From adca939101e3a25309c29e6a263c1c7ac7b0d877 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 15 Oct 2009 12:04:50 +0100 Subject: [PATCH] layout, box: Write long description for Box Also have an example of how to create a Box with a layout manager and how to use the pack() method. --- clutter/clutter-box.c | 45 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-box.c b/clutter/clutter-box.c index 7bcd879f6..42ba18ec7 100644 --- a/clutter/clutter-box.c +++ b/clutter/clutter-box.c @@ -2,7 +2,44 @@ * SECTION:clutter-box * @short_description: A Generic layout container * - * #ClutterBox is a FIXME + * #ClutterBox is a #ClutterActor sub-class implementing the #ClutterContainer + * interface. A Box delegates the whole size requisition and size allocation to + * a #ClutterLayoutManager instance. + * + * + * Using ClutterBox + * The following code shows how to create a #ClutterBox with + * a #ClutterLayoutManager sub-class, and how to add children to + * it via clutter_box_pack(). + * + * ClutterActor *box; + * ClutterLayoutManager *layout; + * + * /* Create the layout manager first */ + * layout = clutter_box_layout_new (); + * clutter_box_layout_set_homogeneous (CLUTTER_BOX_LAYOUT (layout), TRUE); + * clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (layout), 12); + * + * /* Then create the ClutterBox actor. The Box will take + * * ownership of the ClutterLayoutManager instance by sinking + * * its floating reference + * */ + * box = clutter_box_new (layout); + * + * /* Now add children to the Box using the variadic arguments + * * function clutter_box_pack() to set layout properties + * */ + * clutter_box_pack (CLUTTER_BOX (box), actor, + * "x-align", CLUTTER_BOX_ALIGNMENT_CENTER, + * "y-align", CLUTTER_BOX_ALIGNMENT_END, + * "expand", TRUE, + * NULL); + * + * + * + * #ClutterBox's clutter_box_pack() wraps the generic + * clutter_container_add_actor() function, but it also allows setting + * layout properties while adding the new child to the box. * * #ClutterBox is available since Clutter 1.2 */ @@ -237,6 +274,9 @@ clutter_box_real_get_preferred_width (ClutterActor *actor, { ClutterBoxPrivate *priv = CLUTTER_BOX (actor)->priv; + /* if we don't have any children don't bother proxying the + * call to the layout manager instance + */ if (priv->children == NULL) { if (min_width) @@ -262,6 +302,9 @@ clutter_box_real_get_preferred_height (ClutterActor *actor, { ClutterBoxPrivate *priv = CLUTTER_BOX (actor)->priv; + /* if we don't have any children don't bother proxying the + * call to the layout manager instance + */ if (priv->children == NULL) { if (min_height)