summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/layout.h11
-rw-r--r--src/gui/widgets/layoutarray.cpp25
-rw-r--r--src/gui/widgets/layouttype.h42
3 files changed, 55 insertions, 23 deletions
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