]> git.mxchange.org Git - simgear.git/blobdiff - simgear/canvas/layout/Layout.cxx
canvas::NasalWidget: check for empty setGeometry callback.
[simgear.git] / simgear / canvas / layout / Layout.cxx
index a61d2780427e729c7e43ebd20760c161078349a0..ece4ddabe67ce35305a3ea51358f91ff3a5e26f7 100644 (file)
@@ -45,11 +45,11 @@ namespace canvas
   //----------------------------------------------------------------------------
   void Layout::setGeometry(const SGRecti& geom)
   {
-    if( geom == _geometry )
-      return;
-
-    _geometry = geom;
-    _flags |= LAYOUT_DIRTY;
+    if( geom != _geometry )
+    {
+      _geometry = geom;
+      _flags |= LAYOUT_DIRTY;
+    }
 
     update();
   }
@@ -67,6 +67,13 @@ namespace canvas
     }
   }
 
+  //----------------------------------------------------------------------------
+  void Layout::clear()
+  {
+    while( itemAt(0) )
+      takeAt(0);
+  }
+
   //----------------------------------------------------------------------------
   void Layout::ItemData::reset()
   {
@@ -78,9 +85,28 @@ namespace canvas
     padding     = 0;
     size        = 0;
     stretch     = 0;
+    has_hfw     = false;
     done        = false;
   }
 
+  //----------------------------------------------------------------------------
+  int Layout::ItemData::hfw(int w) const
+  {
+    if( has_hfw )
+      return layout_item->heightForWidth(w);
+    else
+      return layout_item->sizeHint().y();
+  }
+
+  //----------------------------------------------------------------------------
+  int Layout::ItemData::mhfw(int w) const
+  {
+    if( has_hfw )
+      return layout_item->minimumHeightForWidth(w);
+    else
+      return layout_item->minimumSize().y();
+  }
+
   //----------------------------------------------------------------------------
   void Layout::safeAdd(int& a, int b)
   {
@@ -98,7 +124,11 @@ namespace canvas
 
     SG_LOG( SG_GUI,
             SG_DEBUG,
-            "Layout::distribute(" << num_children << " items)" );
+            "Layout::distribute(" << space.size << "px for "
+                                  << num_children << " items, s.t."
+                                  << " min=" << space.min_size
+                                  << ", hint=" << space.size_hint
+                                  << ", max=" << space.max_size << ")" );
 
     if( space.size < space.min_size )
     {
@@ -122,6 +152,15 @@ namespace canvas
         d.padding = d.padding_orig;
         d.done = d.size >= (less_then_hint ? d.size_hint : d.max_size);
 
+        SG_LOG(
+          SG_GUI,
+          SG_DEBUG,
+          i << ") initial=" << d.size
+            << ", min=" << d.min_size
+            << ", hint=" << d.size_hint
+            << ", max=" << d.max_size
+        );
+
         if( d.done )
         {
           _num_not_done -= 1;