diff options
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/layout.cpp | 11 | ||||
-rw-r--r-- | src/gui/widgets/layout.h | 18 |
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: |