diff --git a/clutter/clutter-bin-layout.c b/clutter/clutter-bin-layout.c index d7ad9bdd4..f295ce26c 100644 --- a/clutter/clutter-bin-layout.c +++ b/clutter/clutter-bin-layout.c @@ -67,245 +67,25 @@ #include -#define CLUTTER_DISABLE_DEPRECATION_WARNINGS -#include "deprecated/clutter-container.h" -#include "deprecated/clutter-bin-layout.h" - #include "clutter-actor-private.h" #include "clutter-animatable.h" +#include "clutter-bin-layout.h" #include "clutter-child-meta.h" #include "clutter-debug.h" #include "clutter-enum-types.h" #include "clutter-layout-meta.h" #include "clutter-private.h" -#define CLUTTER_TYPE_BIN_LAYER (clutter_bin_layer_get_type ()) -#define CLUTTER_BIN_LAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BIN_LAYER, ClutterBinLayer)) -#define CLUTTER_IS_BIN_LAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BIN_LAYER)) - #define CLUTTER_BIN_LAYOUT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_BIN_LAYOUT, ClutterBinLayoutPrivate)) -typedef struct _ClutterBinLayer ClutterBinLayer; typedef struct _ClutterLayoutMetaClass ClutterBinLayerClass; struct _ClutterBinLayoutPrivate { - ClutterBinAlignment x_align; - ClutterBinAlignment y_align; - ClutterContainer *container; }; -struct _ClutterBinLayer -{ - ClutterLayoutMeta parent_instance; - - ClutterBinAlignment x_align; - ClutterBinAlignment y_align; -}; - -enum -{ - PROP_LAYER_0, - - PROP_LAYER_X_ALIGN, - PROP_LAYER_Y_ALIGN, - - PROP_LAYER_LAST -}; - -enum -{ - PROP_0, - - PROP_X_ALIGN, - PROP_Y_ALIGN, - - PROP_LAST -}; - -static GParamSpec *layer_props[PROP_LAYER_LAST] = { NULL, }; -static GParamSpec *bin_props[PROP_LAST] = { NULL, }; - -GType clutter_bin_layer_get_type (void); - -G_DEFINE_TYPE (ClutterBinLayer, - clutter_bin_layer, - CLUTTER_TYPE_LAYOUT_META); - -G_DEFINE_TYPE (ClutterBinLayout, - clutter_bin_layout, - CLUTTER_TYPE_LAYOUT_MANAGER); - -/* - * ClutterBinLayer - */ - -static void -set_layer_x_align (ClutterBinLayer *self, - ClutterBinAlignment alignment) -{ - ClutterLayoutManager *manager; - ClutterLayoutMeta *meta; - - if (self->x_align == alignment) - return; - - self->x_align = alignment; - - meta = CLUTTER_LAYOUT_META (self); - manager = clutter_layout_meta_get_manager (meta); - clutter_layout_manager_layout_changed (manager); - - g_object_notify_by_pspec (G_OBJECT (self), layer_props[PROP_LAYER_X_ALIGN]); -} - -static void -set_layer_y_align (ClutterBinLayer *self, - ClutterBinAlignment alignment) -{ - ClutterLayoutManager *manager; - ClutterLayoutMeta *meta; - - if (self->y_align == alignment) - return; - - self->y_align = alignment; - - meta = CLUTTER_LAYOUT_META (self); - manager = clutter_layout_meta_get_manager (meta); - clutter_layout_manager_layout_changed (manager); - - g_object_notify_by_pspec (G_OBJECT (self), layer_props[PROP_LAYER_Y_ALIGN]); -} - -static void -clutter_bin_layer_set_property (GObject *gobject, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - ClutterBinLayer *layer = CLUTTER_BIN_LAYER (gobject); - - switch (prop_id) - { - case PROP_LAYER_X_ALIGN: - set_layer_x_align (layer, g_value_get_enum (value)); - break; - - case PROP_LAYER_Y_ALIGN: - set_layer_y_align (layer, g_value_get_enum (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); - break; - } -} - -static void -clutter_bin_layer_get_property (GObject *gobject, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - ClutterBinLayer *layer = CLUTTER_BIN_LAYER (gobject); - - switch (prop_id) - { - case PROP_LAYER_X_ALIGN: - g_value_set_enum (value, layer->x_align); - break; - - case PROP_LAYER_Y_ALIGN: - g_value_set_enum (value, layer->y_align); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); - break; - } -} - -static void -clutter_bin_layer_class_init (ClutterBinLayerClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - gobject_class->set_property = clutter_bin_layer_set_property; - gobject_class->get_property = clutter_bin_layer_get_property; - - layer_props[PROP_LAYER_X_ALIGN] = - g_param_spec_enum ("x-align", - P_("Horizontal Alignment"), - P_("Horizontal alignment for the actor " - "inside the layout manager"), - CLUTTER_TYPE_BIN_ALIGNMENT, - CLUTTER_BIN_ALIGNMENT_CENTER, - CLUTTER_PARAM_READWRITE); - - layer_props[PROP_LAYER_Y_ALIGN] = - g_param_spec_enum ("y-align", - P_("Vertical Alignment"), - P_("Vertical alignment for the actor " - "inside the layout manager"), - CLUTTER_TYPE_BIN_ALIGNMENT, - CLUTTER_BIN_ALIGNMENT_CENTER, - CLUTTER_PARAM_READWRITE); - - g_object_class_install_properties (gobject_class, - PROP_LAYER_LAST, - layer_props); -} - -static void -clutter_bin_layer_init (ClutterBinLayer *layer) -{ - layer->x_align = CLUTTER_BIN_ALIGNMENT_CENTER; - layer->y_align = CLUTTER_BIN_ALIGNMENT_CENTER; -} - -/* - * ClutterBinLayout - */ - -static void -set_x_align (ClutterBinLayout *self, - ClutterBinAlignment alignment) -{ - ClutterBinLayoutPrivate *priv = self->priv; - - if (priv->x_align != alignment) - { - ClutterLayoutManager *manager; - - priv->x_align = alignment; - - manager = CLUTTER_LAYOUT_MANAGER (self); - clutter_layout_manager_layout_changed (manager); - - g_object_notify_by_pspec (G_OBJECT (self), bin_props[PROP_X_ALIGN]); - } -} - -static void -set_y_align (ClutterBinLayout *self, - ClutterBinAlignment alignment) -{ - ClutterBinLayoutPrivate *priv = self->priv; - - if (priv->y_align != alignment) - { - ClutterLayoutManager *manager; - - priv->y_align = alignment; - - manager = CLUTTER_LAYOUT_MANAGER (self); - clutter_layout_manager_layout_changed (manager); - - g_object_notify_by_pspec (G_OBJECT (self), bin_props[PROP_Y_ALIGN]); - } -} +G_DEFINE_TYPE (ClutterBinLayout, clutter_bin_layout, CLUTTER_TYPE_LAYOUT_MANAGER) static void clutter_bin_layout_get_preferred_width (ClutterLayoutManager *manager, @@ -381,50 +161,6 @@ clutter_bin_layout_get_preferred_height (ClutterLayoutManager *manager, *nat_height_p = nat_height; } -static gdouble -get_bin_alignment_factor (ClutterBinAlignment alignment, - ClutterTextDirection text_dir) -{ - switch (alignment) - { - case CLUTTER_BIN_ALIGNMENT_CENTER: - return 0.5; - - case CLUTTER_BIN_ALIGNMENT_START: - return text_dir == CLUTTER_TEXT_DIRECTION_LTR ? 0.0 : 1.0; - - case CLUTTER_BIN_ALIGNMENT_END: - return text_dir == CLUTTER_TEXT_DIRECTION_LTR ? 1.0 : 0.0; - - case CLUTTER_BIN_ALIGNMENT_FIXED: - case CLUTTER_BIN_ALIGNMENT_FILL: - return 0.0; - } - - return 0.0; -} - -static gdouble -get_actor_align_factor (ClutterActorAlign alignment) -{ - switch (alignment) - { - case CLUTTER_ACTOR_ALIGN_CENTER: - return 0.5; - - case CLUTTER_ACTOR_ALIGN_START: - return 0.0; - - case CLUTTER_ACTOR_ALIGN_END: - return 1.0; - - case CLUTTER_ACTOR_ALIGN_FILL: - return 0.0; - } - - return 0.0; -} - static void clutter_bin_layout_allocate (ClutterLayoutManager *manager, ClutterContainer *container, @@ -444,21 +180,13 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager, clutter_actor_iter_init (&iter, actor); while (clutter_actor_iter_next (&iter, &child)) { - ClutterLayoutMeta *meta; - ClutterBinLayer *layer; ClutterActorBox child_alloc = { 0, }; - gdouble x_align, y_align; - gboolean x_fill, y_fill, is_fixed_position_set; + gboolean is_fixed_position_set; float fixed_x, fixed_y; if (!CLUTTER_ACTOR_IS_VISIBLE (child)) continue; - meta = clutter_layout_manager_get_child_meta (manager, - container, - child); - layer = CLUTTER_BIN_LAYER (meta); - fixed_x = fixed_y = 0.f; g_object_get (child, "fixed-position-set", &is_fixed_position_set, @@ -466,106 +194,24 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager, "fixed-y", &fixed_y, NULL); - /* XXX:2.0 - remove the FIXED alignment, and just use the fixed position - * of the actor if one is set - */ - if (is_fixed_position_set || - layer->x_align == CLUTTER_BIN_ALIGNMENT_FIXED) + if (is_fixed_position_set) { - if (is_fixed_position_set) - child_alloc.x1 = fixed_x; - else - child_alloc.x1 = clutter_actor_get_x (child); + child_alloc.x1 = fixed_x; + child_alloc.y1 = fixed_y; } else - child_alloc.x1 = allocation_x; - - if (is_fixed_position_set || - layer->y_align == CLUTTER_BIN_ALIGNMENT_FIXED) - { - if (is_fixed_position_set) - child_alloc.y1 = fixed_y; - else - child_alloc.y1 = clutter_actor_get_y (child); - } - else - child_alloc.y1 = allocation_y; + { + child_alloc.x1 = allocation_x; + child_alloc.y1 = allocation_y; + } child_alloc.x2 = available_w; child_alloc.y2 = available_h; - if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_HORIZONTAL)) - { - ClutterActorAlign align; - - align = clutter_actor_get_x_align (child); - x_fill = align == CLUTTER_ACTOR_ALIGN_FILL; - x_align = get_actor_align_factor (align); - } - else - { - ClutterTextDirection text_dir; - - x_fill = (layer->x_align == CLUTTER_BIN_ALIGNMENT_FILL); - - text_dir = clutter_actor_get_text_direction (child); - - if (!is_fixed_position_set) - x_align = get_bin_alignment_factor (layer->x_align, text_dir); - else - x_align = 0.0; - } - - if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_VERTICAL)) - { - ClutterActorAlign align; - - align = clutter_actor_get_y_align (child); - y_fill = align == CLUTTER_ACTOR_ALIGN_FILL; - y_align = get_actor_align_factor (align); - } - else - { - y_fill = (layer->y_align == CLUTTER_BIN_ALIGNMENT_FILL); - - if (!is_fixed_position_set) - y_align = get_bin_alignment_factor (layer->y_align, - CLUTTER_TEXT_DIRECTION_LTR); - else - y_align = 0.0; - } - - clutter_actor_allocate_align_fill (child, &child_alloc, - x_align, y_align, - x_fill, y_fill, - flags); + clutter_actor_allocate (child, &child_alloc, flags); } } -static GType -clutter_bin_layout_get_child_meta_type (ClutterLayoutManager *manager) -{ - return CLUTTER_TYPE_BIN_LAYER; -} - -static ClutterLayoutMeta * -clutter_bin_layout_create_child_meta (ClutterLayoutManager *manager, - ClutterContainer *container, - ClutterActor *actor) -{ - ClutterBinLayoutPrivate *priv; - - priv = CLUTTER_BIN_LAYOUT (manager)->priv; - - return g_object_new (CLUTTER_TYPE_BIN_LAYER, - "container", container, - "actor", actor, - "manager", manager, - "x-align", priv->x_align, - "y_align", priv->y_align, - NULL); -} - static void clutter_bin_layout_set_container (ClutterLayoutManager *manager, ClutterContainer *container) @@ -580,114 +226,17 @@ clutter_bin_layout_set_container (ClutterLayoutManager *manager, parent_class->set_container (manager, container); } -static void -clutter_bin_layout_set_property (GObject *gobject, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - ClutterBinLayout *layout = CLUTTER_BIN_LAYOUT (gobject); - - switch (prop_id) - { - case PROP_X_ALIGN: - set_x_align (layout, g_value_get_enum (value)); - break; - - case PROP_Y_ALIGN: - set_y_align (layout, g_value_get_enum (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); - break; - } -} - -static void -clutter_bin_layout_get_property (GObject *gobject, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - ClutterBinLayoutPrivate *priv; - - priv = CLUTTER_BIN_LAYOUT (gobject)->priv; - - switch (prop_id) - { - case PROP_X_ALIGN: - g_value_set_enum (value, priv->x_align); - break; - - case PROP_Y_ALIGN: - g_value_set_enum (value, priv->y_align); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); - break; - } -} - static void clutter_bin_layout_class_init (ClutterBinLayoutClass *klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); ClutterLayoutManagerClass *layout_class = CLUTTER_LAYOUT_MANAGER_CLASS (klass); g_type_class_add_private (klass, sizeof (ClutterBinLayoutPrivate)); - /** - * ClutterBinLayout:x-align: - * - * The default horizontal alignment policy for actors managed - * by the #ClutterBinLayout - * - * Since: 1.2 - * - * Deprecated: 1.12: Use the #ClutterActor:x-expand and the - * #ClutterActor:x-align properties on #ClutterActor instead. - */ - bin_props[PROP_X_ALIGN] = - g_param_spec_enum ("x-align", - P_("Horizontal Alignment"), - P_("Default horizontal alignment for the actors " - "inside the layout manager"), - CLUTTER_TYPE_BIN_ALIGNMENT, - CLUTTER_BIN_ALIGNMENT_CENTER, - CLUTTER_PARAM_READWRITE); - - /** - * ClutterBinLayout:y-align: - * - * The default vertical alignment policy for actors managed - * by the #ClutterBinLayout - * - * Since: 1.2 - * - * Deprecated: 1.12: Use the #ClutterActor:y-expand and the - * #ClutterActor:y-align properties on #ClutterActor instead. - */ - bin_props[PROP_Y_ALIGN] = - g_param_spec_enum ("y-align", - P_("Vertical Alignment"), - P_("Default vertical alignment for the actors " - "inside the layout manager"), - CLUTTER_TYPE_BIN_ALIGNMENT, - CLUTTER_BIN_ALIGNMENT_CENTER, - CLUTTER_PARAM_READWRITE); - - gobject_class->set_property = clutter_bin_layout_set_property; - gobject_class->get_property = clutter_bin_layout_get_property; - g_object_class_install_properties (gobject_class, PROP_LAST, bin_props); - layout_class->get_preferred_width = clutter_bin_layout_get_preferred_width; layout_class->get_preferred_height = clutter_bin_layout_get_preferred_height; layout_class->allocate = clutter_bin_layout_allocate; - layout_class->create_child_meta = clutter_bin_layout_create_child_meta; - layout_class->get_child_meta_type = clutter_bin_layout_get_child_meta_type; layout_class->set_container = clutter_bin_layout_set_container; } @@ -695,9 +244,6 @@ static void clutter_bin_layout_init (ClutterBinLayout *self) { self->priv = CLUTTER_BIN_LAYOUT_GET_PRIVATE (self); - - self->priv->x_align = CLUTTER_BIN_ALIGNMENT_CENTER; - self->priv->y_align = CLUTTER_BIN_ALIGNMENT_CENTER; } /** @@ -714,194 +260,7 @@ clutter_bin_layout_init (ClutterBinLayout *self) * Since: 1.2 */ ClutterLayoutManager * -clutter_bin_layout_new (ClutterBinAlignment x_align, - ClutterBinAlignment y_align) +clutter_bin_layout_new (void) { - return g_object_new (CLUTTER_TYPE_BIN_LAYOUT, - "x-align", x_align, - "y-align", y_align, - NULL); -} - -/** - * clutter_bin_layout_set_alignment: - * @self: a #ClutterBinLayout - * @child: (allow-none): a child of @container - * @x_align: the horizontal alignment policy to be used for the @child - * inside @container - * @y_align: the vertical aligment policy to be used on the @child - * inside @container - * - * Sets the horizontal and vertical alignment policies to be applied - * to a @child of @self - * - * If @child is %NULL then the @x_align and @y_align values will - * be set as the default alignment policies - * - * Since: 1.2 - * - * Deprecated: 1.12: Use the #ClutterActor:x-align and - * #ClutterActor:y-align properties of #ClutterActor instead. - */ -void -clutter_bin_layout_set_alignment (ClutterBinLayout *self, - ClutterActor *child, - ClutterBinAlignment x_align, - ClutterBinAlignment y_align) -{ - ClutterBinLayoutPrivate *priv; - ClutterLayoutManager *manager; - ClutterLayoutMeta *meta; - - g_return_if_fail (CLUTTER_IS_BIN_LAYOUT (self)); - g_return_if_fail (child == NULL || CLUTTER_IS_ACTOR (child)); - - priv = self->priv; - - if (priv->container == NULL) - { - if (child == NULL) - { - set_x_align (self, x_align); - set_y_align (self, y_align); - } - else - g_warning ("The layout of type '%s' must be associated to " - "a ClutterContainer before setting the alignment " - "on its children", - G_OBJECT_TYPE_NAME (self)); - - return; - } - - manager = CLUTTER_LAYOUT_MANAGER (self); - meta = clutter_layout_manager_get_child_meta (manager, - priv->container, - child); - g_assert (CLUTTER_IS_BIN_LAYER (meta)); - - set_layer_x_align (CLUTTER_BIN_LAYER (meta), x_align); - set_layer_y_align (CLUTTER_BIN_LAYER (meta), y_align); -} - -/** - * clutter_bin_layout_get_alignment: - * @self: a #ClutterBinLayout - * @child: (allow-none): a child of @container - * @x_align: (out) (allow-none): return location for the horizontal - * alignment policy - * @y_align: (out) (allow-none): return location for the vertical - * alignment policy - * - * Retrieves the horizontal and vertical alignment policies for - * a child of @self - * - * If @child is %NULL the default alignment policies will be returned - * instead - * - * Since: 1.2 - * - * Deprecated: 1.12: Use the #ClutterActor:x-align and the - * #ClutterActor:y-align properties of #ClutterActor instead. - */ -void -clutter_bin_layout_get_alignment (ClutterBinLayout *self, - ClutterActor *child, - ClutterBinAlignment *x_align, - ClutterBinAlignment *y_align) -{ - ClutterBinLayoutPrivate *priv; - ClutterLayoutManager *manager; - ClutterLayoutMeta *meta; - ClutterBinLayer *layer; - - g_return_if_fail (CLUTTER_IS_BIN_LAYOUT (self)); - - priv = self->priv; - - if (priv->container == NULL) - { - if (child == NULL) - { - if (x_align) - *x_align = priv->x_align; - - if (y_align) - *y_align = priv->y_align; - } - else - g_warning ("The layout of type '%s' must be associated to " - "a ClutterContainer before getting the alignment " - "of its children", - G_OBJECT_TYPE_NAME (self)); - - return; - } - - manager = CLUTTER_LAYOUT_MANAGER (self); - meta = clutter_layout_manager_get_child_meta (manager, - priv->container, - child); - g_assert (CLUTTER_IS_BIN_LAYER (meta)); - - layer = CLUTTER_BIN_LAYER (meta); - - if (x_align) - *x_align = layer->x_align; - - if (y_align) - *y_align = layer->y_align; -} - -/** - * clutter_bin_layout_add: - * @self: a #ClutterBinLayout - * @child: a #ClutterActor - * @x_align: horizontal alignment policy for @child - * @y_align: vertical alignment policy for @child - * - * Adds a #ClutterActor to the container using @self and - * sets the alignment policies for it - * - * This function is equivalent to clutter_container_add_actor() - * and clutter_layout_manager_child_set_property() but it does not - * require a pointer to the #ClutterContainer associated to the - * #ClutterBinLayout - * - * Since: 1.2 - * - * Deprecated: 1.12: Use clutter_actor_add_child() instead. - */ -void -clutter_bin_layout_add (ClutterBinLayout *self, - ClutterActor *child, - ClutterBinAlignment x_align, - ClutterBinAlignment y_align) -{ - ClutterBinLayoutPrivate *priv; - ClutterLayoutManager *manager; - ClutterLayoutMeta *meta; - - g_return_if_fail (CLUTTER_IS_BIN_LAYOUT (self)); - g_return_if_fail (CLUTTER_IS_ACTOR (child)); - - priv = self->priv; - - if (priv->container == NULL) - { - g_warning ("The layout of type '%s' must be associated to " - "a ClutterContainer before adding children", - G_OBJECT_TYPE_NAME (self)); - return; - } - - clutter_actor_add_child (CLUTTER_ACTOR (priv->container), child); - manager = CLUTTER_LAYOUT_MANAGER (self); - meta = clutter_layout_manager_get_child_meta (manager, - priv->container, - child); - g_assert (CLUTTER_IS_BIN_LAYER (meta)); - - set_layer_x_align (CLUTTER_BIN_LAYER (meta), x_align); - set_layer_y_align (CLUTTER_BIN_LAYER (meta), y_align); + return g_object_new (CLUTTER_TYPE_BIN_LAYOUT, NULL); } diff --git a/clutter/clutter-bin-layout.h b/clutter/clutter-bin-layout.h index 6f52ba182..3df4187db 100644 --- a/clutter/clutter-bin-layout.h +++ b/clutter/clutter-bin-layout.h @@ -76,8 +76,7 @@ struct _ClutterBinLayoutClass GType clutter_bin_layout_get_type (void) G_GNUC_CONST; -ClutterLayoutManager *clutter_bin_layout_new (ClutterBinAlignment x_align, - ClutterBinAlignment y_align); +ClutterLayoutManager * clutter_bin_layout_new (void); G_END_DECLS diff --git a/clutter/clutter-box-layout.c b/clutter/clutter-box-layout.c index c91d9718c..296d4d938 100644 --- a/clutter/clutter-box-layout.c +++ b/clutter/clutter-box-layout.c @@ -68,28 +68,16 @@ #include -#define CLUTTER_DISABLE_DEPRECATION_WARNINGS -#include "deprecated/clutter-container.h" -#include "deprecated/clutter-alpha.h" - -#include "clutter-box-layout.h" - #include "clutter-actor-private.h" +#include "clutter-box-layout.h" +#include "clutter-container.h" #include "clutter-debug.h" #include "clutter-enum-types.h" -#include "clutter-layout-meta.h" #include "clutter-private.h" #include "clutter-types.h" -#define CLUTTER_TYPE_BOX_CHILD (clutter_box_child_get_type ()) -#define CLUTTER_BOX_CHILD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BOX_CHILD, ClutterBoxChild)) -#define CLUTTER_IS_BOX_CHILD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BOX_CHILD)) - #define CLUTTER_BOX_LAYOUT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_BOX_LAYOUT, ClutterBoxLayoutPrivate)) -typedef struct _ClutterBoxChild ClutterBoxChild; -typedef struct _ClutterLayoutMetaClass ClutterBoxChildClass; - struct _ClutterBoxLayoutPrivate { ClutterContainer *container; @@ -106,42 +94,13 @@ struct _ClutterBoxLayoutPrivate guint is_homogeneous : 1; }; -struct _ClutterBoxChild -{ - ClutterLayoutMeta parent_instance; - - ClutterBoxAlignment x_align; - ClutterBoxAlignment y_align; - - guint x_fill : 1; - guint y_fill : 1; - guint expand : 1; -}; - -enum -{ - PROP_CHILD_0, - - PROP_CHILD_X_ALIGN, - PROP_CHILD_Y_ALIGN, - PROP_CHILD_X_FILL, - PROP_CHILD_Y_FILL, - PROP_CHILD_EXPAND, - - PROP_CHILD_LAST -}; - enum { PROP_0, PROP_SPACING, - PROP_VERTICAL, PROP_HOMOGENEOUS, PROP_PACK_START, - PROP_USE_ANIMATIONS, - PROP_EASING_MODE, - PROP_EASING_DURATION, PROP_ORIENTATION, PROP_LAST @@ -149,12 +108,6 @@ enum static GParamSpec *obj_props[PROP_LAST] = { NULL, }; -GType clutter_box_child_get_type (void); - -G_DEFINE_TYPE (ClutterBoxChild, - clutter_box_child, - CLUTTER_TYPE_LAYOUT_META); - G_DEFINE_TYPE (ClutterBoxLayout, clutter_box_layout, CLUTTER_TYPE_LAYOUT_MANAGER); @@ -176,270 +129,6 @@ static void count_expand_children (ClutterLayoutManager *layout, gint *visible_children, gint *expand_children); -/* - * ClutterBoxChild - */ - -static void -box_child_set_align (ClutterBoxChild *self, - ClutterBoxAlignment x_align, - ClutterBoxAlignment y_align) -{ - gboolean x_changed = FALSE, y_changed = FALSE; - - if (self->x_align != x_align) - { - self->x_align = x_align; - - x_changed = TRUE; - } - - if (self->y_align != y_align) - { - self->y_align = y_align; - - y_changed = TRUE; - } - - if (x_changed || y_changed) - { - ClutterLayoutManager *layout; - - layout = clutter_layout_meta_get_manager (CLUTTER_LAYOUT_META (self)); - - clutter_layout_manager_layout_changed (layout); - - if (x_changed) - g_object_notify (G_OBJECT (self), "x-align"); - - if (y_changed) - g_object_notify (G_OBJECT (self), "y-align"); - } -} - -static void -box_child_set_fill (ClutterBoxChild *self, - gboolean x_fill, - gboolean y_fill) -{ - gboolean x_changed = FALSE, y_changed = FALSE; - - if (self->x_fill != x_fill) - { - self->x_fill = x_fill; - - x_changed = TRUE; - } - - if (self->y_fill != y_fill) - { - self->y_fill = y_fill; - - y_changed = TRUE; - } - - if (x_changed || y_changed) - { - ClutterLayoutManager *layout; - - layout = clutter_layout_meta_get_manager (CLUTTER_LAYOUT_META (self)); - - clutter_layout_manager_layout_changed (layout); - - if (x_changed) - g_object_notify (G_OBJECT (self), "x-fill"); - - if (y_changed) - g_object_notify (G_OBJECT (self), "y-fill"); - } -} - -static void -box_child_set_expand (ClutterBoxChild *self, - gboolean expand) -{ - if (self->expand != expand) - { - ClutterLayoutManager *layout; - - self->expand = expand; - - layout = clutter_layout_meta_get_manager (CLUTTER_LAYOUT_META (self)); - - clutter_layout_manager_layout_changed (layout); - - g_object_notify (G_OBJECT (self), "expand"); - } -} - -static void -clutter_box_child_set_property (GObject *gobject, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - ClutterBoxChild *self = CLUTTER_BOX_CHILD (gobject); - - switch (prop_id) - { - case PROP_CHILD_X_ALIGN: - box_child_set_align (self, - g_value_get_enum (value), - self->y_align); - break; - - case PROP_CHILD_Y_ALIGN: - box_child_set_align (self, - self->x_align, - g_value_get_enum (value)); - break; - - case PROP_CHILD_X_FILL: - box_child_set_fill (self, - g_value_get_boolean (value), - self->y_fill); - break; - - case PROP_CHILD_Y_FILL: - box_child_set_fill (self, - self->x_fill, - g_value_get_boolean (value)); - break; - - case PROP_CHILD_EXPAND: - box_child_set_expand (self, g_value_get_boolean (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); - break; - } -} - -static void -clutter_box_child_get_property (GObject *gobject, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - ClutterBoxChild *self = CLUTTER_BOX_CHILD (gobject); - - switch (prop_id) - { - case PROP_CHILD_X_ALIGN: - g_value_set_enum (value, self->x_align); - break; - - case PROP_CHILD_Y_ALIGN: - g_value_set_enum (value, self->y_align); - break; - - case PROP_CHILD_X_FILL: - g_value_set_boolean (value, self->x_fill); - break; - - case PROP_CHILD_Y_FILL: - g_value_set_boolean (value, self->y_fill); - break; - - case PROP_CHILD_EXPAND: - g_value_set_boolean (value, self->expand); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); - break; - } -} - -static void -clutter_box_child_class_init (ClutterBoxChildClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GParamSpec *pspec; - - gobject_class->set_property = clutter_box_child_set_property; - gobject_class->get_property = clutter_box_child_get_property; - - pspec = g_param_spec_boolean ("expand", - P_("Expand"), - P_("Allocate extra space for the child"), - FALSE, - CLUTTER_PARAM_READWRITE); - g_object_class_install_property (gobject_class, PROP_CHILD_EXPAND, pspec); - - pspec = g_param_spec_boolean ("x-fill", - P_("Horizontal Fill"), - P_("Whether the child should receive priority " - "when the container is allocating spare space " - "on the horizontal axis"), - FALSE, - CLUTTER_PARAM_READWRITE); - g_object_class_install_property (gobject_class, PROP_CHILD_X_FILL, pspec); - - pspec = g_param_spec_boolean ("y-fill", - P_("Vertical Fill"), - P_("Whether the child should receive priority " - "when the container is allocating spare space " - "on the vertical axis"), - FALSE, - CLUTTER_PARAM_READWRITE); - g_object_class_install_property (gobject_class, PROP_CHILD_Y_FILL, pspec); - - pspec = g_param_spec_enum ("x-align", - P_("Horizontal Alignment"), - P_("Horizontal alignment of the actor within " - "the cell"), - CLUTTER_TYPE_BOX_ALIGNMENT, - CLUTTER_BOX_ALIGNMENT_CENTER, - CLUTTER_PARAM_READWRITE); - g_object_class_install_property (gobject_class, PROP_CHILD_X_ALIGN, pspec); - - pspec = g_param_spec_enum ("y-align", - P_("Vertical Alignment"), - P_("Vertical alignment of the actor within " - "the cell"), - CLUTTER_TYPE_BOX_ALIGNMENT, - CLUTTER_BOX_ALIGNMENT_CENTER, - CLUTTER_PARAM_READWRITE); - g_object_class_install_property (gobject_class, PROP_CHILD_Y_ALIGN, pspec); -} - -static void -clutter_box_child_init (ClutterBoxChild *self) -{ - self->x_align = CLUTTER_BOX_ALIGNMENT_CENTER; - self->y_align = CLUTTER_BOX_ALIGNMENT_CENTER; - - self->x_fill = self->y_fill = FALSE; - - self->expand = FALSE; -} - -static gdouble -get_box_alignment_factor (ClutterBoxAlignment alignment) -{ - switch (alignment) - { - case CLUTTER_BOX_ALIGNMENT_CENTER: - return 0.5; - - case CLUTTER_BOX_ALIGNMENT_START: - return 0.0; - - case CLUTTER_BOX_ALIGNMENT_END: - return 1.0; - } - - return 0.0; -} - -static GType -clutter_box_layout_get_child_meta_type (ClutterLayoutManager *manager) -{ - return CLUTTER_TYPE_BOX_CHILD; -} - static void clutter_box_layout_set_container (ClutterLayoutManager *layout, ClutterContainer *container) @@ -507,7 +196,8 @@ get_preferred_size_for_orientation (ClutterBoxLayout *self, n_children++; get_child_size (child, priv->orientation, - for_size, &child_min, &child_nat); + for_size, + &child_min, &child_nat); minimum += child_min; natural += child_nat; @@ -601,7 +291,8 @@ get_preferred_size_for_opposite_orientation (ClutterBoxLayout *self, minimum = natural = 0; count_expand_children (layout, real_container, - &nvis_children, &nexpand_children); + &nvis_children, + &nexpand_children); if (nvis_children < 1) { @@ -659,16 +350,10 @@ get_preferred_size_for_opposite_orientation (ClutterBoxLayout *self, clutter_actor_iter_init (&iter, container); while (clutter_actor_iter_next (&iter, &child)) { - ClutterLayoutMeta *meta; - ClutterBoxChild *box_child; - /* If widget is not visible, skip it. */ if (!CLUTTER_ACTOR_IS_VISIBLE (child)) continue; - meta = clutter_layout_manager_get_child_meta (layout, real_container, child); - box_child = CLUTTER_BOX_CHILD (meta); - if (priv->is_homogeneous) { sizes[i].minimum_size = extra; @@ -681,7 +366,7 @@ get_preferred_size_for_opposite_orientation (ClutterBoxLayout *self, } else { - if (clutter_actor_needs_expand (child, priv->orientation) || box_child->expand) + if (clutter_actor_needs_expand (child, priv->orientation)) { sizes[i].minimum_size += extra; @@ -730,44 +415,13 @@ allocate_box_child (ClutterBoxLayout *self, ClutterActorBox *child_box, ClutterAllocationFlags flags) { - ClutterBoxLayoutPrivate *priv = self->priv; - ClutterBoxChild *box_child; - ClutterLayoutMeta *meta; - - meta = clutter_layout_manager_get_child_meta (CLUTTER_LAYOUT_MANAGER (self), - container, - child); - box_child = CLUTTER_BOX_CHILD (meta); - CLUTTER_NOTE (LAYOUT, "Allocation for %s { %.2f, %.2f, %.2f, %.2f }", _clutter_actor_get_debug_name (child), child_box->x1, child_box->y1, child_box->x2 - child_box->x1, child_box->y2 - child_box->y1); - if (priv->use_animations) - { - clutter_actor_save_easing_state (child); - clutter_actor_set_easing_mode (child, priv->easing_mode); - clutter_actor_set_easing_duration (child, priv->easing_duration); - } - - /* call allocate() instead of allocate_align_fill() if the actor needs - * expand in either direction. this will honour the actors alignment settings - */ - if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_HORIZONTAL) || - clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_VERTICAL)) - clutter_actor_allocate (child, child_box, flags); - else - clutter_actor_allocate_align_fill (child, child_box, - get_box_alignment_factor (box_child->x_align), - get_box_alignment_factor (box_child->y_align), - box_child->x_fill, - box_child->y_fill, - flags); - - if (priv->use_animations) - clutter_actor_restore_easing_state (child); + clutter_actor_allocate (child, child_box, flags); } static void @@ -777,7 +431,7 @@ clutter_box_layout_get_preferred_width (ClutterLayoutManager *layout, gfloat *min_width_p, gfloat *natural_width_p) { - ClutterBoxLayout *self = CLUTTER_BOX_LAYOUT (layout); + ClutterBoxLayout *self = CLUTTER_BOX_LAYOUT (layout); ClutterBoxLayoutPrivate *priv = self->priv; if (priv->orientation == CLUTTER_ORIENTATION_VERTICAL) @@ -786,11 +440,13 @@ clutter_box_layout_get_preferred_width (ClutterLayoutManager *layout, get_base_size_for_opposite_orientation (self, CLUTTER_ACTOR (container), min_width_p, natural_width_p); else - get_preferred_size_for_opposite_orientation (self, CLUTTER_ACTOR (container), for_height, + get_preferred_size_for_opposite_orientation (self, CLUTTER_ACTOR (container), + for_height, min_width_p, natural_width_p); } else - get_preferred_size_for_orientation (self, CLUTTER_ACTOR (container), for_height, + get_preferred_size_for_orientation (self, CLUTTER_ACTOR (container), + for_height, min_width_p, natural_width_p); } @@ -810,11 +466,13 @@ clutter_box_layout_get_preferred_height (ClutterLayoutManager *layout, get_base_size_for_opposite_orientation (self, CLUTTER_ACTOR (container), min_height_p, natural_height_p); else - get_preferred_size_for_opposite_orientation (self, CLUTTER_ACTOR (container), for_width, + get_preferred_size_for_opposite_orientation (self, CLUTTER_ACTOR (container), + for_width, min_height_p, natural_height_p); } else - get_preferred_size_for_orientation (self, CLUTTER_ACTOR (container), for_width, + get_preferred_size_for_orientation (self, CLUTTER_ACTOR (container), + for_width, min_height_p, natural_height_p); } @@ -837,16 +495,9 @@ count_expand_children (ClutterLayoutManager *layout, { if (CLUTTER_ACTOR_IS_VISIBLE (child)) { - ClutterLayoutMeta *meta; - *visible_children += 1; - meta = clutter_layout_manager_get_child_meta (layout, - container, - child); - - if (clutter_actor_needs_expand (child, priv->orientation) || - CLUTTER_BOX_CHILD (meta)->expand) + if (clutter_actor_needs_expand (child, priv->orientation)) *expand_children += 1; } } @@ -1122,18 +773,10 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout, clutter_actor_iter_init (&iter, actor); while (clutter_actor_iter_next (&iter, &child)) { - ClutterLayoutMeta *meta; - ClutterBoxChild *box_child; - /* If widget is not visible, skip it. */ if (!CLUTTER_ACTOR_IS_VISIBLE (child)) continue; - meta = clutter_layout_manager_get_child_meta (layout, - container, - child); - box_child = CLUTTER_BOX_CHILD (meta); - /* Assign the child's size. */ if (priv->is_homogeneous) { @@ -1149,8 +792,7 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout, { child_size = sizes[i].minimum_size; - if (clutter_actor_needs_expand (child, priv->orientation) || - box_child->expand) + if (clutter_actor_needs_expand (child, priv->orientation)) { child_size += extra; @@ -1165,8 +807,7 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout, /* Assign the child's position. */ if (priv->orientation == CLUTTER_ORIENTATION_VERTICAL) { - if (clutter_actor_needs_expand (child, priv->orientation) || - box_child->y_fill) + if (clutter_actor_needs_expand (child, priv->orientation)) { child_allocation.y1 = y; child_allocation.y2 = child_allocation.y1 + MAX (1.0, child_size); @@ -1191,8 +832,7 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout, } else /* CLUTTER_ORIENTATION_HORIZONTAL */ { - if (clutter_actor_needs_expand (child, priv->orientation) || - box_child->x_fill) + if (clutter_actor_needs_expand (child, priv->orientation)) { child_allocation.x1 = x; child_allocation.x2 = child_allocation.x1 + MAX (1.0, child_size); @@ -1224,16 +864,15 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout, - (child_allocation.x2 - child_allocation.x1); child_allocation.x2 = child_allocation.x1 + width; } - } - allocate_box_child (CLUTTER_BOX_LAYOUT (layout), - container, - child, - &child_allocation, - flags); + allocate_box_child (CLUTTER_BOX_LAYOUT (layout), + container, + child, + &child_allocation, + flags); - i += 1; + i += 1; } } @@ -1247,10 +886,6 @@ clutter_box_layout_set_property (GObject *gobject, switch (prop_id) { - case PROP_VERTICAL: - clutter_box_layout_set_vertical (self, g_value_get_boolean (value)); - break; - case PROP_ORIENTATION: clutter_box_layout_set_orientation (self, g_value_get_enum (value)); break; @@ -1267,18 +902,6 @@ clutter_box_layout_set_property (GObject *gobject, clutter_box_layout_set_pack_start (self, g_value_get_boolean (value)); break; - case PROP_USE_ANIMATIONS: - clutter_box_layout_set_use_animations (self, g_value_get_boolean (value)); - break; - - case PROP_EASING_MODE: - clutter_box_layout_set_easing_mode (self, g_value_get_ulong (value)); - break; - - case PROP_EASING_DURATION: - clutter_box_layout_set_easing_duration (self, g_value_get_uint (value)); - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; @@ -1295,11 +918,6 @@ clutter_box_layout_get_property (GObject *gobject, switch (prop_id) { - case PROP_VERTICAL: - g_value_set_boolean (value, - priv->orientation == CLUTTER_ORIENTATION_VERTICAL); - break; - case PROP_ORIENTATION: g_value_set_enum (value, priv->orientation); break; @@ -1316,18 +934,6 @@ clutter_box_layout_get_property (GObject *gobject, g_value_set_boolean (value, priv->is_pack_start); break; - case PROP_USE_ANIMATIONS: - g_value_set_boolean (value, priv->use_animations); - break; - - case PROP_EASING_MODE: - g_value_set_ulong (value, priv->easing_mode); - break; - - case PROP_EASING_DURATION: - g_value_set_uint (value, priv->easing_duration); - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; @@ -1346,30 +952,9 @@ clutter_box_layout_class_init (ClutterBoxLayoutClass *klass) layout_class->get_preferred_height = clutter_box_layout_get_preferred_height; layout_class->allocate = clutter_box_layout_allocate; layout_class->set_container = clutter_box_layout_set_container; - layout_class->get_child_meta_type = clutter_box_layout_get_child_meta_type; g_type_class_add_private (klass, sizeof (ClutterBoxLayoutPrivate)); - /** - * ClutterBoxLayout:vertical: - * - * Whether the #ClutterBoxLayout should arrange its children - * alongside the Y axis, instead of alongside the X axis - * - * Since: 1.2 - * - * Deprecated: 1.12: Use #ClutterBoxLayout:orientation instead. - */ - obj_props[PROP_VERTICAL] = - g_param_spec_boolean ("vertical", - P_("Vertical"), - P_("Whether the layout should be vertical, " - "rather than horizontal"), - FALSE, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS | - G_PARAM_DEPRECATED); - /** * ClutterBoxLayout:orientation: * @@ -1432,71 +1017,6 @@ clutter_box_layout_class_init (ClutterBoxLayoutClass *klass) 0, G_MAXUINT, 0, CLUTTER_PARAM_READWRITE); - /** - * ClutterBoxLayout:use-animations: - * - * Whether the #ClutterBoxLayout should animate changes in the - * layout, overriding the easing state of the children. - * - * Since: 1.2 - * - * Deprecated: 1.12: #ClutterBoxLayout will honour the easing state - * of the children when allocating them. - */ - obj_props[PROP_USE_ANIMATIONS] = - g_param_spec_boolean ("use-animations", - P_("Use Animations"), - P_("Whether layout changes should be animated"), - FALSE, - CLUTTER_PARAM_READWRITE); - - /** - * ClutterBoxLayout:easing-mode: - * - * The easing mode for the animations, in case - * #ClutterBoxLayout:use-animations is set to %TRUE. - * - * The easing mode has the same semantics of #ClutterAnimation:mode: it can - * either be a value from the #ClutterAnimationMode enumeration, like - * %CLUTTER_EASE_OUT_CUBIC, or a logical id as returned by - * clutter_alpha_register_func(). - * - * The default value is %CLUTTER_EASE_OUT_CUBIC. - * - * Since: 1.2 - * - * Deprecated: 1.12: The #ClutterBoxLayout will honour the easing state of - * the children when allocating them. - */ - obj_props[PROP_EASING_MODE] = - g_param_spec_ulong ("easing-mode", - P_("Easing Mode"), - P_("The easing mode of the animations"), - 0, G_MAXULONG, - CLUTTER_EASE_OUT_CUBIC, - CLUTTER_PARAM_READWRITE); - - /** - * ClutterBoxLayout:easing-duration: - * - * The duration of the animations, in case #ClutterBoxLayout:use-animations - * is set to %TRUE. - * - * The duration is expressed in milliseconds. - * - * Since: 1.2 - * - * Deprecated: 1.12: The #ClutterBoxLayout will honour the easing state of - * the children when allocating them. - */ - obj_props[PROP_EASING_DURATION] = - g_param_spec_uint ("easing-duration", - P_("Easing Duration"), - P_("The duration of the animations"), - 0, G_MAXUINT, - 500, - CLUTTER_PARAM_READWRITE); - gobject_class->set_property = clutter_box_layout_set_property; gobject_class->get_property = clutter_box_layout_get_property; g_object_class_install_properties (gobject_class, PROP_LAST, obj_props); @@ -1585,36 +1105,6 @@ clutter_box_layout_get_spacing (ClutterBoxLayout *layout) return layout->priv->spacing; } -/** - * clutter_box_layout_set_vertical: - * @layout: a #ClutterBoxLayout - * @vertical: %TRUE if the layout should be vertical - * - * Sets whether @layout should arrange its children vertically alongside - * the Y axis, instead of horizontally alongside the X axis - * - * Since: 1.2 - * - * Deprecated: 1.12: Use clutter_box_layout_set_orientation() instead. - */ -void -clutter_box_layout_set_vertical (ClutterBoxLayout *layout, - gboolean vertical) -{ - ClutterOrientation new_orientation, old_orientation; - - g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout)); - - old_orientation = layout->priv->orientation; - new_orientation = vertical - ? CLUTTER_ORIENTATION_VERTICAL - : CLUTTER_ORIENTATION_HORIZONTAL; - clutter_box_layout_set_orientation (layout, new_orientation); - - if (old_orientation != new_orientation) - g_object_notify_by_pspec (G_OBJECT (layout), obj_props[PROP_VERTICAL]); -} - /** * clutter_box_layout_set_orientation: * @layout: a #ClutterBoxLayout @@ -1647,28 +1137,6 @@ clutter_box_layout_set_orientation (ClutterBoxLayout *layout, g_object_notify_by_pspec (G_OBJECT (layout), obj_props[PROP_ORIENTATION]); } -/** - * clutter_box_layout_get_vertical: - * @layout: a #ClutterBoxLayout - * - * Retrieves the orientation of the @layout as set using the - * clutter_box_layout_set_vertical() function - * - * Return value: %TRUE if the #ClutterBoxLayout is arranging its children - * vertically, and %FALSE otherwise - * - * Since: 1.2 - * - * Deprecated: 1.12: Use clutter_box_layout_get_orientation() instead - */ -gboolean -clutter_box_layout_get_vertical (ClutterBoxLayout *layout) -{ - g_return_val_if_fail (CLUTTER_IS_BOX_LAYOUT (layout), FALSE); - - return layout->priv->orientation == CLUTTER_ORIENTATION_VERTICAL; -} - /** * clutter_box_layout_get_orientation: * @layout: a #ClutterBoxLayout @@ -1794,562 +1262,3 @@ clutter_box_layout_get_pack_start (ClutterBoxLayout *layout) return layout->priv->is_pack_start; } - -/** - * clutter_box_layout_pack: - * @layout: a #ClutterBoxLayout - * @actor: a #ClutterActor - * @expand: whether the @actor should expand - * @x_fill: whether the @actor should fill horizontally - * @y_fill: whether the @actor should fill vertically - * @x_align: the horizontal alignment policy for @actor - * @y_align: the vertical alignment policy for @actor - * - * Packs @actor inside the #ClutterContainer associated to @layout - * and sets the layout properties - * - * Since: 1.2 - * Deprecated: 1.12: #ClutterBoxLayout honours #ClutterActor's - * align and expand properties. The preferred way is adding - * the @actor with clutter_actor_add_child() and setting - * #ClutterActor:x-align, #ClutterActor:y-align, - * #ClutterActor:x-expand and #ClutterActor:y-expand - */ -void -clutter_box_layout_pack (ClutterBoxLayout *layout, - ClutterActor *actor, - gboolean expand, - gboolean x_fill, - gboolean y_fill, - ClutterBoxAlignment x_align, - ClutterBoxAlignment y_align) -{ - ClutterBoxLayoutPrivate *priv; - ClutterLayoutManager *manager; - ClutterLayoutMeta *meta; - - g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout)); - g_return_if_fail (CLUTTER_IS_ACTOR (actor)); - - priv = layout->priv; - - if (priv->container == NULL) - { - g_warning ("The layout of type '%s' must be associated to " - "a ClutterContainer before adding children", - G_OBJECT_TYPE_NAME (layout)); - return; - } - - clutter_actor_add_child (CLUTTER_ACTOR (priv->container), actor); - - manager = CLUTTER_LAYOUT_MANAGER (layout); - meta = clutter_layout_manager_get_child_meta (manager, - priv->container, - actor); - g_assert (CLUTTER_IS_BOX_CHILD (meta)); - - box_child_set_align (CLUTTER_BOX_CHILD (meta), x_align, y_align); - box_child_set_fill (CLUTTER_BOX_CHILD (meta), x_fill, y_fill); - box_child_set_expand (CLUTTER_BOX_CHILD (meta), expand); -} - -/** - * clutter_box_layout_set_alignment: - * @layout: a #ClutterBoxLayout - * @actor: a #ClutterActor child of @layout - * @x_align: Horizontal alignment policy for @actor - * @y_align: Vertical alignment policy for @actor - * - * Sets the horizontal and vertical alignment policies for @actor - * inside @layout - * - * Since: 1.2 - * Deprecated: 1.12: #ClutterBoxLayout will honour #ClutterActor's - * #ClutterActor:x-align and #ClutterActor:y-align properies - */ -void -clutter_box_layout_set_alignment (ClutterBoxLayout *layout, - ClutterActor *actor, - ClutterBoxAlignment x_align, - ClutterBoxAlignment y_align) -{ - ClutterBoxLayoutPrivate *priv; - ClutterLayoutManager *manager; - ClutterLayoutMeta *meta; - - g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout)); - g_return_if_fail (CLUTTER_IS_ACTOR (actor)); - - priv = layout->priv; - - if (priv->container == NULL) - { - g_warning ("The layout of type '%s' must be associated to " - "a ClutterContainer before querying layout " - "properties", - G_OBJECT_TYPE_NAME (layout)); - return; - } - - manager = CLUTTER_LAYOUT_MANAGER (layout); - meta = clutter_layout_manager_get_child_meta (manager, - priv->container, - actor); - if (meta == NULL) - { - g_warning ("No layout meta found for the child of type '%s' " - "inside the layout manager of type '%s'", - G_OBJECT_TYPE_NAME (actor), - G_OBJECT_TYPE_NAME (manager)); - return; - } - - g_assert (CLUTTER_IS_BOX_CHILD (meta)); - - box_child_set_align (CLUTTER_BOX_CHILD (meta), x_align, y_align); -} - -/** - * clutter_box_layout_get_alignment: - * @layout: a #ClutterBoxLayout - * @actor: a #ClutterActor child of @layout - * @x_align: (out): return location for the horizontal alignment policy - * @y_align: (out): return location for the vertical alignment policy - * - * Retrieves the horizontal and vertical alignment policies for @actor - * as set using clutter_box_layout_pack() or clutter_box_layout_set_alignment() - * - * Since: 1.2 - * Deprecated: 1.12: #ClutterBoxLayout will honour #ClutterActor's - * #ClutterActor:x-align and #ClutterActor:y-align properies - */ -void -clutter_box_layout_get_alignment (ClutterBoxLayout *layout, - ClutterActor *actor, - ClutterBoxAlignment *x_align, - ClutterBoxAlignment *y_align) -{ - ClutterBoxLayoutPrivate *priv; - ClutterLayoutManager *manager; - ClutterLayoutMeta *meta; - - g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout)); - g_return_if_fail (CLUTTER_IS_ACTOR (actor)); - - priv = layout->priv; - - if (priv->container == NULL) - { - g_warning ("The layout of type '%s' must be associated to " - "a ClutterContainer before querying layout " - "properties", - G_OBJECT_TYPE_NAME (layout)); - return; - } - - manager = CLUTTER_LAYOUT_MANAGER (layout); - meta = clutter_layout_manager_get_child_meta (manager, - priv->container, - actor); - if (meta == NULL) - { - g_warning ("No layout meta found for the child of type '%s' " - "inside the layout manager of type '%s'", - G_OBJECT_TYPE_NAME (actor), - G_OBJECT_TYPE_NAME (manager)); - return; - } - - g_assert (CLUTTER_IS_BOX_CHILD (meta)); - - if (x_align) - *x_align = CLUTTER_BOX_CHILD (meta)->x_align; - - if (y_align) - *y_align = CLUTTER_BOX_CHILD (meta)->y_align; -} - -/** - * clutter_box_layout_set_fill: - * @layout: a #ClutterBoxLayout - * @actor: a #ClutterActor child of @layout - * @x_fill: whether @actor should fill horizontally the allocated space - * @y_fill: whether @actor should fill vertically the allocated space - * - * Sets the horizontal and vertical fill policies for @actor - * inside @layout - * - * Since: 1.2 - * Deprecated: 1.12: #ClutterBoxLayout will honour #ClutterActor's - * #ClutterActor:x-align and #ClutterActor:y-align properies - */ -void -clutter_box_layout_set_fill (ClutterBoxLayout *layout, - ClutterActor *actor, - gboolean x_fill, - gboolean y_fill) -{ - ClutterBoxLayoutPrivate *priv; - ClutterLayoutManager *manager; - ClutterLayoutMeta *meta; - - g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout)); - g_return_if_fail (CLUTTER_IS_ACTOR (actor)); - - priv = layout->priv; - - if (priv->container == NULL) - { - g_warning ("The layout of type '%s' must be associated to " - "a ClutterContainer before querying layout " - "properties", - G_OBJECT_TYPE_NAME (layout)); - return; - } - - manager = CLUTTER_LAYOUT_MANAGER (layout); - meta = clutter_layout_manager_get_child_meta (manager, - priv->container, - actor); - if (meta == NULL) - { - g_warning ("No layout meta found for the child of type '%s' " - "inside the layout manager of type '%s'", - G_OBJECT_TYPE_NAME (actor), - G_OBJECT_TYPE_NAME (manager)); - return; - } - - g_assert (CLUTTER_IS_BOX_CHILD (meta)); - - box_child_set_fill (CLUTTER_BOX_CHILD (meta), x_fill, y_fill); -} - -/** - * clutter_box_layout_get_fill: - * @layout: a #ClutterBoxLayout - * @actor: a #ClutterActor child of @layout - * @x_fill: (out): return location for the horizontal fill policy - * @y_fill: (out): return location for the vertical fill policy - * - * Retrieves the horizontal and vertical fill policies for @actor - * as set using clutter_box_layout_pack() or clutter_box_layout_set_fill() - * - * Since: 1.2 - * Deprecated: 1.12: #ClutterBoxLayout will honour #ClutterActor's - * #ClutterActor:x-align and #ClutterActor:y-align properies - */ -void -clutter_box_layout_get_fill (ClutterBoxLayout *layout, - ClutterActor *actor, - gboolean *x_fill, - gboolean *y_fill) -{ - ClutterBoxLayoutPrivate *priv; - ClutterLayoutManager *manager; - ClutterLayoutMeta *meta; - - g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout)); - g_return_if_fail (CLUTTER_IS_ACTOR (actor)); - - priv = layout->priv; - - if (priv->container == NULL) - { - g_warning ("The layout of type '%s' must be associated to " - "a ClutterContainer before querying layout " - "properties", - G_OBJECT_TYPE_NAME (layout)); - return; - } - - manager = CLUTTER_LAYOUT_MANAGER (layout); - meta = clutter_layout_manager_get_child_meta (manager, - priv->container, - actor); - if (meta == NULL) - { - g_warning ("No layout meta found for the child of type '%s' " - "inside the layout manager of type '%s'", - G_OBJECT_TYPE_NAME (actor), - G_OBJECT_TYPE_NAME (manager)); - return; - } - - g_assert (CLUTTER_IS_BOX_CHILD (meta)); - - if (x_fill) - *x_fill = CLUTTER_BOX_CHILD (meta)->x_fill; - - if (y_fill) - *y_fill = CLUTTER_BOX_CHILD (meta)->y_fill; -} - -/** - * clutter_box_layout_set_expand: - * @layout: a #ClutterBoxLayout - * @actor: a #ClutterActor child of @layout - * @expand: whether @actor should expand - * - * Sets whether @actor should expand inside @layout - * - * Since: 1.2 - * Deprecated: 1.12: #ClutterBoxLayout will honour #ClutterActor's - * #ClutterActor:x-expand and #ClutterActor:y-expand properies - */ -void -clutter_box_layout_set_expand (ClutterBoxLayout *layout, - ClutterActor *actor, - gboolean expand) -{ - ClutterBoxLayoutPrivate *priv; - ClutterLayoutManager *manager; - ClutterLayoutMeta *meta; - - g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout)); - g_return_if_fail (CLUTTER_IS_ACTOR (actor)); - - priv = layout->priv; - - if (priv->container == NULL) - { - g_warning ("The layout of type '%s' must be associated to " - "a ClutterContainer before querying layout " - "properties", - G_OBJECT_TYPE_NAME (layout)); - return; - } - - manager = CLUTTER_LAYOUT_MANAGER (layout); - meta = clutter_layout_manager_get_child_meta (manager, - priv->container, - actor); - if (meta == NULL) - { - g_warning ("No layout meta found for the child of type '%s' " - "inside the layout manager of type '%s'", - G_OBJECT_TYPE_NAME (actor), - G_OBJECT_TYPE_NAME (manager)); - return; - } - - g_assert (CLUTTER_IS_BOX_CHILD (meta)); - - box_child_set_expand (CLUTTER_BOX_CHILD (meta), expand); -} - -/** - * clutter_box_layout_get_expand: - * @layout: a #ClutterBoxLayout - * @actor: a #ClutterActor child of @layout - * - * Retrieves whether @actor should expand inside @layout - * - * Return value: %TRUE if the #ClutterActor should expand, %FALSE otherwise - * - * Since: 1.2 - * Deprecated: 1.12: #ClutterBoxLayout will honour #ClutterActor's - * #ClutterActor:x-expand and #ClutterActor:y-expand properies - */ -gboolean -clutter_box_layout_get_expand (ClutterBoxLayout *layout, - ClutterActor *actor) -{ - ClutterBoxLayoutPrivate *priv; - ClutterLayoutManager *manager; - ClutterLayoutMeta *meta; - - g_return_val_if_fail (CLUTTER_IS_BOX_LAYOUT (layout), FALSE); - g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), FALSE); - - priv = layout->priv; - - if (priv->container == NULL) - { - g_warning ("The layout of type '%s' must be associated to " - "a ClutterContainer before querying layout " - "properties", - G_OBJECT_TYPE_NAME (layout)); - return FALSE; - } - - manager = CLUTTER_LAYOUT_MANAGER (layout); - meta = clutter_layout_manager_get_child_meta (manager, - priv->container, - actor); - if (meta == NULL) - { - g_warning ("No layout meta found for the child of type '%s' " - "inside the layout manager of type '%s'", - G_OBJECT_TYPE_NAME (actor), - G_OBJECT_TYPE_NAME (manager)); - return FALSE; - } - - g_assert (CLUTTER_IS_BOX_CHILD (meta)); - - return CLUTTER_BOX_CHILD (meta)->expand; -} - -/** - * clutter_box_layout_set_use_animations: - * @layout: a #ClutterBoxLayout - * @animate: %TRUE if the @layout should use animations - * - * Sets whether @layout should animate changes in the layout properties - * - * The duration of the animations is controlled by - * clutter_box_layout_set_easing_duration(); the easing mode to be used - * by the animations is controlled by clutter_box_layout_set_easing_mode(). - * - * Enabling animations will override the easing state of each child - * of the actor using @layout, and will use the #ClutterBoxLayout:easing-mode - * and #ClutterBoxLayout:easing-duration properties instead. - * - * Since: 1.2 - * - * Deprecated: 1.12: The layout manager will honour the easing state - * of the children when allocating them. - */ -void -clutter_box_layout_set_use_animations (ClutterBoxLayout *layout, - gboolean animate) -{ - ClutterBoxLayoutPrivate *priv; - - g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout)); - - priv = layout->priv; - - if (priv->use_animations != animate) - { - priv->use_animations = animate; - - g_object_notify (G_OBJECT (layout), "use-animations"); - } -} - -/** - * clutter_box_layout_get_use_animations: - * @layout: a #ClutterBoxLayout - * - * Retrieves whether @layout should animate changes in the layout properties. - * - * Return value: %TRUE if the animations should be used, %FALSE otherwise - * - * Since: 1.2 - * - * Deprecated: 1.12 - */ -gboolean -clutter_box_layout_get_use_animations (ClutterBoxLayout *layout) -{ - g_return_val_if_fail (CLUTTER_IS_BOX_LAYOUT (layout), FALSE); - - return layout->priv->use_animations; -} - -/** - * clutter_box_layout_set_easing_mode: - * @layout: a #ClutterBoxLayout - * @mode: an easing mode, either from #ClutterAnimationMode or a logical id - * from clutter_alpha_register_func() - * - * Sets the easing mode to be used by @layout when animating changes in layout - * properties. - * - * Since: 1.2 - * - * Deprecated: 1.12: The layout manager will honour the easing state - * of the children when allocating them. - */ -void -clutter_box_layout_set_easing_mode (ClutterBoxLayout *layout, - gulong mode) -{ - ClutterBoxLayoutPrivate *priv; - - g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout)); - - priv = layout->priv; - - if (priv->easing_mode != mode) - { - priv->easing_mode = mode; - - g_object_notify (G_OBJECT (layout), "easing-mode"); - } -} - -/** - * clutter_box_layout_get_easing_mode: - * @layout: a #ClutterBoxLayout - * - * Retrieves the easing mode set using clutter_box_layout_set_easing_mode() - * - * Return value: an easing mode - * - * Since: 1.2 - * - * Deprecated: 1.12 - */ -gulong -clutter_box_layout_get_easing_mode (ClutterBoxLayout *layout) -{ - g_return_val_if_fail (CLUTTER_IS_BOX_LAYOUT (layout), - CLUTTER_EASE_OUT_CUBIC); - - return layout->priv->easing_mode; -} - -/** - * clutter_box_layout_set_easing_duration: - * @layout: a #ClutterBoxLayout - * @msecs: the duration of the animations, in milliseconds - * - * Sets the duration of the animations used by @layout when animating changes - * in the layout properties. - * - * Since: 1.2 - * - * Deprecated: 1.12: The layout manager will honour the easing state - * of the children when allocating them. - */ -void -clutter_box_layout_set_easing_duration (ClutterBoxLayout *layout, - guint msecs) -{ - ClutterBoxLayoutPrivate *priv; - - g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout)); - - priv = layout->priv; - - if (priv->easing_duration != msecs) - { - priv->easing_duration = msecs; - - g_object_notify (G_OBJECT (layout), "easing-duration"); - } -} - -/** - * clutter_box_layout_get_easing_duration: - * @layout: a #ClutterBoxLayout - * - * Retrieves the duration set using clutter_box_layout_set_easing_duration() - * - * Return value: the duration of the animations, in milliseconds - * - * Since: 1.2 - * - * Deprecated: 1.12 - */ -guint -clutter_box_layout_get_easing_duration (ClutterBoxLayout *layout) -{ - g_return_val_if_fail (CLUTTER_IS_BOX_LAYOUT (layout), 500); - - return layout->priv->easing_duration; -} diff --git a/examples/bin-layout.c b/examples/bin-layout.c index 7dc9b967d..f3bba09a8 100644 --- a/examples/bin-layout.c +++ b/examples/bin-layout.c @@ -180,9 +180,8 @@ main (int argc, char *argv[]) clutter_actor_show (stage); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); - /* this is our BinLayout, with its default alignments */ - layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, - CLUTTER_BIN_ALIGNMENT_CENTER); + /* this is our BinLayout */ + layout = clutter_bin_layout_new (); /* the main container; this actor will use the BinLayout to lay * out its children; we use the anchor point to keep it centered diff --git a/examples/box-layout.c b/examples/box-layout.c index 867b9f69a..fc36152f0 100644 --- a/examples/box-layout.c +++ b/examples/box-layout.c @@ -137,7 +137,6 @@ add_actor (ClutterActor *box, { ClutterActor *rect, *text; ClutterColor color; - ClutterLayoutManager *layout; clutter_color_from_hls (&color, g_random_double_range (0.0, 360.0), @@ -145,10 +144,8 @@ add_actor (ClutterActor *box, 0.5); color.alpha = 255; - layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, - CLUTTER_BIN_ALIGNMENT_CENTER); rect = clutter_actor_new (); - clutter_actor_set_layout_manager (rect, layout); + clutter_actor_set_layout_manager (rect, clutter_bin_layout_new ()); clutter_actor_set_background_color (rect, &color); clutter_actor_set_reactive (rect, TRUE); clutter_actor_set_size (rect, 32, 64); diff --git a/examples/grid-layout.c b/examples/grid-layout.c index c47d88139..68ae4a493 100644 --- a/examples/grid-layout.c +++ b/examples/grid-layout.c @@ -199,9 +199,9 @@ add_actor (ClutterActor *box, gint width, gint height) { + ClutterLayoutManager *layout; ClutterActor *rect, *text; ClutterColor color; - ClutterLayoutManager *layout; clutter_color_from_hls (&color, g_random_double_range (0.0, 360.0), @@ -209,10 +209,8 @@ add_actor (ClutterActor *box, 0.5); color.alpha = 255; - layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, - CLUTTER_BIN_ALIGNMENT_CENTER); rect = clutter_actor_new (); - clutter_actor_set_layout_manager (rect, layout); + clutter_actor_set_layout_manager (rect, clutter_bin_layout_new ()); clutter_actor_set_background_color (rect, &color); clutter_actor_set_reactive (rect, TRUE); @@ -341,10 +339,9 @@ main (int argc, char *argv[]) clutter_actor_set_x_expand (box, TRUE); clutter_actor_set_y_expand (box, TRUE); clutter_actor_set_layout_manager (box, grid_layout); - clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (stage_layout), box, - TRUE, TRUE, TRUE, - CLUTTER_BOX_ALIGNMENT_CENTER, - CLUTTER_BOX_ALIGNMENT_CENTER); + clutter_actor_add_child (stage, box); + clutter_actor_set_x_align (box, CLUTTER_ACTOR_ALIGN_FILL); + clutter_actor_set_y_align (box, CLUTTER_ACTOR_ALIGN_FILL); add_actor (box, 0, 0, 1, 1); add_actor (box, 1, 0, 1, 1); @@ -360,10 +357,9 @@ main (int argc, char *argv[]) clutter_actor_set_margin_top (instructions, 4); clutter_actor_set_margin_left (instructions, 4); clutter_actor_set_margin_bottom (instructions, 4); - clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (stage_layout), instructions, - FALSE, TRUE, FALSE, - CLUTTER_BOX_ALIGNMENT_START, - CLUTTER_BOX_ALIGNMENT_CENTER); + clutter_actor_add_child (stage, instructions); + clutter_actor_set_x_align (instructions, CLUTTER_ACTOR_ALIGN_FILL); + clutter_actor_set_y_align (instructions, CLUTTER_ACTOR_ALIGN_CENTER); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);