Port remaining layout managers to the new child iteration API
TableLayout and FlowLayout now use the ClutterActor API for iterating over the children of an actor.
This commit is contained in:
@ -708,29 +708,35 @@ clutter_table_layout_set_container (ClutterLayoutManager *layout,
|
||||
|
||||
static void
|
||||
update_row_col (ClutterTableLayout *layout,
|
||||
ClutterContainer *container)
|
||||
ClutterContainer *container)
|
||||
{
|
||||
ClutterTableLayoutPrivate *priv = layout->priv;
|
||||
ClutterLayoutManager *manager = CLUTTER_LAYOUT_MANAGER (layout);
|
||||
GList *children, *l;
|
||||
ClutterActor *actor, *child;
|
||||
gint n_cols, n_rows;
|
||||
|
||||
n_cols = n_rows = 0;
|
||||
children = container ? clutter_container_get_children (container) : NULL;
|
||||
|
||||
for (l = children; l; l = g_list_next (l))
|
||||
if (container == NULL)
|
||||
goto out;
|
||||
|
||||
actor = CLUTTER_ACTOR (container);
|
||||
for (child = clutter_actor_get_first_child (actor);
|
||||
child != NULL;
|
||||
child = clutter_actor_get_next_sibling (child))
|
||||
{
|
||||
ClutterActor *child = l->data;
|
||||
ClutterTableChild *meta;
|
||||
|
||||
meta = CLUTTER_TABLE_CHILD (clutter_layout_manager_get_child_meta (manager, container, child));
|
||||
meta =
|
||||
CLUTTER_TABLE_CHILD (clutter_layout_manager_get_child_meta (manager,
|
||||
container,
|
||||
child));
|
||||
|
||||
n_cols = MAX (n_cols, meta->col + meta->col_span);
|
||||
n_rows = MAX (n_rows, meta->row + meta->row_span);
|
||||
}
|
||||
|
||||
g_list_free (children);
|
||||
|
||||
out:
|
||||
priv->n_cols = n_cols;
|
||||
priv->n_rows = n_rows;
|
||||
|
||||
@ -743,9 +749,9 @@ calculate_col_widths (ClutterTableLayout *self,
|
||||
{
|
||||
ClutterTableLayoutPrivate *priv = self->priv;
|
||||
ClutterLayoutManager *manager = CLUTTER_LAYOUT_MANAGER (self);
|
||||
ClutterActor *actor, *child;
|
||||
gint i;
|
||||
DimensionData *columns;
|
||||
GList *l, *children;
|
||||
|
||||
update_row_col (self, container);
|
||||
g_array_set_size (priv->columns, 0);
|
||||
@ -757,12 +763,13 @@ calculate_col_widths (ClutterTableLayout *self,
|
||||
for (i = 0; i < priv->n_cols; i++)
|
||||
columns[i].visible = FALSE;
|
||||
|
||||
children = clutter_container_get_children (container);
|
||||
actor = CLUTTER_ACTOR (container);
|
||||
|
||||
/* STAGE ONE: calculate column widths for non-spanned children */
|
||||
for (l = children; l; l = g_list_next (l))
|
||||
for (child = clutter_actor_get_first_child (actor);
|
||||
child != NULL;
|
||||
child = clutter_actor_get_next_sibling (child))
|
||||
{
|
||||
ClutterActor *child = l->data;
|
||||
ClutterTableChild *meta;
|
||||
DimensionData *col;
|
||||
gfloat c_min, c_pref;
|
||||
@ -770,8 +777,10 @@ calculate_col_widths (ClutterTableLayout *self,
|
||||
if (!CLUTTER_ACTOR_IS_VISIBLE (child))
|
||||
continue;
|
||||
|
||||
meta = (ClutterTableChild *)
|
||||
clutter_layout_manager_get_child_meta (manager, container, child);
|
||||
meta =
|
||||
CLUTTER_TABLE_CHILD (clutter_layout_manager_get_child_meta (manager,
|
||||
container,
|
||||
child));
|
||||
|
||||
if (meta->col_span > 1)
|
||||
continue;
|
||||
@ -792,9 +801,10 @@ calculate_col_widths (ClutterTableLayout *self,
|
||||
}
|
||||
|
||||
/* STAGE TWO: take spanning children into account */
|
||||
for (l = children; l; l = g_list_next (l))
|
||||
for (child = clutter_actor_get_first_child (actor);
|
||||
child != NULL;
|
||||
child = clutter_actor_get_next_sibling (child))
|
||||
{
|
||||
ClutterActor *child = l->data;
|
||||
ClutterTableChild *meta;
|
||||
DimensionData *col;
|
||||
gfloat c_min, c_pref;
|
||||
@ -805,8 +815,10 @@ calculate_col_widths (ClutterTableLayout *self,
|
||||
if (!CLUTTER_ACTOR_IS_VISIBLE (child))
|
||||
continue;
|
||||
|
||||
meta = (ClutterTableChild *)
|
||||
clutter_layout_manager_get_child_meta (manager, container, child);
|
||||
meta =
|
||||
CLUTTER_TABLE_CHILD (clutter_layout_manager_get_child_meta (manager,
|
||||
container,
|
||||
child));
|
||||
|
||||
if (meta->col_span < 2)
|
||||
continue;
|
||||
@ -890,7 +902,6 @@ calculate_col_widths (ClutterTableLayout *self,
|
||||
|
||||
|
||||
}
|
||||
g_list_free (children);
|
||||
|
||||
/* calculate final widths */
|
||||
if (for_width >= 0)
|
||||
@ -901,6 +912,7 @@ calculate_col_widths (ClutterTableLayout *self,
|
||||
min_width = 0;
|
||||
pref_width = 0;
|
||||
n_expand = 0;
|
||||
|
||||
for (i = 0; i < self->priv->n_cols; i++)
|
||||
{
|
||||
pref_width += columns[i].pref_size;
|
||||
@ -908,6 +920,7 @@ calculate_col_widths (ClutterTableLayout *self,
|
||||
if (columns[i].expand)
|
||||
n_expand++;
|
||||
}
|
||||
|
||||
pref_width += priv->col_spacing * (priv->n_cols - 1);
|
||||
min_width += priv->col_spacing * (priv->n_cols - 1);
|
||||
|
||||
@ -1003,7 +1016,7 @@ calculate_row_heights (ClutterTableLayout *self,
|
||||
{
|
||||
ClutterTableLayoutPrivate *priv = self->priv;
|
||||
ClutterLayoutManager *manager = CLUTTER_LAYOUT_MANAGER (self);
|
||||
GList *l, *children;
|
||||
ClutterActor *actor, *child;
|
||||
gint i;
|
||||
DimensionData *rows, *columns;
|
||||
|
||||
@ -1019,11 +1032,13 @@ calculate_row_heights (ClutterTableLayout *self,
|
||||
for (i = 0; i < priv->n_rows; i++)
|
||||
rows[i].visible = FALSE;
|
||||
|
||||
children = clutter_container_get_children (container);
|
||||
actor = CLUTTER_ACTOR (container);
|
||||
|
||||
/* STAGE ONE: calculate row heights for non-spanned children */
|
||||
for (l = children; l; l = g_list_next (l))
|
||||
for (child = clutter_actor_get_first_child (actor);
|
||||
child != NULL;
|
||||
child = clutter_actor_get_next_sibling (child))
|
||||
{
|
||||
ClutterActor *child = l->data;
|
||||
ClutterTableChild *meta;
|
||||
DimensionData *row;
|
||||
gfloat c_min, c_pref;
|
||||
@ -1031,8 +1046,10 @@ calculate_row_heights (ClutterTableLayout *self,
|
||||
if (!CLUTTER_ACTOR_IS_VISIBLE (child))
|
||||
continue;
|
||||
|
||||
meta = (ClutterTableChild *)
|
||||
clutter_layout_manager_get_child_meta (manager, container, child);
|
||||
meta =
|
||||
CLUTTER_TABLE_CHILD (clutter_layout_manager_get_child_meta (manager,
|
||||
container,
|
||||
child));
|
||||
|
||||
if (meta->row_span > 1)
|
||||
continue;
|
||||
@ -1053,12 +1070,11 @@ calculate_row_heights (ClutterTableLayout *self,
|
||||
row->expand = MAX (row->expand, meta->y_expand);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* STAGE TWO: take spanning children into account */
|
||||
for (l = children; l; l = g_list_next (l))
|
||||
for (child = clutter_actor_get_first_child (actor);
|
||||
child != NULL;
|
||||
child = clutter_actor_get_next_sibling (child))
|
||||
{
|
||||
ClutterActor *child = l->data;
|
||||
ClutterTableChild *meta;
|
||||
gfloat c_min, c_pref;
|
||||
gfloat min_height, pref_height;
|
||||
@ -1068,8 +1084,10 @@ calculate_row_heights (ClutterTableLayout *self,
|
||||
if (!CLUTTER_ACTOR_IS_VISIBLE (child))
|
||||
continue;
|
||||
|
||||
meta = (ClutterTableChild *)
|
||||
clutter_layout_manager_get_child_meta (manager, container, child);
|
||||
meta =
|
||||
CLUTTER_TABLE_CHILD (clutter_layout_manager_get_child_meta (manager,
|
||||
container,
|
||||
child));
|
||||
|
||||
if (meta->row_span < 2)
|
||||
continue;
|
||||
@ -1165,8 +1183,6 @@ calculate_row_heights (ClutterTableLayout *self,
|
||||
|
||||
}
|
||||
|
||||
g_list_free (children);
|
||||
|
||||
/* calculate final heights */
|
||||
if (for_height >= 0)
|
||||
{
|
||||
@ -1176,6 +1192,7 @@ calculate_row_heights (ClutterTableLayout *self,
|
||||
min_height = 0;
|
||||
pref_height = 0;
|
||||
n_expand = 0;
|
||||
|
||||
for (i = 0; i < self->priv->n_rows; i++)
|
||||
{
|
||||
pref_height += rows[i].pref_size;
|
||||
@ -1183,6 +1200,7 @@ calculate_row_heights (ClutterTableLayout *self,
|
||||
if (rows[i].expand)
|
||||
n_expand++;
|
||||
}
|
||||
|
||||
pref_height += priv->row_spacing * (priv->n_rows - 1);
|
||||
min_height += priv->row_spacing * (priv->n_rows - 1);
|
||||
|
||||
@ -1387,7 +1405,7 @@ clutter_table_layout_allocate (ClutterLayoutManager *layout,
|
||||
{
|
||||
ClutterTableLayout *self = CLUTTER_TABLE_LAYOUT (layout);
|
||||
ClutterTableLayoutPrivate *priv = self->priv;
|
||||
GList *list, *children;
|
||||
ClutterActor *actor, *child;
|
||||
gint row_spacing, col_spacing;
|
||||
gint i;
|
||||
DimensionData *rows, *columns;
|
||||
@ -1396,8 +1414,9 @@ clutter_table_layout_allocate (ClutterLayoutManager *layout,
|
||||
if (priv->n_cols < 1 || priv->n_rows < 1)
|
||||
return;
|
||||
|
||||
children = clutter_container_get_children (container);
|
||||
if (children == NULL)
|
||||
actor = CLUTTER_ACTOR (container);
|
||||
|
||||
if (clutter_actor_get_n_children (actor) == 0)
|
||||
return;
|
||||
|
||||
col_spacing = (priv->col_spacing);
|
||||
@ -1410,9 +1429,10 @@ clutter_table_layout_allocate (ClutterLayoutManager *layout,
|
||||
rows = (DimensionData *) priv->rows->data;
|
||||
columns = (DimensionData *) priv->columns->data;
|
||||
|
||||
for (list = children; list; list = g_list_next (list))
|
||||
for (child = clutter_actor_get_first_child (actor);
|
||||
child != NULL;
|
||||
child = clutter_actor_get_next_sibling (child))
|
||||
{
|
||||
ClutterActor *child = list->data;
|
||||
gint row, col, row_span, col_span;
|
||||
gint col_width, row_height;
|
||||
ClutterTableChild *meta;
|
||||
@ -1424,8 +1444,10 @@ clutter_table_layout_allocate (ClutterLayoutManager *layout,
|
||||
if (!CLUTTER_ACTOR_IS_VISIBLE (child))
|
||||
continue;
|
||||
|
||||
meta = (ClutterTableChild *)
|
||||
clutter_layout_manager_get_child_meta (layout, priv->container, child);
|
||||
meta =
|
||||
CLUTTER_TABLE_CHILD (clutter_layout_manager_get_child_meta (layout,
|
||||
container,
|
||||
child));
|
||||
|
||||
/* get child properties */
|
||||
col = meta->col;
|
||||
@ -1560,8 +1582,6 @@ clutter_table_layout_allocate (ClutterLayoutManager *layout,
|
||||
do_allocate:
|
||||
clutter_actor_allocate (child, &childbox, flags);
|
||||
}
|
||||
|
||||
g_list_free (children);
|
||||
}
|
||||
|
||||
static ClutterAlpha *
|
||||
|
Reference in New Issue
Block a user