Implements a layout organizing children components in a grid. More...
Public Member Functions | |
GridLayout (System *system) noexcept | |
GridLayout (const GridLayout &)=delete | |
virtual | ~GridLayout () |
Component * | getComponentAt (unsigned int index) const |
Component * | getComponentAt (unsigned int x, unsigned int y) const |
unsigned int | getGridWidth () const |
unsigned int | getGridHeight () const |
float | getFixedSizeRow (unsigned int index) const |
float | getFixedSizeCol (unsigned int index) const |
float | getWeightRow (unsigned int index) const |
float | getWeightCol (unsigned int index) const |
nkMaths::Point | getCellCoordinatesForPoint (nkMaths::Point point) const |
virtual void | setParentComponent (Component *parent) override |
void | setGridWidth (unsigned int value) |
void | setGridHeight (unsigned int value) |
void | insertRow (unsigned int index) |
void | insertCol (unsigned int index) |
void | eraseRow (unsigned int index) |
void | eraseCol (unsigned int index) |
void | setFixedSizeRow (unsigned int rowIndex, float sizePix) |
void | setFixedSizeCol (unsigned int colIndex, float sizePix) |
void | setWeightRow (unsigned int rowIndex, float weight) |
void | setWeightCol (unsigned int colIndex, float weight) |
void | setInternalBorderWidth (float valuePix) |
void | setInternalBorderHeight (float valuePix) |
void | setIgnoreInternalBorderCell (unsigned int rowIndex, unsigned int colIndex, bool value) |
void | addComponent (Component *component, unsigned int x, unsigned int y, unsigned int width, unsigned int height, bool resizeAllowed=false, bool updateLayout=true) |
void | updateComponentCellCoverage (Component *component, unsigned int x, unsigned int y, unsigned int width, unsigned int height, bool updateLayout=true) |
nkMaths::Rectangle | getComponentCellCoverage (Component *component) const |
virtual void | removeComponent (Component *component) override |
virtual void | update () override |
virtual void | exportClassToTree (nkExport::Node *rootNode) override |
virtual void | exportComponentsNodeEntry (nkExport::Node *rootNode) override |
virtual void | importClassFromTree (nkExport::Node *rootNode) override |
virtual void | processComponentsNodeEntry (nkExport::Node *rootNode) override |
GridLayout & | operator= (const GridLayout &)=delete |
Public Member Functions inherited from nkWinUi::Layout | |
Layout (System *system) noexcept | |
virtual | ~Layout () |
Component * | getParentComponent () const |
System * | getSystem () const |
LAYOUT_TYPE | getType () const |
Public Member Functions inherited from nkExport::Exportable | |
Exportable () noexcept | |
virtual | ~Exportable () |
Implements a layout organizing children components in a grid.
This layout will alter the components size to make them fit within the bounds of the window, as described by its settings.
|
noexcept |
Constructor.
system | The parent system in which the layout will live. |
|
delete |
Copy constructor.
|
virtual |
Destructor.
Component* nkWinUi::GridLayout::getComponentAt | ( | unsigned int | index | ) | const |
index | The wanted component's index. |
Component* nkWinUi::GridLayout::getComponentAt | ( | unsigned int | x, |
unsigned int | y | ||
) | const |
Gives access to a component covering given cell coordinates.
x | The x component of the cell to check against. |
y | The y component of the cell to check against. |
unsigned int nkWinUi::GridLayout::getGridWidth | ( | ) | const |
unsigned int nkWinUi::GridLayout::getGridHeight | ( | ) | const |
float nkWinUi::GridLayout::getFixedSizeRow | ( | unsigned int | index | ) | const |
index | The index of the row to retrieve the fixed size from. |
float nkWinUi::GridLayout::getFixedSizeCol | ( | unsigned int | index | ) | const |
index | The index of the column to retrieve the fixed size from. |
float nkWinUi::GridLayout::getWeightRow | ( | unsigned int | index | ) | const |
index | The index of the row to retrieve the weight from. |
float nkWinUi::GridLayout::getWeightCol | ( | unsigned int | index | ) | const |
index | The index of the column to retrieve the weight from. |
nkMaths::Point nkWinUi::GridLayout::getCellCoordinatesForPoint | ( | nkMaths::Point | point | ) | const |
Gives access to the cell pointed by given coordinates.
point | The coordinates to check against, relative the the layout's parent component. |
|
overridevirtual |
See Layout::setParentComponent().
Reimplemented from nkWinUi::Layout.
void nkWinUi::GridLayout::setGridWidth | ( | unsigned int | value | ) |
Sets the width of the grid to organize children components. This corresponds to the number of cells to use.
value | The width to use. |
void nkWinUi::GridLayout::setGridHeight | ( | unsigned int | value | ) |
Sets the height of the grid to organize children components. This corresponds to the number of cells to use.
value | The height to use. |
void nkWinUi::GridLayout::insertRow | ( | unsigned int | index | ) |
Inserts a row in the grid, at given index.
index | The index of the row to create. |
void nkWinUi::GridLayout::insertCol | ( | unsigned int | index | ) |
Inserts a column in the grid, at given index, pushing away components.
index | The index of the column to create. |
void nkWinUi::GridLayout::eraseRow | ( | unsigned int | index | ) |
Erases a row within the layout.
index | The index of the row to erase. |
void nkWinUi::GridLayout::eraseCol | ( | unsigned int | index | ) |
Erases a column within the layout.
index | The intex of the column to erase. |
void nkWinUi::GridLayout::setFixedSizeRow | ( | unsigned int | rowIndex, |
float | sizePix | ||
) |
Allows to add a row that will have a fixed size in pixels.
rowIndex | The index of the row having a fixed size. |
sizePix | The size it will have, in pixels. |
void nkWinUi::GridLayout::setFixedSizeCol | ( | unsigned int | colIndex, |
float | sizePix | ||
) |
Allows to add a column that will have a fixed size in pixels.
colIndex | The index of the row having a fixed size. |
sizePix | The size it will have, in pixels. |
void nkWinUi::GridLayout::setWeightRow | ( | unsigned int | rowIndex, |
float | weight | ||
) |
Sets the weight of one row.
rowIndex | The index of the row to alter. |
weight | The weight to assign to the row (in [0.0, 1.0] range). |
void nkWinUi::GridLayout::setWeightCol | ( | unsigned int | colIndex, |
float | weight | ||
) |
Sets the weight of one column.
colIndex | The index of the column to alter. |
weight | The weight to assign to the row (in [0.0, 1.0] range). |
void nkWinUi::GridLayout::setInternalBorderWidth | ( | float | valuePix | ) |
Sets the border width in between children components.
valuePix | The width, in pixels. |
void nkWinUi::GridLayout::setInternalBorderHeight | ( | float | valuePix | ) |
Sets the border height in between children components.
valuePix | The height, in pixels. |
void nkWinUi::GridLayout::setIgnoreInternalBorderCell | ( | unsigned int | rowIndex, |
unsigned int | colIndex, | ||
bool | value | ||
) |
Sets a cell coordinate for which the internal border setup will be ignored.
rowIndex | The row index of the cell for which border should be ignored. |
colIndex | The column index of the cell for which border should be ignored. |
value | Whether the border should be ignored (true) or not (false). |
void nkWinUi::GridLayout::addComponent | ( | Component * | component, |
unsigned int | x, | ||
unsigned int | y, | ||
unsigned int | width, | ||
unsigned int | height, | ||
bool | resizeAllowed = false , |
||
bool | updateLayout = true |
||
) |
Add a component to this layout, describing its position in the grid.
component | The component to add. |
x | The x origin in the layout's grid. Starts indexing at 0. |
y | The y origin in the layout's grid. Starts indexing at 0. |
width | The width, in cells number, in the grid. |
height | The height, in cells number, in the grid. |
resizeAllowed | Whether the component should be resizable with handles around it. |
updateLayout | Whether the layout should be updated right away (true) or not (false). Can be switched off to update many elements in the layout and then update only once in the end. |
void nkWinUi::GridLayout::updateComponentCellCoverage | ( | Component * | component, |
unsigned int | x, | ||
unsigned int | y, | ||
unsigned int | width, | ||
unsigned int | height, | ||
bool | updateLayout = true |
||
) |
Updates a component's cell coverage within the layout.
component | The component for which coverage will be updated. |
x | The new x position of the component, in the grid. |
y | The new y position of the component, in the grid. |
width | The new width of the component, in columns. |
height | The new height of the component, in rows. |
updateLayout | Whether the layout should be updated right away (true) or not (false). Can be switched off to update many elements in the layout and then update only once in the end. |
nkMaths::Rectangle nkWinUi::GridLayout::getComponentCellCoverage | ( | Component * | component | ) | const |
Allows to retrieve the cell coverage of a component inside the grid.
component | The component from which information should be retrieved. |
|
overridevirtual |
See Layout::removeComponent().
Implements nkWinUi::Layout.
|
overridevirtual |
See Layout::update().
Implements nkWinUi::Layout.
|
overridevirtual |
See Layout::exportClassToTree().
Reimplemented from nkWinUi::Layout.
|
overridevirtual |
See Layout::exportComponentsNodeEntry().
Reimplemented from nkWinUi::Layout.
|
overridevirtual |
See Layout::importClassFromTree().
Reimplemented from nkWinUi::Layout.
|
overridevirtual |
See Layout::processComponentsNodeEntry().
Reimplemented from nkWinUi::Layout.
|
delete |
Copy assignment.