API Documentation
Public Member Functions | List of all members
nkWinUi::GridLayout Class Referencefinal

Implements a layout organizing children components in a grid. More...

Inheritance diagram for nkWinUi::GridLayout:
nkWinUi::Layout nkExport::Exportable

Public Member Functions

 GridLayout (System *system) noexcept
 
 GridLayout (const GridLayout &)=delete
 
virtual ~GridLayout ()
 
ComponentgetComponentAt (unsigned int index) const
 
ComponentgetComponentAt (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
 
- Public Member Functions inherited from nkWinUi::Layout
 Layout (System *system) noexcept
 
virtual ~Layout ()
 
ComponentgetParentComponent () const
 
SystemgetSystem () const
 
LAYOUT_TYPE getType () const
 
- Public Member Functions inherited from nkExport::Exportable
 Exportable () noexcept
 
virtual ~Exportable ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ GridLayout() [1/2]

nkWinUi::GridLayout::GridLayout ( System system)
noexcept

Constructor.

Parameters
systemThe parent system in which the layout will live.

◆ GridLayout() [2/2]

nkWinUi::GridLayout::GridLayout ( const GridLayout )
delete

Copy constructor.

◆ ~GridLayout()

virtual nkWinUi::GridLayout::~GridLayout ( )
virtual

Destructor.

Member Function Documentation

◆ getComponentAt() [1/2]

Component* nkWinUi::GridLayout::getComponentAt ( unsigned int  index) const
Parameters
indexThe wanted component's index.
Returns
The child component at given index, if available. If out of bounds, nullptr.

◆ getComponentAt() [2/2]

Component* nkWinUi::GridLayout::getComponentAt ( unsigned int  x,
unsigned int  y 
) const

Gives access to a component covering given cell coordinates.

Parameters
xThe x component of the cell to check against.
yThe y component of the cell to check against.
Returns
The component covering given cell if available, nullptr else.

◆ getGridWidth()

unsigned int nkWinUi::GridLayout::getGridWidth ( ) const
Returns
The current grid width.

◆ getGridHeight()

unsigned int nkWinUi::GridLayout::getGridHeight ( ) const
Returns
The current grid height.

◆ getFixedSizeRow()

float nkWinUi::GridLayout::getFixedSizeRow ( unsigned int  index) const
Parameters
indexThe index of the row to retrieve the fixed size from.
Returns
The fixed pixel size provided to the row at given index.

◆ getFixedSizeCol()

float nkWinUi::GridLayout::getFixedSizeCol ( unsigned int  index) const
Parameters
indexThe index of the column to retrieve the fixed size from.
Returns
The fixed pixel size provided to the column at given index.

◆ getWeightRow()

float nkWinUi::GridLayout::getWeightRow ( unsigned int  index) const
Parameters
indexThe index of the row to retrieve the weight from.
Returns
The weight given to the row at given index.

◆ getWeightCol()

float nkWinUi::GridLayout::getWeightCol ( unsigned int  index) const
Parameters
indexThe index of the column to retrieve the weight from.
Returns
The weight given to the column at given index.

◆ getCellCoordinatesForPoint()

nkMaths::Point nkWinUi::GridLayout::getCellCoordinatesForPoint ( nkMaths::Point  point) const

Gives access to the cell pointed by given coordinates.

Parameters
pointThe coordinates to check against, relative the the layout's parent component.
Returns
The cell touched by given coordinates, if available, nullptr else.

◆ setParentComponent()

virtual void nkWinUi::GridLayout::setParentComponent ( Component parent)
overridevirtual

◆ setGridWidth()

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.

Parameters
valueThe width to use.

◆ setGridHeight()

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.

Parameters
valueThe height to use.

◆ insertRow()

void nkWinUi::GridLayout::insertRow ( unsigned int  index)

Inserts a row in the grid, at given index.

Parameters
indexThe index of the row to create.

◆ insertCol()

void nkWinUi::GridLayout::insertCol ( unsigned int  index)

Inserts a column in the grid, at given index, pushing away components.

Parameters
indexThe index of the column to create.

◆ eraseRow()

void nkWinUi::GridLayout::eraseRow ( unsigned int  index)

Erases a row within the layout.

Parameters
indexThe index of the row to erase.

◆ eraseCol()

void nkWinUi::GridLayout::eraseCol ( unsigned int  index)

Erases a column within the layout.

Parameters
indexThe intex of the column to erase.

◆ setFixedSizeRow()

void nkWinUi::GridLayout::setFixedSizeRow ( unsigned int  rowIndex,
float  sizePix 
)

Allows to add a row that will have a fixed size in pixels.

Parameters
rowIndexThe index of the row having a fixed size.
sizePixThe size it will have, in pixels.

◆ setFixedSizeCol()

void nkWinUi::GridLayout::setFixedSizeCol ( unsigned int  colIndex,
float  sizePix 
)

Allows to add a column that will have a fixed size in pixels.

Parameters
colIndexThe index of the row having a fixed size.
sizePixThe size it will have, in pixels.

◆ setWeightRow()

void nkWinUi::GridLayout::setWeightRow ( unsigned int  rowIndex,
float  weight 
)

Sets the weight of one row.

Parameters
rowIndexThe index of the row to alter.
weightThe weight to assign to the row (in [0.0, 1.0] range).
Remarks
Full grid has a weight of 1.0. As such, it can be distributed using this function, while rows with no explicit weight will be filled automatically to share the remaining available weight. For instance, having 3 rows with one having a weight of 0.5, then remaining two will get 0.25 (0.5 / 2).

◆ setWeightCol()

void nkWinUi::GridLayout::setWeightCol ( unsigned int  colIndex,
float  weight 
)

Sets the weight of one column.

Parameters
colIndexThe index of the column to alter.
weightThe weight to assign to the row (in [0.0, 1.0] range).
Remarks
Full grid has a weight of 1.0. As such, it can be distributed using this function, while columns with no explicit weight will be filled automatically to share the remaining available weight. For instance, having 3 columns with one having a weight of 0.5, then remaining two will get 0.25 (0.5 / 2).

◆ setInternalBorderWidth()

void nkWinUi::GridLayout::setInternalBorderWidth ( float  valuePix)

Sets the border width in between children components.

Parameters
valuePixThe width, in pixels.

◆ setInternalBorderHeight()

void nkWinUi::GridLayout::setInternalBorderHeight ( float  valuePix)

Sets the border height in between children components.

Parameters
valuePixThe height, in pixels.

◆ setIgnoreInternalBorderCell()

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.

Parameters
rowIndexThe row index of the cell for which border should be ignored.
colIndexThe column index of the cell for which border should be ignored.
valueWhether the border should be ignored (true) or not (false).
Remarks
If a component crosses many cells because of its size, the flags from its origin (aka, the cell it is positioned in) will be used to retrieve the flag value when udpating.

◆ addComponent()

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.

Parameters
componentThe component to add.
xThe x origin in the layout's grid. Starts indexing at 0.
yThe y origin in the layout's grid. Starts indexing at 0.
widthThe width, in cells number, in the grid.
heightThe height, in cells number, in the grid.
resizeAllowedWhether the component should be resizable with handles around it.
updateLayoutWhether 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.
Remarks
Note that if resizing is requested, handles will be added only on edges that are not neighbouring either the layout borders or rows and colums with fixed sizes. Else, no handle will be available.

◆ updateComponentCellCoverage()

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.

Parameters
componentThe component for which coverage will be updated.
xThe new x position of the component, in the grid.
yThe new y position of the component, in the grid.
widthThe new width of the component, in columns.
heightThe new height of the component, in rows.
updateLayoutWhether 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.
Remarks
This function has no effect if the component is not part of the layout.

◆ getComponentCellCoverage()

nkMaths::Rectangle nkWinUi::GridLayout::getComponentCellCoverage ( Component component) const

Allows to retrieve the cell coverage of a component inside the grid.

Parameters
componentThe component from which information should be retrieved.
Returns
The rectangle describing the cell coverage of the component, if any. An empty rectangle if the component is not part of the layout.

◆ removeComponent()

virtual void nkWinUi::GridLayout::removeComponent ( Component component)
overridevirtual

◆ update()

virtual void nkWinUi::GridLayout::update ( )
overridevirtual

◆ exportClassToTree()

virtual void nkWinUi::GridLayout::exportClassToTree ( nkExport::Node rootNode)
overridevirtual

See Layout::exportClassToTree().

Reimplemented from nkWinUi::Layout.

◆ exportComponentsNodeEntry()

virtual void nkWinUi::GridLayout::exportComponentsNodeEntry ( nkExport::Node rootNode)
overridevirtual

◆ importClassFromTree()

virtual void nkWinUi::GridLayout::importClassFromTree ( nkExport::Node rootNode)
overridevirtual

◆ processComponentsNodeEntry()

virtual void nkWinUi::GridLayout::processComponentsNodeEntry ( nkExport::Node rootNode)
overridevirtual

The documentation for this class was generated from the following file: