mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 18:11:05 -05:00
flow-layout: Use macros for subclassing boilerplate
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3387>
This commit is contained in:
parent
5b527ac89b
commit
ba689b86ba
@ -34,7 +34,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBackend, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBrightnessContrastEffect, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterClone, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDesaturateEffect, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterFlowLayout, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterGridLayout, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterInputDevice, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterInterval, g_object_unref)
|
||||
|
@ -63,8 +63,10 @@
|
||||
#include "clutter/clutter-layout-meta.h"
|
||||
#include "clutter/clutter-private.h"
|
||||
|
||||
struct _ClutterFlowLayoutPrivate
|
||||
struct _ClutterFlowLayout
|
||||
{
|
||||
ClutterLayoutManager parent_instance;
|
||||
|
||||
ClutterActor *container;
|
||||
|
||||
ClutterFlowOrientation orientation;
|
||||
@ -115,25 +117,24 @@ enum
|
||||
|
||||
static GParamSpec *flow_properties[N_PROPERTIES] = { NULL, };
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (ClutterFlowLayout,
|
||||
clutter_flow_layout,
|
||||
CLUTTER_TYPE_LAYOUT_MANAGER)
|
||||
G_DEFINE_FINAL_TYPE (ClutterFlowLayout,
|
||||
clutter_flow_layout,
|
||||
CLUTTER_TYPE_LAYOUT_MANAGER)
|
||||
|
||||
static gint
|
||||
get_columns (ClutterFlowLayout *self,
|
||||
gfloat for_width)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv = self->priv;
|
||||
gint n_columns;
|
||||
|
||||
if (for_width < 0)
|
||||
return 1;
|
||||
|
||||
if (priv->col_width == 0)
|
||||
if (self->col_width == 0)
|
||||
return 1;
|
||||
|
||||
n_columns = (gint) (for_width + priv->col_spacing)
|
||||
/ (priv->col_width + priv->col_spacing);
|
||||
n_columns = (gint) (for_width + self->col_spacing)
|
||||
/ (self->col_width + self->col_spacing);
|
||||
|
||||
if (n_columns == 0)
|
||||
return 1;
|
||||
@ -145,17 +146,16 @@ static gint
|
||||
get_rows (ClutterFlowLayout *self,
|
||||
gfloat for_height)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv = self->priv;
|
||||
gint n_rows;
|
||||
|
||||
if (for_height < 0)
|
||||
return 1;
|
||||
|
||||
if (priv->row_height == 0)
|
||||
if (self->row_height == 0)
|
||||
return 1;
|
||||
|
||||
n_rows = (gint) (for_height + priv->row_spacing)
|
||||
/ (priv->row_height + priv->row_spacing);
|
||||
n_rows = (gint) (for_height + self->row_spacing)
|
||||
/ (self->row_height + self->row_spacing);
|
||||
|
||||
if (n_rows == 0)
|
||||
return 1;
|
||||
@ -168,9 +168,7 @@ compute_lines (ClutterFlowLayout *self,
|
||||
gfloat avail_width,
|
||||
gfloat avail_height)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv = self->priv;
|
||||
|
||||
if (priv->orientation == CLUTTER_FLOW_HORIZONTAL)
|
||||
if (self->orientation == CLUTTER_FLOW_HORIZONTAL)
|
||||
return get_columns (self, avail_width);
|
||||
else
|
||||
return get_rows (self, avail_height);
|
||||
@ -183,7 +181,7 @@ clutter_flow_layout_get_preferred_width (ClutterLayoutManager *manager,
|
||||
gfloat *min_width_p,
|
||||
gfloat *nat_width_p)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv = CLUTTER_FLOW_LAYOUT (manager)->priv;
|
||||
ClutterFlowLayout *self = CLUTTER_FLOW_LAYOUT (manager);
|
||||
gint n_rows, line_item_count, line_count;
|
||||
gfloat total_min_width, total_natural_width;
|
||||
gfloat line_min_width, line_natural_width;
|
||||
@ -208,16 +206,16 @@ clutter_flow_layout_get_preferred_width (ClutterLayoutManager *manager,
|
||||
actor = CLUTTER_ACTOR (container);
|
||||
|
||||
/* clear the line width arrays */
|
||||
if (priv->line_min != NULL)
|
||||
g_array_free (priv->line_min, TRUE);
|
||||
if (self->line_min != NULL)
|
||||
g_array_free (self->line_min, TRUE);
|
||||
|
||||
if (priv->line_natural != NULL)
|
||||
g_array_free (priv->line_natural, TRUE);
|
||||
if (self->line_natural != NULL)
|
||||
g_array_free (self->line_natural, TRUE);
|
||||
|
||||
priv->line_min = g_array_sized_new (FALSE, FALSE,
|
||||
self->line_min = g_array_sized_new (FALSE, FALSE,
|
||||
sizeof (gfloat),
|
||||
16);
|
||||
priv->line_natural = g_array_sized_new (FALSE, FALSE,
|
||||
self->line_natural = g_array_sized_new (FALSE, FALSE,
|
||||
sizeof (gfloat),
|
||||
16);
|
||||
|
||||
@ -235,21 +233,21 @@ clutter_flow_layout_get_preferred_width (ClutterLayoutManager *manager,
|
||||
if (!clutter_actor_is_visible (child))
|
||||
continue;
|
||||
|
||||
if (priv->orientation == CLUTTER_FLOW_VERTICAL && for_height > 0)
|
||||
if (self->orientation == CLUTTER_FLOW_VERTICAL && for_height > 0)
|
||||
{
|
||||
clutter_actor_get_preferred_height (child, -1,
|
||||
&child_min,
|
||||
&child_natural);
|
||||
|
||||
if ((priv->snap_to_grid && line_item_count == n_rows) ||
|
||||
(!priv->snap_to_grid && item_y + child_natural > for_height))
|
||||
if ((self->snap_to_grid && line_item_count == n_rows) ||
|
||||
(!self->snap_to_grid && item_y + child_natural > for_height))
|
||||
{
|
||||
total_min_width += line_min_width;
|
||||
total_natural_width += line_natural_width;
|
||||
|
||||
g_array_append_val (priv->line_min,
|
||||
g_array_append_val (self->line_min,
|
||||
line_min_width);
|
||||
g_array_append_val (priv->line_natural,
|
||||
g_array_append_val (self->line_natural,
|
||||
line_natural_width);
|
||||
|
||||
line_min_width = line_natural_width = 0;
|
||||
@ -259,15 +257,15 @@ clutter_flow_layout_get_preferred_width (ClutterLayoutManager *manager,
|
||||
item_y = 0;
|
||||
}
|
||||
|
||||
if (priv->snap_to_grid)
|
||||
if (self->snap_to_grid)
|
||||
{
|
||||
new_y = ((line_item_count + 1) * (for_height + priv->row_spacing))
|
||||
new_y = ((line_item_count + 1) * (for_height + self->row_spacing))
|
||||
/ n_rows;
|
||||
item_height = new_y - item_y - priv->row_spacing;
|
||||
item_height = new_y - item_y - self->row_spacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_y = item_y + child_natural + priv->row_spacing;
|
||||
new_y = item_y + child_natural + self->row_spacing;
|
||||
item_height = child_natural;
|
||||
}
|
||||
|
||||
@ -299,15 +297,15 @@ clutter_flow_layout_get_preferred_width (ClutterLayoutManager *manager,
|
||||
}
|
||||
}
|
||||
|
||||
priv->col_width = max_natural_width;
|
||||
self->col_width = max_natural_width;
|
||||
|
||||
if (priv->max_col_width > 0 && priv->col_width > priv->max_col_width)
|
||||
priv->col_width = MAX (priv->max_col_width, max_min_width);
|
||||
if (self->max_col_width > 0 && self->col_width > self->max_col_width)
|
||||
self->col_width = MAX (self->max_col_width, max_min_width);
|
||||
|
||||
if (priv->col_width < priv->min_col_width)
|
||||
priv->col_width = priv->min_col_width;
|
||||
if (self->col_width < self->min_col_width)
|
||||
self->col_width = self->min_col_width;
|
||||
|
||||
if (priv->orientation == CLUTTER_FLOW_VERTICAL && for_height > 0)
|
||||
if (self->orientation == CLUTTER_FLOW_VERTICAL && for_height > 0)
|
||||
{
|
||||
/* if we have a non-full row we need to add it */
|
||||
if (line_item_count > 0)
|
||||
@ -315,19 +313,19 @@ clutter_flow_layout_get_preferred_width (ClutterLayoutManager *manager,
|
||||
total_min_width += line_min_width;
|
||||
total_natural_width += line_natural_width;
|
||||
|
||||
g_array_append_val (priv->line_min,
|
||||
g_array_append_val (self->line_min,
|
||||
line_min_width);
|
||||
g_array_append_val (priv->line_natural,
|
||||
g_array_append_val (self->line_natural,
|
||||
line_natural_width);
|
||||
}
|
||||
|
||||
priv->line_count = line_count;
|
||||
self->line_count = line_count;
|
||||
|
||||
if (priv->line_count > 0)
|
||||
if (self->line_count > 0)
|
||||
{
|
||||
gfloat total_spacing;
|
||||
|
||||
total_spacing = priv->col_spacing * (priv->line_count - 1);
|
||||
total_spacing = self->col_spacing * (self->line_count - 1);
|
||||
|
||||
total_min_width += total_spacing;
|
||||
total_natural_width += total_spacing;
|
||||
@ -335,16 +333,16 @@ clutter_flow_layout_get_preferred_width (ClutterLayoutManager *manager,
|
||||
}
|
||||
else
|
||||
{
|
||||
g_array_append_val (priv->line_min, line_min_width);
|
||||
g_array_append_val (priv->line_natural, line_natural_width);
|
||||
g_array_append_val (self->line_min, line_min_width);
|
||||
g_array_append_val (self->line_natural, line_natural_width);
|
||||
|
||||
priv->line_count = line_count;
|
||||
self->line_count = line_count;
|
||||
|
||||
if (priv->line_count > 0)
|
||||
if (self->line_count > 0)
|
||||
{
|
||||
gfloat total_spacing;
|
||||
|
||||
total_spacing = priv->col_spacing * (priv->line_count - 1);
|
||||
total_spacing = self->col_spacing * (self->line_count - 1);
|
||||
|
||||
total_min_width += total_spacing;
|
||||
total_natural_width += total_spacing;
|
||||
@ -353,12 +351,12 @@ clutter_flow_layout_get_preferred_width (ClutterLayoutManager *manager,
|
||||
|
||||
CLUTTER_NOTE (LAYOUT,
|
||||
"Flow[w]: %d lines (%d per line): w [ %.2f, %.2f ] for h %.2f",
|
||||
n_rows, priv->line_count,
|
||||
n_rows, self->line_count,
|
||||
total_min_width,
|
||||
total_natural_width,
|
||||
for_height);
|
||||
|
||||
priv->req_height = for_height;
|
||||
self->req_height = for_height;
|
||||
|
||||
if (min_width_p)
|
||||
*min_width_p = max_min_width;
|
||||
@ -374,7 +372,7 @@ clutter_flow_layout_get_preferred_height (ClutterLayoutManager *manager,
|
||||
gfloat *min_height_p,
|
||||
gfloat *nat_height_p)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv = CLUTTER_FLOW_LAYOUT (manager)->priv;
|
||||
ClutterFlowLayout *self = CLUTTER_FLOW_LAYOUT (manager);
|
||||
gint n_columns, line_item_count, line_count;
|
||||
gfloat total_min_height, total_natural_height;
|
||||
gfloat line_min_height, line_natural_height;
|
||||
@ -399,16 +397,16 @@ clutter_flow_layout_get_preferred_height (ClutterLayoutManager *manager,
|
||||
actor = CLUTTER_ACTOR (container);
|
||||
|
||||
/* clear the line height arrays */
|
||||
if (priv->line_min != NULL)
|
||||
g_array_free (priv->line_min, TRUE);
|
||||
if (self->line_min != NULL)
|
||||
g_array_free (self->line_min, TRUE);
|
||||
|
||||
if (priv->line_natural != NULL)
|
||||
g_array_free (priv->line_natural, TRUE);
|
||||
if (self->line_natural != NULL)
|
||||
g_array_free (self->line_natural, TRUE);
|
||||
|
||||
priv->line_min = g_array_sized_new (FALSE, FALSE,
|
||||
self->line_min = g_array_sized_new (FALSE, FALSE,
|
||||
sizeof (gfloat),
|
||||
16);
|
||||
priv->line_natural = g_array_sized_new (FALSE, FALSE,
|
||||
self->line_natural = g_array_sized_new (FALSE, FALSE,
|
||||
sizeof (gfloat),
|
||||
16);
|
||||
|
||||
@ -426,21 +424,21 @@ clutter_flow_layout_get_preferred_height (ClutterLayoutManager *manager,
|
||||
if (!clutter_actor_is_visible (child))
|
||||
continue;
|
||||
|
||||
if (priv->orientation == CLUTTER_FLOW_HORIZONTAL && for_width > 0)
|
||||
if (self->orientation == CLUTTER_FLOW_HORIZONTAL && for_width > 0)
|
||||
{
|
||||
clutter_actor_get_preferred_width (child, -1,
|
||||
&child_min,
|
||||
&child_natural);
|
||||
|
||||
if ((priv->snap_to_grid && line_item_count == n_columns) ||
|
||||
(!priv->snap_to_grid && item_x + child_natural > for_width))
|
||||
if ((self->snap_to_grid && line_item_count == n_columns) ||
|
||||
(!self->snap_to_grid && item_x + child_natural > for_width))
|
||||
{
|
||||
total_min_height += line_min_height;
|
||||
total_natural_height += line_natural_height;
|
||||
|
||||
g_array_append_val (priv->line_min,
|
||||
g_array_append_val (self->line_min,
|
||||
line_min_height);
|
||||
g_array_append_val (priv->line_natural,
|
||||
g_array_append_val (self->line_natural,
|
||||
line_natural_height);
|
||||
|
||||
line_min_height = line_natural_height = 0;
|
||||
@ -450,15 +448,15 @@ clutter_flow_layout_get_preferred_height (ClutterLayoutManager *manager,
|
||||
item_x = 0;
|
||||
}
|
||||
|
||||
if (priv->snap_to_grid)
|
||||
if (self->snap_to_grid)
|
||||
{
|
||||
new_x = ((line_item_count + 1) * (for_width + priv->col_spacing))
|
||||
new_x = ((line_item_count + 1) * (for_width + self->col_spacing))
|
||||
/ n_columns;
|
||||
item_width = new_x - item_x - priv->col_spacing;
|
||||
item_width = new_x - item_x - self->col_spacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_x = item_x + child_natural + priv->col_spacing;
|
||||
new_x = item_x + child_natural + self->col_spacing;
|
||||
item_width = child_natural;
|
||||
}
|
||||
|
||||
@ -491,15 +489,15 @@ clutter_flow_layout_get_preferred_height (ClutterLayoutManager *manager,
|
||||
}
|
||||
}
|
||||
|
||||
priv->row_height = max_natural_height;
|
||||
self->row_height = max_natural_height;
|
||||
|
||||
if (priv->max_row_height > 0 && priv->row_height > priv->max_row_height)
|
||||
priv->row_height = MAX (priv->max_row_height, max_min_height);
|
||||
if (self->max_row_height > 0 && self->row_height > self->max_row_height)
|
||||
self->row_height = MAX (self->max_row_height, max_min_height);
|
||||
|
||||
if (priv->row_height < priv->min_row_height)
|
||||
priv->row_height = priv->min_row_height;
|
||||
if (self->row_height < self->min_row_height)
|
||||
self->row_height = self->min_row_height;
|
||||
|
||||
if (priv->orientation == CLUTTER_FLOW_HORIZONTAL && for_width > 0)
|
||||
if (self->orientation == CLUTTER_FLOW_HORIZONTAL && for_width > 0)
|
||||
{
|
||||
/* if we have a non-full row we need to add it */
|
||||
if (line_item_count > 0)
|
||||
@ -507,18 +505,18 @@ clutter_flow_layout_get_preferred_height (ClutterLayoutManager *manager,
|
||||
total_min_height += line_min_height;
|
||||
total_natural_height += line_natural_height;
|
||||
|
||||
g_array_append_val (priv->line_min,
|
||||
g_array_append_val (self->line_min,
|
||||
line_min_height);
|
||||
g_array_append_val (priv->line_natural,
|
||||
g_array_append_val (self->line_natural,
|
||||
line_natural_height);
|
||||
}
|
||||
|
||||
priv->line_count = line_count;
|
||||
if (priv->line_count > 0)
|
||||
self->line_count = line_count;
|
||||
if (self->line_count > 0)
|
||||
{
|
||||
gfloat total_spacing;
|
||||
|
||||
total_spacing = priv->row_spacing * (priv->line_count - 1);
|
||||
total_spacing = self->row_spacing * (self->line_count - 1);
|
||||
|
||||
total_min_height += total_spacing;
|
||||
total_natural_height += total_spacing;
|
||||
@ -526,16 +524,16 @@ clutter_flow_layout_get_preferred_height (ClutterLayoutManager *manager,
|
||||
}
|
||||
else
|
||||
{
|
||||
g_array_append_val (priv->line_min, line_min_height);
|
||||
g_array_append_val (priv->line_natural, line_natural_height);
|
||||
g_array_append_val (self->line_min, line_min_height);
|
||||
g_array_append_val (self->line_natural, line_natural_height);
|
||||
|
||||
priv->line_count = line_count;
|
||||
self->line_count = line_count;
|
||||
|
||||
if (priv->line_count > 0)
|
||||
if (self->line_count > 0)
|
||||
{
|
||||
gfloat total_spacing;
|
||||
|
||||
total_spacing = priv->col_spacing * priv->line_count;
|
||||
total_spacing = self->col_spacing * self->line_count;
|
||||
|
||||
total_min_height += total_spacing;
|
||||
total_natural_height += total_spacing;
|
||||
@ -544,12 +542,12 @@ clutter_flow_layout_get_preferred_height (ClutterLayoutManager *manager,
|
||||
|
||||
CLUTTER_NOTE (LAYOUT,
|
||||
"Flow[h]: %d lines (%d per line): w [ %.2f, %.2f ] for h %.2f",
|
||||
n_columns, priv->line_count,
|
||||
n_columns, self->line_count,
|
||||
total_min_height,
|
||||
total_natural_height,
|
||||
for_width);
|
||||
|
||||
priv->req_width = for_width;
|
||||
self->req_width = for_width;
|
||||
|
||||
if (min_height_p)
|
||||
*min_height_p = max_min_height;
|
||||
@ -563,7 +561,7 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager,
|
||||
ClutterActor *container,
|
||||
const ClutterActorBox *allocation)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv = CLUTTER_FLOW_LAYOUT (manager)->priv;
|
||||
ClutterFlowLayout *self = CLUTTER_FLOW_LAYOUT (manager);
|
||||
ClutterActor *actor, *child;
|
||||
ClutterActorIter iter;
|
||||
gfloat x_off, y_off;
|
||||
@ -584,8 +582,8 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager,
|
||||
* available size in case the FlowLayout wasn't given the exact
|
||||
* size it requested
|
||||
*/
|
||||
if ((priv->req_width >= 0 && avail_width != priv->req_width) ||
|
||||
(priv->req_height >= 0 && avail_height != priv->req_height))
|
||||
if ((self->req_width >= 0 && avail_width != self->req_width) ||
|
||||
(self->req_height >= 0 && avail_height != self->req_height))
|
||||
{
|
||||
clutter_flow_layout_get_preferred_width (manager, container,
|
||||
avail_height,
|
||||
@ -617,24 +615,24 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager,
|
||||
|
||||
new_x = new_y = 0;
|
||||
|
||||
if (!priv->snap_to_grid)
|
||||
if (!self->snap_to_grid)
|
||||
clutter_actor_get_preferred_size (child,
|
||||
NULL, NULL,
|
||||
&item_width,
|
||||
&item_height);
|
||||
|
||||
if (priv->orientation == CLUTTER_FLOW_HORIZONTAL)
|
||||
if (self->orientation == CLUTTER_FLOW_HORIZONTAL)
|
||||
{
|
||||
if ((priv->snap_to_grid &&
|
||||
if ((self->snap_to_grid &&
|
||||
line_item_count == items_per_line && line_item_count > 0) ||
|
||||
(!priv->snap_to_grid && item_x + item_width > avail_width))
|
||||
(!self->snap_to_grid && item_x + item_width > avail_width))
|
||||
{
|
||||
item_y += g_array_index (priv->line_natural,
|
||||
item_y += g_array_index (self->line_natural,
|
||||
gfloat,
|
||||
line_index);
|
||||
|
||||
if (line_index >= 0)
|
||||
item_y += priv->row_spacing;
|
||||
item_y += self->row_spacing;
|
||||
|
||||
line_item_count = 0;
|
||||
line_index += 1;
|
||||
@ -642,34 +640,34 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager,
|
||||
item_x = x_off;
|
||||
}
|
||||
|
||||
if (priv->snap_to_grid)
|
||||
if (self->snap_to_grid)
|
||||
{
|
||||
new_x = x_off + ((line_item_count + 1) * (avail_width + priv->col_spacing))
|
||||
new_x = x_off + ((line_item_count + 1) * (avail_width + self->col_spacing))
|
||||
/ items_per_line;
|
||||
item_width = new_x - item_x - priv->col_spacing;
|
||||
item_width = new_x - item_x - self->col_spacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_x = item_x + item_width + priv->col_spacing;
|
||||
new_x = item_x + item_width + self->col_spacing;
|
||||
}
|
||||
|
||||
item_height = g_array_index (priv->line_natural,
|
||||
item_height = g_array_index (self->line_natural,
|
||||
gfloat,
|
||||
line_index);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((priv->snap_to_grid &&
|
||||
if ((self->snap_to_grid &&
|
||||
line_item_count == items_per_line && line_item_count > 0) ||
|
||||
(!priv->snap_to_grid && item_y + item_height > avail_height))
|
||||
(!self->snap_to_grid && item_y + item_height > avail_height))
|
||||
{
|
||||
item_x += g_array_index (priv->line_natural,
|
||||
item_x += g_array_index (self->line_natural,
|
||||
gfloat,
|
||||
line_index);
|
||||
|
||||
if (line_index >= 0)
|
||||
item_x += priv->col_spacing;
|
||||
item_x += self->col_spacing;
|
||||
|
||||
line_item_count = 0;
|
||||
line_index += 1;
|
||||
@ -677,23 +675,23 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager,
|
||||
item_y = y_off;
|
||||
}
|
||||
|
||||
if (priv->snap_to_grid)
|
||||
if (self->snap_to_grid)
|
||||
{
|
||||
new_y = y_off + ((line_item_count + 1) * (avail_height + priv->row_spacing))
|
||||
new_y = y_off + ((line_item_count + 1) * (avail_height + self->row_spacing))
|
||||
/ items_per_line;
|
||||
item_height = new_y - item_y - priv->row_spacing;
|
||||
item_height = new_y - item_y - self->row_spacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_y = item_y + item_height + priv->row_spacing;
|
||||
new_y = item_y + item_height + self->row_spacing;
|
||||
}
|
||||
|
||||
item_width = g_array_index (priv->line_natural,
|
||||
item_width = g_array_index (self->line_natural,
|
||||
gfloat,
|
||||
line_index);
|
||||
}
|
||||
|
||||
if (!priv->is_homogeneous &&
|
||||
if (!self->is_homogeneous &&
|
||||
!clutter_actor_needs_expand (child,
|
||||
CLUTTER_ORIENTATION_HORIZONTAL))
|
||||
{
|
||||
@ -703,7 +701,7 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager,
|
||||
item_width = MIN (item_width, child_natural);
|
||||
}
|
||||
|
||||
if (!priv->is_homogeneous &&
|
||||
if (!self->is_homogeneous &&
|
||||
!clutter_actor_needs_expand (child,
|
||||
CLUTTER_ORIENTATION_VERTICAL))
|
||||
{
|
||||
@ -725,7 +723,7 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager,
|
||||
child_alloc.y2 = ceil (child_alloc.y1 + item_height);
|
||||
clutter_actor_allocate (child, &child_alloc);
|
||||
|
||||
if (priv->orientation == CLUTTER_FLOW_HORIZONTAL)
|
||||
if (self->orientation == CLUTTER_FLOW_HORIZONTAL)
|
||||
item_x = new_x;
|
||||
else
|
||||
item_y = new_y;
|
||||
@ -738,22 +736,22 @@ static void
|
||||
clutter_flow_layout_set_container (ClutterLayoutManager *manager,
|
||||
ClutterActor *container)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv = CLUTTER_FLOW_LAYOUT (manager)->priv;
|
||||
ClutterFlowLayout *self = CLUTTER_FLOW_LAYOUT (manager);
|
||||
ClutterLayoutManagerClass *parent_class;
|
||||
|
||||
priv->container = container;
|
||||
self->container = container;
|
||||
|
||||
if (priv->container != NULL)
|
||||
if (self->container != NULL)
|
||||
{
|
||||
ClutterRequestMode request_mode;
|
||||
|
||||
/* we need to change the :request-mode of the container
|
||||
* to match the orientation
|
||||
*/
|
||||
request_mode = (priv->orientation == CLUTTER_FLOW_HORIZONTAL)
|
||||
request_mode = (self->orientation == CLUTTER_FLOW_HORIZONTAL)
|
||||
? CLUTTER_REQUEST_HEIGHT_FOR_WIDTH
|
||||
: CLUTTER_REQUEST_WIDTH_FOR_HEIGHT;
|
||||
clutter_actor_set_request_mode (CLUTTER_ACTOR (priv->container),
|
||||
clutter_actor_set_request_mode (CLUTTER_ACTOR (self->container),
|
||||
request_mode);
|
||||
}
|
||||
|
||||
@ -790,24 +788,24 @@ clutter_flow_layout_set_property (GObject *gobject,
|
||||
case PROP_MIN_COLUMN_WIDTH:
|
||||
clutter_flow_layout_set_column_width (self,
|
||||
g_value_get_float (value),
|
||||
self->priv->max_col_width);
|
||||
self->max_col_width);
|
||||
break;
|
||||
|
||||
case PROP_MAX_COLUMN_WIDTH:
|
||||
clutter_flow_layout_set_column_width (self,
|
||||
self->priv->min_col_width,
|
||||
self->min_col_width,
|
||||
g_value_get_float (value));
|
||||
break;
|
||||
|
||||
case PROP_MIN_ROW_HEGHT:
|
||||
clutter_flow_layout_set_row_height (self,
|
||||
g_value_get_float (value),
|
||||
self->priv->max_row_height);
|
||||
self->max_row_height);
|
||||
break;
|
||||
|
||||
case PROP_MAX_ROW_HEIGHT:
|
||||
clutter_flow_layout_set_row_height (self,
|
||||
self->priv->min_row_height,
|
||||
self->min_row_height,
|
||||
g_value_get_float (value));
|
||||
break;
|
||||
|
||||
@ -828,44 +826,44 @@ clutter_flow_layout_get_property (GObject *gobject,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv = CLUTTER_FLOW_LAYOUT (gobject)->priv;
|
||||
ClutterFlowLayout *self = CLUTTER_FLOW_LAYOUT (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ORIENTATION:
|
||||
g_value_set_enum (value, priv->orientation);
|
||||
g_value_set_enum (value, self->orientation);
|
||||
break;
|
||||
|
||||
case PROP_HOMOGENEOUS:
|
||||
g_value_set_boolean (value, priv->is_homogeneous);
|
||||
g_value_set_boolean (value, self->is_homogeneous);
|
||||
break;
|
||||
|
||||
case PROP_COLUMN_SPACING:
|
||||
g_value_set_float (value, priv->col_spacing);
|
||||
g_value_set_float (value, self->col_spacing);
|
||||
break;
|
||||
|
||||
case PROP_ROW_SPACING:
|
||||
g_value_set_float (value, priv->row_spacing);
|
||||
g_value_set_float (value, self->row_spacing);
|
||||
break;
|
||||
|
||||
case PROP_MIN_COLUMN_WIDTH:
|
||||
g_value_set_float (value, priv->min_col_width);
|
||||
g_value_set_float (value, self->min_col_width);
|
||||
break;
|
||||
|
||||
case PROP_MAX_COLUMN_WIDTH:
|
||||
g_value_set_float (value, priv->max_col_width);
|
||||
g_value_set_float (value, self->max_col_width);
|
||||
break;
|
||||
|
||||
case PROP_MIN_ROW_HEGHT:
|
||||
g_value_set_float (value, priv->min_row_height);
|
||||
g_value_set_float (value, self->min_row_height);
|
||||
break;
|
||||
|
||||
case PROP_MAX_ROW_HEIGHT:
|
||||
g_value_set_float (value, priv->max_row_height);
|
||||
g_value_set_float (value, self->max_row_height);
|
||||
break;
|
||||
|
||||
case PROP_SNAP_TO_GRID:
|
||||
g_value_set_boolean (value, priv->snap_to_grid);
|
||||
g_value_set_boolean (value, self->snap_to_grid);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -877,13 +875,13 @@ clutter_flow_layout_get_property (GObject *gobject,
|
||||
static void
|
||||
clutter_flow_layout_finalize (GObject *gobject)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv = CLUTTER_FLOW_LAYOUT (gobject)->priv;
|
||||
ClutterFlowLayout *self = CLUTTER_FLOW_LAYOUT (gobject);
|
||||
|
||||
if (priv->line_min != NULL)
|
||||
g_array_free (priv->line_min, TRUE);
|
||||
if (self->line_min != NULL)
|
||||
g_array_free (self->line_min, TRUE);
|
||||
|
||||
if (priv->line_natural != NULL)
|
||||
g_array_free (priv->line_natural, TRUE);
|
||||
if (self->line_natural != NULL)
|
||||
g_array_free (self->line_natural, TRUE);
|
||||
|
||||
G_OBJECT_CLASS (clutter_flow_layout_parent_class)->finalize (gobject);
|
||||
}
|
||||
@ -1033,21 +1031,17 @@ clutter_flow_layout_class_init (ClutterFlowLayoutClass *klass)
|
||||
static void
|
||||
clutter_flow_layout_init (ClutterFlowLayout *self)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv;
|
||||
self->orientation = CLUTTER_FLOW_HORIZONTAL;
|
||||
|
||||
self->priv = priv = clutter_flow_layout_get_instance_private (self);
|
||||
self->col_spacing = 0;
|
||||
self->row_spacing = 0;
|
||||
|
||||
priv->orientation = CLUTTER_FLOW_HORIZONTAL;
|
||||
self->min_col_width = self->min_row_height = 0;
|
||||
self->max_col_width = self->max_row_height = -1;
|
||||
|
||||
priv->col_spacing = 0;
|
||||
priv->row_spacing = 0;
|
||||
|
||||
priv->min_col_width = priv->min_row_height = 0;
|
||||
priv->max_col_width = priv->max_row_height = -1;
|
||||
|
||||
priv->line_min = NULL;
|
||||
priv->line_natural = NULL;
|
||||
priv->snap_to_grid = TRUE;
|
||||
self->line_min = NULL;
|
||||
self->line_natural = NULL;
|
||||
self->snap_to_grid = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1081,29 +1075,25 @@ void
|
||||
clutter_flow_layout_set_orientation (ClutterFlowLayout *layout,
|
||||
ClutterFlowOrientation orientation)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_FLOW_LAYOUT (layout));
|
||||
|
||||
priv = layout->priv;
|
||||
|
||||
if (priv->orientation != orientation)
|
||||
if (layout->orientation != orientation)
|
||||
{
|
||||
ClutterLayoutManager *manager;
|
||||
|
||||
priv->orientation = orientation;
|
||||
layout->orientation = orientation;
|
||||
|
||||
if (priv->container != NULL)
|
||||
if (layout->container != NULL)
|
||||
{
|
||||
ClutterRequestMode request_mode;
|
||||
|
||||
/* we need to change the :request-mode of the container
|
||||
* to match the orientation
|
||||
*/
|
||||
request_mode = (priv->orientation == CLUTTER_FLOW_HORIZONTAL)
|
||||
request_mode = (layout->orientation == CLUTTER_FLOW_HORIZONTAL)
|
||||
? CLUTTER_REQUEST_HEIGHT_FOR_WIDTH
|
||||
: CLUTTER_REQUEST_WIDTH_FOR_HEIGHT;
|
||||
clutter_actor_set_request_mode (CLUTTER_ACTOR (priv->container),
|
||||
clutter_actor_set_request_mode (CLUTTER_ACTOR (layout->container),
|
||||
request_mode);
|
||||
}
|
||||
|
||||
@ -1129,7 +1119,7 @@ clutter_flow_layout_get_orientation (ClutterFlowLayout *layout)
|
||||
g_return_val_if_fail (CLUTTER_IS_FLOW_LAYOUT (layout),
|
||||
CLUTTER_FLOW_HORIZONTAL);
|
||||
|
||||
return layout->priv->orientation;
|
||||
return layout->orientation;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1144,17 +1134,13 @@ void
|
||||
clutter_flow_layout_set_homogeneous (ClutterFlowLayout *layout,
|
||||
gboolean homogeneous)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_FLOW_LAYOUT (layout));
|
||||
|
||||
priv = layout->priv;
|
||||
|
||||
if (priv->is_homogeneous != homogeneous)
|
||||
if (layout->is_homogeneous != homogeneous)
|
||||
{
|
||||
ClutterLayoutManager *manager;
|
||||
|
||||
priv->is_homogeneous = homogeneous;
|
||||
layout->is_homogeneous = homogeneous;
|
||||
|
||||
manager = CLUTTER_LAYOUT_MANAGER (layout);
|
||||
clutter_layout_manager_layout_changed (manager);
|
||||
@ -1177,7 +1163,7 @@ clutter_flow_layout_get_homogeneous (ClutterFlowLayout *layout)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_FLOW_LAYOUT (layout), FALSE);
|
||||
|
||||
return layout->priv->is_homogeneous;
|
||||
return layout->is_homogeneous;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1191,17 +1177,13 @@ void
|
||||
clutter_flow_layout_set_column_spacing (ClutterFlowLayout *layout,
|
||||
gfloat spacing)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_FLOW_LAYOUT (layout));
|
||||
|
||||
priv = layout->priv;
|
||||
|
||||
if (priv->col_spacing != spacing)
|
||||
if (layout->col_spacing != spacing)
|
||||
{
|
||||
ClutterLayoutManager *manager;
|
||||
|
||||
priv->col_spacing = spacing;
|
||||
layout->col_spacing = spacing;
|
||||
|
||||
manager = CLUTTER_LAYOUT_MANAGER (layout);
|
||||
clutter_layout_manager_layout_changed (manager);
|
||||
@ -1225,7 +1207,7 @@ clutter_flow_layout_get_column_spacing (ClutterFlowLayout *layout)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_FLOW_LAYOUT (layout), 0.0);
|
||||
|
||||
return layout->priv->col_spacing;
|
||||
return layout->col_spacing;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1239,17 +1221,13 @@ void
|
||||
clutter_flow_layout_set_row_spacing (ClutterFlowLayout *layout,
|
||||
gfloat spacing)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_FLOW_LAYOUT (layout));
|
||||
|
||||
priv = layout->priv;
|
||||
|
||||
if (priv->row_spacing != spacing)
|
||||
if (layout->row_spacing != spacing)
|
||||
{
|
||||
ClutterLayoutManager *manager;
|
||||
|
||||
priv->row_spacing = spacing;
|
||||
layout->row_spacing = spacing;
|
||||
|
||||
manager = CLUTTER_LAYOUT_MANAGER (layout);
|
||||
clutter_layout_manager_layout_changed (manager);
|
||||
@ -1273,7 +1251,7 @@ clutter_flow_layout_get_row_spacing (ClutterFlowLayout *layout)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_FLOW_LAYOUT (layout), 0.0);
|
||||
|
||||
return layout->priv->row_spacing;
|
||||
return layout->row_spacing;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1289,23 +1267,20 @@ clutter_flow_layout_set_column_width (ClutterFlowLayout *layout,
|
||||
gfloat min_width,
|
||||
gfloat max_width)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv;
|
||||
gboolean notify_min = FALSE, notify_max = FALSE;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_FLOW_LAYOUT (layout));
|
||||
|
||||
priv = layout->priv;
|
||||
|
||||
if (priv->min_col_width != min_width)
|
||||
if (layout->min_col_width != min_width)
|
||||
{
|
||||
priv->min_col_width = min_width;
|
||||
layout->min_col_width = min_width;
|
||||
|
||||
notify_min = TRUE;
|
||||
}
|
||||
|
||||
if (priv->max_col_width != max_width)
|
||||
if (layout->max_col_width != max_width)
|
||||
{
|
||||
priv->max_col_width = max_width;
|
||||
layout->max_col_width = max_width;
|
||||
|
||||
notify_max = TRUE;
|
||||
}
|
||||
@ -1346,10 +1321,10 @@ clutter_flow_layout_get_column_width (ClutterFlowLayout *layout,
|
||||
g_return_if_fail (CLUTTER_IS_FLOW_LAYOUT (layout));
|
||||
|
||||
if (min_width)
|
||||
*min_width = layout->priv->min_col_width;
|
||||
*min_width = layout->min_col_width;
|
||||
|
||||
if (max_width)
|
||||
*max_width = layout->priv->max_col_width;
|
||||
*max_width = layout->max_col_width;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1365,23 +1340,20 @@ clutter_flow_layout_set_row_height (ClutterFlowLayout *layout,
|
||||
gfloat min_height,
|
||||
gfloat max_height)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv;
|
||||
gboolean notify_min = FALSE, notify_max = FALSE;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_FLOW_LAYOUT (layout));
|
||||
|
||||
priv = layout->priv;
|
||||
|
||||
if (priv->min_row_height != min_height)
|
||||
if (layout->min_row_height != min_height)
|
||||
{
|
||||
priv->min_row_height = min_height;
|
||||
layout->min_row_height = min_height;
|
||||
|
||||
notify_min = TRUE;
|
||||
}
|
||||
|
||||
if (priv->max_row_height != max_height)
|
||||
if (layout->max_row_height != max_height)
|
||||
{
|
||||
priv->max_row_height = max_height;
|
||||
layout->max_row_height = max_height;
|
||||
|
||||
notify_max = TRUE;
|
||||
}
|
||||
@ -1422,10 +1394,10 @@ clutter_flow_layout_get_row_height (ClutterFlowLayout *layout,
|
||||
g_return_if_fail (CLUTTER_IS_FLOW_LAYOUT (layout));
|
||||
|
||||
if (min_height)
|
||||
*min_height = layout->priv->min_row_height;
|
||||
*min_height = layout->min_row_height;
|
||||
|
||||
if (max_height)
|
||||
*max_height = layout->priv->max_row_height;
|
||||
*max_height = layout->max_row_height;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1439,15 +1411,11 @@ void
|
||||
clutter_flow_layout_set_snap_to_grid (ClutterFlowLayout *layout,
|
||||
gboolean snap_to_grid)
|
||||
{
|
||||
ClutterFlowLayoutPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_FLOW_LAYOUT (layout));
|
||||
|
||||
priv = layout->priv;
|
||||
|
||||
if (priv->snap_to_grid != snap_to_grid)
|
||||
if (layout->snap_to_grid != snap_to_grid)
|
||||
{
|
||||
priv->snap_to_grid = snap_to_grid;
|
||||
layout->snap_to_grid = snap_to_grid;
|
||||
|
||||
clutter_layout_manager_layout_changed (CLUTTER_LAYOUT_MANAGER (layout));
|
||||
|
||||
@ -1469,5 +1437,5 @@ clutter_flow_layout_get_snap_to_grid (ClutterFlowLayout *layout)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_FLOW_LAYOUT (layout), FALSE);
|
||||
|
||||
return layout->priv->snap_to_grid;
|
||||
return layout->snap_to_grid;
|
||||
}
|
||||
|
@ -33,38 +33,12 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_TYPE_FLOW_LAYOUT (clutter_flow_layout_get_type ())
|
||||
#define CLUTTER_FLOW_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_FLOW_LAYOUT, ClutterFlowLayout))
|
||||
#define CLUTTER_IS_FLOW_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_FLOW_LAYOUT))
|
||||
#define CLUTTER_FLOW_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_FLOW_LAYOUT, ClutterFlowLayoutClass))
|
||||
#define CLUTTER_IS_FLOW_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_FLOW_LAYOUT))
|
||||
#define CLUTTER_FLOW_LAYOUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_FLOW_LAYOUT, ClutterFlowLayoutClass))
|
||||
|
||||
typedef struct _ClutterFlowLayout ClutterFlowLayout;
|
||||
typedef struct _ClutterFlowLayoutPrivate ClutterFlowLayoutPrivate;
|
||||
typedef struct _ClutterFlowLayoutClass ClutterFlowLayoutClass;
|
||||
|
||||
struct _ClutterFlowLayout
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterLayoutManager parent_instance;
|
||||
|
||||
ClutterFlowLayoutPrivate *priv;
|
||||
};
|
||||
|
||||
/**
|
||||
* ClutterFlowLayoutClass:
|
||||
*
|
||||
* The #ClutterFlowLayoutClass structure contains only private data
|
||||
* and should be accessed using the provided API
|
||||
*/
|
||||
struct _ClutterFlowLayoutClass
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterLayoutManagerClass parent_class;
|
||||
};
|
||||
|
||||
CLUTTER_EXPORT
|
||||
GType clutter_flow_layout_get_type (void) G_GNUC_CONST;
|
||||
G_DECLARE_FINAL_TYPE (ClutterFlowLayout,
|
||||
clutter_flow_layout,
|
||||
CLUTTER, FLOW_LAYOUT,
|
||||
ClutterLayoutManager)
|
||||
|
||||
CLUTTER_EXPORT
|
||||
ClutterLayoutManager * clutter_flow_layout_new (ClutterFlowOrientation orientation);
|
||||
|
Loading…
Reference in New Issue
Block a user