diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-06-18 23:35:58 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-06-18 23:39:07 +0300 |
commit | dc6771670569d2f296f4c12595966bbcb9aadf65 (patch) | |
tree | 92e0a21bd121c7abe43f22e1d25a8f17b6969214 /src/gui/widgets | |
parent | 6a10bc8d7d186fd83099c75c2a03409d0881aae9 (diff) | |
download | plus-dc6771670569d2f296f4c12595966bbcb9aadf65.tar.gz plus-dc6771670569d2f296f4c12595966bbcb9aadf65.tar.bz2 plus-dc6771670569d2f296f4c12595966bbcb9aadf65.tar.xz plus-dc6771670569d2f296f4c12595966bbcb9aadf65.zip |
Start implimenting new setup pages.
Add new container for setup items. Imporved other containers.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/horizontcontainer.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/setuptabscroll.cpp | 49 | ||||
-rw-r--r-- | src/gui/widgets/setuptabscroll.h | 41 | ||||
-rw-r--r-- | src/gui/widgets/vertcontainer.cpp | 43 | ||||
-rw-r--r-- | src/gui/widgets/vertcontainer.h | 18 |
5 files changed, 142 insertions, 15 deletions
diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp index a04230871..95320055c 100644 --- a/src/gui/widgets/horizontcontainer.cpp +++ b/src/gui/widgets/horizontcontainer.cpp @@ -26,7 +26,7 @@ HorizontContainer::HorizontContainer(int height, int spacing): mSpacing(spacing), mCount(0), - mLastX(0) + mLastX(spacing) { setHeight(height); addWidgetListener(this); @@ -38,9 +38,9 @@ void HorizontContainer::add(gcn::Widget *widget) return; Container::add(widget); - widget->setPosition(mLastX, 0); + widget->setPosition(mLastX, mSpacing); mCount++; - mLastX += widget->getWidth() + mSpacing; + mLastX += widget->getWidth() + 2 * mSpacing; } void HorizontContainer::clear() diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp new file mode 100644 index 000000000..c46ebaf97 --- /dev/null +++ b/src/gui/widgets/setuptabscroll.cpp @@ -0,0 +1,49 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "gui/widgets/setuptabscroll.h" + +#include "gui/widgets/layouthelper.h" +#include "gui/widgets/scrollarea.h" +#include "gui/widgets/vertcontainer.h" + +#include "debug.h" + +SetupTabScroll::SetupTabScroll() : + SetupTab() +{ + mContainer = new VertContainer(32, false, 8); + mScroll = new ScrollArea(mContainer); + mScroll->setOpaque(false); + mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); + mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO); + +// LayoutHelper h(this); +// ContainerPlacer place = h.getPlacer(0, 0); +// place(0, 0, mScroll, 10, 10); +} + +SetupTabScroll::~SetupTabScroll() +{ +// delete mScroll; + mScroll = 0; + delete mContainer; + mContainer = 0; +} diff --git a/src/gui/widgets/setuptabscroll.h b/src/gui/widgets/setuptabscroll.h new file mode 100644 index 000000000..83a5e272c --- /dev/null +++ b/src/gui/widgets/setuptabscroll.h @@ -0,0 +1,41 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GUI_SETUPTABSCROLL_H +#define GUI_SETUPTABSCROLL_H + +#include "gui/widgets/setuptab.h" + +class ScrollArea; +class VertContainer; + +class SetupTabScroll : public SetupTab +{ + public: + SetupTabScroll(); + + ~SetupTabScroll(); + + protected: + VertContainer *mContainer; + ScrollArea *mScroll; +}; + +#endif 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()); + } } diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h index e96bd5561..268c61d4f 100644 --- a/src/gui/widgets/vertcontainer.h +++ b/src/gui/widgets/vertcontainer.h @@ -40,14 +40,26 @@ class VertContainer : public Container, public gcn::WidgetListener { public: - VertContainer(int spacing); - virtual void add(gcn::Widget *widget); + VertContainer(int verticalItemSize, bool resizable = true, + int leftSpacing = 0); + + virtual void add(gcn::Widget *widget, bool resizable, + int spacing = -1); + + virtual void add(gcn::Widget *widget, int spacing = -1); + virtual void clear(); + void widgetResized(const gcn::Event &event); private: - int mSpacing; + std::list<gcn::Widget*> mResizableWidgets; + int mVerticalItemSize; int mCount; + int mNextY; + int mLeftSpacing; + int mVerticalSpacing; + bool mResizable; }; #endif |