From 7ed96aabd8c3703f5b0572ee7f000821a25d019d Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 3 Sep 2015 14:15:11 +0100 Subject: [PATCH] grid: Use the proper orientation for the request mode We automatically switch the request mode of the container depending on the GridLayout's orientation, but we need to keep track of the request mode during allocation, so that we don't get out of sync if the user changed the request mode after adding the layout manager. This change also brings us closer to the code in GtkGrid. --- clutter/clutter-grid-layout.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/clutter/clutter-grid-layout.c b/clutter/clutter-grid-layout.c index ad0320368..f39e58d78 100644 --- a/clutter/clutter-grid-layout.c +++ b/clutter/clutter-grid-layout.c @@ -1397,7 +1397,7 @@ clutter_grid_layout_allocate (ClutterLayoutManager *layout, ClutterAllocationFlags flags) { ClutterGridLayout *self = CLUTTER_GRID_LAYOUT (layout); - ClutterGridLayoutPrivate *priv = self->priv; + ClutterOrientation orientation; ClutterGridRequest request; ClutterGridLines *lines; ClutterActorIter iter; @@ -1414,10 +1414,16 @@ clutter_grid_layout_allocate (ClutterLayoutManager *layout, lines->lines = g_newa (ClutterGridLine, lines->max - lines->min); memset (lines->lines, 0, (lines->max - lines->min) * sizeof (ClutterGridLine)); - clutter_grid_request_run (&request, 1 - priv->orientation, FALSE); - clutter_grid_request_allocate (&request, 1 - priv->orientation, GET_SIZE (allocation, 1 - priv->orientation)); - clutter_grid_request_run (&request, priv->orientation, TRUE); - clutter_grid_request_allocate (&request, priv->orientation, GET_SIZE (allocation, priv->orientation)); + if (clutter_actor_get_request_mode (CLUTTER_ACTOR (container)) == CLUTTER_REQUEST_WIDTH_FOR_HEIGHT) + orientation = CLUTTER_ORIENTATION_HORIZONTAL; + else + orientation = CLUTTER_ORIENTATION_VERTICAL; + + clutter_grid_request_run (&request, 1 - orientation, FALSE); + clutter_grid_request_allocate (&request, 1 - orientation, GET_SIZE (allocation, 1 - orientation)); + clutter_grid_request_run (&request, orientation, TRUE); + + clutter_grid_request_allocate (&request, orientation, GET_SIZE (allocation, orientation)); clutter_grid_request_position (&request, 0); clutter_grid_request_position (&request, 1);