summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-07-25 22:27:32 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-08-05 17:16:58 +0200
commit542570896e1e0ce73ebfc442b48e741c2ea32377 (patch)
tree834b0f9c87d2aa73d22a004a103d8e615ee6d9ba /src/gui
parent1fe16bdda5fa0d7112f4568e7bcd892d01c197b9 (diff)
downloadmana-542570896e1e0ce73ebfc442b48e741c2ea32377.tar.gz
mana-542570896e1e0ce73ebfc442b48e741c2ea32377.tar.bz2
mana-542570896e1e0ce73ebfc442b48e741c2ea32377.tar.xz
mana-542570896e1e0ce73ebfc442b48e741c2ea32377.zip
Removed all the hardcoded sizes of the various setup tabs
Instead, support for dynamically adjusting layout was added to the Container class. Various other places were also adapted to use the new layout support in Container. Reviewed-by: Erik Schilling
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/charselectdialog.cpp6
-rw-r--r--src/gui/debugwindow.cpp4
-rw-r--r--src/gui/setup_audio.cpp7
-rw-r--r--src/gui/setup_colors.cpp7
-rw-r--r--src/gui/setup_interface.cpp7
-rw-r--r--src/gui/setup_joystick.cpp14
-rw-r--r--src/gui/setup_keyboard.cpp7
-rw-r--r--src/gui/setup_players.cpp10
-rw-r--r--src/gui/setup_video.cpp10
-rw-r--r--src/gui/skilldialog.cpp1
-rw-r--r--src/gui/socialwindow.cpp1
-rw-r--r--src/gui/specialswindow.cpp1
-rw-r--r--src/gui/statuswindow.cpp11
-rw-r--r--src/gui/widgets/container.cpp25
-rw-r--r--src/gui/widgets/container.h24
-rw-r--r--src/gui/widgets/layouthelper.cpp5
-rw-r--r--src/gui/widgets/layouthelper.h4
-rw-r--r--src/gui/widgets/setuptab.cpp1
-rw-r--r--src/gui/widgets/vertcontainer.h2
19 files changed, 66 insertions, 81 deletions
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 1850eb9d..dff648ec 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -39,7 +39,6 @@
#include "gui/widgets/container.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
-#include "gui/widgets/layouthelper.h"
#include "gui/widgets/playerbox.h"
#include "gui/widgets/textfield.h"
@@ -358,9 +357,6 @@ CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog):
mDelete = new Button(_("Delete"), "delete", charSelectDialog);
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
place(0, 0, mPlayerBox, 3, 5);
place(0, 5, mName, 3);
place(0, 6, mLevel, 3);
@@ -370,7 +366,7 @@ CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog):
update();
- h.reflowLayout(80, 112 + mName->getHeight() + mLevel->getHeight() +
+ setSize(80, 112 + mName->getHeight() + mLevel->getHeight() +
mMoney->getHeight() + mButton->getHeight() + mDelete->getHeight());
}
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index cb871b44..37c68673 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -66,7 +66,7 @@ public:
mTileMouseLabel = new Label("");
mParticleCountLabel = new Label("");
- LayoutHelper h = (this);
+ LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
place(0, 0, mFPSLabel, 1);
@@ -145,7 +145,7 @@ public:
mSpecial2 = new RadioButton(_("Special 2"), "mapdebug");
mSpecial3 = new RadioButton(_("Special 3"), "mapdebug");
- LayoutHelper h = (this);
+ LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
place(0, 0, showLabel, 1);
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index 69ee3dc3..56815e32 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -29,7 +29,6 @@
#include "gui/widgets/checkbox.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
#include "gui/widgets/slider.h"
#include "utils/gettext.h"
@@ -47,7 +46,6 @@ Setup_Audio::Setup_Audio():
mMusicSlider(new Slider(0, sound.getMaxVolume()))
{
setName(_("Audio"));
- setDimension(gcn::Rectangle(0, 0, 250, 200));
gcn::Label *sfxLabel = new Label(_("Sfx volume"));
gcn::Label *notificationsLabel = new Label(_("Notifications volume"));
@@ -72,9 +70,6 @@ Setup_Audio::Setup_Audio():
mMusicSlider->setWidth(90);
// Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
place(0, 0, mSoundCheckBox);
place(0, 1, mSfxSlider);
place(1, 1, sfxLabel);
@@ -83,8 +78,6 @@ Setup_Audio::Setup_Audio():
place(0, 3, mMusicSlider);
place(1, 3, musicLabel);
place(0, 4, mDownloadMusicCheckBox);
-
- setDimension(gcn::Rectangle(0, 0, 370, 280));
}
void Setup_Audio::apply()
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index 95b2000d..cf234eb3 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -28,7 +28,7 @@
#include "gui/widgets/browserbox.h"
#include "gui/widgets/itemlinkhandler.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/layout.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/slider.h"
@@ -155,9 +155,6 @@ Setup_Colors::Setup_Colors() :
setOpaque(false);
// Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
place(0, 0, mScroll, 6, 6).setPadding(2);
place(0, 6, mPreviewBox, 6).setPadding(2);
place(0, 7, mGradTypeLabel, 3);
@@ -177,8 +174,6 @@ Setup_Colors::Setup_Colors() :
place(5, 11, mGradDelayText).setPadding(1);
mGradTypeText->setCaption("");
-
- setDimension(gcn::Rectangle(0, 0, 370, 280));
}
Setup_Colors::~Setup_Colors()
diff --git a/src/gui/setup_interface.cpp b/src/gui/setup_interface.cpp
index 67d8d476..b35a30fe 100644
--- a/src/gui/setup_interface.cpp
+++ b/src/gui/setup_interface.cpp
@@ -33,7 +33,7 @@
#include "gui/widgets/checkbox.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/layout.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/slider.h"
@@ -164,9 +164,6 @@ Setup_Interface::Setup_Interface():
mFontSizeDropDown->adjustHeight();
// Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
place(0, 0, mVisibleNamesCheckBox, 3);
place(3, 0, mNameCheckBox, 3);
@@ -193,8 +190,6 @@ Setup_Interface::Setup_Interface():
place(0, 9, mSpeechSlider, 2);
place(2, 9, speechLabel, 2);
place(4, 9, mSpeechLabel, 2).setPadding(2);
-
- setDimension(gcn::Rectangle(0, 0, 370, 300));
}
Setup_Interface::~Setup_Interface()
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index b3bdc226..1109f06e 100644
--- a/src/gui/setup_joystick.cpp
+++ b/src/gui/setup_joystick.cpp
@@ -27,7 +27,6 @@
#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
#include "utils/gettext.h"
@@ -46,16 +45,9 @@ Setup_Joystick::Setup_Joystick():
mJoystickCheckBox->addActionListener(this);
// Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
- place(0, 0, mJoystickCheckBox);
- place(0, 1, mCalibrateLabel);
- place.getCell().matchColWidth(0, 0);
- place = h.getPlacer(0, 1);
- place(0, 0, mCalibrateButton);
-
- setDimension(gcn::Rectangle(0, 0, 370, 75));
+ place(0, 0, mJoystickCheckBox, 2);
+ place(0, 1, mCalibrateLabel, 2);
+ place(0, 2, mCalibrateButton);
}
void Setup_Joystick::action(const gcn::ActionEvent &event)
diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp
index a108ae6a..5e29519b 100644
--- a/src/gui/setup_keyboard.cpp
+++ b/src/gui/setup_keyboard.cpp
@@ -29,7 +29,7 @@
#include "gui/okdialog.h"
#include "gui/widgets/button.h"
-#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/layout.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
@@ -98,15 +98,10 @@ Setup_Keyboard::Setup_Keyboard():
mMakeDefaultButton->addActionListener(this);
// Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
place(0, 0, scrollArea, 4, 6).setPadding(2);
place(0, 6, mMakeDefaultButton);
place(2, 6, mAssignKeyButton);
place(3, 6, mUnassignKeyButton);
-
- setDimension(gcn::Rectangle(0, 0, 370, 280));
}
Setup_Keyboard::~Setup_Keyboard()
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index c9776fe3..ad50baad 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -31,7 +31,7 @@
#include "gui/widgets/checkbox.h"
#include "gui/widgets/dropdown.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/layout.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/table.h"
@@ -99,8 +99,7 @@ public:
{
freeWidgets();
delete mListModel;
- if (mPlayers)
- delete mPlayers;
+ delete mPlayers;
}
virtual int getRows() const
@@ -287,9 +286,6 @@ Setup_Players::Setup_Players():
reset();
// Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
place(0, 0, mPlayerTitleTable, 4);
place(0, 1, mPlayerScrollArea, 4, 4).setPadding(2);
place(0, 5, mDeleteButton);
@@ -302,8 +298,6 @@ Setup_Players::Setup_Players():
place(0, 10, mWhisperTabCheckBox, 4).setPadding(4);
player_relations.addListener(this);
-
- setDimension(gcn::Rectangle(0, 0, 370, 280));
}
Setup_Players::~Setup_Players()
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 3c92aa31..c4fe60a1 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -34,7 +34,7 @@
#include "gui/widgets/checkbox.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/layout.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/slider.h"
@@ -248,9 +248,7 @@ Setup_Video::Setup_Video():
mParticleDetailSlider->setValue(mParticleDetail);
// Do the layout
- LayoutHelper h(this);
-
- ContainerPlacer place = h.getPlacer(0, 0);
+ ContainerPlacer place = getPlacer(0, 0);
place.getCell().setHAlign(LayoutCell::FILL);
place(0, 0, scrollArea, 1, 4).setPadding(2).setHAlign(LayoutCell::FILL);
@@ -259,7 +257,7 @@ Setup_Video::Setup_Video():
place(2, 1, mOpenGLCheckBox);
place(2, 2, mCustomCursorCheckBox);
- place = h.getPlacer(0, 1);
+ place = getPlacer(0, 1);
place.getCell().setHAlign(LayoutCell::FILL);
place(0, 0, space, 3);
@@ -278,8 +276,6 @@ Setup_Video::Setup_Video():
place(0, 5, overlayDetailLabel);
place(1, 5, mOverlayDetailSlider, 2);
place(3, 5, mOverlayDetailField);
-
- setDimension(gcn::Rectangle(0, 0, 370, 300));
}
Setup_Video::~Setup_Video()
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 485d5d5b..8c8abd19 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -31,7 +31,6 @@
#include "gui/widgets/button.h"
#include "gui/widgets/container.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/progressbar.h"
#include "gui/widgets/scrollarea.h"
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 4203a137..1b960d64 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -35,7 +35,6 @@
#include "gui/widgets/button.h"
#include "gui/widgets/container.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
#include "gui/widgets/linkhandler.h"
#include "gui/widgets/popup.h"
#include "gui/widgets/scrollarea.h"
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
index 7db5952a..53106da2 100644
--- a/src/gui/specialswindow.cpp
+++ b/src/gui/specialswindow.cpp
@@ -28,7 +28,6 @@
#include "gui/widgets/container.h"
#include "gui/widgets/icon.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/progressbar.h"
#include "gui/widgets/scrollarea.h"
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index ebd54f33..430d47ed 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -29,7 +29,7 @@
#include "gui/widgets/button.h"
#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/layout.h"
#include "gui/widgets/progressbar.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/vertcontainer.h"
@@ -65,7 +65,6 @@ class AttrDisplay : public Container
const int mId;
const std::string mName;
- LayoutHelper *mLayout;
Label *mLabel;
Label *mValue;
};
@@ -433,13 +432,10 @@ AttrDisplay::AttrDisplay(int id, const std::string &name):
mLabel->setAlignment(Graphics::CENTER);
mValue->setAlignment(Graphics::CENTER);
-
- mLayout = new LayoutHelper(this);
}
AttrDisplay::~AttrDisplay()
{
- delete mLayout;
}
std::string AttrDisplay::update()
@@ -458,9 +454,6 @@ DerDisplay::DerDisplay(int id, const std::string &name):
AttrDisplay(id, name)
{
// Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = mLayout->getPlacer(0, 0);
-
place(0, 0, mLabel, 3);
place(3, 0, mValue, 2);
@@ -474,8 +467,6 @@ ChangeDisplay::ChangeDisplay(int id, const std::string &name):
mInc = new Button(_("+"), "inc", this);
// Do the layout
- ContainerPlacer place = mLayout->getPlacer(0, 0);
-
place(0, 0, mLabel, 3);
place(4, 0, mValue, 2);
place(6, 0, mInc);
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp
index af4f0155..e1b99af7 100644
--- a/src/gui/widgets/container.cpp
+++ b/src/gui/widgets/container.cpp
@@ -21,7 +21,10 @@
#include "gui/widgets/container.h"
-Container::Container()
+#include "gui/widgets/layouthelper.h"
+
+Container::Container():
+ mLayoutHelper(0)
{
setOpaque(false);
}
@@ -30,4 +33,24 @@ Container::~Container()
{
while (!mWidgets.empty())
delete mWidgets.front();
+
+ delete mLayoutHelper;
+}
+
+Layout &Container::getLayout()
+{
+ if (!mLayoutHelper)
+ mLayoutHelper = new LayoutHelper(this);
+ return mLayoutHelper->getLayout();
+}
+
+LayoutCell &Container::place(int x, int y, gcn::Widget *wg, int w, int h)
+{
+ add(wg);
+ return getLayout().place(wg, x, y, w, h);
+}
+
+ContainerPlacer Container::getPlacer(int x, int y)
+{
+ return ContainerPlacer(this, &getLayout().at(x, y));
}
diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h
index e582f2a8..46b719a1 100644
--- a/src/gui/widgets/container.h
+++ b/src/gui/widgets/container.h
@@ -24,6 +24,11 @@
#include <guichan/widgets/container.hpp>
+class ContainerPlacer;
+class Layout;
+class LayoutCell;
+class LayoutHelper;
+
/**
* A widget container.
*
@@ -38,6 +43,25 @@ class Container : public gcn::Container
public:
Container();
~Container();
+
+ protected:
+ /**
+ * Gets the layout handler for this container.
+ */
+ Layout &getLayout();
+
+ /**
+ * Adds a widget to the container and sets it at given cell.
+ */
+ LayoutCell &place(int x, int y, gcn::Widget *wg, int w = 1, int h = 1);
+
+ /**
+ * Returns a proxy for adding widgets in an inner table of the layout.
+ */
+ ContainerPlacer getPlacer(int x, int y);
+
+ private:
+ LayoutHelper *mLayoutHelper;
};
#endif
diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp
index 1a634fcd..e1006bd9 100644
--- a/src/gui/widgets/layouthelper.cpp
+++ b/src/gui/widgets/layouthelper.cpp
@@ -32,11 +32,6 @@ LayoutHelper::~LayoutHelper()
mContainer->removeWidgetListener(this);
}
-Layout &LayoutHelper::getLayout()
-{
- return mLayout;
-}
-
LayoutCell &LayoutHelper::place(int x, int y, gcn::Widget *wg, int w, int h)
{
mContainer->add(wg);
diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h
index 055e6fa6..b8512212 100644
--- a/src/gui/widgets/layouthelper.h
+++ b/src/gui/widgets/layouthelper.h
@@ -34,14 +34,14 @@
class LayoutHelper : public gcn::WidgetListener
{
public:
- LayoutHelper(gcn::Container *container);
+ explicit LayoutHelper(gcn::Container *container);
~LayoutHelper();
/**
* Gets the layout handler.
*/
- Layout &getLayout();
+ Layout &getLayout() { return mLayout; }
/**
* Computes the position of the widgets according to the current
diff --git a/src/gui/widgets/setuptab.cpp b/src/gui/widgets/setuptab.cpp
index a1a493ad..dc183a50 100644
--- a/src/gui/widgets/setuptab.cpp
+++ b/src/gui/widgets/setuptab.cpp
@@ -23,5 +23,4 @@
SetupTab::SetupTab()
{
- setOpaque(false);
}
diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h
index 10bc68c3..c2403afb 100644
--- a/src/gui/widgets/vertcontainer.h
+++ b/src/gui/widgets/vertcontainer.h
@@ -28,7 +28,7 @@
/**
* A widget container.
*
- * This container places it's contents veritcally.
+ * This container places its contents vertically.
*/
class VertContainer : public Container, public gcn::WidgetListener
{