layout: Change the request-mode along with the orientation
authorEmmanuele Bassi <ebassi@gnome.org>
Wed, 7 Oct 2009 14:28:01 +0000 (15:28 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Wed, 14 Oct 2009 10:31:31 +0000 (11:31 +0100)
When changing the orientation of a FlowLayout, the associated
container should also change its request mode. A horizontally
flowing layout has a height depending on the width, since it
will reflow vertically; similarly, a vertically reflowing layout
will have a width depending on the height.

clutter/clutter-flow-layout.c

index 9605850..027221f 100644 (file)
@@ -69,8 +69,6 @@ struct _ClutterFlowLayoutPrivate
   gfloat max_row_height;
   gfloat row_height;
 
-  gint max_row_items;
-
   guint is_homogeneous : 1;
 };
 
@@ -333,6 +331,20 @@ clutter_flow_layout_set_container (ClutterLayoutManager *manager,
   ClutterFlowLayoutPrivate *priv = CLUTTER_FLOW_LAYOUT (manager)->priv;
 
   priv->container = container;
+
+  if (priv->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)
+                   ? CLUTTER_REQUEST_HEIGHT_FOR_WIDTH
+                   : CLUTTER_REQUEST_WIDTH_FOR_HEIGHT;
+      clutter_actor_set_request_mode (CLUTTER_ACTOR (priv->container),
+                                      request_mode);
+    }
 }
 
 static void
@@ -668,6 +680,20 @@ clutter_flow_layout_set_orientation (ClutterFlowLayout      *layout,
 
       priv->orientation = orientation;
 
+      if (priv->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)
+                       ? CLUTTER_REQUEST_HEIGHT_FOR_WIDTH
+                       : CLUTTER_REQUEST_WIDTH_FOR_HEIGHT;
+          clutter_actor_set_request_mode (CLUTTER_ACTOR (priv->container),
+                                          request_mode);
+        }
+
       manager = CLUTTER_LAYOUT_MANAGER (layout);
       clutter_layout_manager_layout_changed (manager);