diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-14 22:34:39 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-14 22:34:39 +0300 |
commit | e149243eb20a1bb74657914122bcabc01de2ae36 (patch) | |
tree | 28df950c01da2d3d357204c0273531607b682e35 /src | |
parent | 4e7b98accb8f6fa927711174e4ee82a731317c74 (diff) | |
download | mv-e149243eb20a1bb74657914122bcabc01de2ae36.tar.gz mv-e149243eb20a1bb74657914122bcabc01de2ae36.tar.bz2 mv-e149243eb20a1bb74657914122bcabc01de2ae36.tar.xz mv-e149243eb20a1bb74657914122bcabc01de2ae36.zip |
Move enum from layout into separate file.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/gui/widgets/layout.h | 11 | ||||
-rw-r--r-- | src/gui/widgets/layoutarray.cpp | 25 | ||||
-rw-r--r-- | src/gui/widgets/layouttype.h | 42 | ||||
-rw-r--r-- | src/gui/windows/buydialog.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/didyouknowwindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/helpwindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/inventorywindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/npcdialog.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/outfitwindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/questswindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/selldialog.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/shopwindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/shortcutwindow.cpp | 5 | ||||
-rw-r--r-- | src/gui/windows/statuswindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/tradewindow.cpp | 9 | ||||
-rw-r--r-- | src/gui/windows/updaterwindow.cpp | 3 |
18 files changed, 87 insertions, 40 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index baf729677..3a549563c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -187,6 +187,7 @@ SET(SRCS gui/widgets/layoutcell.h gui/widgets/layouthelper.cpp gui/widgets/layouthelper.h + gui/widgets/layouttype.h gui/widgets/linepart.cpp gui/widgets/linepart.h gui/widgets/linkhandler.h diff --git a/src/Makefile.am b/src/Makefile.am index ee08b6c4a..69f58ab06 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -279,6 +279,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/layoutcell.h \ gui/widgets/layouthelper.cpp \ gui/widgets/layouthelper.h \ + gui/widgets/layouttype.h \ gui/widgets/linepart.cpp \ gui/widgets/linepart.h \ gui/widgets/linkhandler.h \ diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index 9e2cbb698..86b5dddcb 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -64,17 +64,6 @@ class Layout final : public LayoutCell */ void reflow(int &restrict nW, int &restrict nH); - /** - * When the minimum size of the layout is less than the available size, - * the remaining pixels are equally split amongst the FILL items. - */ - enum - { - AUTO_DEF = -42, /**< Default value, behaves like AUTO_ADD. */ - AUTO_SET = -43, /**< Uses the share as the new size. */ - AUTO_ADD = -44 /**< Adds the share to the current size. */ - }; - private: bool mComputed; }; diff --git a/src/gui/widgets/layoutarray.cpp b/src/gui/widgets/layoutarray.cpp index b0d534f00..b174ba5b3 100644 --- a/src/gui/widgets/layoutarray.cpp +++ b/src/gui/widgets/layoutarray.cpp @@ -26,6 +26,7 @@ #include "gui/widgets/basiccontainer2.h" #include "gui/widgets/layout.h" +#include "gui/widgets/layouttype.h" #include "utils/delete2.h" @@ -78,14 +79,14 @@ void LayoutArray::resizeGrid(int w, const int h) if (extH) { - mSizes[1].resize(h, Layout::AUTO_DEF); + mSizes[1].resize(h, LayoutType::DEF); mCells.resize(h); if (!extW) w = static_cast<int>(mSizes[0].size()); } if (extW) - mSizes[0].resize(w, Layout::AUTO_DEF); + mSizes[0].resize(w, LayoutType::DEF); std::vector <std::vector <LayoutCell *> >::iterator i = mCells.begin(); @@ -113,7 +114,7 @@ void LayoutArray::setRowHeight(const int n, const int h) void LayoutArray::matchColWidth(const int n1, const int n2) { resizeGrid(std::max(n1, n2) + 1, 0); - const std::vector<int> widths = getSizes(0, Layout::AUTO_DEF); + const std::vector<int> widths = getSizes(0, LayoutType::DEF); const int s = std::max(widths[n1], widths[n2]); mSizes[0][n1] = s; mSizes[0][n2] = s; @@ -150,9 +151,9 @@ LayoutCell &LayoutArray::place(Widget *const widget, const int x, cell.mAlign[0] = LayoutCell::FILL; cell.mAlign[1] = LayoutCell::FILL; int &cs = mSizes[0][x], &rs = mSizes[1][y]; - if (cs == Layout::AUTO_DEF && w == 1) + if (cs == LayoutType::DEF && w == 1) cs = 0; - if (rs == Layout::AUTO_DEF && h == 1) + if (rs == LayoutType::DEF && h == 1) rs = 0; return cell; } @@ -220,7 +221,7 @@ std::vector<int> LayoutArray::getSizes(const int dim, int upp) const } } - if (upp == Layout::AUTO_DEF) + if (upp == LayoutType::DEF) return sizes; // Compute the FILL sizes. @@ -228,11 +229,11 @@ std::vector<int> LayoutArray::getSizes(const int dim, int upp) const int nbFill = 0; for (int i = 0; i < nb; ++i) { - if (mSizes[dim][i] <= Layout::AUTO_DEF) + if (mSizes[dim][i] <= LayoutType::DEF) { ++nbFill; - if (mSizes[dim][i] == Layout::AUTO_SET || - sizes[i] <= Layout::AUTO_DEF) + if (mSizes[dim][i] == LayoutType::SET || + sizes[i] <= LayoutType::DEF) { sizes[i] = 0; } @@ -246,7 +247,7 @@ std::vector<int> LayoutArray::getSizes(const int dim, int upp) const for (int i = 0; i < nb; ++i) { - if (mSizes[dim][i] > Layout::AUTO_DEF) + if (mSizes[dim][i] > LayoutType::DEF) continue; const int s = upp / nbFill; @@ -260,12 +261,12 @@ std::vector<int> LayoutArray::getSizes(const int dim, int upp) const int LayoutArray::getSize(const int dim) const { - std::vector<int> sizes = getSizes(dim, Layout::AUTO_DEF); + std::vector<int> sizes = getSizes(dim, LayoutType::DEF); int size = 0; const int nb = static_cast<int>(sizes.size()); for (int i = 0; i < nb; ++i) { - if (sizes[i] > Layout::AUTO_DEF) + if (sizes[i] > LayoutType::DEF) size += sizes[i]; size += mSpacing; } diff --git a/src/gui/widgets/layouttype.h b/src/gui/widgets/layouttype.h new file mode 100644 index 000000000..aecd4bcd4 --- /dev/null +++ b/src/gui/widgets/layouttype.h @@ -0,0 +1,42 @@ +/* + * The ManaPlus Client + * Copyright (C) 2007-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 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_WIDGETS_LAYOUTTYPE_H +#define GUI_WIDGETS_LAYOUTTYPE_H + +#include "localconsts.h" + +namespace LayoutType +{ + /** + * When the minimum size of the layout is less than the available size, + * the remaining pixels are equally split amongst the FILL items. + */ + enum Type + { + DEF = -42, /**< Default value, behaves like AUTO_ADD. */ + SET = -43, /**< Uses the share as the new size. */ + ADD = -44 /**< Adds the share to the current size. */ + }; +} + +#endif // GUI_WIDGETS_LAYOUTTYPE_H diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index 0d2349143..a672ba338 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -37,6 +37,7 @@ #include "gui/widgets/inttextfield.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" +#include "gui/widgets/layouttype.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/shoplistbox.h" #include "gui/widgets/slider.h" @@ -289,7 +290,7 @@ void BuyDialog::init() placer(8, 8, mQuitButton); Layout &layout = getLayout(); - layout.setRowHeight(0, Layout::AUTO_SET); + layout.setRowHeight(0, LayoutType::SET); center(); loadWindowState(); diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index 79ad4c208..09051e9c0 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -32,6 +32,7 @@ #include "gui/widgets/browserbox.h" #include "gui/widgets/checkbox.h" #include "gui/widgets/layout.h" +#include "gui/widgets/layouttype.h" #include "gui/widgets/scrollarea.h" #include "utils/gettext.h" @@ -92,7 +93,7 @@ DidYouKnowWindow::DidYouKnowWindow() : place(4, 4, okButton); Layout &layout = getLayout(); - layout.setRowHeight(0, Layout::AUTO_SET); + layout.setRowHeight(0, LayoutType::SET); loadWindowState(); enableVisibleSound(true); diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index fa9963217..934e01359 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -32,6 +32,7 @@ #include "gui/widgets/button.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/layout.h" +#include "gui/widgets/layouttype.h" #include "gui/widgets/scrollarea.h" #include "resources/resourcemanager.h" @@ -84,7 +85,7 @@ HelpWindow::HelpWindow() : place(0, 0, mScrollArea, 5, 3).setPadding(3); Layout &layout = getLayout(); - layout.setRowHeight(0, Layout::AUTO_SET); + layout.setRowHeight(0, LayoutType::SET); loadWindowState(); loadTags(); diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index cf48e4fd1..90ce6eca4 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -52,6 +52,7 @@ #include "gui/widgets/dropdown.h" #include "gui/widgets/itemcontainer.h" #include "gui/widgets/layout.h" +#include "gui/widgets/layouttype.h" #include "gui/widgets/progressbar.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/tabstrip.h" @@ -238,7 +239,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory): } Layout &layout = getLayout(); - layout.setRowHeight(2, Layout::AUTO_SET); + layout.setRowHeight(2, LayoutType::SET); mInventory->addInventoyListener(this); diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index e8bc1763e..5de307963 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -44,6 +44,7 @@ #include "gui/widgets/itemcontainer.h" #include "gui/widgets/itemlinkhandler.h" #include "gui/widgets/layout.h" +#include "gui/widgets/layouttype.h" #include "gui/widgets/extendedlistbox.h" #include "gui/widgets/playerbox.h" #include "gui/widgets/scrollarea.h" @@ -811,7 +812,7 @@ void NpcDialog::buildLayout() } Layout &layout = getLayout(); - layout.setRowHeight(1, Layout::AUTO_SET); + layout.setRowHeight(1, LayoutType::SET); redraw(); mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll()); } diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index eb46022ba..7748ae256 100644 --- a/src/gui/windows/outfitwindow.cpp +++ b/src/gui/windows/outfitwindow.cpp @@ -39,6 +39,7 @@ #include "gui/widgets/checkbox.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" +#include "gui/widgets/layouttype.h" #include "resources/image.h" @@ -109,7 +110,7 @@ OutfitWindow::OutfitWindow(): place(0, 7, mAwayOutfitCheck, 4); Layout &layout = getLayout(); - layout.setRowHeight(0, Layout::AUTO_SET); + layout.setRowHeight(0, LayoutType::SET); layout.setColWidth(4, Layout::CENTER); loadWindowState(); diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index 3b4191178..c32d8e928 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -35,6 +35,7 @@ #include "gui/widgets/button.h" #include "gui/widgets/containerplacer.h" #include "gui/widgets/layout.h" +#include "gui/widgets/layouttype.h" #include "gui/widgets/extendedlistbox.h" #include "gui/widgets/itemlinkhandler.h" #include "gui/widgets/scrollarea.h" @@ -171,7 +172,7 @@ QuestsWindow::QuestsWindow() : placer(7, 3, mCloseButton); Layout &layout = getLayout(); - layout.setRowHeight(0, Layout::AUTO_SET); + layout.setRowHeight(0, LayoutType::SET); loadWindowState(); enableVisibleSound(true); diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index b317d6f54..691624e06 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -36,6 +36,7 @@ #include "gui/widgets/containerplacer.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" +#include "gui/widgets/layouttype.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/shoplistbox.h" #include "gui/widgets/slider.h" @@ -152,7 +153,7 @@ void SellDialog::init() placer(7, 7, mQuitButton); Layout &layout = getLayout(); - layout.setRowHeight(0, Layout::AUTO_SET); + layout.setRowHeight(0, LayoutType::SET); center(); loadWindowState(); diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 1c2afe9e8..01fb7b033 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -34,6 +34,7 @@ #include "gui/widgets/containerplacer.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" +#include "gui/widgets/layouttype.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/shoplistbox.h" @@ -181,7 +182,7 @@ ShopWindow::ShopWindow(): } Layout &layout = getLayout(); - layout.setRowHeight(0, Layout::AUTO_SET); + layout.setRowHeight(0, LayoutType::SET); center(); loadWindowState(); diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp index 8387d7e91..8b0e51472 100644 --- a/src/gui/windows/shortcutwindow.cpp +++ b/src/gui/windows/shortcutwindow.cpp @@ -26,6 +26,7 @@ #include "gui/widgets/tabbedarea.h" #include "gui/widgets/layout.h" +#include "gui/widgets/layouttype.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/shortcutcontainer.h" #include "gui/widgets/tabs/tab.h" @@ -104,7 +105,7 @@ ShortcutWindow::ShortcutWindow(const std::string &restrict title, place(0, 0, mScrollArea, 5, 5).setPadding(0); Layout &layout = getLayout(); - layout.setRowHeight(0, Layout::AUTO_SET); + layout.setRowHeight(0, LayoutType::SET); layout.setMargin(0); loadWindowState(); @@ -143,7 +144,7 @@ ShortcutWindow::ShortcutWindow(const std::string &restrict title, place(0, 0, mTabs, 5, 5); Layout &layout = getLayout(); - layout.setRowHeight(0, Layout::AUTO_SET); + layout.setRowHeight(0, LayoutType::SET); layout.setMargin(0); loadWindowState(); diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index fa0fd3378..99ed112eb 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -43,6 +43,7 @@ #include "gui/widgets/containerplacer.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" +#include "gui/widgets/layouttype.h" #include "gui/widgets/progressbar.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/vertcontainer.h" @@ -292,7 +293,7 @@ StatusWindow::StatusWindow() : mDAttrScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO); place(6, 3, mDAttrScroll, 5, 3); - getLayout().setRowHeight(3, Layout::AUTO_SET); + getLayout().setRowHeight(3, LayoutType::SET); place(0, 6, mCharacterPointsLabel, 5); place(0, 5, mCopyButton); diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 60ef9255b..305106af8 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -43,9 +43,10 @@ #include "gui/widgets/containerplacer.h" #include "gui/widgets/itemcontainer.h" #include "gui/widgets/label.h" +#include "gui/widgets/layout.h" +#include "gui/widgets/layouttype.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/textfield.h" -#include "gui/widgets/layout.h" #include "gui/widgets/tabs/chattab.h" @@ -141,10 +142,10 @@ TradeWindow::TradeWindow(): placer(1, 0, mOkButton); Layout &layout = getLayout(); layout.extend(0, 2, 2, 1); - layout.setRowHeight(1, Layout::AUTO_SET); + layout.setRowHeight(1, LayoutType::SET); layout.setRowHeight(2, 0); - layout.setColWidth(0, Layout::AUTO_SET); - layout.setColWidth(1, Layout::AUTO_SET); + layout.setColWidth(0, LayoutType::SET); + layout.setColWidth(1, LayoutType::SET); loadWindowState(); enableVisibleSound(true); diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 0884f5f7a..1f7b8f18d 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -34,6 +34,7 @@ #include "gui/widgets/containerplacer.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" +#include "gui/widgets/layouttype.h" #include "gui/widgets/progressbar.h" #include "gui/widgets/scrollarea.h" @@ -220,7 +221,7 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost, placer(4, 5, mPlayButton); Layout &layout = getLayout(); - layout.setRowHeight(0, Layout::AUTO_SET); + layout.setRowHeight(0, LayoutType::SET); addKeyListener(this); |