summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-10-20 17:38:23 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-10-20 17:38:23 +0000
commit94ab3f3afa12f9f73d7f832e95aa0af2d9efdf16 (patch)
treef16d0fbe9c185ed57ff311ca99db02b29a455fe9 /src/gui/widgets
parentaab0b1724897e186d2d4056da7f0cd34ccc12fcb (diff)
downloadmana-client-94ab3f3afa12f9f73d7f832e95aa0af2d9efdf16.tar.gz
mana-client-94ab3f3afa12f9f73d7f832e95aa0af2d9efdf16.tar.bz2
mana-client-94ab3f3afa12f9f73d7f832e95aa0af2d9efdf16.tar.xz
mana-client-94ab3f3afa12f9f73d7f832e95aa0af2d9efdf16.zip
Set FILL as default size in layout. Converted server selection dialog to layout handler.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/layout.cpp11
-rw-r--r--src/gui/widgets/layout.h18
2 files changed, 20 insertions, 9 deletions
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index 2133b077..9d0b4791 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -31,14 +31,14 @@ void Layout::resizeGrid(int w, int h)
if (extH)
{
- mSizes[1].resize(h, 0);
+ mSizes[1].resize(h, FILL);
mCells.resize(h);
if (!extW) w = mSizes[0].size();
}
if (extW)
{
- mSizes[0].resize(w, 0);
+ mSizes[0].resize(w, FILL);
}
for (std::vector< std::vector< Cell > >::iterator
@@ -79,6 +79,9 @@ Cell &Layout::place(gcn::Widget *widget, int x, int y, int w, int h)
cell.mPadding = 0;
cell.mAlign[0] = Cell::FILL;
cell.mAlign[1] = Cell::FILL;
+ int &cs = mSizes[0][x], &rs = mSizes[1][y];
+ if (cs == FILL) cs = 0;
+ if (rs == FILL) rs = 0;
return cell;
}
@@ -137,8 +140,8 @@ std::vector< int > Layout::compute(int dim, int upp)
for (int i = 0; i < nb; ++i)
{
if (mSizes[dim][i] == FILL) ++nbFill;
- if (sizes[i] > 0) upp -= sizes[i];
- upp -= mPadding;
+ if (sizes[i] == FILL) sizes[i] = 0;
+ else upp -= sizes[i];
}
upp += mPadding;
diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h
index 09b511f6..05a84d53 100644
--- a/src/gui/widgets/layout.h
+++ b/src/gui/widgets/layout.h
@@ -76,10 +76,14 @@ class Cell
/**
* This class is an helper for setting the position of widgets. They are
- * positioned along the cells of a rectangular table. The size of a given
- * table column can either be set manually or be chosen from the widest widget
- * of the column. The process is similar for table rows. By default, there is a
- * padding of 4 pixels between rows and between columns.
+ * positioned along the cells of a rectangular table.
+ *
+ * The size of a given table column can either be set manually or be chosen
+ * from the widest widget of the column. An empty column has a FILL width,
+ * which means it will be extended so that the layout fits its minimum width.
+ *
+ * The process is similar for table rows. By default, there is a padding of 4
+ * pixels between rows and between columns.
*/
class Layout
{
@@ -89,11 +93,15 @@ class Layout
/**
* Sets the minimum width of a column.
+ * @note Setting the width to FILL and then placing a widget in the
+ * column will reset the width to zero.
*/
void setColWidth(int n, int w);
/**
* Sets the minimum height of a row.
+ * @note Setting the height to FILL and then placing a widget in the
+ * row will reset the height to zero.
*/
void setRowHeight(int n, int h);
@@ -138,7 +146,7 @@ class Layout
enum
{
- FILL = -1, /**< Expand until the layout as the expected size. */
+ FILL = -42, /**< Expand until the layout as the expected size. */
};
private: