HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions
v1::grid_layout Class Reference

#include <hikogui/widgets/grid_layout.hpp>

Public Member Functions

 grid_layout (grid_layout const &)=delete
 
 grid_layout (grid_layout &&)=delete
 
grid_layoutoperator= (grid_layout const &)=delete
 
grid_layoutoperator= (grid_layout &&)=delete
 
void clear () noexcept
 Clear the list of widgets in the layout.
 
void add_constraint (std::size_t first, std::size_t last, float minimum, float preferred, float maximum, float margin_before, float margin_after, widget_baseline baseline=widget_baseline{}) noexcept
 Add a constraint for a widget.
 
void add_constraint (std::size_t index, float minimum, float preferred, float maximum, float margin_before, float margin_after, widget_baseline baseline=widget_baseline{}) noexcept
 Add a constraint for a widget.
 
void commit_constraints () noexcept
 Commit all the constraints.
 
std::size_t num_cells () const noexcept
 The number of cells of the grid_layout.
 
float minimum () const noexcept
 The minimum size of the total grid_layout.
 
float preferred () const noexcept
 The minimum size of the total grid_layout.
 
float maximum () const noexcept
 The minimum size of the total grid_layout.
 
float margin_before () const noexcept
 
float margin_after () const noexcept
 
void layout (float size) noexcept
 Layout the cells based on the total size.
 
float get_position (std::size_t index) const noexcept
 Get position of cell.
 
float get_size (std::size_t first, std::size_t last) const noexcept
 Get size of the cells.
 
float get_size (std::size_t index) const noexcept
 Get size of the cell.
 
std::pair< float, float > get_position_and_size (std::size_t first, std::size_t last) const noexcept
 Get the position and size of a cell-span.
 
std::pair< float, float > get_position_and_size (std::size_t index) const noexcept
 Get the position and size of cell.
 
std::pair< float, float > get_positions (std::size_t first, std::size_t last) const noexcept
 Get the start and end position of the cells.
 
std::pair< float, float > get_positions (std::size_t index) const noexcept
 Get the start and end position of a cell.
 
widget_baseline get_baseline (std::size_t first, std::size_t last) const noexcept
 
widget_baseline get_baseline (std::size_t index) const noexcept
 

Detailed Description

Grid layout is used to layout widgets along an axis.

A grid_widget will use two grid_layout, one for column and one for row layout. The row_widget and column_widget only need a single grid_layout.

Member Function Documentation

◆ add_constraint() [1/2]

void v1::grid_layout::add_constraint ( std::size_t first,
std::size_t last,
float minimum,
float preferred,
float maximum,
float margin_before,
float margin_after,
widget_baseline baseline = widget_baseline{} )
inlinenoexcept

Add a constraint for a widget.

Parameters
firstThe index of the first cell that the widget occupies.
lastThe index one past the last cell that the widget occupies.
minimumThe absolute minimum size that a widget must be laid out as.
preferredThe preferred size a widgets wants to be laid out as.
maximumThe maximum size that a widget should be laid out as.
margin_beforeThe space between this widget and other widgets.
margin_afterThe space between this widget and other widgets.

◆ add_constraint() [2/2]

void v1::grid_layout::add_constraint ( std::size_t index,
float minimum,
float preferred,
float maximum,
float margin_before,
float margin_after,
widget_baseline baseline = widget_baseline{} )
inlinenoexcept

Add a constraint for a widget.

Parameters
indexThe index of the cell that the widget occupies.
minimumThe absolute minimum size that a widget must be laid out as.
preferredThe preferred size a widgets wants to be laid out as.
maximumThe maximum size that a widget should be laid out as.
margin_beforeThe space between this widget and other widgets.
margin_afterThe space between this widget and other widgets.

◆ clear()

void v1::grid_layout::clear ( )
inlinenoexcept

Clear the list of widgets in the layout.

◆ commit_constraints()

void v1::grid_layout::commit_constraints ( )
noexcept

Commit all the constraints.

This function will start calculating the constraints of the grid_layout.

Precondition
All constraints have been set using add_constraints().
Note
It is undefined behavior when a widget is added more than once.
It is undefined behavior when a cell in a sequence is unused.

◆ get_position()

float v1::grid_layout::get_position ( std::size_t index) const
inlinenoexcept

Get position of cell.

Parameters
indexThe index of the cell.
Returns
The lower position of the cell, excluding the cell's margin.

◆ get_position_and_size() [1/2]

std::pair< float, float > v1::grid_layout::get_position_and_size ( std::size_t first,
std::size_t last ) const
inlinenoexcept

Get the position and size of a cell-span.

Parameters
firstThe index of the first cell.
lastThe index one past the last cell.
Returns
The position and size of the cell-span excluding external margins.

◆ get_position_and_size() [2/2]

std::pair< float, float > v1::grid_layout::get_position_and_size ( std::size_t index) const
inlinenoexcept

Get the position and size of cell.

Parameters
indexThe index of the cell.
Returns
The position and size of the cell-span excluding external margins.

◆ get_positions() [1/2]

std::pair< float, float > v1::grid_layout::get_positions ( std::size_t first,
std::size_t last ) const
inlinenoexcept

Get the start and end position of the cells.

Parameters
firstThe index of the first cell.
lastThe index one past the last cell.
Returns
The first and last position of the cell-span excluding external margins.

◆ get_positions() [2/2]

std::pair< float, float > v1::grid_layout::get_positions ( std::size_t index) const
inlinenoexcept

Get the start and end position of a cell.

Precondition
layout() must be called.
Parameters
indexThe index of the cell.
Returns
The first and last position of the cell excluding external margins.

◆ get_size() [1/2]

float v1::grid_layout::get_size ( std::size_t first,
std::size_t last ) const
inlinenoexcept

Get size of the cells.

Parameters
firstThe index of the first cell.
lastThe index one past the last cell.
Returns
The size of the cell-span excluding external margins.

◆ get_size() [2/2]

float v1::grid_layout::get_size ( std::size_t index) const
inlinenoexcept

Get size of the cell.

Parameters
indexThe index of the cell.
Returns
The size of the cell-span excluding external margins.

◆ layout()

void v1::grid_layout::layout ( float size)
noexcept

Layout the cells based on the total size.

Precondition
commit_constraints() must be called.

◆ maximum()

float v1::grid_layout::maximum ( ) const
inlinenoexcept

The minimum size of the total grid_layout.

Precondition
commit_constraints() must be called.

◆ minimum()

float v1::grid_layout::minimum ( ) const
inlinenoexcept

The minimum size of the total grid_layout.

Precondition
commit_constraints() must be called.

◆ num_cells()

std::size_t v1::grid_layout::num_cells ( ) const
inlinenoexcept

The number of cells of the grid_layout.

Precondition
commit_constraints() must be called.

◆ preferred()

float v1::grid_layout::preferred ( ) const
inlinenoexcept

The minimum size of the total grid_layout.

Precondition
commit_constraints() must be called.

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