2009-09-14 07:04:42 -04:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Intel Corporation.
|
|
|
|
*
|
|
|
|
* 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Author:
|
|
|
|
* Emmanuele Bassi <ebassi@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:clutter-bin-layout
|
|
|
|
* @short_description: A simple layout manager
|
|
|
|
*
|
|
|
|
* #ClutterBinLayout is a layout manager which implements the following
|
|
|
|
* policy:
|
|
|
|
*
|
2014-03-17 19:07:58 -04:00
|
|
|
* - the preferred size is the maximum preferred size
|
2009-09-17 06:38:43 -04:00
|
|
|
* between all the children of the container using the
|
2014-03-17 19:07:58 -04:00
|
|
|
* layout;
|
|
|
|
* - each child is allocated in "layers", on on top
|
|
|
|
* of the other;
|
|
|
|
* - for each layer there are horizontal and vertical
|
|
|
|
* alignment policies.
|
2009-09-17 06:38:43 -04:00
|
|
|
*
|
2014-03-17 19:07:58 -04:00
|
|
|
* The [bin-layout example](https://git.gnome.org/browse/clutter/tree/examples/bin-layout.c?h=clutter-1.18)
|
|
|
|
* shows how to pack actors inside a #ClutterBinLayout.
|
2009-09-14 07:04:42 -04:00
|
|
|
*
|
|
|
|
* #ClutterBinLayout is available since Clutter 1.2
|
|
|
|
*/
|
|
|
|
|
2009-09-11 08:51:23 -04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2009-10-15 09:12:37 -04:00
|
|
|
#include <math.h>
|
|
|
|
|
2011-12-19 13:48:02 -05:00
|
|
|
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
|
|
|
|
#include "deprecated/clutter-container.h"
|
2012-03-29 12:27:34 -04:00
|
|
|
#include "deprecated/clutter-bin-layout.h"
|
2011-12-19 13:48:02 -05:00
|
|
|
|
2012-03-29 11:34:36 -04:00
|
|
|
#include "clutter-actor-private.h"
|
2009-09-11 08:51:23 -04:00
|
|
|
#include "clutter-animatable.h"
|
2009-09-14 16:51:49 -04:00
|
|
|
#include "clutter-child-meta.h"
|
2009-09-11 08:51:23 -04:00
|
|
|
#include "clutter-debug.h"
|
|
|
|
#include "clutter-enum-types.h"
|
2009-09-15 12:37:11 -04:00
|
|
|
#include "clutter-layout-meta.h"
|
2009-09-11 08:51:23 -04:00
|
|
|
#include "clutter-private.h"
|
|
|
|
|
2009-09-14 16:51:49 -04:00
|
|
|
#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))
|
|
|
|
|
|
|
|
typedef struct _ClutterBinLayer ClutterBinLayer;
|
2009-09-15 12:37:11 -04:00
|
|
|
typedef struct _ClutterLayoutMetaClass ClutterBinLayerClass;
|
2009-09-14 16:51:49 -04:00
|
|
|
|
2009-09-11 08:51:23 -04:00
|
|
|
struct _ClutterBinLayoutPrivate
|
|
|
|
{
|
|
|
|
ClutterBinAlignment x_align;
|
|
|
|
ClutterBinAlignment y_align;
|
|
|
|
|
2009-09-16 10:51:13 -04:00
|
|
|
ClutterContainer *container;
|
2009-09-11 08:51:23 -04:00
|
|
|
};
|
|
|
|
|
2009-09-14 16:51:49 -04:00
|
|
|
struct _ClutterBinLayer
|
|
|
|
{
|
2009-09-15 12:37:11 -04:00
|
|
|
ClutterLayoutMeta parent_instance;
|
2009-09-14 16:51:49 -04:00
|
|
|
|
|
|
|
ClutterBinAlignment x_align;
|
|
|
|
ClutterBinAlignment y_align;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_LAYER_0,
|
|
|
|
|
|
|
|
PROP_LAYER_X_ALIGN,
|
2010-10-15 10:24:27 -04:00
|
|
|
PROP_LAYER_Y_ALIGN,
|
|
|
|
|
|
|
|
PROP_LAYER_LAST
|
2009-09-14 16:51:49 -04:00
|
|
|
};
|
|
|
|
|
2009-09-11 08:51:23 -04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
|
|
|
|
PROP_X_ALIGN,
|
2010-06-21 05:20:32 -04:00
|
|
|
PROP_Y_ALIGN,
|
|
|
|
|
|
|
|
PROP_LAST
|
2009-09-11 08:51:23 -04:00
|
|
|
};
|
|
|
|
|
2010-10-15 10:24:27 -04:00
|
|
|
static GParamSpec *layer_props[PROP_LAYER_LAST] = { NULL, };
|
|
|
|
static GParamSpec *bin_props[PROP_LAST] = { NULL, };
|
2010-06-21 05:20:32 -04:00
|
|
|
|
2012-03-07 07:34:06 -05:00
|
|
|
GType clutter_bin_layer_get_type (void);
|
|
|
|
|
2009-09-14 16:51:49 -04:00
|
|
|
G_DEFINE_TYPE (ClutterBinLayer,
|
|
|
|
clutter_bin_layer,
|
2013-07-03 09:14:01 -04:00
|
|
|
CLUTTER_TYPE_LAYOUT_META)
|
2009-09-14 16:51:49 -04:00
|
|
|
|
2013-07-03 09:14:01 -04:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (ClutterBinLayout,
|
|
|
|
clutter_bin_layout,
|
|
|
|
CLUTTER_TYPE_LAYOUT_MANAGER)
|
2009-09-11 08:51:23 -04:00
|
|
|
|
2009-09-14 16:51:49 -04:00
|
|
|
/*
|
|
|
|
* ClutterBinLayer
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_layer_x_align (ClutterBinLayer *self,
|
|
|
|
ClutterBinAlignment alignment)
|
|
|
|
{
|
|
|
|
ClutterLayoutManager *manager;
|
2009-09-15 12:37:11 -04:00
|
|
|
ClutterLayoutMeta *meta;
|
2009-09-14 16:51:49 -04:00
|
|
|
|
|
|
|
if (self->x_align == alignment)
|
|
|
|
return;
|
|
|
|
|
|
|
|
self->x_align = alignment;
|
|
|
|
|
2009-09-15 12:37:11 -04:00
|
|
|
meta = CLUTTER_LAYOUT_META (self);
|
|
|
|
manager = clutter_layout_meta_get_manager (meta);
|
2009-09-14 16:51:49 -04:00
|
|
|
clutter_layout_manager_layout_changed (manager);
|
|
|
|
|
2011-03-03 06:35:46 -05:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), layer_props[PROP_LAYER_X_ALIGN]);
|
2009-09-14 16:51:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_layer_y_align (ClutterBinLayer *self,
|
|
|
|
ClutterBinAlignment alignment)
|
|
|
|
{
|
|
|
|
ClutterLayoutManager *manager;
|
2009-09-15 12:37:11 -04:00
|
|
|
ClutterLayoutMeta *meta;
|
2009-09-14 16:51:49 -04:00
|
|
|
|
|
|
|
if (self->y_align == alignment)
|
|
|
|
return;
|
|
|
|
|
|
|
|
self->y_align = alignment;
|
|
|
|
|
2009-09-15 12:37:11 -04:00
|
|
|
meta = CLUTTER_LAYOUT_META (self);
|
|
|
|
manager = clutter_layout_meta_get_manager (meta);
|
2009-09-14 16:51:49 -04:00
|
|
|
clutter_layout_manager_layout_changed (manager);
|
|
|
|
|
2011-03-03 06:35:46 -05:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), layer_props[PROP_LAYER_Y_ALIGN]);
|
2009-09-14 16:51:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2010-10-15 10:24:27 -04:00
|
|
|
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);
|
|
|
|
|
2011-03-03 06:35:46 -05:00
|
|
|
g_object_class_install_properties (gobject_class,
|
|
|
|
PROP_LAYER_LAST,
|
|
|
|
layer_props);
|
2009-09-14 16:51:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_bin_layer_init (ClutterBinLayer *layer)
|
|
|
|
{
|
|
|
|
layer->x_align = CLUTTER_BIN_ALIGNMENT_CENTER;
|
|
|
|
layer->y_align = CLUTTER_BIN_ALIGNMENT_CENTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ClutterBinLayout
|
|
|
|
*/
|
|
|
|
|
2009-09-11 08:51:23 -04:00
|
|
|
static void
|
|
|
|
set_x_align (ClutterBinLayout *self,
|
|
|
|
ClutterBinAlignment alignment)
|
|
|
|
{
|
|
|
|
ClutterBinLayoutPrivate *priv = self->priv;
|
|
|
|
|
|
|
|
if (priv->x_align != alignment)
|
|
|
|
{
|
2009-09-14 07:03:38 -04:00
|
|
|
ClutterLayoutManager *manager;
|
|
|
|
|
2009-09-11 08:51:23 -04:00
|
|
|
priv->x_align = alignment;
|
|
|
|
|
2009-09-14 07:03:38 -04:00
|
|
|
manager = CLUTTER_LAYOUT_MANAGER (self);
|
|
|
|
clutter_layout_manager_layout_changed (manager);
|
|
|
|
|
2011-03-03 06:35:46 -05:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), bin_props[PROP_X_ALIGN]);
|
2009-09-11 08:51:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_y_align (ClutterBinLayout *self,
|
|
|
|
ClutterBinAlignment alignment)
|
|
|
|
{
|
|
|
|
ClutterBinLayoutPrivate *priv = self->priv;
|
|
|
|
|
|
|
|
if (priv->y_align != alignment)
|
|
|
|
{
|
2009-09-14 07:03:38 -04:00
|
|
|
ClutterLayoutManager *manager;
|
|
|
|
|
2009-09-11 08:51:23 -04:00
|
|
|
priv->y_align = alignment;
|
|
|
|
|
2009-09-14 07:03:38 -04:00
|
|
|
manager = CLUTTER_LAYOUT_MANAGER (self);
|
|
|
|
clutter_layout_manager_layout_changed (manager);
|
|
|
|
|
2011-03-03 06:35:46 -05:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), bin_props[PROP_Y_ALIGN]);
|
2009-09-11 08:51:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_bin_layout_get_preferred_width (ClutterLayoutManager *manager,
|
|
|
|
ClutterContainer *container,
|
|
|
|
gfloat for_height,
|
|
|
|
gfloat *min_width_p,
|
|
|
|
gfloat *nat_width_p)
|
|
|
|
{
|
2011-12-18 05:29:01 -05:00
|
|
|
ClutterActor *actor = CLUTTER_ACTOR (container);
|
2012-01-30 05:55:30 -05:00
|
|
|
ClutterActorIter iter;
|
2011-12-18 05:29:01 -05:00
|
|
|
ClutterActor *child;
|
2009-09-11 08:51:23 -04:00
|
|
|
gfloat min_width, nat_width;
|
|
|
|
|
|
|
|
min_width = nat_width = 0.0;
|
|
|
|
|
2012-01-30 05:55:30 -05:00
|
|
|
clutter_actor_iter_init (&iter, actor);
|
|
|
|
while (clutter_actor_iter_next (&iter, &child))
|
2009-09-11 08:51:23 -04:00
|
|
|
{
|
|
|
|
gfloat minimum, natural;
|
|
|
|
|
2015-04-23 12:39:30 -04:00
|
|
|
if (!clutter_actor_is_visible (child))
|
2012-06-05 04:55:17 -04:00
|
|
|
continue;
|
|
|
|
|
2009-09-11 08:51:23 -04:00
|
|
|
clutter_actor_get_preferred_width (child, for_height,
|
|
|
|
&minimum,
|
|
|
|
&natural);
|
|
|
|
|
|
|
|
min_width = MAX (min_width, minimum);
|
|
|
|
nat_width = MAX (nat_width, natural);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (min_width_p)
|
|
|
|
*min_width_p = min_width;
|
|
|
|
|
|
|
|
if (nat_width_p)
|
|
|
|
*nat_width_p = nat_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_bin_layout_get_preferred_height (ClutterLayoutManager *manager,
|
|
|
|
ClutterContainer *container,
|
|
|
|
gfloat for_width,
|
|
|
|
gfloat *min_height_p,
|
|
|
|
gfloat *nat_height_p)
|
|
|
|
{
|
2011-12-18 05:29:01 -05:00
|
|
|
ClutterActor *actor = CLUTTER_ACTOR (container);
|
2012-01-30 05:55:30 -05:00
|
|
|
ClutterActorIter iter;
|
2011-12-18 05:29:01 -05:00
|
|
|
ClutterActor *child;
|
2009-09-11 08:51:23 -04:00
|
|
|
gfloat min_height, nat_height;
|
|
|
|
|
|
|
|
min_height = nat_height = 0.0;
|
|
|
|
|
2012-01-30 05:55:30 -05:00
|
|
|
clutter_actor_iter_init (&iter, actor);
|
|
|
|
while (clutter_actor_iter_next (&iter, &child))
|
2009-09-11 08:51:23 -04:00
|
|
|
{
|
|
|
|
gfloat minimum, natural;
|
|
|
|
|
2015-04-23 12:39:30 -04:00
|
|
|
if (!clutter_actor_is_visible (child))
|
2012-06-05 04:55:17 -04:00
|
|
|
continue;
|
|
|
|
|
2009-09-11 08:51:23 -04:00
|
|
|
clutter_actor_get_preferred_height (child, for_width,
|
|
|
|
&minimum,
|
|
|
|
&natural);
|
|
|
|
|
|
|
|
min_height = MAX (min_height, minimum);
|
|
|
|
nat_height = MAX (nat_height, natural);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (min_height_p)
|
|
|
|
*min_height_p = min_height;
|
|
|
|
|
|
|
|
if (nat_height_p)
|
|
|
|
*nat_height_p = nat_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gdouble
|
2012-09-19 06:40:33 -04:00
|
|
|
get_bin_alignment_factor (ClutterBinAlignment alignment,
|
|
|
|
ClutterTextDirection text_dir)
|
2009-09-11 08:51:23 -04:00
|
|
|
{
|
|
|
|
switch (alignment)
|
|
|
|
{
|
|
|
|
case CLUTTER_BIN_ALIGNMENT_CENTER:
|
|
|
|
return 0.5;
|
|
|
|
|
|
|
|
case CLUTTER_BIN_ALIGNMENT_START:
|
2012-09-19 06:40:33 -04:00
|
|
|
return text_dir == CLUTTER_TEXT_DIRECTION_LTR ? 0.0 : 1.0;
|
2009-09-11 08:51:23 -04:00
|
|
|
|
|
|
|
case CLUTTER_BIN_ALIGNMENT_END:
|
2012-09-19 06:40:33 -04:00
|
|
|
return text_dir == CLUTTER_TEXT_DIRECTION_LTR ? 1.0 : 0.0;
|
2009-09-11 08:51:23 -04:00
|
|
|
|
|
|
|
case CLUTTER_BIN_ALIGNMENT_FIXED:
|
|
|
|
case CLUTTER_BIN_ALIGNMENT_FILL:
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2012-03-29 11:34:36 -04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-09-11 08:51:23 -04:00
|
|
|
static void
|
|
|
|
clutter_bin_layout_allocate (ClutterLayoutManager *manager,
|
|
|
|
ClutterContainer *container,
|
|
|
|
const ClutterActorBox *allocation,
|
|
|
|
ClutterAllocationFlags flags)
|
|
|
|
{
|
2011-08-24 13:38:17 -04:00
|
|
|
gfloat allocation_x, allocation_y;
|
2009-09-11 08:51:23 -04:00
|
|
|
gfloat available_w, available_h;
|
2011-12-18 05:29:01 -05:00
|
|
|
ClutterActor *actor, *child;
|
2012-01-30 05:55:30 -05:00
|
|
|
ClutterActorIter iter;
|
2009-09-11 08:51:23 -04:00
|
|
|
|
2011-08-24 13:38:17 -04:00
|
|
|
clutter_actor_box_get_origin (allocation, &allocation_x, &allocation_y);
|
|
|
|
clutter_actor_box_get_size (allocation, &available_w, &available_h);
|
2009-09-11 08:51:23 -04:00
|
|
|
|
2011-12-18 05:29:01 -05:00
|
|
|
actor = CLUTTER_ACTOR (container);
|
|
|
|
|
2012-01-30 05:55:30 -05:00
|
|
|
clutter_actor_iter_init (&iter, actor);
|
|
|
|
while (clutter_actor_iter_next (&iter, &child))
|
2009-09-11 08:51:23 -04:00
|
|
|
{
|
2009-09-15 12:37:11 -04:00
|
|
|
ClutterLayoutMeta *meta;
|
2009-09-14 16:51:49 -04:00
|
|
|
ClutterBinLayer *layer;
|
2009-09-11 08:51:23 -04:00
|
|
|
ClutterActorBox child_alloc = { 0, };
|
2010-08-10 12:43:26 -04:00
|
|
|
gdouble x_align, y_align;
|
2012-08-09 12:11:10 -04:00
|
|
|
gboolean x_fill, y_fill, is_fixed_position_set;
|
|
|
|
float fixed_x, fixed_y;
|
2009-09-11 08:51:23 -04:00
|
|
|
|
2015-04-23 12:39:30 -04:00
|
|
|
if (!clutter_actor_is_visible (child))
|
2012-06-08 05:29:43 -04:00
|
|
|
continue;
|
|
|
|
|
2009-09-14 16:51:49 -04:00
|
|
|
meta = clutter_layout_manager_get_child_meta (manager,
|
|
|
|
container,
|
|
|
|
child);
|
|
|
|
layer = CLUTTER_BIN_LAYER (meta);
|
|
|
|
|
2012-08-09 12:11:10 -04:00
|
|
|
fixed_x = fixed_y = 0.f;
|
|
|
|
g_object_get (child,
|
|
|
|
"fixed-position-set", &is_fixed_position_set,
|
|
|
|
"fixed-x", &fixed_x,
|
|
|
|
"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)
|
2012-06-07 10:44:08 -04:00
|
|
|
{
|
2012-08-09 12:11:10 -04:00
|
|
|
if (is_fixed_position_set)
|
|
|
|
child_alloc.x1 = fixed_x;
|
|
|
|
else
|
|
|
|
child_alloc.x1 = clutter_actor_get_x (child);
|
2012-06-07 10:44:08 -04:00
|
|
|
}
|
2009-09-11 08:51:23 -04:00
|
|
|
else
|
2011-08-24 13:38:17 -04:00
|
|
|
child_alloc.x1 = allocation_x;
|
2009-09-11 08:51:23 -04:00
|
|
|
|
2012-08-09 12:11:10 -04:00
|
|
|
if (is_fixed_position_set ||
|
|
|
|
layer->y_align == CLUTTER_BIN_ALIGNMENT_FIXED)
|
2012-06-07 10:44:08 -04:00
|
|
|
{
|
2012-08-09 12:11:10 -04:00
|
|
|
if (is_fixed_position_set)
|
|
|
|
child_alloc.y1 = fixed_y;
|
|
|
|
else
|
2012-06-07 10:44:08 -04:00
|
|
|
child_alloc.y1 = clutter_actor_get_y (child);
|
|
|
|
}
|
2009-09-11 08:51:23 -04:00
|
|
|
else
|
2011-08-24 13:38:17 -04:00
|
|
|
child_alloc.y1 = allocation_y;
|
2010-08-10 12:43:26 -04:00
|
|
|
|
2013-07-05 19:38:28 -04:00
|
|
|
child_alloc.x2 = allocation_x + available_w;
|
|
|
|
child_alloc.y2 = allocation_y + available_h;
|
2009-09-11 08:51:23 -04:00
|
|
|
|
2012-04-20 07:45:54 -04:00
|
|
|
if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_HORIZONTAL))
|
2012-03-29 11:34:36 -04:00
|
|
|
{
|
|
|
|
ClutterActorAlign align;
|
|
|
|
|
2012-09-19 06:40:33 -04:00
|
|
|
align = clutter_actor_get_x_align (child);
|
2012-03-29 11:34:36 -04:00
|
|
|
x_fill = align == CLUTTER_ACTOR_ALIGN_FILL;
|
|
|
|
x_align = get_actor_align_factor (align);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-19 06:40:33 -04:00
|
|
|
ClutterTextDirection text_dir;
|
|
|
|
|
2012-03-29 11:34:36 -04:00
|
|
|
x_fill = (layer->x_align == CLUTTER_BIN_ALIGNMENT_FILL);
|
2012-08-20 09:47:53 -04:00
|
|
|
|
2012-09-19 06:40:33 -04:00
|
|
|
text_dir = clutter_actor_get_text_direction (child);
|
|
|
|
|
2012-08-20 09:47:53 -04:00
|
|
|
if (!is_fixed_position_set)
|
2012-09-19 06:40:33 -04:00
|
|
|
x_align = get_bin_alignment_factor (layer->x_align, text_dir);
|
2012-08-20 09:47:53 -04:00
|
|
|
else
|
|
|
|
x_align = 0.0;
|
2012-03-29 11:34:36 -04:00
|
|
|
}
|
|
|
|
|
2012-04-20 07:45:54 -04:00
|
|
|
if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_VERTICAL))
|
2012-03-29 11:34:36 -04:00
|
|
|
{
|
|
|
|
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);
|
2012-08-20 09:47:53 -04:00
|
|
|
|
|
|
|
if (!is_fixed_position_set)
|
2012-09-19 06:40:33 -04:00
|
|
|
y_align = get_bin_alignment_factor (layer->y_align,
|
|
|
|
CLUTTER_TEXT_DIRECTION_LTR);
|
2012-08-20 09:47:53 -04:00
|
|
|
else
|
|
|
|
y_align = 0.0;
|
2012-03-29 11:34:36 -04:00
|
|
|
}
|
2009-09-11 08:51:23 -04:00
|
|
|
|
2010-08-10 12:43:26 -04:00
|
|
|
clutter_actor_allocate_align_fill (child, &child_alloc,
|
|
|
|
x_align, y_align,
|
|
|
|
x_fill, y_fill,
|
|
|
|
flags);
|
2009-09-11 08:51:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-05 07:23:22 -05:00
|
|
|
static GType
|
|
|
|
clutter_bin_layout_get_child_meta_type (ClutterLayoutManager *manager)
|
|
|
|
{
|
|
|
|
return CLUTTER_TYPE_BIN_LAYER;
|
|
|
|
}
|
|
|
|
|
2009-09-15 12:37:11 -04:00
|
|
|
static ClutterLayoutMeta *
|
2009-09-14 16:51:49 -04:00
|
|
|
clutter_bin_layout_create_child_meta (ClutterLayoutManager *manager,
|
|
|
|
ClutterContainer *container,
|
|
|
|
ClutterActor *actor)
|
|
|
|
{
|
|
|
|
ClutterBinLayoutPrivate *priv;
|
|
|
|
|
|
|
|
priv = CLUTTER_BIN_LAYOUT (manager)->priv;
|
|
|
|
|
2009-09-15 12:37:11 -04:00
|
|
|
return g_object_new (CLUTTER_TYPE_BIN_LAYER,
|
2009-09-14 16:51:49 -04:00
|
|
|
"container", container,
|
|
|
|
"actor", actor,
|
2009-09-15 12:37:11 -04:00
|
|
|
"manager", manager,
|
2009-09-14 16:51:49 -04:00
|
|
|
"x-align", priv->x_align,
|
|
|
|
"y_align", priv->y_align,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2009-09-16 10:51:13 -04:00
|
|
|
static void
|
|
|
|
clutter_bin_layout_set_container (ClutterLayoutManager *manager,
|
|
|
|
ClutterContainer *container)
|
|
|
|
{
|
|
|
|
ClutterBinLayoutPrivate *priv;
|
2010-06-07 16:34:36 -04:00
|
|
|
ClutterLayoutManagerClass *parent_class;
|
2009-09-16 10:51:13 -04:00
|
|
|
|
|
|
|
priv = CLUTTER_BIN_LAYOUT (manager)->priv;
|
|
|
|
priv->container = container;
|
2010-06-07 16:34:36 -04:00
|
|
|
|
|
|
|
parent_class = CLUTTER_LAYOUT_MANAGER_CLASS (clutter_bin_layout_parent_class);
|
|
|
|
parent_class->set_container (manager, container);
|
2009-09-16 10:51:13 -04:00
|
|
|
}
|
|
|
|
|
2009-09-11 08:51:23 -04:00
|
|
|
static void
|
|
|
|
clutter_bin_layout_set_property (GObject *gobject,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2009-09-17 06:38:43 -04:00
|
|
|
ClutterBinLayout *layout = CLUTTER_BIN_LAYOUT (gobject);
|
|
|
|
|
2009-09-11 08:51:23 -04:00
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_X_ALIGN:
|
2009-09-17 06:38:43 -04:00
|
|
|
set_x_align (layout, g_value_get_enum (value));
|
2009-09-11 08:51:23 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_Y_ALIGN:
|
2009-09-17 06:38:43 -04:00
|
|
|
set_y_align (layout, g_value_get_enum (value));
|
2009-09-11 08:51:23 -04:00
|
|
|
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);
|
|
|
|
|
2009-09-14 07:04:42 -04:00
|
|
|
/**
|
|
|
|
* ClutterBinLayout:x-align:
|
|
|
|
*
|
2009-09-17 06:38:43 -04:00
|
|
|
* The default horizontal alignment policy for actors managed
|
|
|
|
* by the #ClutterBinLayout
|
2009-09-14 07:04:42 -04:00
|
|
|
*
|
|
|
|
* Since: 1.2
|
2012-03-29 12:27:34 -04:00
|
|
|
*
|
|
|
|
* Deprecated: 1.12: Use the #ClutterActor:x-expand and the
|
|
|
|
* #ClutterActor:x-align properties on #ClutterActor instead.
|
2009-09-14 07:04:42 -04:00
|
|
|
*/
|
2010-10-15 10:24:27 -04:00
|
|
|
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);
|
2009-09-11 08:51:23 -04:00
|
|
|
|
2009-09-14 07:04:42 -04:00
|
|
|
/**
|
|
|
|
* ClutterBinLayout:y-align:
|
|
|
|
*
|
2009-09-17 06:38:43 -04:00
|
|
|
* The default vertical alignment policy for actors managed
|
|
|
|
* by the #ClutterBinLayout
|
2009-09-14 07:04:42 -04:00
|
|
|
*
|
|
|
|
* Since: 1.2
|
2012-03-29 12:27:34 -04:00
|
|
|
*
|
|
|
|
* Deprecated: 1.12: Use the #ClutterActor:y-expand and the
|
|
|
|
* #ClutterActor:y-align properties on #ClutterActor instead.
|
2009-09-14 07:04:42 -04:00
|
|
|
*/
|
2010-10-15 10:24:27 -04:00
|
|
|
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;
|
2012-01-30 05:55:30 -05:00
|
|
|
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;
|
2009-09-11 08:51:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_bin_layout_init (ClutterBinLayout *self)
|
|
|
|
{
|
2013-07-03 09:14:01 -04:00
|
|
|
self->priv = clutter_bin_layout_get_instance_private (self);
|
2009-09-11 08:51:23 -04:00
|
|
|
|
|
|
|
self->priv->x_align = CLUTTER_BIN_ALIGNMENT_CENTER;
|
|
|
|
self->priv->y_align = CLUTTER_BIN_ALIGNMENT_CENTER;
|
|
|
|
}
|
|
|
|
|
2009-09-14 07:04:42 -04:00
|
|
|
/**
|
|
|
|
* clutter_bin_layout_new:
|
2009-09-14 16:51:49 -04:00
|
|
|
* @x_align: the default alignment policy to be used on the
|
2009-09-14 07:04:42 -04:00
|
|
|
* horizontal axis
|
2009-09-14 16:51:49 -04:00
|
|
|
* @y_align: the default alignment policy to be used on the
|
2009-09-14 07:04:42 -04:00
|
|
|
* vertical axis
|
|
|
|
*
|
|
|
|
* Creates a new #ClutterBinLayout layout manager
|
|
|
|
*
|
|
|
|
* Return value: the newly created layout manager
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
2009-09-11 08:51:23 -04:00
|
|
|
ClutterLayoutManager *
|
|
|
|
clutter_bin_layout_new (ClutterBinAlignment x_align,
|
|
|
|
ClutterBinAlignment y_align)
|
|
|
|
{
|
|
|
|
return g_object_new (CLUTTER_TYPE_BIN_LAYOUT,
|
|
|
|
"x-align", x_align,
|
|
|
|
"y-align", y_align,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2009-09-14 07:04:42 -04:00
|
|
|
/**
|
|
|
|
* clutter_bin_layout_set_alignment:
|
|
|
|
* @self: a #ClutterBinLayout
|
2009-09-16 10:51:13 -04:00
|
|
|
* @child: (allow-none): a child of @container
|
2009-09-14 16:51:49 -04:00
|
|
|
* @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
|
2009-09-14 07:04:42 -04:00
|
|
|
*
|
2009-09-14 16:51:49 -04:00
|
|
|
* Sets the horizontal and vertical alignment policies to be applied
|
2009-09-16 10:51:13 -04:00
|
|
|
* 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
|
2009-09-14 07:04:42 -04:00
|
|
|
*
|
|
|
|
* Since: 1.2
|
2012-03-29 12:27:34 -04:00
|
|
|
*
|
|
|
|
* Deprecated: 1.12: Use the #ClutterActor:x-align and
|
|
|
|
* #ClutterActor:y-align properties of #ClutterActor instead.
|
2009-09-14 07:04:42 -04:00
|
|
|
*/
|
2009-09-11 08:51:23 -04:00
|
|
|
void
|
|
|
|
clutter_bin_layout_set_alignment (ClutterBinLayout *self,
|
2009-09-14 16:51:49 -04:00
|
|
|
ClutterActor *child,
|
2009-09-11 08:51:23 -04:00
|
|
|
ClutterBinAlignment x_align,
|
|
|
|
ClutterBinAlignment y_align)
|
|
|
|
{
|
2009-09-16 10:51:13 -04:00
|
|
|
ClutterBinLayoutPrivate *priv;
|
2009-09-14 16:51:49 -04:00
|
|
|
ClutterLayoutManager *manager;
|
2009-09-15 12:37:11 -04:00
|
|
|
ClutterLayoutMeta *meta;
|
2009-09-14 16:51:49 -04:00
|
|
|
|
2009-09-11 08:51:23 -04:00
|
|
|
g_return_if_fail (CLUTTER_IS_BIN_LAYOUT (self));
|
2009-09-17 06:38:43 -04:00
|
|
|
g_return_if_fail (child == NULL || CLUTTER_IS_ACTOR (child));
|
2009-09-11 08:51:23 -04:00
|
|
|
|
2009-09-16 10:51:13 -04:00
|
|
|
priv = self->priv;
|
|
|
|
|
2009-09-17 06:38:43 -04:00
|
|
|
if (priv->container == NULL)
|
2009-09-16 10:51:13 -04:00
|
|
|
{
|
2009-09-17 06:38:43 -04:00
|
|
|
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));
|
2009-09-16 10:51:13 -04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-09-14 16:51:49 -04:00
|
|
|
manager = CLUTTER_LAYOUT_MANAGER (self);
|
2009-09-16 10:51:13 -04:00
|
|
|
meta = clutter_layout_manager_get_child_meta (manager,
|
|
|
|
priv->container,
|
|
|
|
child);
|
2009-09-17 06:38:43 -04:00
|
|
|
g_assert (CLUTTER_IS_BIN_LAYER (meta));
|
2009-09-14 07:04:42 -04:00
|
|
|
|
2009-09-17 06:38:43 -04:00
|
|
|
set_layer_x_align (CLUTTER_BIN_LAYER (meta), x_align);
|
|
|
|
set_layer_y_align (CLUTTER_BIN_LAYER (meta), y_align);
|
2009-09-11 08:51:23 -04:00
|
|
|
}
|
|
|
|
|
2009-09-14 07:04:42 -04:00
|
|
|
/**
|
|
|
|
* clutter_bin_layout_get_alignment:
|
|
|
|
* @self: a #ClutterBinLayout
|
2009-09-16 10:51:13 -04:00
|
|
|
* @child: (allow-none): a child of @container
|
2009-09-14 07:04:42 -04:00
|
|
|
* @x_align: (out) (allow-none): return location for the horizontal
|
|
|
|
* alignment policy
|
|
|
|
* @y_align: (out) (allow-none): return location for the vertical
|
|
|
|
* alignment policy
|
|
|
|
*
|
2009-09-16 10:51:13 -04:00
|
|
|
* Retrieves the horizontal and vertical alignment policies for
|
|
|
|
* a child of @self
|
|
|
|
*
|
|
|
|
* If @child is %NULL the default alignment policies will be returned
|
|
|
|
* instead
|
2009-09-14 07:04:42 -04:00
|
|
|
*
|
|
|
|
* Since: 1.2
|
2012-03-29 12:27:34 -04:00
|
|
|
*
|
|
|
|
* Deprecated: 1.12: Use the #ClutterActor:x-align and the
|
|
|
|
* #ClutterActor:y-align properties of #ClutterActor instead.
|
2009-09-14 07:04:42 -04:00
|
|
|
*/
|
2009-09-11 08:51:23 -04:00
|
|
|
void
|
|
|
|
clutter_bin_layout_get_alignment (ClutterBinLayout *self,
|
2009-09-14 16:51:49 -04:00
|
|
|
ClutterActor *child,
|
2009-09-11 08:51:23 -04:00
|
|
|
ClutterBinAlignment *x_align,
|
|
|
|
ClutterBinAlignment *y_align)
|
|
|
|
{
|
2009-09-16 10:51:13 -04:00
|
|
|
ClutterBinLayoutPrivate *priv;
|
2009-09-14 16:51:49 -04:00
|
|
|
ClutterLayoutManager *manager;
|
2009-09-15 12:37:11 -04:00
|
|
|
ClutterLayoutMeta *meta;
|
2009-09-14 16:51:49 -04:00
|
|
|
ClutterBinLayer *layer;
|
|
|
|
|
2009-09-11 08:51:23 -04:00
|
|
|
g_return_if_fail (CLUTTER_IS_BIN_LAYOUT (self));
|
|
|
|
|
2009-09-16 10:51:13 -04:00
|
|
|
priv = self->priv;
|
|
|
|
|
2009-09-17 06:38:43 -04:00
|
|
|
if (priv->container == NULL)
|
2009-09-16 10:51:13 -04:00
|
|
|
{
|
2009-09-17 06:38:43 -04:00
|
|
|
if (child == NULL)
|
|
|
|
{
|
|
|
|
if (x_align)
|
|
|
|
*x_align = priv->x_align;
|
2009-09-16 10:51:13 -04:00
|
|
|
|
2009-09-17 06:38:43 -04:00
|
|
|
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));
|
2009-09-16 10:51:13 -04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-09-14 16:51:49 -04:00
|
|
|
manager = CLUTTER_LAYOUT_MANAGER (self);
|
2009-09-16 10:51:13 -04:00
|
|
|
meta = clutter_layout_manager_get_child_meta (manager,
|
|
|
|
priv->container,
|
|
|
|
child);
|
2009-09-17 06:38:43 -04:00
|
|
|
g_assert (CLUTTER_IS_BIN_LAYER (meta));
|
2009-09-14 16:51:49 -04:00
|
|
|
|
|
|
|
layer = CLUTTER_BIN_LAYER (meta);
|
|
|
|
|
2009-09-11 08:51:23 -04:00
|
|
|
if (x_align)
|
2009-09-14 16:51:49 -04:00
|
|
|
*x_align = layer->x_align;
|
2009-09-11 08:51:23 -04:00
|
|
|
|
|
|
|
if (y_align)
|
2009-09-14 16:51:49 -04:00
|
|
|
*y_align = layer->y_align;
|
2009-09-11 08:51:23 -04:00
|
|
|
}
|
2009-09-16 10:51:13 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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()
|
2009-09-17 06:38:43 -04:00
|
|
|
* and clutter_layout_manager_child_set_property() but it does not
|
|
|
|
* require a pointer to the #ClutterContainer associated to the
|
|
|
|
* #ClutterBinLayout
|
2009-09-16 10:51:13 -04:00
|
|
|
*
|
|
|
|
* Since: 1.2
|
2012-03-29 12:27:34 -04:00
|
|
|
*
|
|
|
|
* Deprecated: 1.12: Use clutter_actor_add_child() instead.
|
2009-09-16 10:51:13 -04:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_bin_layout_add (ClutterBinLayout *self,
|
|
|
|
ClutterActor *child,
|
|
|
|
ClutterBinAlignment x_align,
|
|
|
|
ClutterBinAlignment y_align)
|
|
|
|
{
|
|
|
|
ClutterBinLayoutPrivate *priv;
|
2009-09-17 06:38:43 -04:00
|
|
|
ClutterLayoutManager *manager;
|
|
|
|
ClutterLayoutMeta *meta;
|
2009-09-16 10:51:13 -04:00
|
|
|
|
|
|
|
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_container_add_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));
|
|
|
|
|
2009-09-17 06:38:43 -04:00
|
|
|
set_layer_x_align (CLUTTER_BIN_LAYER (meta), x_align);
|
|
|
|
set_layer_y_align (CLUTTER_BIN_LAYER (meta), y_align);
|
2009-09-16 10:51:13 -04:00
|
|
|
}
|