32 (
int x,
int y, gcn::Widget *wg,
int w,
int h)
35 return mCell->
place(wg, x, y, w, h);
69 mWidget->setDimension(gcn::Rectangle(nx, ny, nw, nh));
80 if (cell && cell->mType ==
ARRAY)
97 for (
auto &cell : row)
117 bool extW = w && w > (int)
mSizes[0].size(),
118 extH = h && h > (int)
mSizes[1].size();
126 if (!extW) w =
mSizes[0].size();
136 row.resize(w,
nullptr);
156 int s = std::max(widths[n1], widths[n2]);
174 cell.
mSize[0] = w == 1 ? widget->getWidth() : 0;
175 cell.
mSize[1] = h == 1 ? widget->getHeight() : 0;
191 LayoutCell const &cell,
const short *sizes)
const
193 int size_max = sizes[0];
194 for (
int i = 1; i < cell.
mExtent[dim]; ++i)
196 size = std::min<int>(cell.
mSize[dim], size_max);
203 pos += size_max - size;
206 pos += (size_max - size) / 2;
216 int gridW =
mSizes[0].size();
217 int gridH =
mSizes[1].size();
218 std::vector< short > sizes =
mSizes[dim];
221 for (
int gridY = 0; gridY < gridH; ++gridY)
223 for (
int gridX = 0; gridX < gridW; ++gridX)
231 int n = dim == 0 ? gridX : gridY;
233 if (s > sizes[n]) sizes[n] = s;
241 int nb = sizes.size();
243 for (
int i = 0; i < nb; ++i)
261 for (
int i = 0; i < nb; ++i)
265 int s = upp / nbFill;
278 int nb = sizes.size();
279 for (
int i = 0; i < nb; ++i)
289 int gridW =
mSizes[0].size();
290 int gridH =
mSizes[1].size();
292 std::vector< short > widths =
getSizes(0, nw);
293 std::vector< short > heights =
getSizes(1, nh);
296 for (
int gridY = 0; gridY < gridH; ++gridY)
299 for (
int gridX = 0; gridX < gridW; ++gridX)
304 int dx = x, dy = y, dw, dh;
305 align(dx, dw, 0, *cell, &widths[gridX]);
306 align(dy, dh, 1, *cell, &heights[gridY]);
307 cell->
reflow(dx, dy, dw, dh);
This class is a helper for adding widgets to nested tables in a window.
gcn::Container * mContainer
ContainerPlacer at(int x, int y)
Returns a placer for the same container but to an inner cell.
This class contains a rectangular array of cells.
std::vector< std::vector< LayoutCell * > > mCells
void align(int &pos, int &size, int dim, LayoutCell const &cell, const short *sizes) const
Gets the position and size of a widget along a given axis.
std::vector< short > mSizes[2]
void setColWidth(int n, int w)
Sets the minimum width of a column.
void reflow(int nX, int nY, int nW, int nH)
Computes and sets the positions of all the widgets.
void matchColWidth(int n1, int n2)
Sets the widths of two columns to the maximum of their widths.
int getSize(int dim) const
Gets the total size along a given axis.
void extend(int x, int y, int w, int h)
Spawns a cell over several columns/rows.
void resizeGrid(int w, int h)
Ensures the private vectors are large enough.
LayoutCell & place(gcn::Widget *, int x, int y, int w=1, int h=1)
Places a widget in a given cell.
std::vector< short > getSizes(int dim, int upp) const
Gets the column/row sizes along a given axis.
void setRowHeight(int n, int h)
Sets the minimum height of a row.
LayoutCell & at(int x, int y, int w=1, int h=1)
Returns a reference on the cell at given position.
This class describes the formatting of a widget in the cell of a layout table.
LayoutCell & setPadding(int p)
Sets the padding around the cell content.
void reflow(int nx, int ny, int nw, int nh)
LayoutCell & place(gcn::Widget *wg, int x, int y, int w=1, int h=1)
LayoutCell & at(int x, int y)
LayoutArray & getArray()
Returns the embedded array.
void computeSizes()
Sets the minimum widths and heights of this cell and of all the inner cells.
void reflow(int &nW, int &nH)
Sets the positions of all the widgets.
@ AUTO_SET
Uses the share as the new size.
@ AUTO_DEF
Default value, behaves like AUTO_ADD.