From dc6771670569d2f296f4c12595966bbcb9aadf65 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 18 Jun 2011 23:35:58 +0300 Subject: Start implimenting new setup pages. Add new container for setup items. Imporved other containers. --- src/gui/widgets/vertcontainer.cpp | 43 +++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'src/gui/widgets/vertcontainer.cpp') diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index d4cf0a13f..6f94df535 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -23,23 +23,45 @@ #include "debug.h" -VertContainer::VertContainer(int spacing): - mSpacing(spacing), - mCount(0) +VertContainer::VertContainer(int verticalItemSize, bool resizable, + int leftSpacing): + mVerticalItemSize(verticalItemSize), + mCount(0), + mNextY(0), + mLeftSpacing(leftSpacing), + mVerticalSpacing(0), + mResizable(resizable) { addWidgetListener(this); } -void VertContainer::add(gcn::Widget *widget) +void VertContainer::add(gcn::Widget *widget, int spacing) +{ + add(widget, mResizable, spacing); +} + +void VertContainer::add(gcn::Widget *widget, bool resizable, int spacing) { if (!widget) return; Container::add(widget); - widget->setPosition(0, mCount * mSpacing); - widget->setSize(getWidth(), mSpacing); - mCount++; - setHeight(mCount * mSpacing); + widget->setPosition(mLeftSpacing, mNextY); + if (resizable) + { + widget->setSize(getWidth() - mLeftSpacing, mVerticalItemSize); + mResizableWidgets.push_back(widget); + } + else if (widget->getHeight() > mVerticalItemSize) + { + widget->setSize(widget->getWidth(), mVerticalItemSize); + } + + if (spacing == -1) + mNextY += mVerticalItemSize + (mVerticalSpacing * 2); + else + mNextY += mVerticalItemSize + (spacing * 2); + setHeight(mNextY); } void VertContainer::clear() @@ -51,6 +73,9 @@ void VertContainer::clear() void VertContainer::widgetResized(const gcn::Event &event _UNUSED_) { - for (WidgetListIterator it = mWidgets.begin(); it != mWidgets.end(); it++) + for (WidgetListIterator it = mResizableWidgets.begin(); + it != mResizableWidgets.end(); it++) + { (*it)->setWidth(getWidth()); + } } -- cgit v1.2.3-70-g09d2