data.layout_item->minimumSize().x(),
data.layout_item->maximumSize().x() );
- int d = data.layout_item->minimumHeightForWidth(w) - data.min_size;
- data.min_size += d;
- _layout_data.min_size += d;
-
- d = data.layout_item->heightForWidth(w) - data.size_hint;
- data.size_hint += d;
- _layout_data.size_hint += d;
+ data.min_size = data.mhfw(w);
+ data.size_hint = data.hfw(w);
+
+ // Update size hints for layouting with difference to size hints
+ // calculated by using the size hints provided (without trading
+ // height for width)
+ _layout_data.min_size += data.min_size
+ - data.layout_item->minimumSize().y();
+ _layout_data.size_hint += data.size_hint
+ - data.layout_item->sizeHint().y();
}
}
}
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 )
{
void NasalWidget::setHeightForWidthFunc(const HeightForWidthFunc& func)
{
_height_for_width = func;
- invalidateParent();
+ invalidate();
}
//----------------------------------------------------------------------------
void NasalWidget::setMinimumHeightForWidthFunc(const HeightForWidthFunc& func)
{
_min_height_for_width = func;
- invalidateParent();
+ invalidate();
}
//----------------------------------------------------------------------------
_size_hint = s;
// TODO just invalidate size_hint? Probably not a performance issue...
- invalidateParent();
+ invalidate();
}
//----------------------------------------------------------------------------
return;
_min_size = s;
- invalidateParent();
+ invalidate();
}
//----------------------------------------------------------------------------
return;
_max_size = s;
- invalidateParent();
+ invalidate();
}
//----------------------------------------------------------------------------
vbox.setGeometry(SGRecti(0, 0, 50, 122));
- BOOST_CHECK_EQUAL(w1->geometry(), SGRecti(0, 0, 50, 44));
- BOOST_CHECK_EQUAL(w2->geometry(), SGRecti(0, 49, 50, 70));
- BOOST_CHECK_EQUAL(w_no_hfw->geometry(), SGRecti(0, 124, 50, 56));
+ BOOST_CHECK_EQUAL(w1->geometry(), SGRecti(0, 0, 50, 25));
+ BOOST_CHECK_EQUAL(w2->geometry(), SGRecti(0, 30, 50, 51));
+ BOOST_CHECK_EQUAL(w_no_hfw->geometry(), SGRecti(0, 86, 50, 36));
+
+ // Same geometry as before -> should get same widget geometry
+ // (check internal size hint cache updates correctly)
+ vbox.setGeometry(SGRecti(0, 0, 24, 122));
+
+ BOOST_CHECK_EQUAL(w1->geometry(), SGRecti(0, 0, 24, 33));
+ BOOST_CHECK_EQUAL(w2->geometry(), SGRecti(0, 38, 24, 47));
+ BOOST_CHECK_EQUAL(w_no_hfw->geometry(), SGRecti(0, 90, 24, 32));
}
//------------------------------------------------------------------------------