|
Packit Service |
bf98b9 |
/*
|
|
Packit Service |
bf98b9 |
* Clutter.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* An OpenGL based 'interactive canvas' library.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Copyright (C) 2010 Red Hat, Inc.
|
|
Packit Service |
bf98b9 |
* Copyright (C) 2012 Bastian Winkler <buz@netbuz.org>
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* This library is free software; you can redistribute it and/or
|
|
Packit Service |
bf98b9 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
bf98b9 |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
bf98b9 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* This library is distributed in the hope that it will be useful,
|
|
Packit Service |
bf98b9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
bf98b9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
bf98b9 |
* Lesser General Public License for more details.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
bf98b9 |
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Author:
|
|
Packit Service |
bf98b9 |
* Bastian Winkler <buz@netbuz.org>
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Based on GtkGrid widget by:
|
|
Packit Service |
bf98b9 |
* Matthias Clasen
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
bf98b9 |
#include "config.h"
|
|
Packit Service |
bf98b9 |
#endif
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
#include <string.h>
|
|
Packit Service |
bf98b9 |
#include <math.h>
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
#include "clutter-grid-layout.h"
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
#include "clutter-actor-private.h"
|
|
Packit Service |
bf98b9 |
#include "clutter-container.h"
|
|
Packit Service |
bf98b9 |
#include "clutter-debug.h"
|
|
Packit Service |
bf98b9 |
#include "clutter-enum-types.h"
|
|
Packit Service |
bf98b9 |
#include "clutter-layout-meta.h"
|
|
Packit Service |
bf98b9 |
#include "clutter-private.h"
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* SECTION:clutter-grid-layout
|
|
Packit Service |
bf98b9 |
* @Short_description: A layout manager for a grid of actors
|
|
Packit Service |
bf98b9 |
* @Title: ClutterGridLayout
|
|
Packit Service |
bf98b9 |
* @See_also: #ClutterTableLayout, #ClutterBoxLayout
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* #ClutterGridLayout is a layout manager which arranges its child widgets in
|
|
Packit Service |
bf98b9 |
* rows and columns. It is a very similar to #ClutterTableLayout and
|
|
Packit Service |
bf98b9 |
* #ClutterBoxLayout, but it consistently uses #ClutterActor's
|
|
Packit Service |
bf98b9 |
* alignment and expansion flags instead of custom child properties.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Children are added using clutter_grid_layout_attach(). They can span
|
|
Packit Service |
bf98b9 |
* multiple rows or columns. It is also possible to add a child next to an
|
|
Packit Service |
bf98b9 |
* existing child, using clutter_grid_layout_attach_next_to(). The behaviour of
|
|
Packit Service |
bf98b9 |
* #ClutterGridLayout when several children occupy the same grid cell is undefined.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* #ClutterGridLayout can be used like a #ClutterBoxLayout by just using
|
|
Packit Service |
bf98b9 |
* clutter_actor_add_child(), which will place children next to each other in
|
|
Packit Service |
bf98b9 |
* the direction determined by the #ClutterGridLayout:orientation property.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
#define CLUTTER_TYPE_GRID_CHILD (clutter_grid_child_get_type ())
|
|
Packit Service |
bf98b9 |
#define CLUTTER_GRID_CHILD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_GRID_CHILD, ClutterGridChild))
|
|
Packit Service |
bf98b9 |
#define CLUTTER_IS_GRID_CHILD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_GRID_CHILD))
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
typedef struct _ClutterGridChild ClutterGridChild;
|
|
Packit Service |
bf98b9 |
typedef struct _ClutterLayoutMetaClass ClutterGridChildClass;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
typedef struct _ClutterGridAttach ClutterGridAttach;
|
|
Packit Service |
bf98b9 |
typedef struct _ClutterGridLine ClutterGridLine;
|
|
Packit Service |
bf98b9 |
typedef struct _ClutterGridLines ClutterGridLines;
|
|
Packit Service |
bf98b9 |
typedef struct _ClutterGridLineData ClutterGridLineData;
|
|
Packit Service |
bf98b9 |
typedef struct _ClutterGridRequest ClutterGridRequest;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
struct _ClutterGridAttach
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
gint pos;
|
|
Packit Service |
bf98b9 |
gint span;
|
|
Packit Service |
bf98b9 |
};
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
struct _ClutterGridChild
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterLayoutMeta parent_instance;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
ClutterGridAttach attach[2];
|
|
Packit Service |
bf98b9 |
};
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
#define CHILD_LEFT(child) ((child)->attach[CLUTTER_ORIENTATION_HORIZONTAL].pos)
|
|
Packit Service |
bf98b9 |
#define CHILD_WIDTH(child) ((child)->attach[CLUTTER_ORIENTATION_HORIZONTAL].span)
|
|
Packit Service |
bf98b9 |
#define CHILD_TOP(child) ((child)->attach[CLUTTER_ORIENTATION_VERTICAL].pos)
|
|
Packit Service |
bf98b9 |
#define CHILD_HEIGHT(child) ((child)->attach[CLUTTER_ORIENTATION_VERTICAL].span)
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* A ClutterGridLineData struct contains row/column specific parts
|
|
Packit Service |
bf98b9 |
* of the grid.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
struct _ClutterGridLineData
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
gfloat spacing;
|
|
Packit Service |
bf98b9 |
guint homogeneous : 1;
|
|
Packit Service |
bf98b9 |
};
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
struct _ClutterGridLayoutPrivate
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterContainer *container;
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
ClutterGridLineData linedata[2];
|
|
Packit Service |
bf98b9 |
};
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
#define ROWS(priv) (&(priv)->linedata[CLUTTER_ORIENTATION_HORIZONTAL])
|
|
Packit Service |
bf98b9 |
#define COLUMNS(priv) (&(priv)->linedata[CLUTTER_ORIENTATION_VERTICAL])
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* A ClutterGridLine struct represents a single row or column
|
|
Packit Service |
bf98b9 |
* during size requests
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
struct _ClutterGridLine
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
gfloat minimum;
|
|
Packit Service |
bf98b9 |
gfloat natural;
|
|
Packit Service |
bf98b9 |
gfloat position;
|
|
Packit Service |
bf98b9 |
gfloat allocation;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
guint need_expand : 1;
|
|
Packit Service |
bf98b9 |
guint expand : 1;
|
|
Packit Service |
bf98b9 |
guint empty : 1;
|
|
Packit Service |
bf98b9 |
};
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
struct _ClutterGridLines
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLine *lines;
|
|
Packit Service |
bf98b9 |
gint min, max;
|
|
Packit Service |
bf98b9 |
};
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
struct _ClutterGridRequest
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayout *grid;
|
|
Packit Service |
bf98b9 |
ClutterGridLines lines[2];
|
|
Packit Service |
bf98b9 |
};
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
enum
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
PROP_0,
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
PROP_ORIENTATION,
|
|
Packit Service |
bf98b9 |
PROP_ROW_SPACING,
|
|
Packit Service |
bf98b9 |
PROP_COLUMN_SPACING,
|
|
Packit Service |
bf98b9 |
PROP_ROW_HOMOGENEOUS,
|
|
Packit Service |
bf98b9 |
PROP_COLUMN_HOMOGENEOUS,
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
PROP_LAST
|
|
Packit Service |
bf98b9 |
};
|
|
Packit Service |
bf98b9 |
static GParamSpec *obj_props[PROP_LAST];
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
enum
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
PROP_CHILD_0,
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
PROP_CHILD_LEFT_ATTACH,
|
|
Packit Service |
bf98b9 |
PROP_CHILD_TOP_ATTACH,
|
|
Packit Service |
bf98b9 |
PROP_CHILD_WIDTH,
|
|
Packit Service |
bf98b9 |
PROP_CHILD_HEIGHT,
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
PROP_CHILD_LAST
|
|
Packit Service |
bf98b9 |
};
|
|
Packit Service |
bf98b9 |
static GParamSpec *child_props[PROP_CHILD_LAST];
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
GType clutter_grid_child_get_type (void);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
G_DEFINE_TYPE (ClutterGridChild, clutter_grid_child,
|
|
Packit Service |
bf98b9 |
CLUTTER_TYPE_LAYOUT_META)
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
G_DEFINE_TYPE_WITH_PRIVATE (ClutterGridLayout,
|
|
Packit Service |
bf98b9 |
clutter_grid_layout,
|
|
Packit Service |
bf98b9 |
CLUTTER_TYPE_LAYOUT_MANAGER)
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
#define GET_GRID_CHILD(grid, child) \
|
|
Packit Service |
bf98b9 |
(CLUTTER_GRID_CHILD(clutter_layout_manager_get_child_meta \
|
|
Packit Service |
bf98b9 |
(CLUTTER_LAYOUT_MANAGER((grid)),\
|
|
Packit Service |
bf98b9 |
CLUTTER_GRID_LAYOUT((grid))->priv->container,(child))))
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
grid_attach (ClutterGridLayout *self,
|
|
Packit Service |
bf98b9 |
ClutterActor *actor,
|
|
Packit Service |
bf98b9 |
gint left,
|
|
Packit Service |
bf98b9 |
gint top,
|
|
Packit Service |
bf98b9 |
gint width,
|
|
Packit Service |
bf98b9 |
gint height)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
grid_child = GET_GRID_CHILD (self, actor);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
CHILD_LEFT (grid_child) = left;
|
|
Packit Service |
bf98b9 |
CHILD_TOP (grid_child) = top;
|
|
Packit Service |
bf98b9 |
CHILD_WIDTH (grid_child) = width;
|
|
Packit Service |
bf98b9 |
CHILD_HEIGHT (grid_child) = height;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Find the position 'touching' existing
|
|
Packit Service |
bf98b9 |
* children. @orientation and @max determine
|
|
Packit Service |
bf98b9 |
* from which direction to approach (horizontal
|
|
Packit Service |
bf98b9 |
* + max = right, vertical + !max = top, etc).
|
|
Packit Service |
bf98b9 |
* @op_pos, @op_span determine the rows/columns
|
|
Packit Service |
bf98b9 |
* in which the touching has to happen.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
static gint
|
|
Packit Service |
bf98b9 |
find_attach_position (ClutterGridLayout *self,
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation,
|
|
Packit Service |
bf98b9 |
gint op_pos,
|
|
Packit Service |
bf98b9 |
gint op_span,
|
|
Packit Service |
bf98b9 |
gboolean max)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = self->priv;
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child;
|
|
Packit Service |
bf98b9 |
ClutterGridAttach *attach;
|
|
Packit Service |
bf98b9 |
ClutterGridAttach *opposite;
|
|
Packit Service |
bf98b9 |
ClutterActorIter iter;
|
|
Packit Service |
bf98b9 |
ClutterActor *child;
|
|
Packit Service |
bf98b9 |
gint pos;
|
|
Packit Service |
bf98b9 |
gboolean hit;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (max)
|
|
Packit Service |
bf98b9 |
pos = -G_MAXINT;
|
|
Packit Service |
bf98b9 |
else
|
|
Packit Service |
bf98b9 |
pos = G_MAXINT;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
hit = FALSE;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (!priv->container)
|
|
Packit Service |
bf98b9 |
return -1;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (priv->container));
|
|
Packit Service |
bf98b9 |
while (clutter_actor_iter_next (&iter, &child))
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
grid_child = GET_GRID_CHILD (self, child);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
attach = &grid_child->attach[orientation];
|
|
Packit Service |
bf98b9 |
opposite = &grid_child->attach[1 - orientation];
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* check if the ranges overlap */
|
|
Packit Service |
bf98b9 |
if (opposite->pos <= op_pos + op_span && op_pos <= opposite->pos + opposite->span)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
hit = TRUE;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (max)
|
|
Packit Service |
bf98b9 |
pos = MAX (pos, attach->pos + attach->span);
|
|
Packit Service |
bf98b9 |
else
|
|
Packit Service |
bf98b9 |
pos = MIN (pos, attach->pos);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (!hit)
|
|
Packit Service |
bf98b9 |
pos = 0;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
return pos;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
grid_attach_next_to (ClutterGridLayout *layout,
|
|
Packit Service |
bf98b9 |
ClutterActor *child,
|
|
Packit Service |
bf98b9 |
ClutterActor *sibling,
|
|
Packit Service |
bf98b9 |
ClutterGridPosition side,
|
|
Packit Service |
bf98b9 |
gint width,
|
|
Packit Service |
bf98b9 |
gint height)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_sibling;
|
|
Packit Service |
bf98b9 |
gint left, top;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (sibling)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
grid_sibling = GET_GRID_CHILD (layout, sibling);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
switch (side)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
case CLUTTER_GRID_POSITION_LEFT:
|
|
Packit Service |
bf98b9 |
left = CHILD_LEFT (grid_sibling) - width;
|
|
Packit Service |
bf98b9 |
top = CHILD_TOP (grid_sibling);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case CLUTTER_GRID_POSITION_RIGHT:
|
|
Packit Service |
bf98b9 |
left = CHILD_LEFT (grid_sibling) + CHILD_WIDTH (grid_sibling);
|
|
Packit Service |
bf98b9 |
top = CHILD_TOP (grid_sibling);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case CLUTTER_GRID_POSITION_TOP:
|
|
Packit Service |
bf98b9 |
left = CHILD_LEFT (grid_sibling);
|
|
Packit Service |
bf98b9 |
top = CHILD_TOP (grid_sibling) - height;
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case CLUTTER_GRID_POSITION_BOTTOM:
|
|
Packit Service |
bf98b9 |
left = CHILD_LEFT (grid_sibling);
|
|
Packit Service |
bf98b9 |
top = CHILD_TOP (grid_sibling) + CHILD_HEIGHT (grid_sibling);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
default:
|
|
Packit Service |
bf98b9 |
g_assert_not_reached ();
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
else
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
switch (side)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
case CLUTTER_GRID_POSITION_LEFT:
|
|
Packit Service |
bf98b9 |
left = find_attach_position (layout, CLUTTER_ORIENTATION_HORIZONTAL,
|
|
Packit Service |
bf98b9 |
0, height, FALSE);
|
|
Packit Service |
bf98b9 |
left -= width;
|
|
Packit Service |
bf98b9 |
top = 0;
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case CLUTTER_GRID_POSITION_RIGHT:
|
|
Packit Service |
bf98b9 |
left = find_attach_position (layout, CLUTTER_ORIENTATION_HORIZONTAL,
|
|
Packit Service |
bf98b9 |
0, height, TRUE);
|
|
Packit Service |
bf98b9 |
top = 0;
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case CLUTTER_GRID_POSITION_TOP:
|
|
Packit Service |
bf98b9 |
left = 0;
|
|
Packit Service |
bf98b9 |
top = find_attach_position (layout, CLUTTER_ORIENTATION_VERTICAL,
|
|
Packit Service |
bf98b9 |
0, width, FALSE);
|
|
Packit Service |
bf98b9 |
top -= height;
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case CLUTTER_GRID_POSITION_BOTTOM:
|
|
Packit Service |
bf98b9 |
left = 0;
|
|
Packit Service |
bf98b9 |
top = find_attach_position (layout, CLUTTER_ORIENTATION_VERTICAL,
|
|
Packit Service |
bf98b9 |
0, width, TRUE);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
default:
|
|
Packit Service |
bf98b9 |
g_assert_not_reached ();
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
grid_attach (layout, child, left, top, width, height);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_request_update_child_attach (ClutterGridRequest *request,
|
|
Packit Service |
bf98b9 |
ClutterActor *actor)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = request->grid->priv;
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
grid_child = GET_GRID_CHILD (request->grid, actor);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (CHILD_LEFT (grid_child) == -1 || CHILD_TOP (grid_child) == -1)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridPosition side;
|
|
Packit Service |
bf98b9 |
ClutterActor *sibling;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (priv->orientation == CLUTTER_ORIENTATION_HORIZONTAL)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterTextDirection td;
|
|
Packit Service |
bf98b9 |
gboolean rtl;
|
|
Packit Service |
bf98b9 |
ClutterActor *container = CLUTTER_ACTOR (priv->container);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
td = clutter_actor_get_text_direction (container);
|
|
Packit Service |
bf98b9 |
rtl = (td == CLUTTER_TEXT_DIRECTION_RTL) ? TRUE : FALSE;
|
|
Packit Service |
bf98b9 |
side = rtl ? CLUTTER_GRID_POSITION_LEFT : CLUTTER_GRID_POSITION_RIGHT;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
else
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
/* XXX: maybe we should also add a :pack-start property to modify
|
|
Packit Service |
bf98b9 |
* this */
|
|
Packit Service |
bf98b9 |
side = CLUTTER_GRID_POSITION_BOTTOM;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
sibling = clutter_actor_get_previous_sibling (actor);
|
|
Packit Service |
bf98b9 |
if (sibling)
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_insert_next_to (request->grid, sibling, side);
|
|
Packit Service |
bf98b9 |
grid_attach_next_to (request->grid, actor, sibling, side,
|
|
Packit Service |
bf98b9 |
CHILD_WIDTH (grid_child),
|
|
Packit Service |
bf98b9 |
CHILD_HEIGHT (grid_child));
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_request_update_attach (ClutterGridRequest *request)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = request->grid->priv;
|
|
Packit Service |
bf98b9 |
ClutterActorIter iter;
|
|
Packit Service |
bf98b9 |
ClutterActor *child;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (priv->container));
|
|
Packit Service |
bf98b9 |
while (clutter_actor_iter_next (&iter, &child))
|
|
Packit Service |
bf98b9 |
clutter_grid_request_update_child_attach (request, child);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Calculates the min and max numbers for both orientations.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_request_count_lines (ClutterGridRequest *request)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = request->grid->priv;
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child;
|
|
Packit Service |
bf98b9 |
ClutterGridAttach *attach;
|
|
Packit Service |
bf98b9 |
ClutterActorIter iter;
|
|
Packit Service |
bf98b9 |
ClutterActor *child;
|
|
Packit Service |
bf98b9 |
gint min[2];
|
|
Packit Service |
bf98b9 |
gint max[2];
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
min[0] = min[1] = G_MAXINT;
|
|
Packit Service |
bf98b9 |
max[0] = max[1] = G_MININT;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (priv->container));
|
|
Packit Service |
bf98b9 |
while (clutter_actor_iter_next (&iter, &child))
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
grid_child = GET_GRID_CHILD (request->grid, child);
|
|
Packit Service |
bf98b9 |
attach = grid_child->attach;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
min[0] = MIN (min[0], attach[0].pos);
|
|
Packit Service |
bf98b9 |
max[0] = MAX (max[0], attach[0].pos + attach[0].span);
|
|
Packit Service |
bf98b9 |
min[1] = MIN (min[1], attach[1].pos);
|
|
Packit Service |
bf98b9 |
max[1] = MAX (max[1], attach[1].pos + attach[1].span);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
request->lines[0].min = min[0];
|
|
Packit Service |
bf98b9 |
request->lines[0].max = max[0];
|
|
Packit Service |
bf98b9 |
request->lines[1].min = min[1];
|
|
Packit Service |
bf98b9 |
request->lines[1].max = max[1];
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Sets line sizes to 0 and marks lines as expand
|
|
Packit Service |
bf98b9 |
* if they have a non-spanning expanding child.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_request_init (ClutterGridRequest *request,
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = request->grid->priv;
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child;
|
|
Packit Service |
bf98b9 |
ClutterGridAttach *attach;
|
|
Packit Service |
bf98b9 |
ClutterGridLines *lines;
|
|
Packit Service |
bf98b9 |
ClutterActorIter iter;
|
|
Packit Service |
bf98b9 |
ClutterActor *child;
|
|
Packit Service |
bf98b9 |
gint i;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
lines = &request->lines[orientation];
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
for (i = 0; i < lines->max - lines->min; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
lines->lines[i].minimum = 0;
|
|
Packit Service |
bf98b9 |
lines->lines[i].natural = 0;
|
|
Packit Service |
bf98b9 |
lines->lines[i].expand = FALSE;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (priv->container));
|
|
Packit Service |
bf98b9 |
while (clutter_actor_iter_next (&iter, &child))
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
grid_child = GET_GRID_CHILD (request->grid, child);
|
|
Packit Service |
bf98b9 |
attach = &grid_child->attach[orientation];
|
|
Packit Service |
bf98b9 |
if (attach->span == 1 && clutter_actor_needs_expand (child, orientation))
|
|
Packit Service |
bf98b9 |
lines->lines[attach->pos - lines->min].expand = TRUE;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Sums allocations for lines spanned by child and their spacing.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
static gfloat
|
|
Packit Service |
bf98b9 |
compute_allocation_for_child (ClutterGridRequest *request,
|
|
Packit Service |
bf98b9 |
ClutterActor *child,
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = request->grid->priv;
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child;
|
|
Packit Service |
bf98b9 |
ClutterGridLineData *linedata;
|
|
Packit Service |
bf98b9 |
ClutterGridLines *lines;
|
|
Packit Service |
bf98b9 |
ClutterGridLine *line;
|
|
Packit Service |
bf98b9 |
ClutterGridAttach *attach;
|
|
Packit Service |
bf98b9 |
gfloat size;
|
|
Packit Service |
bf98b9 |
gint i;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
grid_child = GET_GRID_CHILD (request->grid, child);
|
|
Packit Service |
bf98b9 |
linedata = &priv->linedata[orientation];
|
|
Packit Service |
bf98b9 |
lines = &request->lines[orientation];
|
|
Packit Service |
bf98b9 |
attach = &grid_child->attach[orientation];
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
size = (attach->span - 1) * linedata->spacing;
|
|
Packit Service |
bf98b9 |
for (i = 0; i < attach->span; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line = &lines->lines[attach->pos - lines->min + i];
|
|
Packit Service |
bf98b9 |
size += line->allocation;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
return size;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
compute_request_for_child (ClutterGridRequest *request,
|
|
Packit Service |
bf98b9 |
ClutterActor *child,
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation,
|
|
Packit Service |
bf98b9 |
gboolean contextual,
|
|
Packit Service |
bf98b9 |
gfloat *minimum,
|
|
Packit Service |
bf98b9 |
gfloat *natural)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
if (contextual)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
gfloat size;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
size = compute_allocation_for_child (request, child, 1 - orientation);
|
|
Packit Service |
bf98b9 |
if (orientation == CLUTTER_ORIENTATION_HORIZONTAL)
|
|
Packit Service |
bf98b9 |
clutter_actor_get_preferred_width (child, size, minimum, natural);
|
|
Packit Service |
bf98b9 |
else
|
|
Packit Service |
bf98b9 |
clutter_actor_get_preferred_height (child, size, minimum, natural);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
else
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
if (orientation == CLUTTER_ORIENTATION_HORIZONTAL)
|
|
Packit Service |
bf98b9 |
clutter_actor_get_preferred_width (child, -1, minimum, natural);
|
|
Packit Service |
bf98b9 |
else
|
|
Packit Service |
bf98b9 |
clutter_actor_get_preferred_height (child, -1, minimum, natural);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Sets requisition to max. of non-spanning children.
|
|
Packit Service |
bf98b9 |
* If contextual is TRUE, requires allocations of
|
|
Packit Service |
bf98b9 |
* lines in the opposite orientation to be set.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_request_non_spanning (ClutterGridRequest *request,
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation,
|
|
Packit Service |
bf98b9 |
gboolean contextual)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = request->grid->priv;
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child;
|
|
Packit Service |
bf98b9 |
ClutterGridAttach *attach;
|
|
Packit Service |
bf98b9 |
ClutterGridLines *lines;
|
|
Packit Service |
bf98b9 |
ClutterGridLine *line;
|
|
Packit Service |
bf98b9 |
ClutterActorIter iter;
|
|
Packit Service |
bf98b9 |
ClutterActor *child;
|
|
Packit Service |
bf98b9 |
gfloat minimum;
|
|
Packit Service |
bf98b9 |
gfloat natural;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
lines = &request->lines[orientation];
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (priv->container));
|
|
Packit Service |
bf98b9 |
while (clutter_actor_iter_next (&iter, &child))
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
if (!clutter_actor_is_visible (child))
|
|
Packit Service |
bf98b9 |
continue;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
grid_child = GET_GRID_CHILD (request->grid, child);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
attach = &grid_child->attach[orientation];
|
|
Packit Service |
bf98b9 |
if (attach->span != 1)
|
|
Packit Service |
bf98b9 |
continue;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
compute_request_for_child (request, child, orientation, contextual, &minimum, &natural);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
line = &lines->lines[attach->pos - lines->min];
|
|
Packit Service |
bf98b9 |
line->minimum = MAX (line->minimum, minimum);
|
|
Packit Service |
bf98b9 |
line->natural = MAX (line->natural, natural);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Enforce homogeneous sizes.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_request_homogeneous (ClutterGridRequest *request,
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = request->grid->priv;
|
|
Packit Service |
bf98b9 |
ClutterGridLineData *linedata;
|
|
Packit Service |
bf98b9 |
ClutterGridLines *lines;
|
|
Packit Service |
bf98b9 |
gfloat minimum, natural;
|
|
Packit Service |
bf98b9 |
gint i;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
linedata = &priv->linedata[orientation];
|
|
Packit Service |
bf98b9 |
lines = &request->lines[orientation];
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (!linedata->homogeneous)
|
|
Packit Service |
bf98b9 |
return;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
minimum = 0.0f;
|
|
Packit Service |
bf98b9 |
natural = 0.0f;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
for (i = 0; i < lines->max - lines->min; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
minimum = MAX (minimum, lines->lines[i].minimum);
|
|
Packit Service |
bf98b9 |
natural = MAX (natural, lines->lines[i].natural);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
for (i = 0; i < lines->max - lines->min; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
lines->lines[i].minimum = minimum;
|
|
Packit Service |
bf98b9 |
lines->lines[i].natural = natural;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Deals with spanning children.
|
|
Packit Service |
bf98b9 |
* Requires expand fields of lines to be set for
|
|
Packit Service |
bf98b9 |
* non-spanning children.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_request_spanning (ClutterGridRequest *request,
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation,
|
|
Packit Service |
bf98b9 |
gboolean contextual)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = request->grid->priv;
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child;
|
|
Packit Service |
bf98b9 |
ClutterActor *child;
|
|
Packit Service |
bf98b9 |
ClutterActorIter iter;
|
|
Packit Service |
bf98b9 |
ClutterGridAttach *attach;
|
|
Packit Service |
bf98b9 |
ClutterGridLineData *linedata;
|
|
Packit Service |
bf98b9 |
ClutterGridLines *lines;
|
|
Packit Service |
bf98b9 |
ClutterGridLine *line;
|
|
Packit Service |
bf98b9 |
gfloat minimum;
|
|
Packit Service |
bf98b9 |
gfloat natural;
|
|
Packit Service |
bf98b9 |
gint span_minimum;
|
|
Packit Service |
bf98b9 |
gint span_natural;
|
|
Packit Service |
bf98b9 |
gint span_expand;
|
|
Packit Service |
bf98b9 |
gboolean force_expand;
|
|
Packit Service |
bf98b9 |
gint extra;
|
|
Packit Service |
bf98b9 |
gint expand;
|
|
Packit Service |
bf98b9 |
gint line_extra;
|
|
Packit Service |
bf98b9 |
gint i;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
linedata = &priv->linedata[orientation];
|
|
Packit Service |
bf98b9 |
lines = &request->lines[orientation];
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (priv->container));
|
|
Packit Service |
bf98b9 |
while (clutter_actor_iter_next (&iter, &child))
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
if (!clutter_actor_is_visible (child))
|
|
Packit Service |
bf98b9 |
continue;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
grid_child = GET_GRID_CHILD (request->grid, child);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
attach = &grid_child->attach[orientation];
|
|
Packit Service |
bf98b9 |
if (attach->span == 1)
|
|
Packit Service |
bf98b9 |
continue;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
compute_request_for_child (request, child, orientation, contextual,
|
|
Packit Service |
bf98b9 |
&minimum, &natural);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
span_minimum = (attach->span - 1) * linedata->spacing;
|
|
Packit Service |
bf98b9 |
span_natural = (attach->span - 1) * linedata->spacing;
|
|
Packit Service |
bf98b9 |
span_expand = 0;
|
|
Packit Service |
bf98b9 |
force_expand = FALSE;
|
|
Packit Service |
bf98b9 |
for (i = 0; i < attach->span; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line = &lines->lines[attach->pos - lines->min + i];
|
|
Packit Service |
bf98b9 |
span_minimum += line->minimum;
|
|
Packit Service |
bf98b9 |
span_natural += line->natural;
|
|
Packit Service |
bf98b9 |
if (line->expand)
|
|
Packit Service |
bf98b9 |
span_expand += 1;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
if (span_expand == 0)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
span_expand = attach->span;
|
|
Packit Service |
bf98b9 |
force_expand = TRUE;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* If we need to request more space for this child to fill
|
|
Packit Service |
bf98b9 |
* its requisition, then divide up the needed space amongst the
|
|
Packit Service |
bf98b9 |
* lines it spans, favoring expandable lines if any.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* When doing homogeneous allocation though, try to keep the
|
|
Packit Service |
bf98b9 |
* line allocations even, since we're going to force them to
|
|
Packit Service |
bf98b9 |
* be the same anyway, and we don't want to introduce unnecessary
|
|
Packit Service |
bf98b9 |
* extra space.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
if (span_minimum < minimum)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
if (linedata->homogeneous)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
gint total, m;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
total = minimum - (attach->span - 1) * linedata->spacing;
|
|
Packit Service |
bf98b9 |
m = total / attach->span + (total % attach->span ? 1 : 0);
|
|
Packit Service |
bf98b9 |
for (i = 0; i < attach->span; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line = &lines->lines[attach->pos - lines->min + i];
|
|
Packit Service |
bf98b9 |
line->minimum = MAX(line->minimum, m);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
else
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
extra = minimum - span_minimum;
|
|
Packit Service |
bf98b9 |
expand = span_expand;
|
|
Packit Service |
bf98b9 |
for (i = 0; i < attach->span; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line = &lines->lines[attach->pos - lines->min + i];
|
|
Packit Service |
bf98b9 |
if (force_expand || line->expand)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line_extra = extra / expand;
|
|
Packit Service |
bf98b9 |
line->minimum += line_extra;
|
|
Packit Service |
bf98b9 |
extra -= line_extra;
|
|
Packit Service |
bf98b9 |
expand -= 1;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (span_natural < natural)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
if (linedata->homogeneous)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
gint total, n;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
total = natural - (attach->span - 1) * linedata->spacing;
|
|
Packit Service |
bf98b9 |
n = total / attach->span + (total % attach->span ? 1 : 0);
|
|
Packit Service |
bf98b9 |
for (i = 0; i < attach->span; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line = &lines->lines[attach->pos - lines->min + i];
|
|
Packit Service |
bf98b9 |
line->natural = MAX(line->natural, n);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
else
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
extra = natural - span_natural;
|
|
Packit Service |
bf98b9 |
expand = span_expand;
|
|
Packit Service |
bf98b9 |
for (i = 0; i < attach->span; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line = &lines->lines[attach->pos - lines->min + i];
|
|
Packit Service |
bf98b9 |
if (force_expand || line->expand)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line_extra = extra / expand;
|
|
Packit Service |
bf98b9 |
line->natural += line_extra;
|
|
Packit Service |
bf98b9 |
extra -= line_extra;
|
|
Packit Service |
bf98b9 |
expand -= 1;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Marks empty and expanding lines and counts them.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_request_compute_expand (ClutterGridRequest *request,
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation,
|
|
Packit Service |
bf98b9 |
gint *nonempty_lines,
|
|
Packit Service |
bf98b9 |
gint *expand_lines)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = request->grid->priv;
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child;
|
|
Packit Service |
bf98b9 |
ClutterGridAttach *attach;
|
|
Packit Service |
bf98b9 |
ClutterActorIter iter;
|
|
Packit Service |
bf98b9 |
ClutterActor *child;
|
|
Packit Service |
bf98b9 |
gint i;
|
|
Packit Service |
bf98b9 |
ClutterGridLines *lines;
|
|
Packit Service |
bf98b9 |
ClutterGridLine *line;
|
|
Packit Service |
bf98b9 |
gboolean has_expand;
|
|
Packit Service |
bf98b9 |
gint expand;
|
|
Packit Service |
bf98b9 |
gint empty;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
lines = &request->lines[orientation];
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
for (i = 0; i < lines->max - lines->min; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
lines->lines[i].need_expand = FALSE;
|
|
Packit Service |
bf98b9 |
lines->lines[i].expand = FALSE;
|
|
Packit Service |
bf98b9 |
lines->lines[i].empty = TRUE;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (priv->container));
|
|
Packit Service |
bf98b9 |
while (clutter_actor_iter_next (&iter, &child))
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
if (!clutter_actor_is_visible (child))
|
|
Packit Service |
bf98b9 |
continue;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
grid_child = GET_GRID_CHILD (request->grid, child);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
attach = &grid_child->attach[orientation];
|
|
Packit Service |
bf98b9 |
if (attach->span != 1)
|
|
Packit Service |
bf98b9 |
continue;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
line = &lines->lines[attach->pos - lines->min];
|
|
Packit Service |
bf98b9 |
line->empty = FALSE;
|
|
Packit Service |
bf98b9 |
if (clutter_actor_needs_expand (child, orientation))
|
|
Packit Service |
bf98b9 |
line->expand = TRUE;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (priv->container));
|
|
Packit Service |
bf98b9 |
while (clutter_actor_iter_next (&iter, &child))
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
if (!clutter_actor_is_visible (child))
|
|
Packit Service |
bf98b9 |
continue;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
grid_child = GET_GRID_CHILD (request->grid, child);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
attach = &grid_child->attach[orientation];
|
|
Packit Service |
bf98b9 |
if (attach->span == 1)
|
|
Packit Service |
bf98b9 |
continue;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
has_expand = FALSE;
|
|
Packit Service |
bf98b9 |
for (i = 0; i < attach->span; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line = &lines->lines[attach->pos - lines->min + i];
|
|
Packit Service |
bf98b9 |
line->empty = FALSE;
|
|
Packit Service |
bf98b9 |
if (line->expand)
|
|
Packit Service |
bf98b9 |
has_expand = TRUE;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (!has_expand && clutter_actor_needs_expand (child, orientation))
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
for (i = 0; i < attach->span; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line = &lines->lines[attach->pos - lines->min + i];
|
|
Packit Service |
bf98b9 |
line->need_expand = TRUE;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
empty = 0;
|
|
Packit Service |
bf98b9 |
expand = 0;
|
|
Packit Service |
bf98b9 |
for (i = 0; i < lines->max - lines->min; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line = &lines->lines[i];
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (line->need_expand)
|
|
Packit Service |
bf98b9 |
line->expand = TRUE;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (line->empty)
|
|
Packit Service |
bf98b9 |
empty += 1;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (line->expand)
|
|
Packit Service |
bf98b9 |
expand += 1;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (nonempty_lines)
|
|
Packit Service |
bf98b9 |
*nonempty_lines = lines->max - lines->min - empty;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (expand_lines)
|
|
Packit Service |
bf98b9 |
*expand_lines = expand;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Sums the minimum and natural fields of lines and their spacing.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_request_sum (ClutterGridRequest *request,
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation,
|
|
Packit Service |
bf98b9 |
gfloat *minimum,
|
|
Packit Service |
bf98b9 |
gfloat *natural)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = request->grid->priv;
|
|
Packit Service |
bf98b9 |
ClutterGridLineData *linedata;
|
|
Packit Service |
bf98b9 |
ClutterGridLines *lines;
|
|
Packit Service |
bf98b9 |
gint i;
|
|
Packit Service |
bf98b9 |
gfloat min, nat;
|
|
Packit Service |
bf98b9 |
gint nonempty;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_grid_request_compute_expand (request, orientation, &nonempty, NULL);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
linedata = &priv->linedata[orientation];
|
|
Packit Service |
bf98b9 |
lines = &request->lines[orientation];
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
min = 0;
|
|
Packit Service |
bf98b9 |
nat = 0;
|
|
Packit Service |
bf98b9 |
if (nonempty > 0)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
min = (nonempty - 1) * linedata->spacing;
|
|
Packit Service |
bf98b9 |
nat = (nonempty - 1) * linedata->spacing;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
for (i = 0; i < lines->max - lines->min; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
min += lines->lines[i].minimum;
|
|
Packit Service |
bf98b9 |
nat += lines->lines[i].natural;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (minimum)
|
|
Packit Service |
bf98b9 |
*minimum = min;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (natural)
|
|
Packit Service |
bf98b9 |
*natural = nat;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Computes minimum and natural fields of lines.
|
|
Packit Service |
bf98b9 |
* When contextual is TRUE, requires allocation of
|
|
Packit Service |
bf98b9 |
* lines in the opposite orientation to be set.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_request_run (ClutterGridRequest *request,
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation,
|
|
Packit Service |
bf98b9 |
gboolean contextual)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
clutter_grid_request_init (request, orientation);
|
|
Packit Service |
bf98b9 |
clutter_grid_request_non_spanning (request, orientation, contextual);
|
|
Packit Service |
bf98b9 |
clutter_grid_request_homogeneous (request, orientation);
|
|
Packit Service |
bf98b9 |
clutter_grid_request_spanning (request, orientation, contextual);
|
|
Packit Service |
bf98b9 |
clutter_grid_request_homogeneous (request, orientation);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
typedef struct _RequestedSize
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
gpointer data;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
gfloat minimum_size;
|
|
Packit Service |
bf98b9 |
gfloat natural_size;
|
|
Packit Service |
bf98b9 |
} RequestedSize;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Pulled from gtksizerequest.c from Gtk+ */
|
|
Packit Service |
bf98b9 |
static gint
|
|
Packit Service |
bf98b9 |
compare_gap (gconstpointer p1,
|
|
Packit Service |
bf98b9 |
gconstpointer p2,
|
|
Packit Service |
bf98b9 |
gpointer data)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
RequestedSize *sizes = data;
|
|
Packit Service |
bf98b9 |
const guint *c1 = p1;
|
|
Packit Service |
bf98b9 |
const guint *c2 = p2;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
const gint d1 = MAX (sizes[*c1].natural_size -
|
|
Packit Service |
bf98b9 |
sizes[*c1].minimum_size,
|
|
Packit Service |
bf98b9 |
0);
|
|
Packit Service |
bf98b9 |
const gint d2 = MAX (sizes[*c2].natural_size -
|
|
Packit Service |
bf98b9 |
sizes[*c2].minimum_size,
|
|
Packit Service |
bf98b9 |
0);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
gint delta = (d2 - d1);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (0 == delta)
|
|
Packit Service |
bf98b9 |
delta = (*c2 - *c1);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
return delta;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/*
|
|
Packit Service |
bf98b9 |
* distribute_natural_allocation:
|
|
Packit Service |
bf98b9 |
* @extra_space: Extra space to redistribute among children after subtracting
|
|
Packit Service |
bf98b9 |
* minimum sizes and any child padding from the overall allocation
|
|
Packit Service |
bf98b9 |
* @n_requested_sizes: Number of requests to fit into the allocation
|
|
Packit Service |
bf98b9 |
* @sizes: An array of structs with a client pointer and a minimum/natural size
|
|
Packit Service |
bf98b9 |
* in the orientation of the allocation.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Distributes @extra_space to child @sizes by bringing smaller
|
|
Packit Service |
bf98b9 |
* children up to natural size first.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* The remaining space will be added to the @minimum_size member of the
|
|
Packit Service |
bf98b9 |
* RequestedSize struct. If all sizes reach their natural size then
|
|
Packit Service |
bf98b9 |
* the remaining space is returned.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Returns: The remainder of @extra_space after redistributing space
|
|
Packit Service |
bf98b9 |
* to @sizes.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Pulled from gtksizerequest.c from Gtk+
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
static gint
|
|
Packit Service |
bf98b9 |
distribute_natural_allocation (gint extra_space,
|
|
Packit Service |
bf98b9 |
guint n_requested_sizes,
|
|
Packit Service |
bf98b9 |
RequestedSize *sizes)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
guint *spreading;
|
|
Packit Service |
bf98b9 |
gint i;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_val_if_fail (extra_space >= 0, 0);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
spreading = g_newa (guint, n_requested_sizes);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
for (i = 0; i < n_requested_sizes; i++)
|
|
Packit Service |
bf98b9 |
spreading[i] = i;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Distribute the container's extra space c_gap. We want to assign
|
|
Packit Service |
bf98b9 |
* this space such that the sum of extra space assigned to children
|
|
Packit Service |
bf98b9 |
* (c^i_gap) is equal to c_cap. The case that there's not enough
|
|
Packit Service |
bf98b9 |
* space for all children to take their natural size needs some
|
|
Packit Service |
bf98b9 |
* attention. The goals we want to achieve are:
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* a) Maximize number of children taking their natural size.
|
|
Packit Service |
bf98b9 |
* b) The allocated size of children should be a continuous
|
|
Packit Service |
bf98b9 |
* function of c_gap. That is, increasing the container size by
|
|
Packit Service |
bf98b9 |
* one pixel should never make drastic changes in the distribution.
|
|
Packit Service |
bf98b9 |
* c) If child i takes its natural size and child j doesn't,
|
|
Packit Service |
bf98b9 |
* child j should have received at least as much gap as child i.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* The following code distributes the additional space by following
|
|
Packit Service |
bf98b9 |
* these rules.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Sort descending by gap and position. */
|
|
Packit Service |
bf98b9 |
g_qsort_with_data (spreading,
|
|
Packit Service |
bf98b9 |
n_requested_sizes, sizeof (guint),
|
|
Packit Service |
bf98b9 |
compare_gap, sizes);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Distribute available space.
|
|
Packit Service |
bf98b9 |
* This master piece of a loop was conceived by Behdad Esfahbod.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
for (i = n_requested_sizes - 1; extra_space > 0 && i >= 0; --i)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
/* Divide remaining space by number of remaining children.
|
|
Packit Service |
bf98b9 |
* Sort order and reducing remaining space by assigned space
|
|
Packit Service |
bf98b9 |
* ensures that space is distributed equally.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
gint glue = (extra_space + i) / (i + 1);
|
|
Packit Service |
bf98b9 |
gint gap = sizes[(spreading[i])].natural_size
|
|
Packit Service |
bf98b9 |
- sizes[(spreading[i])].minimum_size;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
gint extra = MIN (glue, gap);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
sizes[spreading[i]].minimum_size += extra;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
extra_space -= extra;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
return extra_space;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Requires that the minimum and natural fields of lines
|
|
Packit Service |
bf98b9 |
* have been set, computes the allocation field of lines
|
|
Packit Service |
bf98b9 |
* by distributing total_size among lines.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_request_allocate (ClutterGridRequest *request,
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation,
|
|
Packit Service |
bf98b9 |
gfloat total_size)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = request->grid->priv;
|
|
Packit Service |
bf98b9 |
ClutterGridLineData *linedata;
|
|
Packit Service |
bf98b9 |
ClutterGridLines *lines;
|
|
Packit Service |
bf98b9 |
ClutterGridLine *line;
|
|
Packit Service |
bf98b9 |
gint nonempty;
|
|
Packit Service |
bf98b9 |
gint expand;
|
|
Packit Service |
bf98b9 |
gint i, j;
|
|
Packit Service |
bf98b9 |
RequestedSize *sizes;
|
|
Packit Service |
bf98b9 |
gint extra;
|
|
Packit Service |
bf98b9 |
gint rest;
|
|
Packit Service |
bf98b9 |
gint size;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_grid_request_compute_expand (request, orientation, &nonempty, &expand);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (nonempty == 0)
|
|
Packit Service |
bf98b9 |
return;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
linedata = &priv->linedata[orientation];
|
|
Packit Service |
bf98b9 |
lines = &request->lines[orientation];
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
size = total_size - (nonempty - 1) * linedata->spacing;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (linedata->homogeneous)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
extra = size / nonempty;
|
|
Packit Service |
bf98b9 |
rest = size % nonempty;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
for (i = 0; i < lines->max - lines->min; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line = &lines->lines[i];
|
|
Packit Service |
bf98b9 |
if (line->empty)
|
|
Packit Service |
bf98b9 |
continue;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
line->allocation = extra;
|
|
Packit Service |
bf98b9 |
if (rest > 0)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line->allocation += 1;
|
|
Packit Service |
bf98b9 |
rest -= 1;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
else
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
sizes = g_newa (RequestedSize, nonempty);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
j = 0;
|
|
Packit Service |
bf98b9 |
for (i = 0; i < lines->max - lines->min; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line = &lines->lines[i];
|
|
Packit Service |
bf98b9 |
if (line->empty)
|
|
Packit Service |
bf98b9 |
continue;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
size -= line->minimum;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
sizes[j].minimum_size = line->minimum;
|
|
Packit Service |
bf98b9 |
sizes[j].natural_size = line->natural;
|
|
Packit Service |
bf98b9 |
sizes[j].data = line;
|
|
Packit Service |
bf98b9 |
j++;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
size = distribute_natural_allocation (MAX (0, size), nonempty, sizes);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (expand > 0)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
extra = size / expand;
|
|
Packit Service |
bf98b9 |
rest = size % expand;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
else
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
extra = 0;
|
|
Packit Service |
bf98b9 |
rest = 0;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
j = 0;
|
|
Packit Service |
bf98b9 |
for (i = 0; i < lines->max - lines->min; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line = &lines->lines[i];
|
|
Packit Service |
bf98b9 |
if (line->empty)
|
|
Packit Service |
bf98b9 |
continue;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_assert (line == sizes[j].data);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
line->allocation = sizes[j].minimum_size;
|
|
Packit Service |
bf98b9 |
if (line->expand)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line->allocation += extra;
|
|
Packit Service |
bf98b9 |
if (rest > 0)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line->allocation += 1;
|
|
Packit Service |
bf98b9 |
rest -= 1;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
j++;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* Computes the position fields from allocation and spacing.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_request_position (ClutterGridRequest *request,
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = request->grid->priv;
|
|
Packit Service |
bf98b9 |
ClutterGridLineData *linedata;
|
|
Packit Service |
bf98b9 |
ClutterGridLines *lines;
|
|
Packit Service |
bf98b9 |
ClutterGridLine *line;
|
|
Packit Service |
bf98b9 |
gfloat position;
|
|
Packit Service |
bf98b9 |
gint i;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
linedata = &priv->linedata[orientation];
|
|
Packit Service |
bf98b9 |
lines = &request->lines[orientation];
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
position = 0.f;
|
|
Packit Service |
bf98b9 |
for (i = 0; i < lines->max - lines->min; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line = &lines->lines[i];
|
|
Packit Service |
bf98b9 |
if (!line->empty)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line->position = position;
|
|
Packit Service |
bf98b9 |
position += line->allocation + linedata->spacing;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_child_set_property (GObject *gobject,
|
|
Packit Service |
bf98b9 |
guint prop_id,
|
|
Packit Service |
bf98b9 |
const GValue *value,
|
|
Packit Service |
bf98b9 |
GParamSpec *pspec)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child = CLUTTER_GRID_CHILD (gobject);
|
|
Packit Service |
bf98b9 |
ClutterLayoutManager *manager;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
manager = clutter_layout_meta_get_manager (CLUTTER_LAYOUT_META (gobject));
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
switch (prop_id)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
case PROP_CHILD_LEFT_ATTACH:
|
|
Packit Service |
bf98b9 |
CHILD_LEFT (grid_child) = g_value_get_int (value);
|
|
Packit Service |
bf98b9 |
clutter_layout_manager_layout_changed (manager);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case PROP_CHILD_TOP_ATTACH:
|
|
Packit Service |
bf98b9 |
CHILD_TOP (grid_child) = g_value_get_int (value);
|
|
Packit Service |
bf98b9 |
clutter_layout_manager_layout_changed (manager);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case PROP_CHILD_WIDTH:
|
|
Packit Service |
bf98b9 |
CHILD_WIDTH (grid_child) = g_value_get_int (value);
|
|
Packit Service |
bf98b9 |
clutter_layout_manager_layout_changed (manager);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case PROP_CHILD_HEIGHT:
|
|
Packit Service |
bf98b9 |
CHILD_HEIGHT (grid_child) = g_value_get_int (value);
|
|
Packit Service |
bf98b9 |
clutter_layout_manager_layout_changed (manager);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
default:
|
|
Packit Service |
bf98b9 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_child_get_property (GObject *gobject,
|
|
Packit Service |
bf98b9 |
guint prop_id,
|
|
Packit Service |
bf98b9 |
GValue *value,
|
|
Packit Service |
bf98b9 |
GParamSpec *pspec)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child = CLUTTER_GRID_CHILD (gobject);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
switch (prop_id)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
case PROP_CHILD_LEFT_ATTACH:
|
|
Packit Service |
bf98b9 |
g_value_set_int (value, CHILD_LEFT (grid_child));
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case PROP_CHILD_TOP_ATTACH:
|
|
Packit Service |
bf98b9 |
g_value_set_int (value, CHILD_TOP (grid_child));
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case PROP_CHILD_WIDTH:
|
|
Packit Service |
bf98b9 |
g_value_set_int (value, CHILD_WIDTH (grid_child));
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case PROP_CHILD_HEIGHT:
|
|
Packit Service |
bf98b9 |
g_value_set_int (value, CHILD_HEIGHT (grid_child));
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
default:
|
|
Packit Service |
bf98b9 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_child_class_init (ClutterGridChildClass *klass)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
gobject_class->set_property = clutter_grid_child_set_property;
|
|
Packit Service |
bf98b9 |
gobject_class->get_property = clutter_grid_child_get_property;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
child_props[PROP_CHILD_LEFT_ATTACH] =
|
|
Packit Service |
bf98b9 |
g_param_spec_int ("left-attach",
|
|
Packit Service |
bf98b9 |
P_("Left attachment"),
|
|
Packit Service |
bf98b9 |
P_("The column number to attach the left side of the "
|
|
Packit Service |
bf98b9 |
"child to"),
|
|
Packit Service |
bf98b9 |
-G_MAXINT, G_MAXINT, 0,
|
|
Packit Service |
bf98b9 |
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
child_props[PROP_CHILD_TOP_ATTACH] =
|
|
Packit Service |
bf98b9 |
g_param_spec_int ("top-attach",
|
|
Packit Service |
bf98b9 |
P_("Top attachment"),
|
|
Packit Service |
bf98b9 |
P_("The row number to attach the top side of a child "
|
|
Packit Service |
bf98b9 |
"widget to"),
|
|
Packit Service |
bf98b9 |
-G_MAXINT, G_MAXINT, 0,
|
|
Packit Service |
bf98b9 |
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
child_props[PROP_CHILD_WIDTH] =
|
|
Packit Service |
bf98b9 |
g_param_spec_int ("width",
|
|
Packit Service |
bf98b9 |
P_("Width"),
|
|
Packit Service |
bf98b9 |
P_("The number of columns that a child spans"),
|
|
Packit Service |
bf98b9 |
-G_MAXINT, G_MAXINT, 1,
|
|
Packit Service |
bf98b9 |
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
child_props[PROP_CHILD_HEIGHT] =
|
|
Packit Service |
bf98b9 |
g_param_spec_int ("height",
|
|
Packit Service |
bf98b9 |
P_("Height"),
|
|
Packit Service |
bf98b9 |
P_("The number of rows that a child spans"),
|
|
Packit Service |
bf98b9 |
-G_MAXINT, G_MAXINT, 1,
|
|
Packit Service |
bf98b9 |
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_object_class_install_properties (gobject_class, PROP_CHILD_LAST,
|
|
Packit Service |
bf98b9 |
child_props);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_child_init (ClutterGridChild *self)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
CHILD_LEFT (self) = -1;
|
|
Packit Service |
bf98b9 |
CHILD_TOP (self) = -1;
|
|
Packit Service |
bf98b9 |
CHILD_WIDTH (self) = 1;
|
|
Packit Service |
bf98b9 |
CHILD_HEIGHT (self) = 1;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_set_container (ClutterLayoutManager *self,
|
|
Packit Service |
bf98b9 |
ClutterContainer *container)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = CLUTTER_GRID_LAYOUT (self)->priv;
|
|
Packit Service |
bf98b9 |
ClutterLayoutManagerClass *parent_class;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
priv->container = container;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (priv->container != NULL)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterRequestMode request_mode;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/* we need to change the :request-mode of the container
|
|
Packit Service |
bf98b9 |
* to match the orientation
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
request_mode = priv->orientation == CLUTTER_ORIENTATION_VERTICAL
|
|
Packit Service |
bf98b9 |
? CLUTTER_REQUEST_HEIGHT_FOR_WIDTH
|
|
Packit Service |
bf98b9 |
: CLUTTER_REQUEST_WIDTH_FOR_HEIGHT;
|
|
Packit Service |
bf98b9 |
clutter_actor_set_request_mode (CLUTTER_ACTOR (priv->container),
|
|
Packit Service |
bf98b9 |
request_mode);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
parent_class = CLUTTER_LAYOUT_MANAGER_CLASS (clutter_grid_layout_parent_class);
|
|
Packit Service |
bf98b9 |
parent_class->set_container (self, container);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_get_size_for_size (ClutterGridLayout *self,
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation,
|
|
Packit Service |
bf98b9 |
float size,
|
|
Packit Service |
bf98b9 |
float *minimum,
|
|
Packit Service |
bf98b9 |
float *natural)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridRequest request;
|
|
Packit Service |
bf98b9 |
ClutterGridLines *lines;
|
|
Packit Service |
bf98b9 |
float min_size, nat_size;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
request.grid = self;
|
|
Packit Service |
bf98b9 |
clutter_grid_request_update_attach (&request);
|
|
Packit Service |
bf98b9 |
clutter_grid_request_count_lines (&request);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
lines = &request.lines[0];
|
|
Packit Service |
bf98b9 |
lines->lines = g_newa (ClutterGridLine, lines->max - lines->min);
|
|
Packit Service |
bf98b9 |
memset (lines->lines, 0, (lines->max - lines->min) * sizeof (ClutterGridLine));
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
lines = &request.lines[1];
|
|
Packit Service |
bf98b9 |
lines->lines = g_newa (ClutterGridLine, lines->max - lines->min);
|
|
Packit Service |
bf98b9 |
memset (lines->lines, 0, (lines->max - lines->min) * sizeof (ClutterGridLine));
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_grid_request_run (&request, 1 - orientation, FALSE);
|
|
Packit Service |
bf98b9 |
clutter_grid_request_sum (&request, 1 - orientation, &min_size, &nat_size);
|
|
Packit Service |
bf98b9 |
clutter_grid_request_allocate (&request, 1 - orientation, MAX (size, nat_size));
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_grid_request_run (&request, orientation, TRUE);
|
|
Packit Service |
bf98b9 |
clutter_grid_request_sum (&request, orientation, minimum, natural);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_get_preferred_width (ClutterLayoutManager *manager,
|
|
Packit Service |
bf98b9 |
ClutterContainer *container,
|
|
Packit Service |
bf98b9 |
gfloat for_height,
|
|
Packit Service |
bf98b9 |
gfloat *min_width_p,
|
|
Packit Service |
bf98b9 |
gfloat *nat_width_p)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayout *self = CLUTTER_GRID_LAYOUT (manager);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (min_width_p)
|
|
Packit Service |
bf98b9 |
*min_width_p = 0.0f;
|
|
Packit Service |
bf98b9 |
if (nat_width_p)
|
|
Packit Service |
bf98b9 |
*nat_width_p = 0.0f;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_get_size_for_size (self, CLUTTER_ORIENTATION_HORIZONTAL,
|
|
Packit Service |
bf98b9 |
for_height,
|
|
Packit Service |
bf98b9 |
min_width_p, nat_width_p);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_get_preferred_height (ClutterLayoutManager *manager,
|
|
Packit Service |
bf98b9 |
ClutterContainer *container,
|
|
Packit Service |
bf98b9 |
gfloat for_width,
|
|
Packit Service |
bf98b9 |
gfloat *min_height_p,
|
|
Packit Service |
bf98b9 |
gfloat *nat_height_p)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayout *self = CLUTTER_GRID_LAYOUT (manager);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (min_height_p)
|
|
Packit Service |
bf98b9 |
*min_height_p = 0.0f;
|
|
Packit Service |
bf98b9 |
if (nat_height_p)
|
|
Packit Service |
bf98b9 |
*nat_height_p = 0.0f;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_get_size_for_size (self, CLUTTER_ORIENTATION_VERTICAL,
|
|
Packit Service |
bf98b9 |
for_width,
|
|
Packit Service |
bf98b9 |
min_height_p, nat_height_p);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
allocate_child (ClutterGridRequest *request,
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation,
|
|
Packit Service |
bf98b9 |
ClutterGridChild *child,
|
|
Packit Service |
bf98b9 |
gfloat *position,
|
|
Packit Service |
bf98b9 |
gfloat *size)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = request->grid->priv;
|
|
Packit Service |
bf98b9 |
ClutterGridLineData *linedata;
|
|
Packit Service |
bf98b9 |
ClutterGridLines *lines;
|
|
Packit Service |
bf98b9 |
ClutterGridLine *line;
|
|
Packit Service |
bf98b9 |
ClutterGridAttach *attach;
|
|
Packit Service |
bf98b9 |
gint i;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
linedata = &priv->linedata[orientation];
|
|
Packit Service |
bf98b9 |
lines = &request->lines[orientation];
|
|
Packit Service |
bf98b9 |
attach = &child->attach[orientation];
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
*position = lines->lines[attach->pos - lines->min].position;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
*size = (attach->span - 1) * linedata->spacing;
|
|
Packit Service |
bf98b9 |
for (i = 0; i < attach->span; i++)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
line = &lines->lines[attach->pos - lines->min + i];
|
|
Packit Service |
bf98b9 |
*size += line->allocation;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
#define GET_SIZE(allocation, orientation) \
|
|
Packit Service |
bf98b9 |
(orientation == CLUTTER_ORIENTATION_HORIZONTAL \
|
|
Packit Service |
bf98b9 |
? clutter_actor_box_get_width ((allocation)) \
|
|
Packit Service |
bf98b9 |
: clutter_actor_box_get_height ((allocation)))
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_allocate (ClutterLayoutManager *layout,
|
|
Packit Service |
bf98b9 |
ClutterContainer *container,
|
|
Packit Service |
bf98b9 |
const ClutterActorBox *allocation,
|
|
Packit Service |
bf98b9 |
ClutterAllocationFlags flags)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayout *self = CLUTTER_GRID_LAYOUT (layout);
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation;
|
|
Packit Service |
bf98b9 |
ClutterGridRequest request;
|
|
Packit Service |
bf98b9 |
ClutterGridLines *lines;
|
|
Packit Service |
bf98b9 |
ClutterActorIter iter;
|
|
Packit Service |
bf98b9 |
ClutterActor *child;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
request.grid = self;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_grid_request_update_attach (&request);
|
|
Packit Service |
bf98b9 |
clutter_grid_request_count_lines (&request);
|
|
Packit Service |
bf98b9 |
lines = &request.lines[0];
|
|
Packit Service |
bf98b9 |
lines->lines = g_newa (ClutterGridLine, lines->max - lines->min);
|
|
Packit Service |
bf98b9 |
memset (lines->lines, 0, (lines->max - lines->min) * sizeof (ClutterGridLine));
|
|
Packit Service |
bf98b9 |
lines = &request.lines[1];
|
|
Packit Service |
bf98b9 |
lines->lines = g_newa (ClutterGridLine, lines->max - lines->min);
|
|
Packit Service |
bf98b9 |
memset (lines->lines, 0, (lines->max - lines->min) * sizeof (ClutterGridLine));
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (clutter_actor_get_request_mode (CLUTTER_ACTOR (container)) == CLUTTER_REQUEST_WIDTH_FOR_HEIGHT)
|
|
Packit Service |
bf98b9 |
orientation = CLUTTER_ORIENTATION_HORIZONTAL;
|
|
Packit Service |
bf98b9 |
else
|
|
Packit Service |
bf98b9 |
orientation = CLUTTER_ORIENTATION_VERTICAL;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_grid_request_run (&request, 1 - orientation, FALSE);
|
|
Packit Service |
bf98b9 |
clutter_grid_request_allocate (&request, 1 - orientation, GET_SIZE (allocation, 1 - orientation));
|
|
Packit Service |
bf98b9 |
clutter_grid_request_run (&request, orientation, TRUE);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_grid_request_allocate (&request, orientation, GET_SIZE (allocation, orientation));
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_grid_request_position (&request, 0);
|
|
Packit Service |
bf98b9 |
clutter_grid_request_position (&request, 1);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (container));
|
|
Packit Service |
bf98b9 |
while (clutter_actor_iter_next (&iter, &child))
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterActorBox child_allocation;
|
|
Packit Service |
bf98b9 |
gfloat x, y, width, height;
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (!clutter_actor_is_visible (child))
|
|
Packit Service |
bf98b9 |
continue;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
grid_child = GET_GRID_CHILD (self, child);
|
|
Packit Service |
bf98b9 |
allocate_child (&request, CLUTTER_ORIENTATION_HORIZONTAL, grid_child,
|
|
Packit Service |
bf98b9 |
&x, &width);
|
|
Packit Service |
bf98b9 |
allocate_child (&request, CLUTTER_ORIENTATION_VERTICAL, grid_child,
|
|
Packit Service |
bf98b9 |
&y, &height);
|
|
Packit Service |
bf98b9 |
x += allocation->x1;
|
|
Packit Service |
bf98b9 |
y += allocation->y1;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
CLUTTER_NOTE (LAYOUT, "Allocation for %s { %.2f, %.2f - %.2f x %.2f }",
|
|
Packit Service |
bf98b9 |
_clutter_actor_get_debug_name (child),
|
|
Packit Service |
bf98b9 |
x, y, width, height);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
child_allocation.x1 = x;
|
|
Packit Service |
bf98b9 |
child_allocation.y1 = y;
|
|
Packit Service |
bf98b9 |
child_allocation.x2 = child_allocation.x1 + width;
|
|
Packit Service |
bf98b9 |
child_allocation.y2 = child_allocation.y1 + height;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_actor_allocate (child, &child_allocation, flags);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static GType
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_get_child_meta_type (ClutterLayoutManager *self)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
return CLUTTER_TYPE_GRID_CHILD;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_set_property (GObject *gobject,
|
|
Packit Service |
bf98b9 |
guint prop_id,
|
|
Packit Service |
bf98b9 |
const GValue *value,
|
|
Packit Service |
bf98b9 |
GParamSpec *pspec)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayout *self = CLUTTER_GRID_LAYOUT (gobject);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
switch (prop_id)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
case PROP_ORIENTATION:
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_set_orientation (self, g_value_get_enum (value));
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case PROP_ROW_SPACING:
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_set_row_spacing (self, g_value_get_uint (value));
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case PROP_COLUMN_SPACING:
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_set_column_spacing (self, g_value_get_uint (value));
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case PROP_ROW_HOMOGENEOUS:
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_set_row_homogeneous (self,
|
|
Packit Service |
bf98b9 |
g_value_get_boolean (value));
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case PROP_COLUMN_HOMOGENEOUS:
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_set_column_homogeneous (self,
|
|
Packit Service |
bf98b9 |
g_value_get_boolean (value));
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
default:
|
|
Packit Service |
bf98b9 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_get_property (GObject *gobject,
|
|
Packit Service |
bf98b9 |
guint prop_id,
|
|
Packit Service |
bf98b9 |
GValue *value,
|
|
Packit Service |
bf98b9 |
GParamSpec *pspec)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv = CLUTTER_GRID_LAYOUT (gobject)->priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
switch (prop_id)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
case PROP_ORIENTATION:
|
|
Packit Service |
bf98b9 |
g_value_set_enum (value, priv->orientation);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case PROP_ROW_SPACING:
|
|
Packit Service |
bf98b9 |
g_value_set_uint (value, COLUMNS (priv)->spacing);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case PROP_COLUMN_SPACING:
|
|
Packit Service |
bf98b9 |
g_value_set_uint (value, ROWS (priv)->spacing);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case PROP_ROW_HOMOGENEOUS:
|
|
Packit Service |
bf98b9 |
g_value_set_boolean (value, COLUMNS (priv)->homogeneous);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case PROP_COLUMN_HOMOGENEOUS:
|
|
Packit Service |
bf98b9 |
g_value_set_boolean (value, ROWS (priv)->homogeneous);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
default:
|
|
Packit Service |
bf98b9 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_class_init (ClutterGridLayoutClass *klass)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
Packit Service |
bf98b9 |
ClutterLayoutManagerClass *layout_class;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
layout_class = CLUTTER_LAYOUT_MANAGER_CLASS (klass);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
object_class->set_property = clutter_grid_layout_set_property;
|
|
Packit Service |
bf98b9 |
object_class->get_property = clutter_grid_layout_get_property;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
layout_class->set_container = clutter_grid_layout_set_container;
|
|
Packit Service |
bf98b9 |
layout_class->get_preferred_width = clutter_grid_layout_get_preferred_width;
|
|
Packit Service |
bf98b9 |
layout_class->get_preferred_height = clutter_grid_layout_get_preferred_height;
|
|
Packit Service |
bf98b9 |
layout_class->allocate = clutter_grid_layout_allocate;
|
|
Packit Service |
bf98b9 |
layout_class->get_child_meta_type = clutter_grid_layout_get_child_meta_type;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* ClutterGridLayout:orientation:
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* The orientation of the layout, either horizontal or vertical
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
obj_props[PROP_ORIENTATION] =
|
|
Packit Service |
bf98b9 |
g_param_spec_enum ("orientation",
|
|
Packit Service |
bf98b9 |
P_("Orientation"),
|
|
Packit Service |
bf98b9 |
P_("The orientation of the layout"),
|
|
Packit Service |
bf98b9 |
CLUTTER_TYPE_ORIENTATION,
|
|
Packit Service |
bf98b9 |
CLUTTER_ORIENTATION_HORIZONTAL,
|
|
Packit Service |
bf98b9 |
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* ClutterGridLayout:row-spacing:
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* The amount of space in pixels between two consecutive rows
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
obj_props[PROP_ROW_SPACING] =
|
|
Packit Service |
bf98b9 |
g_param_spec_uint ("row-spacing",
|
|
Packit Service |
bf98b9 |
P_("Row spacing"),
|
|
Packit Service |
bf98b9 |
P_("The amount of space between two consecutive rows"),
|
|
Packit Service |
bf98b9 |
0, G_MAXUINT, 0,
|
|
Packit Service |
bf98b9 |
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* ClutterGridLayout:column-spacing:
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* The amount of space in pixels between two consecutive columns
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
obj_props[PROP_COLUMN_SPACING] =
|
|
Packit Service |
bf98b9 |
g_param_spec_uint ("column-spacing",
|
|
Packit Service |
bf98b9 |
P_("Column spacing"),
|
|
Packit Service |
bf98b9 |
P_("The amount of space between two consecutive "
|
|
Packit Service |
bf98b9 |
"columns"),
|
|
Packit Service |
bf98b9 |
0, G_MAXUINT, 0,
|
|
Packit Service |
bf98b9 |
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* ClutterGridLayout:row-homogeneous:
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Whether all rows of the layout should have the same height
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
obj_props[PROP_ROW_HOMOGENEOUS] =
|
|
Packit Service |
bf98b9 |
g_param_spec_boolean ("row-homogeneous",
|
|
Packit Service |
bf98b9 |
P_("Row Homogeneous"),
|
|
Packit Service |
bf98b9 |
P_("If TRUE, the rows are all the same height"),
|
|
Packit Service |
bf98b9 |
FALSE,
|
|
Packit Service |
bf98b9 |
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* ClutterGridLayout:column-homogeneous:
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Whether all columns of the layout should have the same width
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
obj_props[PROP_COLUMN_HOMOGENEOUS] =
|
|
Packit Service |
bf98b9 |
g_param_spec_boolean ("column-homogeneous",
|
|
Packit Service |
bf98b9 |
P_("Column Homogeneous"),
|
|
Packit Service |
bf98b9 |
P_("If TRUE, the columns are all the same width"),
|
|
Packit Service |
bf98b9 |
FALSE,
|
|
Packit Service |
bf98b9 |
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_object_class_install_properties (object_class, PROP_LAST, obj_props);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
static void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_init (ClutterGridLayout *self)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
self->priv = clutter_grid_layout_get_instance_private (self);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
self->priv->orientation = CLUTTER_ORIENTATION_HORIZONTAL;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
self->priv->linedata[0].spacing = 0;
|
|
Packit Service |
bf98b9 |
self->priv->linedata[1].spacing = 0;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
self->priv->linedata[0].homogeneous = FALSE;
|
|
Packit Service |
bf98b9 |
self->priv->linedata[1].homogeneous = FALSE;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_new:
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Creates a new #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Return value: the new #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
ClutterLayoutManager *
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_new (void)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
return g_object_new (CLUTTER_TYPE_GRID_LAYOUT, NULL);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_attach:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
* @child: the #ClutterActor to add
|
|
Packit Service |
bf98b9 |
* @left: the column number to attach the left side of @child to
|
|
Packit Service |
bf98b9 |
* @top: the row number to attach the top side of @child to
|
|
Packit Service |
bf98b9 |
* @width: the number of columns that @child will span
|
|
Packit Service |
bf98b9 |
* @height: the number of rows that @child will span
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Adds a widget to the grid.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* The position of @child is determined by @left and @top. The
|
|
Packit Service |
bf98b9 |
* number of 'cells' that @child will occupy is determined by
|
|
Packit Service |
bf98b9 |
* @width and @height.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_attach (ClutterGridLayout *layout,
|
|
Packit Service |
bf98b9 |
ClutterActor *child,
|
|
Packit Service |
bf98b9 |
gint left,
|
|
Packit Service |
bf98b9 |
gint top,
|
|
Packit Service |
bf98b9 |
gint width,
|
|
Packit Service |
bf98b9 |
gint height)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_if_fail (CLUTTER_IS_GRID_LAYOUT (layout));
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
priv = layout->priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (!priv->container)
|
|
Packit Service |
bf98b9 |
return;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
grid_attach (layout, child, left, top, width, height);
|
|
Packit Service |
bf98b9 |
clutter_actor_add_child (CLUTTER_ACTOR (priv->container), child);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_attach_next_to:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
* @child: the actor to add
|
|
Packit Service |
bf98b9 |
* @sibling: (allow-none): the child of @layout that @child will be placed
|
|
Packit Service |
bf98b9 |
* next to, or %NULL to place @child at the beginning or end
|
|
Packit Service |
bf98b9 |
* @side: the side of @sibling that @child is positioned next to
|
|
Packit Service |
bf98b9 |
* @width: the number of columns that @child will span
|
|
Packit Service |
bf98b9 |
* @height: the number of rows that @child will span
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Adds a actor to the grid.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* The actor is placed next to @sibling, on the side determined by
|
|
Packit Service |
bf98b9 |
* @side. When @sibling is %NULL, the actor is placed in row (for
|
|
Packit Service |
bf98b9 |
* left or right placement) or column 0 (for top or bottom placement),
|
|
Packit Service |
bf98b9 |
* at the end indicated by @side.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Attaching widgets labeled [1], [2], [3] with @sibling == %NULL and
|
|
Packit Service |
bf98b9 |
* @side == %CLUTTER_GRID_POSITION_LEFT yields a layout of [3][2][1].
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_attach_next_to (ClutterGridLayout *layout,
|
|
Packit Service |
bf98b9 |
ClutterActor *child,
|
|
Packit Service |
bf98b9 |
ClutterActor *sibling,
|
|
Packit Service |
bf98b9 |
ClutterGridPosition side,
|
|
Packit Service |
bf98b9 |
gint width,
|
|
Packit Service |
bf98b9 |
gint height)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_if_fail (CLUTTER_IS_GRID_LAYOUT (layout));
|
|
Packit Service |
bf98b9 |
g_return_if_fail (CLUTTER_IS_ACTOR (child));
|
|
Packit Service |
bf98b9 |
g_return_if_fail (clutter_actor_get_parent (child) == NULL);
|
|
Packit Service |
bf98b9 |
g_return_if_fail (sibling == NULL || CLUTTER_IS_ACTOR (sibling));
|
|
Packit Service |
bf98b9 |
g_return_if_fail (width > 0);
|
|
Packit Service |
bf98b9 |
g_return_if_fail (height > 0);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
priv = layout->priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (!priv->container)
|
|
Packit Service |
bf98b9 |
return;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
grid_attach_next_to (layout, child, sibling, side, width, height);
|
|
Packit Service |
bf98b9 |
clutter_actor_add_child (CLUTTER_ACTOR (priv->container), child);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_set_orientation:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
* @orientation: the orientation of the #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Sets the orientation of the @layout.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* #ClutterGridLayout uses the orientation as a hint when adding
|
|
Packit Service |
bf98b9 |
* children to the #ClutterActor using it as a layout manager via
|
|
Packit Service |
bf98b9 |
* clutter_actor_add_child(); changing this value will not have
|
|
Packit Service |
bf98b9 |
* any effect on children that are already part of the layout.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_set_orientation (ClutterGridLayout *layout,
|
|
Packit Service |
bf98b9 |
ClutterOrientation orientation)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_if_fail (CLUTTER_IS_GRID_LAYOUT (layout));
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
priv = layout->priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (priv->orientation != orientation)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
priv->orientation = orientation;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_layout_manager_layout_changed (CLUTTER_LAYOUT_MANAGER (layout));
|
|
Packit Service |
bf98b9 |
g_object_notify_by_pspec (G_OBJECT (layout), obj_props[PROP_ORIENTATION]);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_get_child_at:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
* @left: the left edge of the cell
|
|
Packit Service |
bf98b9 |
* @top: the top edge of the cell
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Gets the child of @layout whose area covers the grid
|
|
Packit Service |
bf98b9 |
* cell whose upper left corner is at @left, @top.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Returns: (transfer none): the child at the given position, or %NULL
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
ClutterActor *
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_get_child_at (ClutterGridLayout *layout,
|
|
Packit Service |
bf98b9 |
gint left,
|
|
Packit Service |
bf98b9 |
gint top)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv;
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child;
|
|
Packit Service |
bf98b9 |
ClutterActorIter iter;
|
|
Packit Service |
bf98b9 |
ClutterActor *child;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_val_if_fail (CLUTTER_IS_GRID_LAYOUT (layout), NULL);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
priv = layout->priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (!priv->container)
|
|
Packit Service |
bf98b9 |
return NULL;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (priv->container));
|
|
Packit Service |
bf98b9 |
while (clutter_actor_iter_next (&iter, &child))
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
grid_child = GET_GRID_CHILD (layout, child);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (CHILD_LEFT (grid_child) <= left &&
|
|
Packit Service |
bf98b9 |
CHILD_LEFT (grid_child) + CHILD_WIDTH (grid_child) > left &&
|
|
Packit Service |
bf98b9 |
CHILD_TOP (grid_child) <= top &&
|
|
Packit Service |
bf98b9 |
CHILD_TOP (grid_child) + CHILD_HEIGHT (grid_child) > top)
|
|
Packit Service |
bf98b9 |
return child;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
return NULL;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_insert_row:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
* @position: the position to insert the row at
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Inserts a row at the specified position.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Children which are attached at or below this position
|
|
Packit Service |
bf98b9 |
* are moved one row down. Children which span across this
|
|
Packit Service |
bf98b9 |
* position are grown to span the new row.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_insert_row (ClutterGridLayout *layout,
|
|
Packit Service |
bf98b9 |
gint position)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv;
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child;
|
|
Packit Service |
bf98b9 |
ClutterActorIter iter;
|
|
Packit Service |
bf98b9 |
ClutterActor *child;
|
|
Packit Service |
bf98b9 |
gint top, height;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_if_fail (CLUTTER_IS_GRID_LAYOUT (layout));
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
priv = layout->priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (!priv->container)
|
|
Packit Service |
bf98b9 |
return;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (priv->container));
|
|
Packit Service |
bf98b9 |
while (clutter_actor_iter_next (&iter, &child))
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
grid_child = GET_GRID_CHILD (layout, child);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
top = CHILD_TOP (grid_child);
|
|
Packit Service |
bf98b9 |
height = CHILD_HEIGHT (grid_child);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (top >= position)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
CHILD_TOP (grid_child) = top + 1;
|
|
Packit Service |
bf98b9 |
g_object_notify_by_pspec (G_OBJECT (grid_child),
|
|
Packit Service |
bf98b9 |
child_props[PROP_CHILD_TOP_ATTACH]);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
else if (top + height > position)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
CHILD_HEIGHT (grid_child) = height + 1;
|
|
Packit Service |
bf98b9 |
g_object_notify_by_pspec (G_OBJECT (grid_child),
|
|
Packit Service |
bf98b9 |
child_props[PROP_CHILD_HEIGHT]);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
clutter_layout_manager_layout_changed (CLUTTER_LAYOUT_MANAGER (layout));
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_insert_column:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
* @position: the position to insert the column at
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Inserts a column at the specified position.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Children which are attached at or to the right of this position
|
|
Packit Service |
bf98b9 |
* are moved one column to the right. Children which span across this
|
|
Packit Service |
bf98b9 |
* position are grown to span the new column.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_insert_column (ClutterGridLayout *layout,
|
|
Packit Service |
bf98b9 |
gint position)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv;
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child;
|
|
Packit Service |
bf98b9 |
ClutterActorIter iter;
|
|
Packit Service |
bf98b9 |
ClutterActor *child;
|
|
Packit Service |
bf98b9 |
gint left, width;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_if_fail (CLUTTER_IS_GRID_LAYOUT (layout));
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
priv = layout->priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (!priv->container)
|
|
Packit Service |
bf98b9 |
return;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (priv->container));
|
|
Packit Service |
bf98b9 |
while (clutter_actor_iter_next (&iter, &child))
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
grid_child = GET_GRID_CHILD (layout, child);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
left = CHILD_LEFT (grid_child);
|
|
Packit Service |
bf98b9 |
width = CHILD_WIDTH (grid_child);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (left >= position)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
CHILD_LEFT (grid_child) = left + 1;
|
|
Packit Service |
bf98b9 |
g_object_notify_by_pspec (G_OBJECT (grid_child),
|
|
Packit Service |
bf98b9 |
child_props[PROP_CHILD_LEFT_ATTACH]);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
else if (left + width > position)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
CHILD_WIDTH (grid_child) = width + 1;
|
|
Packit Service |
bf98b9 |
g_object_notify_by_pspec (G_OBJECT (grid_child),
|
|
Packit Service |
bf98b9 |
child_props[PROP_CHILD_WIDTH]);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
clutter_layout_manager_layout_changed (CLUTTER_LAYOUT_MANAGER (layout));
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_insert_next_to:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
* @sibling: the child of @layout that the new row or column will be
|
|
Packit Service |
bf98b9 |
* placed next to
|
|
Packit Service |
bf98b9 |
* @side: the side of @sibling that @child is positioned next to
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Inserts a row or column at the specified position.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* The new row or column is placed next to @sibling, on the side
|
|
Packit Service |
bf98b9 |
* determined by @side. If @side is %CLUTTER_GRID_POSITION_LEFT or
|
|
Packit Service |
bf98b9 |
* %CLUTTER_GRID_POSITION_BOTTOM, a row is inserted. If @side is
|
|
Packit Service |
bf98b9 |
* %CLUTTER_GRID_POSITION_LEFT of %CLUTTER_GRID_POSITION_RIGHT,
|
|
Packit Service |
bf98b9 |
* a column is inserted.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_insert_next_to (ClutterGridLayout *layout,
|
|
Packit Service |
bf98b9 |
ClutterActor *sibling,
|
|
Packit Service |
bf98b9 |
ClutterGridPosition side)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridChild *grid_child;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_if_fail (CLUTTER_IS_GRID_LAYOUT (layout));
|
|
Packit Service |
bf98b9 |
g_return_if_fail (CLUTTER_IS_ACTOR (sibling));
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
grid_child = GET_GRID_CHILD (layout, sibling);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
switch (side)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
case CLUTTER_GRID_POSITION_LEFT:
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_insert_column (layout, CHILD_LEFT (grid_child));
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case CLUTTER_GRID_POSITION_RIGHT:
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_insert_column (layout, CHILD_LEFT (grid_child) +
|
|
Packit Service |
bf98b9 |
CHILD_WIDTH (grid_child));
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case CLUTTER_GRID_POSITION_TOP:
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_insert_row (layout, CHILD_TOP (grid_child));
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
case CLUTTER_GRID_POSITION_BOTTOM:
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_insert_row (layout, CHILD_TOP (grid_child) +
|
|
Packit Service |
bf98b9 |
CHILD_HEIGHT (grid_child));
|
|
Packit Service |
bf98b9 |
break;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
default:
|
|
Packit Service |
bf98b9 |
g_assert_not_reached ();
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_get_orientation:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Retrieves the orientation of the @layout.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Return value: the orientation of the layout
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
ClutterOrientation
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_get_orientation (ClutterGridLayout *layout)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
g_return_val_if_fail (CLUTTER_IS_GRID_LAYOUT (layout),
|
|
Packit Service |
bf98b9 |
CLUTTER_ORIENTATION_HORIZONTAL);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
return layout->priv->orientation;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_set_row_spacing:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
* @spacing: the spacing between rows of the layout, in pixels
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Sets the spacing between rows of @layout
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_set_row_spacing (ClutterGridLayout *layout,
|
|
Packit Service |
bf98b9 |
guint spacing)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_if_fail (CLUTTER_IS_GRID_LAYOUT (layout));
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
priv = layout->priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (COLUMNS (priv)->spacing != spacing)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
COLUMNS (priv)->spacing = spacing;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_layout_manager_layout_changed (CLUTTER_LAYOUT_MANAGER (layout));
|
|
Packit Service |
bf98b9 |
g_object_notify_by_pspec (G_OBJECT (layout),
|
|
Packit Service |
bf98b9 |
obj_props[PROP_ROW_SPACING]);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_get_row_spacing:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Retrieves the spacing set using clutter_grid_layout_set_row_spacing()
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Return value: the spacing between rows of @layout
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
guint
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_get_row_spacing (ClutterGridLayout *layout)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_val_if_fail (CLUTTER_IS_GRID_LAYOUT (layout), 0);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
priv = layout->priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
return COLUMNS (priv)->spacing;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_set_column_spacing:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
* @spacing: the spacing between columns of the layout, in pixels
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Sets the spacing between columns of @layout
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_set_column_spacing (ClutterGridLayout *layout,
|
|
Packit Service |
bf98b9 |
guint spacing)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_if_fail (CLUTTER_IS_GRID_LAYOUT (layout));
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
priv = layout->priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (ROWS (priv)->spacing != spacing)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ROWS (priv)->spacing = spacing;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_layout_manager_layout_changed (CLUTTER_LAYOUT_MANAGER (layout));
|
|
Packit Service |
bf98b9 |
g_object_notify_by_pspec (G_OBJECT (layout),
|
|
Packit Service |
bf98b9 |
obj_props[PROP_COLUMN_SPACING]);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_get_column_spacing:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Retrieves the spacing set using clutter_grid_layout_set_column_spacing()
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Return value: the spacing between coluns of @layout
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
guint
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_get_column_spacing (ClutterGridLayout *layout)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_val_if_fail (CLUTTER_IS_GRID_LAYOUT (layout), 0);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
priv = layout->priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
return ROWS (priv)->spacing;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_set_column_homogeneous:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
* @homogeneous: %TRUE to make columns homogeneous
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Sets whether all columns of @layout will have the same width.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_set_column_homogeneous (ClutterGridLayout *layout,
|
|
Packit Service |
bf98b9 |
gboolean homogeneous)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_if_fail (CLUTTER_IS_GRID_LAYOUT (layout));
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
priv = layout->priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (ROWS (priv)->homogeneous != homogeneous)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ROWS (priv)->homogeneous = homogeneous;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_layout_manager_layout_changed (CLUTTER_LAYOUT_MANAGER (layout));
|
|
Packit Service |
bf98b9 |
g_object_notify_by_pspec (G_OBJECT (layout),
|
|
Packit Service |
bf98b9 |
obj_props[PROP_COLUMN_HOMOGENEOUS]);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_get_column_homogeneous:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Returns whether all columns of @layout have the same width.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Returns: whether all columns of @layout have the same width.
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
gboolean
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_get_column_homogeneous (ClutterGridLayout *layout)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_val_if_fail (CLUTTER_IS_GRID_LAYOUT (layout), FALSE);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
priv = layout->priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
return ROWS (priv)->homogeneous;
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_set_row_homogeneous:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
* @homogeneous: %TRUE to make rows homogeneous
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Sets whether all rows of @layout will have the same height.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
void
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_set_row_homogeneous (ClutterGridLayout *layout,
|
|
Packit Service |
bf98b9 |
gboolean homogeneous)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_if_fail (CLUTTER_IS_GRID_LAYOUT (layout));
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
priv = layout->priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
if (COLUMNS (priv)->homogeneous != homogeneous)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
COLUMNS (priv)->homogeneous = homogeneous;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
clutter_layout_manager_layout_changed (CLUTTER_LAYOUT_MANAGER (layout));
|
|
Packit Service |
bf98b9 |
g_object_notify_by_pspec (G_OBJECT (layout),
|
|
Packit Service |
bf98b9 |
obj_props[PROP_ROW_HOMOGENEOUS]);
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
}
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
/**
|
|
Packit Service |
bf98b9 |
* clutter_grid_layout_get_row_homogeneous:
|
|
Packit Service |
bf98b9 |
* @layout: a #ClutterGridLayout
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Returns whether all rows of @layout have the same height.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Returns: whether all rows of @layout have the same height.
|
|
Packit Service |
bf98b9 |
*
|
|
Packit Service |
bf98b9 |
* Since: 1.12
|
|
Packit Service |
bf98b9 |
*/
|
|
Packit Service |
bf98b9 |
gboolean
|
|
Packit Service |
bf98b9 |
clutter_grid_layout_get_row_homogeneous (ClutterGridLayout *layout)
|
|
Packit Service |
bf98b9 |
{
|
|
Packit Service |
bf98b9 |
ClutterGridLayoutPrivate *priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
g_return_val_if_fail (CLUTTER_IS_GRID_LAYOUT (layout), FALSE);
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
priv = layout->priv;
|
|
Packit Service |
bf98b9 |
|
|
Packit Service |
bf98b9 |
return COLUMNS (priv)->homogeneous;
|
|
Packit Service |
bf98b9 |
}
|