diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-07-25 22:27:32 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-07-25 22:27:41 +0200 |
commit | 8331284990b8d998a7e323e6fcf3c25f2f7d60d8 (patch) | |
tree | 168cf7bdc4cc4e8d93c8072ded3c4a1246c12e64 | |
parent | f0d0f33c8fa4910040204ea3023cd08b4660f56f (diff) | |
download | mana-8331284990b8d998a7e323e6fcf3c25f2f7d60d8.tar.gz mana-8331284990b8d998a7e323e6fcf3c25f2f7d60d8.tar.bz2 mana-8331284990b8d998a7e323e6fcf3c25f2f7d60d8.tar.xz mana-8331284990b8d998a7e323e6fcf3c25f2f7d60d8.zip |
Reduced the height of the Setup window
Also 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.
-rw-r--r-- | src/gui/charselectdialog.cpp | 6 | ||||
-rw-r--r-- | src/gui/debugwindow.cpp | 4 | ||||
-rw-r--r-- | src/gui/setup.cpp | 2 | ||||
-rw-r--r-- | src/gui/setup_audio.cpp | 7 | ||||
-rw-r--r-- | src/gui/setup_colors.cpp | 7 | ||||
-rw-r--r-- | src/gui/setup_interface.cpp | 7 | ||||
-rw-r--r-- | src/gui/setup_joystick.cpp | 14 | ||||
-rw-r--r-- | src/gui/setup_keyboard.cpp | 7 | ||||
-rw-r--r-- | src/gui/setup_players.cpp | 10 | ||||
-rw-r--r-- | src/gui/setup_video.cpp | 10 | ||||
-rw-r--r-- | src/gui/skilldialog.cpp | 1 | ||||
-rw-r--r-- | src/gui/socialwindow.cpp | 1 | ||||
-rw-r--r-- | src/gui/specialswindow.cpp | 1 | ||||
-rw-r--r-- | src/gui/statuswindow.cpp | 11 | ||||
-rw-r--r-- | src/gui/widgets/container.cpp | 25 | ||||
-rw-r--r-- | src/gui/widgets/container.h | 24 | ||||
-rw-r--r-- | src/gui/widgets/layouthelper.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/layouthelper.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/setuptab.cpp | 1 | ||||
-rw-r--r-- | src/gui/widgets/vertcontainer.h | 2 |
20 files changed, 66 insertions, 83 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 d2fd4a29..1eedd638 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); @@ -144,7 +144,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.cpp b/src/gui/setup.cpp index f378572b..c468490c 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -45,7 +45,7 @@ Setup::Setup(): { setCloseButton(true); int width = 395; - int height = 360; + int height = 300; setContentSize(width, height); static const char *buttonNames[] = { 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 fecfcdcb..05bc6c44 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.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" @@ -187,11 +187,7 @@ Setup_Video::Setup_Video(): mFpsSlider->addActionListener(this); // Do the layout - LayoutHelper h(this); - - ContainerPlacer place = h.getPlacer(0, 0); - place.getCell().setHAlign(LayoutCell::FILL); - + getLayout().setHAlign(LayoutCell::FILL); place(0, 0, scrollArea, 1, 4).setPadding(2).setHAlign(LayoutCell::FILL); place(1, 0, space, 1, 4); place(2, 0, mFsCheckBox); @@ -201,8 +197,6 @@ Setup_Video::Setup_Video(): place(2, 4, mFpsCheckBox); place(3, 4, mFpsSlider, 2); place(5, 4, mFpsLabel); - - 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 { |