![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GUI/DisplayLayoutConfig.h>
The DisplayLayoutConfig serves as static "snapshot" of the view configuration of a DisplayLayout. More...
The DisplayLayoutConfig serves as static "snapshot" of the view configuration of a DisplayLayout.
Instead of using recursive binary subdivision, it uses a table/grid-like representation where a View is assigned to one cell. By default the grid is regular but each row/column can be adjusted in size and views can span multiple cells in either dimension. In a valid configuration each cell is occupied by exactly one view and rows/columns do not overlap each other.
When manually specifying a DisplayLayout it is often easier/more intuitive to do so in a grid-like fashion and create a temporary DisplayLayoutConfig, and then assign it via DisplayLayout::loadConfiguration().
Classes | |
| class | LayoutCell |
| The LayoutCell class represents one cell in the grid. More... | |
Public Member Functions | |
| DisplayLayoutConfig () | |
| Creates an empty (but valid) configuration. | |
| DisplayLayoutConfig (int x, int y) | |
| Creates a configuration of x*y regular grid. | |
| DisplayLayoutConfig (const GUI::View *view) | |
| Convenient method to create a configuration with only one view. | |
| void | clear () |
| Removes all views. | |
| bool | addView (const GUI::View *view, int x, int y, int spanX=1, int spanY=1) |
| Adds a new view at the given coordinates to the configuration. | |
| bool | addSubLayout (const DisplayLayoutConfig &sublayout, int x, int y, int spanX=1, int spanY=1) |
| Adds a new sublayout at the given coordinates to the configuration. | |
| const std::vector< LayoutCell > & | views () const |
| Returns a list of all views that have been added to the configuration. | |
| void | resize (int newX, int newY, int offsetX=0, int offsetY=0) |
| Resizes the grid of the configuration. | |
| void | setRowSpacing (int row, float spacing) |
| Set the spacing of a row. | |
| void | setColumnSpacing (int col, float spacing) |
| Set the spacing of a column. | |
| float | rowSpacing (int row) const |
| Returns the spacing of a row. | |
| float | columnSpacing (int col) const |
| Returns the spacing of a column. | |
| void | resetSpacing () |
| Resets the spacing to a regular grid. | |
| void | removeColumn (int col) |
| Removes a column. | |
| void | removeRow (int row) |
| Removes a row. | |
| void | removeEmptyRows () |
| Removes all rows that do not contain any views. | |
| void | removeEmptyColumns () |
| Removes all columns that do not contain any views. | |
| void | spanViewsHorizontal (bool leftToRight) |
| Extends the column span of all views over empty, neighboring columns. | |
| void | spanViewsVertical (bool topToBottom) |
| Extends the row span of all views over empty, neighboring rows. | |
| bool | isValid () const |
| Returns true if the configuration is valid, false otherwise. | |
| int | numColumns () const |
| Returns the number of columns. | |
| int | numRows () const |
| Returns the number of rows. | |
| void | prettyPrint () |
| Prints the layout as ASCII "art" on the console. | |
Protected Member Functions | |
| const LayoutCell * | _cellAt (int x, int y) const |
| LayoutCell * | _cellAt (int x, int y) |
Protected Attributes | |
| int | m_gridSizeX |
| int | m_gridSizeY |
| std::vector< LayoutCell > | m_cells |
| std::vector< float > | m_rowSplit |
| std::vector< float > | m_columnSplit |
| bool addView | ( | const GUI::View * | view, |
| int | x, | ||
| int | y, | ||
| int | spanX = 1, | ||
| int | spanY = 1 ) |
Adds a new view at the given coordinates to the configuration.
| view | The view to add |
| x | column number, must be between 0 and gridX()-1 |
| y | row number, must be between 0 and gridY()-1 |
| spanX | spans the view over spanX columns, default is 1. Must be larger than 0. |
| spanY | spans the view over spanY rows, default is 1. Must be larger than 0. |
| bool addSubLayout | ( | const DisplayLayoutConfig & | sublayout, |
| int | x, | ||
| int | y, | ||
| int | spanX = 1, | ||
| int | spanY = 1 ) |
Adds a new sublayout at the given coordinates to the configuration.
The sublayout must be valid.
| sublayout | The layout to add |
| x | column number, must be between 0 and gridX()-1 |
| y | row number, must be between 0 and gridY()-1 |
| spanX | spans the view over spanX columns, default is 1. Must be larger than 0. |
| spanY | spans the view over spanY rows, default is 1. Must be larger than 0. |
| void resize | ( | int | newX, |
| int | newY, | ||
| int | offsetX = 0, | ||
| int | offsetY = 0 ) |
Resizes the grid of the configuration.
The grid will take size defined by newX and newY. All views are moved by the offset. WARNING: shrinking the view has not been tested yet
| void setRowSpacing | ( | int | row, |
| float | spacing ) |
Set the spacing of a row.
'spacing' is the normalized position of the top border of the row between 0.0 (left border) and 1.0 (right border)
| void setColumnSpacing | ( | int | col, |
| float | spacing ) |
Set the spacing of a column.
'spacing' is the normalized position of the right border of the column between 0.0 (bottom border) and 1.0 (top border)
| void removeColumn | ( | int | col | ) |
Removes a column.
Views that are only in this column will be removed. Views that span over this column will just be reduced in size.
| void removeRow | ( | int | row | ) |
Removes a row.
Views that are only in this row will be removed. Views that span over this row will just be reduced in size.
| void spanViewsHorizontal | ( | bool | leftToRight | ) |
Extends the column span of all views over empty, neighboring columns.
If leftToRight is true, views will only extend to the right. Otherwise, they will extend to the left.
| void spanViewsVertical | ( | bool | topToBottom | ) |
Extends the row span of all views over empty, neighboring rows.
If topToBottom is true, views will only extend to the bottom. Otherwise, they will extend to the top.