invalidate();
}
+ //----------------------------------------------------------------------------
+ bool BoxLayout::setStretchFactor(const LayoutItemRef& item, int stretch)
+ {
+ for( LayoutItems::iterator it = _layout_items.begin();
+ it != _layout_items.end();
+ ++it )
+ {
+ if( item == it->layout_item )
+ {
+ it->stretch = std::max(0, stretch);
+ invalidate();
+ return true;
+ }
+ }
+
+ return false;
+ }
+
//----------------------------------------------------------------------------
int BoxLayout::stretch(size_t index) const
{
*/
void setStretch(size_t index, int stretch);
+ /**
+ * Set the stretch factor of the given @a item to @a stretch, if it exists
+ * in this layout.
+ *
+ * @return true, if the @a item was found in the layout
+ */
+ bool setStretchFactor(const LayoutItemRef& item, int stretch);
+
/**
* Get the stretch factor of the item at position @a index
*/
BOOST_CHECK_EQUAL(w1->geometry(), SGRecti(0, 0, 125, 32));
BOOST_CHECK_EQUAL(w2->geometry(), SGRecti(130, 0, 126, 32));
+
+ BOOST_REQUIRE( hbox.setStretchFactor(w1, 2) );
+ BOOST_REQUIRE( hbox.setStretchFactor(w2, 3) );
+ BOOST_CHECK_EQUAL(hbox.stretch(0), 2);
+ BOOST_CHECK_EQUAL(hbox.stretch(1), 3);
+
+ hbox.removeItem(w1);
+
+ BOOST_CHECK( !hbox.setStretchFactor(w1, 0) );
}
}