]> git.mxchange.org Git - simgear.git/blobdiff - simgear/canvas/layout/Layout.cxx
canvas::Text: add heightForWidth method.
[simgear.git] / simgear / canvas / layout / Layout.cxx
index 8c10a520d533b6dac918698902331658cb912ca6..b7e29c361c43c52d11c919513ca0df5918ad6308 100644 (file)
@@ -54,6 +54,19 @@ namespace canvas
     update();
   }
 
+  //----------------------------------------------------------------------------
+  void Layout::removeItem(const LayoutItemRef& item)
+  {
+    size_t i = 0;
+    while( LayoutItemRef child = itemAt(i) )
+    {
+      if( item == child )
+        return (void)takeAt(i);
+
+      ++i;
+    }
+  }
+
   //----------------------------------------------------------------------------
   void Layout::ItemData::reset()
   {
@@ -65,9 +78,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)
   {
@@ -109,6 +141,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;