diff --git a/ChangeLog b/ChangeLog index 7295ed6d1..d047d7ecb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,42 @@ +2007-11-28 Emmanuele Bassi + + Remove the layout containers: they will be moved to a + high-level library. + + * clutter/clutter.h: + * clutter/Makefile.am: Remove layout and boxes from the + build. + + * clutter/clutter-layout.[ch]: Remove the ClutterLayout + interface. + + * clutter/clutter-box.[ch]: + * clutter/clutter-hbox.[ch]: + * clutter/clutter-vbox.[ch]: Remove ClutterBox and its + subclasses. + + * clutter/clutter-label.c: Remove ClutterLayout implementation + + * clutter/clutter-script-private.h: + * clutter/clutter-script-parser.c: + * clutter/clutter-script.c: + (clutter_script_parse_node): Remove special parsing for + ClutterMargin and ClutterPadding. + + * clutter/clutter-types.h: Remove ClutterPadding and ClutterMargin. + + * tests/Makefile.am: + * tests/test-boxes.c: Remove the boxes test case. + 2007-11-28 Tomas Frydrych - * clutter/NEWS: + * clutter/NEWS: Started 0.6.0 section with comment on actor anchor point. - * clutter/clutter/clutter-actor.c: - * clutter/clutter/clutter-actor.h: - * clutter/clutter/clutter-behaviour-scale.c: - * clutter/clutter/clutter-deprecated.h: + * clutter/clutter/clutter-actor.c: + * clutter/clutter/clutter-actor.h: + * clutter/clutter/clutter-behaviour-scale.c: + * clutter/clutter/clutter-deprecated.h: (clutter_actor_set_anchor_point): (clutter_actor_set_anchor_pointu): (clutter_actor_get_anchor_point): diff --git a/clutter/Makefile.am b/clutter/Makefile.am index 10a867d7a..f260c1d2c 100644 --- a/clutter/Makefile.am +++ b/clutter/Makefile.am @@ -50,7 +50,6 @@ source_h = \ $(srcdir)/clutter-behaviour-path.h \ $(srcdir)/clutter-behaviour-rotate.h \ $(srcdir)/clutter-behaviour-scale.h \ - $(srcdir)/clutter-box.h \ $(srcdir)/clutter-clone-texture.h \ $(srcdir)/clutter-color.h \ $(srcdir)/clutter-container.h \ @@ -61,10 +60,8 @@ source_h = \ $(srcdir)/clutter-feature.h \ $(srcdir)/clutter-fixed.h \ $(srcdir)/clutter-group.h \ - $(srcdir)/clutter-hbox.h \ $(srcdir)/clutter-keysyms.h \ $(srcdir)/clutter-label.h \ - $(srcdir)/clutter-layout.h \ $(srcdir)/clutter-main.h \ $(srcdir)/clutter-media.h \ $(srcdir)/clutter-model.h \ @@ -79,7 +76,6 @@ source_h = \ $(srcdir)/clutter-types.h \ $(srcdir)/clutter-units.h \ $(srcdir)/clutter-util.h \ - $(srcdir)/clutter-vbox.h \ $(srcdir)/clutter-version.h \ $(NULL) @@ -137,7 +133,6 @@ source_c = \ clutter-behaviour-path.c \ clutter-behaviour-rotate.c \ clutter-behaviour-scale.c \ - clutter-box.c \ clutter-color.c \ clutter-container.c \ clutter-clone-texture.c \ @@ -148,9 +143,7 @@ source_c = \ clutter-feature.c \ clutter-fixed.c \ clutter-group.c \ - clutter-hbox.c \ clutter-label.c \ - clutter-layout.c \ clutter-main.c \ clutter-marshal.c \ clutter-media.c \ @@ -165,7 +158,6 @@ source_c = \ clutter-timeline.c \ clutter-timeout-pool.c \ clutter-util.c \ - clutter-vbox.c \ $(NULL) source_h_priv = \ diff --git a/clutter/clutter-box.c b/clutter/clutter-box.c deleted file mode 100644 index 3a68930d3..000000000 --- a/clutter/clutter-box.c +++ /dev/null @@ -1,915 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "cogl.h" - -#include "clutter-box.h" -#include "clutter-container.h" -#include "clutter-debug.h" -#include "clutter-enum-types.h" -#include "clutter-main.h" -#include "clutter-private.h" - -/** - * SECTION:clutter-box - * @short_description: Base class for layout containers - * - * #ClutterBox is a base class for containers which impose a specific layout - * on their children, unlike #ClutterGroup which is a free-form container. - * - * Layout containers are expected to move and size their children depending - * on a layout contract they establish per-class. For instance, a #ClutterHBox - * (a subclass of #ClutterBox) lays out its children along an imaginary - * horizontal line. - * - * All #ClutterBoxes have a margin, which is decomposed in four - * components (top, right, bottom left) and a background color. Each child - * of a #ClutterBox has a packing type and a padding, decomposed like the - * margin. Actors can be packed using clutter_box_pack() and providing - * the packing type and the padding, or using clutter_box_pack_defaults() - * and setting a default padding with clutter_box_set_default_padding(). - * A #ClutterBox implements the #ClutterContainer interface: calling - * clutter_container_add_actor() on a #ClutterBox will automatically invoke - * clutter_box_pack_defaults(). - * - * Each child of a #ClutterBox has its packing information wrapped into the - * #ClutterBoxChild structure, which can be retrieved either using the - * clutter_box_query_child() or the clutter_box_query_nth_child() function. - * - * Subclasses of #ClutterBox must implement the ClutterBox::pack_child and - * ClutterBox::unpack_child virtual functions; these functions will be called - * when adding a child and when removing one, respectively. - * - * #ClutterBox is available since Clutter 0.4 - */ - -enum -{ - PROP_0, - - PROP_MARGIN, - PROP_COLOR -}; - -static void clutter_container_iface_init (ClutterContainerIface *iface); - -G_DEFINE_ABSTRACT_TYPE_WITH_CODE (ClutterBox, - clutter_box, - CLUTTER_TYPE_ACTOR, - G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER, - clutter_container_iface_init)); - - -static void -clutter_box_add (ClutterContainer *container, - ClutterActor *actor) -{ - clutter_box_pack_defaults (CLUTTER_BOX (container), actor); -} - -static void -clutter_box_remove (ClutterContainer *container, - ClutterActor *actor) -{ - ClutterBox *box = CLUTTER_BOX (container); - GList *l; - - g_object_ref (actor); - - for (l = box->children; l; l = l->next) - { - ClutterBoxChild *child = l->data; - - if (child->actor == actor) - { - CLUTTER_BOX_GET_CLASS (box)->unpack_child (box, child); - - clutter_actor_unparent (actor); - - box->children = g_list_remove_link (box->children, l); - g_list_free (l); - g_slice_free (ClutterBoxChild, child); - - g_signal_emit_by_name (container, "actor-removed", actor); - - if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (box))) - clutter_actor_queue_redraw (CLUTTER_ACTOR (box)); - - break; - } - } - - g_object_unref (actor); -} - -static void -clutter_box_foreach (ClutterContainer *container, - ClutterCallback callback, - gpointer user_data) -{ - ClutterBox *box = CLUTTER_BOX (container); - GList *l; - - for (l = box->children; l; l = l->next) - { - ClutterBoxChild *child = l->data; - - if (child->pack_type == CLUTTER_PACK_START) - (* callback) (child->actor, user_data); - } - - for (l = g_list_last (box->children); l; l = l->prev) - { - ClutterBoxChild *child = l->data; - - if (child->pack_type == CLUTTER_PACK_END) - (* callback) (child->actor, user_data); - } -} - -static void -clutter_box_raise (ClutterContainer *container, - ClutterActor *actor, - ClutterActor *sibling) -{ - ClutterBox *box = CLUTTER_BOX (container); - ClutterBoxChild *child = NULL, *sibling_child = NULL; - GList *l; - gint pos; - - for (l = box->children; l; l = l->next) - { - child = l->data; - - if (child->actor == actor) - break; - } - - box->children = g_list_remove (box->children, child); - - if (!sibling) - { - GList *last_item; - - /* raise to top */ - last_item = g_list_last (box->children); - if (last_item) - sibling_child = last_item->data; - - box->children = g_list_append (box->children, child); - } - else - { - for (pos = 1, l = box->children; l; l = l->next, pos += 1) - { - sibling_child = l->data; - - if (sibling_child->actor == sibling) - break; - } - - box->children = g_list_insert (box->children, child, pos); - } - - if (sibling_child) - { - ClutterActor *a = child->actor; - ClutterActor *b = sibling_child->actor; - - if (clutter_actor_get_depth (a) != clutter_actor_get_depth (b)) - clutter_actor_set_depth (a, clutter_actor_get_depth (b)); - } -} - -static void -clutter_box_lower (ClutterContainer *container, - ClutterActor *actor, - ClutterActor *sibling) -{ - ClutterBox *box = CLUTTER_BOX (container); - ClutterBoxChild *child = NULL, *sibling_child = NULL; - GList *l; - gint pos; - - for (l = box->children; l; l = l->next) - { - child = l->data; - - if (child->actor == actor) - break; - } - - box->children = g_list_remove (box->children, child); - - if (!sibling) - { - GList *first_item; - - /* lower to bottom */ - first_item = g_list_first (box->children); - if (first_item) - sibling_child = first_item->data; - - box->children = g_list_prepend (box->children, child); - } - else - { - for (pos = 1, l = box->children; l; l = l->next, pos += 1) - { - sibling_child = l->data; - - if (sibling_child->actor == sibling) - break; - } - - box->children = g_list_insert (box->children, child, pos); - } - - if (sibling_child) - { - ClutterActor *a = child->actor; - ClutterActor *b = sibling_child->actor; - - if (clutter_actor_get_depth (a) != clutter_actor_get_depth (b)) - clutter_actor_set_depth (a, clutter_actor_get_depth (b)); - } -} - -static gint -sort_z_order (gconstpointer a, - gconstpointer b) -{ - ClutterBoxChild *child_a = (ClutterBoxChild *) a; - ClutterBoxChild *child_b = (ClutterBoxChild *) b; - gint depth_a, depth_b; - - depth_a = clutter_actor_get_depth (child_a->actor); - depth_b = clutter_actor_get_depth (child_b->actor); - - if (depth_a == depth_b) - return 0; - - if (depth_a > depth_b) - return 1; - - return -1; -} - -static void -clutter_box_sort_depth_order (ClutterContainer *container) -{ - ClutterBox *box = CLUTTER_BOX (container); - - box->children = g_list_sort (box->children, sort_z_order); - - if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (box))) - clutter_actor_queue_redraw (CLUTTER_ACTOR (box)); -} - -static void -clutter_container_iface_init (ClutterContainerIface *iface) -{ - iface->add = clutter_box_add; - iface->remove = clutter_box_remove; - iface->foreach = clutter_box_foreach; - iface->raise = clutter_box_raise; - iface->lower = clutter_box_lower; - iface->sort_depth_order = clutter_box_sort_depth_order; -} - -static void -clutter_box_show_all (ClutterActor *actor) -{ - ClutterBox *box = CLUTTER_BOX (actor); - GList *l; - - for (l = box->children; l; l = l->next) - { - ClutterBoxChild *child = l->data; - - clutter_actor_show (child->actor); - } - - clutter_actor_show (actor); -} - -static void -clutter_box_hide_all (ClutterActor *actor) -{ - ClutterBox *box = CLUTTER_BOX (actor); - GList *l; - - clutter_actor_hide (actor); - - for (l = box->children; l; l = l->next) - { - ClutterBoxChild *child = l->data; - - clutter_actor_hide (child->actor); - } -} - -static void -clutter_box_paint (ClutterActor *actor) -{ - ClutterBox *box = CLUTTER_BOX (actor); - GList *l; - - cogl_push_matrix (); - - cogl_color (&box->color); - - for (l = box->children; l; l = l->next) - { - ClutterBoxChild *child = l->data; - - if (CLUTTER_ACTOR_IS_MAPPED (child->actor)) - clutter_actor_paint (child->actor); - } - - cogl_pop_matrix (); -} - -static void -clutter_box_pick (ClutterActor *actor, - const ClutterColor *color) -{ - /* just repaint; in the future we might enter in a "focused" status here */ - clutter_box_paint (actor); -} - -static void -clutter_box_dispose (GObject *gobject) -{ - ClutterBox *box = CLUTTER_BOX (gobject); - GList *l; - - for (l = box->children; l; l = l->next) - { - ClutterBoxChild *child = l->data; - - clutter_actor_unparent (child->actor); - g_slice_free (ClutterBoxChild, child); - } - - g_list_free (box->children); - box->children = NULL; - - G_OBJECT_CLASS (clutter_box_parent_class)->dispose (gobject); -} - -static void -clutter_box_pack_child_unimplemented (ClutterBox *box, - ClutterBoxChild *child) -{ - g_warning ("ClutterBox of type `%s' does not implement the " - "ClutterBox::pack_child method.", - g_type_name (G_OBJECT_TYPE (box))); -} - -static void -clutter_box_unpack_child_unimplemented (ClutterBox *box, - ClutterBoxChild *child) -{ - g_warning ("ClutterBox of type `%s' does not implement the " - "ClutterBox::unpack_child method.", - g_type_name (G_OBJECT_TYPE (box))); -} - -static void -clutter_box_set_property (GObject *gobject, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - ClutterBox *box = CLUTTER_BOX (gobject); - - switch (prop_id) - { - case PROP_COLOR: - clutter_box_set_color (box, g_value_get_boxed (value)); - break; - case PROP_MARGIN: - clutter_box_set_margin (box, g_value_get_boxed (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); - break; - } -} - -static void -clutter_box_get_property (GObject *gobject, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - ClutterBox *box = CLUTTER_BOX (gobject); - - switch (prop_id) - { - case PROP_MARGIN: - { - ClutterMargin margin; - clutter_box_get_margin (box, &margin); - g_value_set_boxed (value, &margin); - } - break; - case PROP_COLOR: - { - ClutterColor color; - clutter_box_get_color (box, &color); - g_value_set_boxed (value, &color); - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); - break; - } -} - -static void -clutter_box_class_init (ClutterBoxClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); - - gobject_class->set_property = clutter_box_set_property; - gobject_class->get_property = clutter_box_get_property; - gobject_class->dispose = clutter_box_dispose; - - actor_class->show_all = clutter_box_show_all; - actor_class->hide_all = clutter_box_hide_all; - actor_class->paint = clutter_box_paint; - actor_class->pick = clutter_box_pick; - - klass->pack_child = clutter_box_pack_child_unimplemented; - klass->unpack_child = clutter_box_unpack_child_unimplemented; - - /** - * ClutterBox:margin: - * - * The margin between the inner border of a #ClutterBox and its - * children. - * - * Since: 0.4 - */ - g_object_class_install_property (gobject_class, - PROP_MARGIN, - g_param_spec_boxed ("margin", - "Margin", - "Margin between the inner border of a box and its children", - CLUTTER_TYPE_MARGIN, - CLUTTER_PARAM_READWRITE)); - /** - * ClutterBox:color: - * - * The background color of a #ClutterBox. - * - * Since: 0.4 - */ - g_object_class_install_property (gobject_class, - PROP_COLOR, - g_param_spec_boxed ("color", - "Color", - "Background color of a box", - CLUTTER_TYPE_COLOR, - CLUTTER_PARAM_READWRITE)); -} - -static void -clutter_box_init (ClutterBox *box) -{ - box->allocation.x1 = box->allocation.y1 = 0; - box->allocation.x2 = box->allocation.y2 = -1; -} - -/* - * Public API - */ - -/** - * clutter_box_pack: - * @box: a #ClutterBox - * @actor: a #ClutterActor to pack into the box - * @pack_type: Type of packing to use - * @padding: padding to use on the actor - * - * Packs @actor into @box. - * - * Since: 0.4 - */ -void -clutter_box_pack (ClutterBox *box, - ClutterActor *actor, - ClutterPackType pack_type, - const ClutterPadding *padding) -{ - ClutterBoxChild *child; - - g_return_if_fail (CLUTTER_IS_BOX (box)); - g_return_if_fail (CLUTTER_IS_ACTOR (actor)); - g_return_if_fail (padding != NULL); - - child = g_slice_new (ClutterBoxChild); - child->actor = actor; - child->pack_type = pack_type; - memcpy (&(child->padding), padding, sizeof (ClutterPadding)); - - CLUTTER_BOX_GET_CLASS (box)->pack_child (box, child); - - box->children = g_list_prepend (box->children, child); - clutter_actor_set_parent (actor, CLUTTER_ACTOR (box)); - - if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (box))) - clutter_actor_queue_redraw (CLUTTER_ACTOR (box)); -} - -/** - * clutter_box_pack_defaults: - * @box: a #ClutterBox - * @actor: a #ClutterActor - * - * Packs @actor into @box, using the default settings for the - * pack type and padding. - * - * Since: 0.4 - */ -void -clutter_box_pack_defaults (ClutterBox *box, - ClutterActor *actor) -{ - g_return_if_fail (CLUTTER_IS_BOX (box)); - g_return_if_fail (CLUTTER_IS_ACTOR (actor)); - - clutter_box_pack (box, actor, - CLUTTER_PACK_START, - &box->default_padding); -} - -/** - * clutter_box_query_child: - * @box: a #ClutterBox - * @actor: child to query - * @child: return location for a #ClutterBoxChild or %NULL - * - * Queries @box for the packing data of @actor. - * - * Return value: %TRUE if @actor is a child of @box - * - * Since: 0.4 - */ -gboolean -clutter_box_query_child (ClutterBox *box, - ClutterActor *actor, - ClutterBoxChild *child) -{ - GList *l; - - g_return_val_if_fail (CLUTTER_IS_BOX (box), FALSE); - g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), FALSE); - - for (l = box->children; l; l = l->next) - { - ClutterBoxChild *box_child = l->data; - - if (box_child->actor == actor) - { - if (child) - { - child->actor = actor; - - child->pack_type = box_child->pack_type; - - child->child_coords.x1 = box_child->child_coords.x1; - child->child_coords.y1 = box_child->child_coords.y1; - child->child_coords.x2 = box_child->child_coords.x2; - child->child_coords.y2 = box_child->child_coords.y2; - - child->padding.top = box_child->padding.top; - child->padding.right = box_child->padding.right; - child->padding.bottom = box_child->padding.bottom; - child->padding.left = box_child->padding.left; - } - - return TRUE; - } - } - - return FALSE; -} - -/** - * clutter_box_query_nth_child: - * @box: a #ClutterBox - * @index_: position of the child - * @child: return value for a #ClutterBoxChild, or %NULL - * - * Queries the child of @box at @index_ and puts the packing informations - * inside @child. - * - * Return value: %TRUE if an actor was found at @index_ - * - * Since: 0.4 - */ -gboolean -clutter_box_query_nth_child (ClutterBox *box, - gint index_, - ClutterBoxChild *child) -{ - ClutterBoxChild *box_child; - - g_return_val_if_fail (CLUTTER_IS_BOX (box), FALSE); - g_return_val_if_fail (index_ > 0, FALSE); - - box_child = g_list_nth_data (box->children, index_); - if (!box_child) - return FALSE; - - if (child) - { - child->actor = box_child->actor; - - child->pack_type = box_child->pack_type; - - child->child_coords.x1 = box_child->child_coords.x1; - child->child_coords.y1 = box_child->child_coords.y1; - child->child_coords.x2 = box_child->child_coords.x2; - child->child_coords.y2 = box_child->child_coords.y2; - - child->padding.top = box_child->padding.top; - child->padding.right = box_child->padding.right; - child->padding.bottom = box_child->padding.bottom; - child->padding.left = box_child->padding.left; - } - - return TRUE; -} - -/** - * clutter_box_get_margin: - * @box: a #ClutterBox - * @margin: return location for a #ClutterMargin - * - * Gets the value set using clutter_box_set_margin(). - * - * Since: 0.4 - */ -void -clutter_box_get_margin (ClutterBox *box, - ClutterMargin *margin) -{ - g_return_if_fail (CLUTTER_IS_BOX (box)); - g_return_if_fail (margin != NULL); - - margin->top = box->margin.top; - margin->right = box->margin.right; - margin->bottom = box->margin.bottom; - margin->left = box->margin.left; -} - -/** - * clutter_box_set_margin: - * @box: a #ClutterBox - * @margin: a #ClutterMargin, or %NULL to unset the margin - * - * Sets the margin, in #ClutterUnits, between the inner border - * of the box and the children of the box. - * - * Since: 0.4 - */ -void -clutter_box_set_margin (ClutterBox *box, - const ClutterMargin *margin) -{ - g_return_if_fail (CLUTTER_IS_BOX (box)); - - if (margin) - { - box->margin.top = margin->top; - box->margin.right = margin->right; - box->margin.bottom = margin->bottom; - box->margin.left = margin->left; - } - else - { - box->margin.top = 0; - box->margin.right = 0; - box->margin.bottom = 0; - box->margin.left = 0; - } - - if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (box))) - clutter_actor_queue_redraw (CLUTTER_ACTOR (box)); - - g_object_notify (G_OBJECT (box), "margin"); -} - -/** - * clutter_box_get_color: - * @box: a #ClutterBox - * @color: return location for the color - * - * Gets the background color of the box set with clutter_box_set_color(). - * - * Since: 0.4 - */ -void -clutter_box_get_color (ClutterBox *box, - ClutterColor *color) -{ - g_return_if_fail (CLUTTER_IS_BOX (box)); - g_return_if_fail (color != NULL); - - color->red = box->color.red; - color->green = box->color.green; - color->blue = box->color.blue; - color->alpha = box->color.alpha; -} - -/** - * clutter_box_set_color: - * @box: a #ClutterBox - * @color: the background color of the box - * - * Sets the background color of the box. - * - * Since: 0.4 - */ -void -clutter_box_set_color (ClutterBox *box, - const ClutterColor *color) -{ - g_return_if_fail (CLUTTER_IS_BOX (box)); - g_return_if_fail (color != NULL); - - box->color.red = color->red; - box->color.green = color->green; - box->color.blue = color->blue; - box->color.alpha = color->alpha; - - if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (box))) - clutter_actor_queue_redraw (CLUTTER_ACTOR (box)); - - g_object_notify (G_OBJECT (box), "color"); -} - -/** - * clutter_box_remove_all: - * @box: a #ClutterBox - * - * Removes all children actors from the #ClutterBox - * - * Since: 0.4 - */ -void -clutter_box_remove_all (ClutterBox *box) -{ - GList *children; - - g_return_if_fail (CLUTTER_IS_BOX (box)); - - children = box->children; - while (children) - { - ClutterBoxChild *child = children->data; - children = children->next; - - clutter_container_remove_actor (CLUTTER_CONTAINER (box), child->actor); - } -} - -/** - * clutter_box_set_default_padding: - * @box: a #ClutterBox - * @padding_top: top padding, in pixels - * @padding_right: right padding, in pixels - * @padding_bottom: bottom padding, in pixels - * @padding_left: left padding, in pixels - * - * Sets the default padding for children, which will be used when - * packing actors with clutter_box_pack_defaults(). The padding is - * given in pixels. - * - * Since: 0.4 - */ -void -clutter_box_set_default_padding (ClutterBox *box, - gint padding_top, - gint padding_right, - gint padding_bottom, - gint padding_left) -{ - g_return_if_fail (CLUTTER_IS_BOX (box)); - - box->default_padding.top = CLUTTER_UNITS_FROM_INT (padding_top); - box->default_padding.right = CLUTTER_UNITS_FROM_INT (padding_right); - box->default_padding.bottom = CLUTTER_UNITS_FROM_INT (padding_bottom); - box->default_padding.left = CLUTTER_UNITS_FROM_INT (padding_left); -} - -/** - * clutter_box_get_default_padding: - * @box: a #ClutterBox - * @padding_top: return location for the top padding, or %NULL - * @padding_right: return location for the right padding, or %NULL - * @padding_bottom: return location for the bottom padding, or %NULL - * @padding_left: return location for the left padding, or %NULL - * - * Gets the default padding set with clutter_box_set_default_padding(). - * - * Since: 0.4 - */ -void -clutter_box_get_default_padding (ClutterBox *box, - gint *padding_top, - gint *padding_right, - gint *padding_bottom, - gint *padding_left) -{ - g_return_if_fail (CLUTTER_IS_BOX (box)); - - if (padding_top) - *padding_top = CLUTTER_UNITS_TO_INT (box->default_padding.top); - if (padding_right) - *padding_right = CLUTTER_UNITS_TO_INT (box->default_padding.right); - if (padding_bottom) - *padding_bottom = CLUTTER_UNITS_TO_INT (box->default_padding.bottom); - if (padding_left) - *padding_left = CLUTTER_UNITS_TO_INT (box->default_padding.left); -} - -/* - * Boxed types - */ - -static void -clutter_margin_free (ClutterMargin *margin) -{ - if (G_LIKELY (margin)) - { - g_slice_free (ClutterMargin, margin); - } -} - -static ClutterMargin * -clutter_margin_copy (const ClutterMargin *margin) -{ - ClutterMargin *copy; - - g_return_val_if_fail (margin != NULL, NULL); - - copy = g_slice_new (ClutterMargin); - *copy = *margin; - - return copy; -} - -GType -clutter_margin_get_type (void) -{ - static GType gtype = 0; - - if (G_UNLIKELY (gtype == 0)) - gtype = g_boxed_type_register_static (g_intern_static_string ("ClutterMargin"), - (GBoxedCopyFunc) clutter_margin_copy, - (GBoxedFreeFunc) clutter_margin_free); - - return gtype; -} - -static void -clutter_padding_free (ClutterPadding *padding) -{ - if (G_LIKELY (padding)) - { - g_slice_free (ClutterPadding, padding); - } -} - -static ClutterPadding * -clutter_padding_copy (const ClutterPadding *padding) -{ - ClutterPadding *copy; - - g_return_val_if_fail (padding != NULL, NULL); - - copy = g_slice_new (ClutterPadding); - *copy = *padding; - - return copy; -} - -GType -clutter_padding_get_type (void) -{ - static GType gtype = 0; - - if (G_UNLIKELY (gtype == 0)) - gtype = g_boxed_type_register_static (g_intern_static_string ("ClutterPadding"), - (GBoxedCopyFunc) clutter_padding_copy, - (GBoxedFreeFunc) clutter_padding_free); - - return gtype; -} diff --git a/clutter/clutter-box.h b/clutter/clutter-box.h deleted file mode 100644 index 473240229..000000000 --- a/clutter/clutter-box.h +++ /dev/null @@ -1,149 +0,0 @@ -#ifndef __CLUTTER_BOX_H__ -#define __CLUTTER_BOX_H__ - -#include -#include - -G_BEGIN_DECLS - -#define CLUTTER_TYPE_BOX (clutter_box_get_type ()) -#define CLUTTER_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BOX, ClutterBox)) -#define CLUTTER_IS_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BOX)) -#define CLUTTER_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BOX, ClutterBoxClass)) -#define CLUTTER_IS_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_BOX)) -#define CLUTTER_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_BOX, ClutterBoxClass)) - -/** - * ClutterPackType: - * @CLUTTER_PACK_START: append child from the start - * @CLUTTER_PACK_END: append child from the end - * - * Pack order for a #ClutterBox child. - * - * Since: 0.4 - */ -typedef enum { - CLUTTER_PACK_START, - CLUTTER_PACK_END -} ClutterPackType; - -typedef struct _ClutterBoxChild ClutterBoxChild; -typedef struct _ClutterBox ClutterBox; -typedef struct _ClutterBoxClass ClutterBoxClass; - -struct _ClutterBox -{ - /*< private >*/ - ClutterActor parent_instance; - - /* We need to put these in the instance structure, since this - * is an abstract class meant to be subclassed; think of these - * as "protected" attributes of the ClutterBox class - */ - - /* Allocation of the box */ - ClutterActorBox allocation; - - /* List of ClutterBoxChild structures */ - GList *children; - - /* Background color of the box */ - ClutterColor color; - - /* Margin between the inner border of the box and the children */ - ClutterMargin margin; - - /* Default padding for the children */ - ClutterPadding default_padding; -}; - -/** - * ClutterBoxClass: - * @pack_child: virtual function, called when packing a new child. All - * #ClutterBox subclasses must implement this function - * @unpack_child: virtual function, called when unpacking a child. All - * #ClutterBox subclasses must implement this function - * - * Base class for layout containers - * - * Since: 0.4 - */ -struct _ClutterBoxClass -{ - /*< private >*/ - ClutterActorClass parent_class; - - /*< public >*/ - /* vfuncs, not signals */ - void (* pack_child) (ClutterBox *box, - ClutterBoxChild *child); - void (* unpack_child) (ClutterBox *box, - ClutterBoxChild *child); - - /*< private >*/ - /* padding, for future expansion */ - void (*_clutter_reserved1) (void); - void (*_clutter_reserved2) (void); - void (*_clutter_reserved3) (void); - void (*_clutter_reserved4) (void); - void (*_clutter_reserved5) (void); - void (*_clutter_reserved6) (void); - void (*_clutter_reserved7) (void); - void (*_clutter_reserved8) (void); -}; - -/** - * ClutterBoxChild: - * @actor: the child #ClutterActor - * @child_coords: the original coordinates of the child - * @pack_type: the type of packing used by the child - * @padding: the padding around the child - * - * Packing data for children of a #ClutterBox. - * - * Since: 0.4 - */ -struct _ClutterBoxChild -{ - ClutterActor *actor; - ClutterActorBox child_coords; - ClutterPackType pack_type; - ClutterPadding padding; -}; - -GType clutter_box_get_type (void) G_GNUC_CONST; -void clutter_box_set_color (ClutterBox *box, - const ClutterColor *color); -void clutter_box_get_color (ClutterBox *box, - ClutterColor *color); -void clutter_box_set_margin (ClutterBox *box, - const ClutterMargin *margin); -void clutter_box_get_margin (ClutterBox *box, - ClutterMargin *margin); -void clutter_box_set_default_padding (ClutterBox *box, - gint padding_top, - gint padding_right, - gint padding_bottom, - gint padding_left); -void clutter_box_get_default_padding (ClutterBox *box, - gint *padding_top, - gint *padding_right, - gint *padding_bottom, - gint *padding_left); -void clutter_box_pack (ClutterBox *box, - ClutterActor *actor, - ClutterPackType pack_type, - const ClutterPadding *padding); -void clutter_box_pack_defaults (ClutterBox *box, - ClutterActor *actor); -void clutter_box_remove_all (ClutterBox *box); -gboolean clutter_box_query_child (ClutterBox *box, - ClutterActor *actor, - ClutterBoxChild *child); -gboolean clutter_box_query_nth_child (ClutterBox *box, - gint index_, - ClutterBoxChild *child); - -G_END_DECLS - -#endif /* __CLUTTER_BOX_H__ */ diff --git a/clutter/clutter-hbox.c b/clutter/clutter-hbox.c deleted file mode 100644 index 6e96cfe70..000000000 --- a/clutter/clutter-hbox.c +++ /dev/null @@ -1,231 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "clutter-hbox.h" - -#include "clutter-box.h" -#include "clutter-container.h" -#include "clutter-layout.h" -#include "clutter-debug.h" -#include "clutter-units.h" -#include "clutter-enum-types.h" -#include "clutter-main.h" -#include "clutter-private.h" - -/** - * SECTION:clutter-hbox - * @short_description: Simple horizontal box - * - * A #ClutterHBox is a #ClutterBox which lays all its children horizontally. - * - * See #ClutterBox for more details. - * - * #ClutterHBox is available since Clutter 0.4. - */ - -enum -{ - PROP_0, - - PROP_LAYOUT_FLAGS -}; - -static void clutter_layout_iface_init (ClutterLayoutIface *iface); - -G_DEFINE_TYPE_WITH_CODE (ClutterHBox, - clutter_hbox, - CLUTTER_TYPE_BOX, - G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_LAYOUT, - clutter_layout_iface_init)); - -static void -clutter_hbox_query_coords (ClutterActor *actor, - ClutterActorBox *coords) -{ - ClutterBox *box = CLUTTER_BOX (actor); - ClutterMargin box_margin; - GList *l; - gint width, height; - - if (box->allocation.x2 != -1 && box->allocation.y2 != -1) - { - 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) - { - ClutterBoxChild *child = l->data; - - if (CLUTTER_ACTOR_IS_VISIBLE (child->actor)) - { - guint child_width, child_height; - - clutter_actor_get_size (child->actor, &child_width, &child_height); - - width = width - + CLUTTER_UNITS_TO_INT (child->padding.left) - + child_width - + CLUTTER_UNITS_TO_INT (child->padding.right); - - height = MAX ((child_height - + CLUTTER_UNITS_TO_INT (child->padding.top) - + CLUTTER_UNITS_TO_INT (child->padding.bottom)), - height); - } - } - - width += CLUTTER_UNITS_TO_INT (box_margin.right); - 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 -clutter_hbox_request_coords (ClutterActor *actor, - ClutterActorBox *coords) -{ - 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; - - CLUTTER_ACTOR_CLASS (clutter_hbox_parent_class)->request_coords (actor, coords); -} - -static void -clutter_hbox_pack_child (ClutterBox *box, - ClutterBoxChild *child) -{ - ClutterGeometry box_geom, child_geom; - ClutterMargin box_margin; - - /* reset the saved allocation */ - box->allocation.x2 = box->allocation.y2 = -1; - - clutter_actor_get_geometry (CLUTTER_ACTOR (box), &box_geom); - clutter_actor_get_geometry (child->actor, &child_geom); - - clutter_box_get_margin (box, &box_margin); - - if (child->pack_type == CLUTTER_PACK_START) - { - child_geom.x = box_geom.width - + CLUTTER_UNITS_TO_INT (child->padding.right); - child_geom.y = CLUTTER_UNITS_TO_INT (child->padding.top); - } - else if (child->pack_type == CLUTTER_PACK_END) - { - child_geom.x = box_geom.width - child_geom.width - - CLUTTER_UNITS_TO_INT (child->padding.right); - child_geom.y = CLUTTER_UNITS_TO_INT (child->padding.top); - } - - 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); -} - -static void -clutter_hbox_unpack_child (ClutterBox *box, - ClutterBoxChild *child) -{ - /* no need to do anything */ -} - -static ClutterLayoutFlags -clutter_hbox_get_layout_flags (ClutterLayout *layout) -{ - return CLUTTER_LAYOUT_HEIGHT_FOR_WIDTH; -} - -static void -clutter_hbox_height_for_width (ClutterLayout *layout, - gint width, - gint *height) -{ - -} - -static void -clutter_hbox_get_property (GObject *gobject, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - switch (prop_id) - { - case PROP_LAYOUT_FLAGS: - g_value_set_enum (value, CLUTTER_LAYOUT_HEIGHT_FOR_WIDTH); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); - break; - } -} - -static void -clutter_layout_iface_init (ClutterLayoutIface *iface) -{ - iface->get_layout_flags = clutter_hbox_get_layout_flags; - iface->height_for_width = clutter_hbox_height_for_width; -} - -static void -clutter_hbox_class_init (ClutterHBoxClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); - ClutterBoxClass *box_class = CLUTTER_BOX_CLASS (klass); - - gobject_class->get_property = clutter_hbox_get_property; - - actor_class->query_coords = clutter_hbox_query_coords; - actor_class->request_coords = clutter_hbox_request_coords; - - box_class->pack_child = clutter_hbox_pack_child; - box_class->unpack_child = clutter_hbox_unpack_child; - - g_object_class_override_property (gobject_class, - PROP_LAYOUT_FLAGS, - "layout-flags"); -} - -static void -clutter_hbox_init (ClutterHBox *box) -{ - -} - -/** - * clutter_hbox_new: - * - * Creates a new horizontal layout box. - * - * Return value: the newly created #ClutterHBox - * - * Since: 0.4 - */ -ClutterActor * -clutter_hbox_new (void) -{ - return g_object_new (CLUTTER_TYPE_HBOX, NULL); -} diff --git a/clutter/clutter-hbox.h b/clutter/clutter-hbox.h deleted file mode 100644 index 2cc854b3d..000000000 --- a/clutter/clutter-hbox.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __CLUTTER_HBOX_H__ -#define __CLUTTER_HBOX_H__ - -#include - -G_BEGIN_DECLS - -#define CLUTTER_TYPE_HBOX (clutter_hbox_get_type ()) -#define CLUTTER_HBOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_HBOX, ClutterHBox)) -#define CLUTTER_IS_HBOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_HBOX)) -#define CLUTTER_HBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_HBOX, ClutterHBoxClass)) -#define CLUTTER_IS_HBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_HBOX)) -#define CLUTTER_HBOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_HBOX, ClutterHBoxClass)) - -typedef struct _ClutterHBox ClutterHBox; -typedef struct _ClutterHBoxClass ClutterHBoxClass; - -struct _ClutterHBox -{ - ClutterBox parent_instance; -}; - -struct _ClutterHBoxClass -{ - ClutterBoxClass parent_class; -}; - -GType clutter_hbox_get_type (void) G_GNUC_CONST; -ClutterActor *clutter_hbox_new (void); - -G_END_DECLS - -#endif /* __CLUTTER_HBOX_H__ */ diff --git a/clutter/clutter-label.c b/clutter/clutter-label.c index 90cdd8127..5550f2aa6 100644 --- a/clutter/clutter-label.c +++ b/clutter/clutter-label.c @@ -35,7 +35,6 @@ #endif #include "clutter-label.h" -#include "clutter-layout.h" #include "clutter-main.h" #include "clutter-enum-types.h" #include "clutter-private.h" @@ -46,13 +45,7 @@ #define DEFAULT_FONT_NAME "Sans 10" -static void clutter_layout_iface_init (ClutterLayoutIface *iface); - -G_DEFINE_TYPE_WITH_CODE (ClutterLabel, - clutter_label, - CLUTTER_TYPE_ACTOR, - G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_LAYOUT, - clutter_layout_iface_init)); +G_DEFINE_TYPE (ClutterLabel, clutter_label, CLUTTER_TYPE_ACTOR) /* Probably move into main */ static PangoClutterFontMap *_font_map = NULL; @@ -71,7 +64,6 @@ enum PROP_WRAP_MODE, PROP_JUSTIFY, PROP_ELLIPSIZE, - PROP_LAYOUT_FLAGS }; #define CLUTTER_LABEL_GET_PRIVATE(obj) \ @@ -406,102 +398,6 @@ clutter_label_finalize (GObject *object) G_OBJECT_CLASS (clutter_label_parent_class)->finalize (object); } -static ClutterLayoutFlags -clutter_label_get_layout_flags (ClutterLayout *layout) -{ - ClutterLayoutFlags flags; - ClutterFixed angle; - - flags = CLUTTER_LAYOUT_NATURAL; - - angle = clutter_actor_get_rotationx (CLUTTER_ACTOR (layout), - CLUTTER_Z_AXIS, - NULL, NULL, NULL); - - if (angle == 0 || angle == CLUTTER_INT_TO_FIXED (180)) - flags |= CLUTTER_LAYOUT_HEIGHT_FOR_WIDTH; - else if (angle == CLUTTER_INT_TO_FIXED (90) || angle == CLUTTER_INT_TO_FIXED (270)) - flags |= CLUTTER_LAYOUT_WIDTH_FOR_HEIGHT; - - return flags; -} - -static void -clutter_label_width_for_height (ClutterLayout *layout, - ClutterUnit *width, - ClutterUnit height) -{ - ClutterLabel *label = CLUTTER_LABEL (layout); - PangoLayout *tmp; - gint layout_height; - - clutter_label_ensure_layout (label); - - tmp = pango_layout_copy (label->priv->layout); - pango_layout_set_width (tmp, CLUTTER_UNITS_TO_PANGO_UNIT (height)); - pango_layout_get_pixel_size (tmp, NULL, &layout_height); - - if (width) - *width = CLUTTER_UNITS_FROM_INT (layout_height); - - g_object_unref (tmp); -} - -static void -clutter_label_height_for_width (ClutterLayout *layout, - ClutterUnit width, - ClutterUnit *height) -{ - ClutterLabel *label = CLUTTER_LABEL (layout); - PangoLayout *tmp; - gint layout_height; - - clutter_label_ensure_layout (label); - - tmp = pango_layout_copy (label->priv->layout); - pango_layout_set_width (tmp, CLUTTER_UNITS_TO_PANGO_UNIT (width)); - pango_layout_get_pixel_size (tmp, NULL, &layout_height); - - if (height) - *height = CLUTTER_UNITS_FROM_INT (layout_height); - - g_object_unref (tmp); -} - -static void -clutter_label_natural_request (ClutterLayout *layout, - ClutterUnit *width, - ClutterUnit *height) -{ - ClutterLabel *label = CLUTTER_LABEL (layout); - PangoLayout *tmp; - PangoRectangle logical_rect = { 0, }; - - clutter_label_ensure_layout (label); - - tmp = pango_layout_copy (label->priv->layout); - pango_layout_set_width (tmp, -1); - pango_layout_set_ellipsize (tmp, PANGO_ELLIPSIZE_NONE); - - pango_layout_get_extents (tmp, NULL, &logical_rect); - - if (width) - *width = CLUTTER_UNITS_FROM_PANGO_UNIT (logical_rect.width); - if (height) - *height = CLUTTER_UNITS_FROM_PANGO_UNIT (logical_rect.height); - - g_object_unref (tmp); -} - -static void -clutter_layout_iface_init (ClutterLayoutIface *iface) -{ - iface->get_layout_flags = clutter_label_get_layout_flags; - iface->height_for_width = clutter_label_height_for_width; - iface->width_for_height = clutter_label_width_for_height; - iface->natural_request = clutter_label_natural_request; -} - static void clutter_label_set_property (GObject *object, guint prop_id, @@ -598,10 +494,6 @@ clutter_label_get_property (GObject *object, case PROP_ELLIPSIZE: g_value_set_enum (value, priv->ellipsize); break; - case PROP_LAYOUT_FLAGS: - g_value_set_flags (value, - clutter_label_get_layout_flags (CLUTTER_LAYOUT (label))); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -709,10 +601,6 @@ clutter_label_class_init (ClutterLabelClass *klass) FALSE, CLUTTER_PARAM_READWRITE)); - g_object_class_override_property (gobject_class, - PROP_LAYOUT_FLAGS, - "layout-flags"); - g_type_class_add_private (gobject_class, sizeof (ClutterLabelPrivate)); } @@ -760,8 +648,6 @@ clutter_label_init (ClutterLabel *self) priv->font_name = g_strdup (DEFAULT_FONT_NAME); priv->font_desc = pango_font_description_from_string (priv->font_name); - - CLUTTER_MARK(); } /** diff --git a/clutter/clutter-layout.c b/clutter/clutter-layout.c deleted file mode 100644 index 91ddfb8d6..000000000 --- a/clutter/clutter-layout.c +++ /dev/null @@ -1,380 +0,0 @@ -/* - * Clutter. - * - * An OpenGL based 'interactive canvas' library. - * - * Authored By Matthew Allum - * - * Copyright (C) 2006 OpenedHand - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * ClutterLayout: interface to be implemented by actors providing - * extended layouts. - * - * Author: Emmanuele Bassi - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "clutter-layout.h" -#include "clutter-main.h" -#include "clutter-private.h" -#include "clutter-units.h" -#include "clutter-debug.h" -#include "clutter-enum-types.h" - -#define MAX_TUNE_REQUESTS 3 - -/** - * SECTION:clutter-layout - * @short_description: An interface for implementing layouts - * - * #ClutterLayout is an interface that #ClutterActors might - * implement to provide complex or extended layouts. The default - * size allocation of a #ClutterActor inside a #ClutterGroup is to - * make the group size allocation grow enough to contain the actor. - * A #ClutterActor implementing the #ClutterLayout interface will - * be queried for its size when it is added to a #ClutterGroup subclass - * that honours the #ClutterLayout interface; the resulting size - * allocation will depend on the #ClutterLayoutFlags that the actor - * supports. - * - * There are various types of layout available for actors implementing - * the #ClutterLayout interface: %CLUTTER_LAYOUT_WIDTH_FOR_HEIGHT will - * ask the actor for its width given the height allocated by the - * container; %CLUTTER_LAYOUT_HEIGHT_FOR_WIDTH will ask the actor for - * its height given the width allocated by the container. These two - * layout types are especially useful for labels and unidirectional - * container types, like vertical and horizontal boxes. - * - * Another layout available is %CLUTTER_LAYOUT_NATURAL, which will - * query the actor for its natural (default) width and height; the - * container actor will then try to allocate as much as it can, - * and might resort to scaling the actor to fit the allocation. This - * layout type is suited for #ClutterTextures and shapes. - * - * Finally, the %CLUTTER_LAYOUT_TUNABLE is an iterative layout. An actor - * will be queried multiple times until it's satisfied with the size - * given. - * - * A #ClutterContainer implementation that honours the #ClutterLayout - * interface should check whether an actor is implementing this interface - * when adding it, by using the %CLUTTER_IS_LAYOUT type check macro. If the - * actor does implement the interface, the #ClutterContainer should get - * the supported layouts using clutter_layout_get_layout_flags() and - * verify which layout is compatible with the group's own layout; for - * instance, vertical containers should check for actors implementing the - * %CLUTTER_LAYOUT_WIDTH_FOR_HEIGHT layout management, while horizontal - * containers should check for actors implementing the - * %CLUTTER_LAYOUT_HEIGHT_FOR_WIDTH layout management. If the actor - * satisfies the layout requirements, the container actor should query - * the actor for a geometry request using the appropriate function and - * allocate space for the newly added actor accordingly. - * - * #ClutterLayout is available since Clutter 0.4 - */ - -static void -clutter_layout_base_init (gpointer g_iface) -{ - static gboolean initialised = FALSE; - - if (G_UNLIKELY (!initialised)) - { - initialised = TRUE; - - /** - * ClutterLayout:layout-flags: - * - * The layout types that the #ClutterLayout supports. - * - * Since: 0.4 - */ - g_object_interface_install_property (g_iface, - g_param_spec_flags ("layout-flags", - "Layout Flags", - "Supported layouts", - CLUTTER_TYPE_LAYOUT_FLAGS, - CLUTTER_LAYOUT_NONE, - CLUTTER_PARAM_READABLE)); - } -} - -GType -clutter_layout_get_type (void) -{ - static GType layout_type = 0; - - if (!layout_type) - { - GTypeInfo layout_info = - { - sizeof (ClutterLayoutIface), - clutter_layout_base_init, - NULL, - }; - - layout_type = g_type_register_static (G_TYPE_INTERFACE, "ClutterLayout", - &layout_info, 0); - g_type_interface_add_prerequisite (layout_type, CLUTTER_TYPE_ACTOR); - } - - return layout_type; -} - -/* - * Public API - */ - -/** - * clutter_layout_get_layout_flags: - * @layout: a #ClutterLayout - * - * Retrieves the supported layout types from the #ClutterLayout - * - * Return value: bitwise or of #ClutterLayoutFlags - * - * Since: 0.4 - */ -ClutterLayoutFlags -clutter_layout_get_layout_flags (ClutterLayout *layout) -{ - g_return_val_if_fail (CLUTTER_IS_LAYOUT (layout), CLUTTER_LAYOUT_NONE); - - if (CLUTTER_LAYOUT_GET_IFACE (layout)->get_layout_flags) - return CLUTTER_LAYOUT_GET_IFACE (layout)->get_layout_flags (layout); - - return CLUTTER_LAYOUT_NONE; -} - -/** - * clutter_layout_width_for_height: - * @layout: a #ClutterLayout - * @width: return location for the width - * @height: height allocated by the parent - * - * Queries a #ClutterLayout actor for its width with a known height. - * - * Since: 0.4 - */ -void -clutter_layout_width_for_height (ClutterLayout *layout, - gint *width, - gint height) -{ - ClutterLayoutFlags layout_type; - - g_return_if_fail (CLUTTER_IS_LAYOUT (layout)); - - layout_type = clutter_layout_get_layout_flags (layout); - if (layout_type & CLUTTER_LAYOUT_WIDTH_FOR_HEIGHT) - { - ClutterUnit u_width, u_height; - - u_height = CLUTTER_UNITS_FROM_INT (height); - CLUTTER_LAYOUT_GET_IFACE (layout)->width_for_height (layout, - &u_width, - u_height); - - if (width) - *width = CLUTTER_UNITS_TO_INT (u_width); - } - else - { - g_warning ("Actor queried for width with a given height, but " - "actors of type `%s' do not support width-for-height " - "layouts.", - g_type_name (G_OBJECT_TYPE (layout))); - - if (width) - *width = -1; - } -} - -/** - * clutter_layout_height_for_width: - * @layout: a #ClutterLayout - * @width: width allocated by the parent - * @height: return location for the height - * - * Queries a #ClutterLayout actor for its height with a known width. - * - * Since: 0.4 - */ -void -clutter_layout_height_for_width (ClutterLayout *layout, - gint width, - gint *height) -{ - ClutterLayoutFlags layout_type; - - g_return_if_fail (CLUTTER_IS_LAYOUT (layout)); - - layout_type = clutter_layout_get_layout_flags (layout); - if (layout_type & CLUTTER_LAYOUT_HEIGHT_FOR_WIDTH) - { - ClutterUnit u_width, u_height; - - u_width = CLUTTER_UNITS_FROM_INT (width); - CLUTTER_LAYOUT_GET_IFACE (layout)->height_for_width (layout, - u_width, - &u_height); - - if (height) - *height = CLUTTER_UNITS_TO_INT (u_height); - } - else - { - g_warning ("Actor queried for height with a given width, but " - "actors of type `%s' do not support height-for-width " - "layouts.", - g_type_name (G_OBJECT_TYPE (layout))); - - if (height) - *height = -1; - } -} - -/** - * clutter_layout_natural_request: - * @layout: a #ClutterLayout - * @width: return location for the natural width - * @height: return location for the natural height - * - * Queries a #ClutterLayout actor for its natural (default) width - * and height. - * - * Since: 0.4 - */ -void -clutter_layout_natural_request (ClutterLayout *layout, - gint *width, - gint *height) -{ - ClutterLayoutFlags layout_type; - - g_return_if_fail (CLUTTER_IS_LAYOUT (layout)); - - layout_type = clutter_layout_get_layout_flags (layout); - if (layout_type & CLUTTER_LAYOUT_NATURAL) - { - ClutterUnit u_width, u_height; - - CLUTTER_LAYOUT_GET_IFACE (layout)->natural_request (layout, - &u_width, - &u_height); - - if (width) - *width = CLUTTER_UNITS_TO_INT (u_width); - - if (height) - *height = CLUTTER_UNITS_TO_INT (u_height); - } - else - { - g_warning ("Actor queried for natural size, but actors of type `%s' " - "do not support natural-size layouts.", - g_type_name (G_OBJECT_TYPE (layout))); - - if (width) - *width = -1; - if (height) - *height = -1; - } -} - -/** - * clutter_layout_tune_request: - * @layout: a #ClutterLayout - * @given_width: width allocated by the parent - * @given_height: height allocated by the parent - * @width: return location for the new width - * @height: return location for the new height - * - * Iteratively queries a #ClutterLayout actor until it finds - * its desired size, given a width and height tuple. - * - * Since: 0.4 - */ -void -clutter_layout_tune_request (ClutterLayout *layout, - gint given_width, - gint given_height, - gint *width, - gint *height) -{ - ClutterLayoutFlags layout_type; - gint tries; - ClutterUnit try_width, try_height; - ClutterUnit new_width, new_height; - - g_return_if_fail (CLUTTER_IS_LAYOUT (layout)); - - layout_type = clutter_layout_get_layout_flags (layout); - if ((layout_type & CLUTTER_LAYOUT_TUNABLE) == 0) - { - g_warning ("Actor queried for tunable size size but actors of " - "type `%s' do not support tunable layouts.", - g_type_name (G_OBJECT_TYPE (layout))); - - if (width) - *width = -1; - - if (height) - *height = -1; - - return; - } - - tries = 0; - try_width = CLUTTER_UNITS_FROM_INT (given_width); - try_height = CLUTTER_UNITS_FROM_INT (given_height); - new_width = new_height = 0; - - do - { - gboolean res; - - res = CLUTTER_LAYOUT_GET_IFACE (layout)->tune_request (layout, - try_width, - try_height, - &new_width, - &new_height); - - if (res) - break; - - if (new_width) - try_width = new_width; - - if (new_height) - try_height = new_height; - - new_width = new_height = 0; - - tries += 1; - } - while (tries <= MAX_TUNE_REQUESTS); - - if (width) - *width = CLUTTER_UNITS_TO_INT (new_width); - - if (height) - *height = CLUTTER_UNITS_TO_INT (new_height); -} diff --git a/clutter/clutter-layout.h b/clutter/clutter-layout.h deleted file mode 100644 index 194cfceba..000000000 --- a/clutter/clutter-layout.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Clutter. - * - * An OpenGL based 'interactive canvas' library. - * - * Authored By Matthew Allum - * - * Copyright (C) 2006 OpenedHand - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * ClutterLayout: interface to be implemented by actors providing - * extended layouts. - * - * Author: Emmanuele Bassi - */ - -#ifndef __CLUTTER_LAYOUT_H__ -#define __CLUTTER_LAYOUT_H__ - -#include - -G_BEGIN_DECLS - -#define CLUTTER_TYPE_LAYOUT (clutter_layout_get_type ()) -#define CLUTTER_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_LAYOUT, ClutterLayout)) -#define CLUTTER_IS_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_LAYOUT)) -#define CLUTTER_LAYOUT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CLUTTER_TYPE_LAYOUT, ClutterLayoutIface)) - -#define CLUTTER_LAYOUT_HAS(layout,f) \ - (CLUTTER_IS_LAYOUT ((layout)) && \ - (clutter_layout_get_layout_flags ((ClutterLayout *) (layout)) & (f))) - -#define CLUTTER_LAYOUT_HAS_WIDTH_FOR_HEIGHT(layout) \ - (CLUTTER_LAYOUT_HAS ((layout), CLUTTER_LAYOUT_WIDTH_FOR_HEIGHT)) -#define CLUTTER_LAYOUT_HAS_HEIGHT_FOR_WIDTH(layout) \ - (CLUTTER_LAYOUT_HAS ((layout), CLUTTER_LAYOUT_HEIGHT_FOR_WIDTH)) -#define CLUTTER_LAYOUT_HAS_NATURAL_SIZE(layout) \ - (CLUTTER_LAYOUT_HAS ((layout), CLUTTER_LAYOUT_NATURAL)) -#define CLUTTER_LAYOUT_HAS_TUNABLE_SIZE(layout) \ - (CLUTTER_LAYOUT_HAS ((layout), CLUTTER_LAYOUT_TUNABLE)) - -/** - * ClutterLayoutFlags - * @CLUTTER_LAYOUT_NONE: No layout (default behaviour) - * @CLUTTER_LAYOUT_WIDTH_FOR_HEIGHT: Width-for-height - * @CLUTTER_LAYOUT_HEIGHT_FOR_WIDTH: Height-for-width - * @CLUTTER_LAYOUT_NATURAL: Natural size request - * @CLUTTER_LAYOUT_TUNABLE: Tunable size request - * - * Type of layouts supported by an actor. - * - * Since: 0.4 - */ -typedef enum { - CLUTTER_LAYOUT_NONE = 0, - CLUTTER_LAYOUT_WIDTH_FOR_HEIGHT = 1 << 0, - CLUTTER_LAYOUT_HEIGHT_FOR_WIDTH = 1 << 1, - CLUTTER_LAYOUT_NATURAL = 1 << 2, - CLUTTER_LAYOUT_TUNABLE = 1 << 3 -} ClutterLayoutFlags; - -typedef struct _ClutterLayout ClutterLayout; /* dummy */ -typedef struct _ClutterLayoutIface ClutterLayoutIface; - -/** - * ClutterLayoutIface: - * @get_layout_flags: Retrieve the layout mode used by the actor - * @width_for_height: Compute width for a given height - * @height_for_width: Compute height for a given width - * @natural_request: Natural size of an actor - * @tune_request: Iterative size allocation - * - * Interface for extended layout support in actors. - * - * Since: 0.4 - */ -struct _ClutterLayoutIface -{ - /*< private >*/ - GTypeInterface g_iface; - - /*< public >*/ - /* Retrieve the layout mode used by the actor */ - ClutterLayoutFlags (* get_layout_flags) (ClutterLayout *layout); - - /* Width-for-Height and Height-for-Width: one size is known - * and the other is queried. useful for labels and unidirectional - * containers, like vertical and horizontal boxes. - */ - void (* width_for_height) (ClutterLayout *layout, - ClutterUnit *width, - ClutterUnit height); - void (* height_for_width) (ClutterLayout *layout, - ClutterUnit width, - ClutterUnit *height); - - /* Natural size request: the actor is queried for its natural - * size and the container can decide to either scale the actor - * or to resize itself to make it fit. useful for textures - * or shapes. - */ - void (* natural_request) (ClutterLayout *layout, - ClutterUnit *width, - ClutterUnit *height); - - /* Iterative allocation: the actor is iteratively queried - * for its size, until it finds it. - */ - gboolean (* tune_request) (ClutterLayout *layout, - ClutterUnit given_width, - ClutterUnit given_height, - ClutterUnit *width, - ClutterUnit *height); -}; - -GType clutter_layout_get_type (void) G_GNUC_CONST; - -ClutterLayoutFlags clutter_layout_get_layout_flags (ClutterLayout *layout); -void clutter_layout_width_for_height (ClutterLayout *layout, - gint *width, - gint height); -void clutter_layout_height_for_width (ClutterLayout *layout, - gint width, - gint *height); -void clutter_layout_natural_request (ClutterLayout *layout, - gint *width, - gint *height); -void clutter_layout_tune_request (ClutterLayout *layout, - gint given_width, - gint given_height, - gint *width, - gint *height); - -G_END_DECLS - -#endif /* __CLUTTER_LAYOUT_H__ */ diff --git a/clutter/clutter-script-parser.c b/clutter/clutter-script-parser.c index 09e846919..acf17eec8 100644 --- a/clutter/clutter-script-parser.c +++ b/clutter/clutter-script-parser.c @@ -264,129 +264,6 @@ clutter_script_parse_knot (ClutterScript *script, return FALSE; } -static ClutterUnit -get_units_from_node (JsonNode *node) -{ - ClutterUnit retval = 0; - GValue value = { 0, }; - - if (JSON_NODE_TYPE (node) != JSON_NODE_VALUE) - return 0; - - json_node_get_value (node, &value); - switch (G_VALUE_TYPE (&value)) - { - case G_TYPE_INT: - retval = CLUTTER_UNITS_FROM_INT (g_value_get_int (&value)); - break; - - default: - break; - } - - g_value_unset (&value); - - return retval; -} - -gboolean -clutter_script_parse_padding (ClutterScript *script, - JsonNode *node, - ClutterPadding *padding) -{ - JsonArray *array; - gint array_len, i; - - g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), FALSE); - g_return_val_if_fail (node != NULL, FALSE); - g_return_val_if_fail (padding != NULL, FALSE); - - if (JSON_NODE_TYPE (node) != JSON_NODE_ARRAY) - return FALSE; - - array = json_node_get_array (node); - array_len = json_array_get_length (array); - - for (i = 0; i < array_len; i++) - { - JsonNode *val = json_array_get_element (array, i); - ClutterUnit units = get_units_from_node (val); - - switch (i) - { - case 0: - padding->top = units; - padding->right = padding->top; - padding->bottom = padding->top; - padding->left = padding->top; - break; - - case 1: - padding->right = padding->left = units; - break; - - case 2: - padding->bottom = units; - break; - - case 3: - padding->left = units; - break; - } - } - - return TRUE; -} - -gboolean -clutter_script_parse_margin (ClutterScript *script, - JsonNode *node, - ClutterMargin *margin) -{ - JsonArray *array; - gint array_len, i; - - g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), FALSE); - g_return_val_if_fail (node != NULL, FALSE); - g_return_val_if_fail (margin != NULL, FALSE); - - if (JSON_NODE_TYPE (node) != JSON_NODE_ARRAY) - return FALSE; - - array = json_node_get_array (node); - array_len = json_array_get_length (array); - - for (i = 0; i < array_len; i++) - { - JsonNode *val = json_array_get_element (array, i); - ClutterUnit units = get_units_from_node (val); - - switch (i) - { - case 0: - margin->top = units; - margin->right = margin->top; - margin->bottom = margin->top; - margin->left = margin->top; - break; - - case 1: - margin->right = margin->left = units; - break; - - case 2: - margin->bottom = units; - break; - - case 3: - margin->left = units; - break; - } - } - - return TRUE; -} - static gboolean parse_geometry_from_array (JsonArray *array, ClutterGeometry *geometry) diff --git a/clutter/clutter-script-private.h b/clutter/clutter-script-private.h index 1203e069d..2d17d95ac 100644 --- a/clutter/clutter-script-private.h +++ b/clutter/clutter-script-private.h @@ -95,12 +95,6 @@ gboolean clutter_script_flags_from_string (GType gtype, gboolean clutter_script_parse_knot (ClutterScript *script, JsonNode *node, ClutterKnot *knot); -gboolean clutter_script_parse_padding (ClutterScript *script, - JsonNode *node, - ClutterPadding *padding); -gboolean clutter_script_parse_margin (ClutterScript *script, - JsonNode *node, - ClutterMargin *margin); gboolean clutter_script_parse_geometry (ClutterScript *script, JsonNode *node, ClutterGeometry *geometry); diff --git a/clutter/clutter-script.c b/clutter/clutter-script.c index 966a605d7..93e037432 100644 --- a/clutter/clutter-script.c +++ b/clutter/clutter-script.c @@ -761,26 +761,6 @@ clutter_script_parse_node (ClutterScript *script, return TRUE; } } - else if (G_VALUE_HOLDS (value, CLUTTER_TYPE_PADDING)) - { - ClutterPadding padding = { 0, }; - - if (clutter_script_parse_padding (script, node, &padding)) - { - g_value_set_boxed (value, &padding); - return TRUE; - } - } - else if (G_VALUE_HOLDS (value, CLUTTER_TYPE_MARGIN)) - { - ClutterMargin margin = { 0, }; - - if (clutter_script_parse_margin (script, node, &margin)) - { - g_value_set_boxed (value, &margin); - return TRUE; - } - } else if (G_VALUE_HOLDS (value, CLUTTER_TYPE_GEOMETRY)) { ClutterGeometry geom = { 0, }; diff --git a/clutter/clutter-types.h b/clutter/clutter-types.h index 8d189c645..9c3223b4c 100644 --- a/clutter/clutter-types.h +++ b/clutter/clutter-types.h @@ -35,8 +35,6 @@ G_BEGIN_DECLS #define CLUTTER_TYPE_GEOMETRY (clutter_geometry_get_type ()) #define CLUTTER_TYPE_KNOT (clutter_knot_get_type ()) -#define CLUTTER_TYPE_MARGIN (clutter_margin_get_type ()) -#define CLUTTER_TYPE_PADDING (clutter_padding_get_type ()) #define CLUTTER_TYPE_VERTEX (clutter_vertex_get_type ()) /* Forward delarations to avoid header catch 22's */ @@ -76,8 +74,6 @@ typedef enum { /*< prefix=CLUTTER_GRAVITY >*/ typedef struct _ClutterGeometry ClutterGeometry; typedef struct _ClutterKnot ClutterKnot; -typedef struct _ClutterMargin ClutterMargin; -typedef struct _ClutterPadding ClutterPadding; typedef struct _ClutterVertex ClutterVertex; /** @@ -171,48 +167,6 @@ typedef enum { /*< prefix=CLUTTER_ROTATE >*/ CLUTTER_ROTATE_CCW } ClutterRotateDirection; -/** - * ClutterMargin: - * @top: top margin - * @right: right margin - * @bottom: bottom margin - * @left: left margin - * - * Margins from the inner borders of a container - * - * Since: 0.4 - */ -struct _ClutterMargin -{ - ClutterUnit top; - ClutterUnit right; - ClutterUnit bottom; - ClutterUnit left; -}; - -GType clutter_margin_get_type (void) G_GNUC_CONST; - -/** - * ClutterPadding - * @top: top padding - * @right: right padding - * @bottom: bottom padding - * @left: left padding - * - * Padding of the children of a container - * - * Since: 0.4 - */ -struct _ClutterPadding -{ - ClutterUnit top; - ClutterUnit right; - ClutterUnit bottom; - ClutterUnit left; -}; - -GType clutter_padding_get_type (void) G_GNUC_CONST; - G_END_DECLS #endif /* __CLUTTER_TYPES_H__ */ diff --git a/clutter/clutter-vbox.c b/clutter/clutter-vbox.c deleted file mode 100644 index 5041ced2c..000000000 --- a/clutter/clutter-vbox.c +++ /dev/null @@ -1,231 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "clutter-vbox.h" - -#include "clutter-box.h" -#include "clutter-container.h" -#include "clutter-layout.h" -#include "clutter-debug.h" -#include "clutter-units.h" -#include "clutter-enum-types.h" -#include "clutter-main.h" -#include "clutter-private.h" - -/** - * SECTION:clutter-vbox - * @short_description: Simple vertical box - * - * A #ClutterVBox is a #ClutterBox that lays out its children vertically. - * - * See #ClutterBox for more details. - * - * #ClutterVBox is available since Clutter 0.4. - */ - -enum -{ - PROP_0, - - PROP_LAYOUT_FLAGS -}; - -static void clutter_layout_iface_init (ClutterLayoutIface *iface); - -G_DEFINE_TYPE_WITH_CODE (ClutterVBox, - clutter_vbox, - CLUTTER_TYPE_BOX, - G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_LAYOUT, - clutter_layout_iface_init)); - -static void -clutter_vbox_query_coords (ClutterActor *actor, - ClutterActorBox *coords) -{ - ClutterBox *box = CLUTTER_BOX (actor); - ClutterMargin box_margin; - GList *l; - gint width, height; - - if (box->allocation.x2 != -1 && box->allocation.y2 != -1) - { - 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) - { - ClutterBoxChild *child = l->data; - - if (CLUTTER_ACTOR_IS_VISIBLE (child->actor)) - { - guint child_width, child_height; - - clutter_actor_get_size (child->actor, &child_width, &child_height); - - height = height - + 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); - } - } - - width += CLUTTER_UNITS_TO_INT (box_margin.right); - 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 -clutter_vbox_request_coords (ClutterActor *actor, - ClutterActorBox *coords) -{ - 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; - - CLUTTER_ACTOR_CLASS (clutter_vbox_parent_class)->request_coords (actor, coords); -} - -static void -clutter_vbox_pack_child (ClutterBox *box, - ClutterBoxChild *child) -{ - ClutterGeometry box_geom, child_geom; - ClutterMargin box_margin; - - /* reset the saved allocation */ - box->allocation.x2 = box->allocation.y2 = -1; - - clutter_actor_get_geometry (CLUTTER_ACTOR (box), &box_geom); - clutter_actor_get_geometry (child->actor, &child_geom); - - clutter_box_get_margin (box, &box_margin); - - 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); -} - -static void -clutter_vbox_unpack_child (ClutterBox *box, - ClutterBoxChild *child) -{ - /* no need to do anything */ -} - -static ClutterLayoutFlags -clutter_vbox_get_layout_flags (ClutterLayout *layout) -{ - return CLUTTER_LAYOUT_WIDTH_FOR_HEIGHT; -} - -static void -clutter_vbox_width_for_height (ClutterLayout *layout, - gint *width, - gint height) -{ - -} - -static void -clutter_vbox_get_property (GObject *gobject, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - switch (prop_id) - { - case PROP_LAYOUT_FLAGS: - g_value_set_enum (value, CLUTTER_LAYOUT_WIDTH_FOR_HEIGHT); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); - break; - } -} - -static void -clutter_layout_iface_init (ClutterLayoutIface *iface) -{ - iface->get_layout_flags = clutter_vbox_get_layout_flags; - iface->width_for_height = clutter_vbox_width_for_height; -} - -static void -clutter_vbox_class_init (ClutterVBoxClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); - ClutterBoxClass *box_class = CLUTTER_BOX_CLASS (klass); - - gobject_class->get_property = clutter_vbox_get_property; - - actor_class->query_coords = clutter_vbox_query_coords; - actor_class->request_coords = clutter_vbox_request_coords; - - box_class->pack_child = clutter_vbox_pack_child; - box_class->unpack_child = clutter_vbox_unpack_child; - - g_object_class_override_property (gobject_class, - PROP_LAYOUT_FLAGS, - "layout-flags"); -} - -static void -clutter_vbox_init (ClutterVBox *box) -{ - -} - -/** - * clutter_vbox_new: - * - * Creates a new vertical layout box. - * - * Return value: the newly created #ClutterVBox - * - * Since: 0.4 - */ -ClutterActor * -clutter_vbox_new (void) -{ - return g_object_new (CLUTTER_TYPE_VBOX, NULL); -} diff --git a/clutter/clutter-vbox.h b/clutter/clutter-vbox.h deleted file mode 100644 index d8d194453..000000000 --- a/clutter/clutter-vbox.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __CLUTTER_VBOX_H__ -#define __CLUTTER_VBOX_H__ - -#include - -G_BEGIN_DECLS - -#define CLUTTER_TYPE_VBOX (clutter_vbox_get_type ()) -#define CLUTTER_VBOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_VBOX, ClutterVBox)) -#define CLUTTER_IS_VBOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_VBOX)) -#define CLUTTER_VBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_VBOX, ClutterVBoxClass)) -#define CLUTTER_IS_VBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_VBOX)) -#define CLUTTER_VBOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_VBOX, ClutterVBoxClass)) - -typedef struct _ClutterVBox ClutterVBox; -typedef struct _ClutterVBoxClass ClutterVBoxClass; - -struct _ClutterVBox -{ - ClutterBox parent_instance; -}; - -struct _ClutterVBoxClass -{ - ClutterBoxClass parent_class; -}; - -GType clutter_vbox_get_type (void) G_GNUC_CONST; -ClutterActor *clutter_vbox_new (void); - -G_END_DECLS - -#endif /* __CLUTTER_VBOX_H__ */ diff --git a/clutter/clutter.h b/clutter/clutter.h index 01a239884..06c8a063e 100644 --- a/clutter/clutter.h +++ b/clutter/clutter.h @@ -39,7 +39,6 @@ #include "clutter-behaviour-path.h" #include "clutter-behaviour-rotate.h" #include "clutter-behaviour-scale.h" -#include "clutter-box.h" #include "clutter-clone-texture.h" #include "clutter-deprecated.h" #include "clutter-effect.h" @@ -48,10 +47,8 @@ #include "clutter-feature.h" #include "clutter-rectangle.h" #include "clutter-group.h" -#include "clutter-hbox.h" #include "clutter-keysyms.h" #include "clutter-label.h" -#include "clutter-layout.h" #include "clutter-main.h" #include "clutter-media.h" #include "clutter-model.h" @@ -65,7 +62,6 @@ #include "clutter-types.h" #include "clutter-units.h" #include "clutter-util.h" -#include "clutter-vbox.h" #include "clutter-version.h" #include "clutter-enum-types.h" diff --git a/doc/reference/ChangeLog b/doc/reference/ChangeLog index 53678741e..455a49bac 100644 --- a/doc/reference/ChangeLog +++ b/doc/reference/ChangeLog @@ -1,3 +1,9 @@ +2007-11-28 Emmanuele Bassi,,, + + reviewed by: + + * clutter.types: + 2007-11-28 Emmanuele Bassi * clutter-sections.txt: Add the new ClutterEffectTemplate::construct diff --git a/doc/reference/clutter-docs.sgml b/doc/reference/clutter-docs.sgml index 3a76a1f70..d5b3d41de 100644 --- a/doc/reference/clutter-docs.sgml +++ b/doc/reference/clutter-docs.sgml @@ -78,8 +78,6 @@ Abstract classes and interfaces - - @@ -97,8 +95,6 @@ Container actors - - diff --git a/doc/reference/clutter.types b/doc/reference/clutter.types index c9412ca48..c1fda8153 100644 --- a/doc/reference/clutter.types +++ b/doc/reference/clutter.types @@ -7,7 +7,6 @@ clutter_rectangle_get_type clutter_texture_get_type clutter_clone_texture_get_type clutter_label_get_type -clutter_layout_get_type clutter_timeline_get_type clutter_media_get_type clutter_behaviour_get_type @@ -21,9 +20,6 @@ clutter_behaviour_rotate_get_type clutter_behaviour_scale_get_type clutter_backend_get_type clutter_entry_get_type -clutter_box_get_type -clutter_hbox_get_type -clutter_vbox_get_type clutter_script_get_type clutter_scriptable_get_type clutter_model_get_type diff --git a/tests/Makefile.am b/tests/Makefile.am index ae9a05741..328326384 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ noinst_PROGRAMS = test-textures test-events test-offscreen test-scale \ test-actors test-behave test-text test-entry test-project \ - test-boxes test-perspective test-rotate test-depth \ + test-perspective test-rotate test-depth \ test-threads test-timeline test-score test-script \ test-model test-grab test-effects test-fullscreen @@ -19,7 +19,6 @@ test_behave_SOURCES = test-behave.c test_text_SOURCES = test-text.c test_entry_SOURCES = test-entry.c test_project_SOURCES = test-project.c -test_boxes_SOURCES = test-boxes.c test_perspective_SOURCES = test-perspective.c test_rotate_SOURCES = test-rotate.c test_depth_SOURCES = test-depth.c diff --git a/tests/test-boxes.c b/tests/test-boxes.c deleted file mode 100644 index 73db6f70b..000000000 --- a/tests/test-boxes.c +++ /dev/null @@ -1,119 +0,0 @@ -#include -#include - -static void -on_button_press_cb (ClutterStage *stage, - ClutterEvent *event, - gpointer data) -{ - ClutterActor *rect; - gint x, y; - - clutter_event_get_coords (event, &x, &y); - rect = clutter_stage_get_actor_at_pos (stage, x, y); - if (!rect) - return; - - if (!CLUTTER_IS_RECTANGLE (rect)) - { - g_print ("[!] No rectangle selected (%s selected instead)\n", - g_type_name (G_OBJECT_TYPE (rect))); - return; - } - - g_print ("[*] Picked rectangle at (%d, %d)\n", x, y); -} - -static void -on_key_press_cb (ClutterStage *stage, - ClutterEvent *event, - gpointer data) -{ - ClutterKeyEvent *key_event = (ClutterKeyEvent *) event; - - if (clutter_key_event_symbol (key_event) == CLUTTER_Escape) - clutter_main_quit (); -} - -int -main (int argc, char *argv[]) -{ - ClutterActor *stage; - ClutterActor *vbox; - ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff }; - ClutterColor label_color = { 0xff, 0xff, 0xff, 0x99 }; - gint i, j; - - clutter_init (&argc, &argv); - - stage = clutter_stage_get_default (); - clutter_actor_set_size (stage, 800, 600); - clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); - g_signal_connect (stage, "button-press-event", - G_CALLBACK (on_button_press_cb), - NULL); - g_signal_connect (stage, "key-press-event", - G_CALLBACK (on_key_press_cb), - NULL); - - vbox = clutter_vbox_new (); - clutter_box_set_default_padding (CLUTTER_BOX (vbox), 10, 0, 10, 0); - clutter_actor_set_position (vbox, 100, 100); - clutter_container_add_actor (CLUTTER_CONTAINER (stage), vbox); - clutter_actor_show (vbox); - - for (i = 0; i < 3; i++) - { - ClutterActor *hbox; - - hbox = clutter_hbox_new (); - - for (j = 0; j < 3; j++) - { - ClutterActor *rect; - ClutterPadding rect_padding; - - rect = clutter_rectangle_new_with_color (&label_color); - clutter_actor_set_size (rect, 100, 100); - - rect_padding.top = rect_padding.bottom = 0; - rect_padding.left = CLUTTER_UNITS_FROM_INT (10); - rect_padding.right = CLUTTER_UNITS_FROM_INT (10); - - clutter_box_pack (CLUTTER_BOX (hbox), rect, - CLUTTER_PACK_START, - &rect_padding); - clutter_actor_show (rect); - - g_print ("rect[%d][%d] - (x:%3d, y:%3d, w:%3d, h:%3d)\n", - i, j, - clutter_actor_get_x (rect), - clutter_actor_get_y (rect), - clutter_actor_get_width (rect), - clutter_actor_get_height (rect)); - } - - clutter_box_pack_defaults (CLUTTER_BOX (vbox), hbox); - clutter_actor_show (hbox); - - g_print ("hbox[%d] - (x:%3d, y:%3d, w:%3d, h:%3d)\n", - i, - clutter_actor_get_x (hbox), - clutter_actor_get_y (hbox), - clutter_actor_get_width (hbox), - clutter_actor_get_height (hbox)); - - } - - clutter_actor_show_all (stage); - - g_print ("vbox - (x:%3d, y:%3d, w:%3d, h:%3d)\n", - clutter_actor_get_x (vbox), - clutter_actor_get_y (vbox), - clutter_actor_get_width (vbox), - clutter_actor_get_height (vbox)); - - clutter_main (); - - return EXIT_SUCCESS; -}