HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
hi::v1::detail::grid_layout_axis_constraints< Axis, T > Class Template Reference

Data Structures

struct  constraint_type

Public Types

using value_type = T
using alignment_type = std::conditional_t<axis == axis::y, vertical_alignment, horizontal_alignment>
using cell_type = grid_layout_cell<value_type>
using cell_vector = std::vector<cell_type>
using constraint_vector = std::vector<constraint_type>
using iterator = constraint_vector::iterator
using const_iterator = constraint_vector::const_iterator
using reverse_iterator = constraint_vector::reverse_iterator
using reference = constraint_vector::reference
using const_reference = constraint_vector::const_reference

Public Member Functions

constexpr grid_layout_axis_constraints (grid_layout_axis_constraints const &) noexcept=default
constexpr grid_layout_axis_constraints (grid_layout_axis_constraints &&) noexcept=default
constexpr grid_layout_axis_constraints & operator= (grid_layout_axis_constraints const &) noexcept=default
constexpr grid_layout_axis_constraints & operator= (grid_layout_axis_constraints &&) noexcept=default
constexpr grid_layout_axis_constraints (cell_vector const &cells, size_t num, bool forward) noexcept
 Construct constraints for this axis.
constexpr float margin_before () const noexcept
constexpr float margin_after () const noexcept
constexpr float padding_before () const noexcept
constexpr float padding_after () const noexcept
constexpr std::tuple< float, float, float > update_constraints () const noexcept
constexpr std::tuple< float, float, float > constraints (cell_type const &cell) const noexcept
 Get the minimum, preferred, maximum size of the span.
constexpr float position (cell_type const &cell) const noexcept
constexpr float extent (cell_type const &cell) const noexcept
constexpr std::optional< float > guideline (cell_type const &cell) const noexcept
constexpr void layout (float new_position, float new_extent, std::optional< float > external_guideline, float guideline_width) noexcept
 Layout each cell along an axis.
constexpr size_t size () const noexcept
 Number of cell on this axis.
constexpr bool empty () const noexcept
 Check if this axis is empty.
constexpr iterator begin () noexcept
 Iterator to the first cell on this axis.
constexpr const_iterator begin () const noexcept
 Iterator to the first cell on this axis.
constexpr const_iterator cbegin () const noexcept
 Iterator to the first cell on this axis.
constexpr iterator end () noexcept
 Iterator to beyond the last cell on this axis.
constexpr const_iterator end () const noexcept
 Iterator to beyond the last cell on this axis.
constexpr const_iterator cend () const noexcept
 Iterator to beyond the last cell on this axis.
constexpr reverse_iterator rbegin () noexcept
 Iterator to the first cell on this axis.
constexpr reverse_iterator rend () noexcept
 Iterator to the first cell on this axis.
constexpr reference operator[] (size_t index) noexcept
 Get element.
constexpr const_reference operator[] (size_t index) const noexcept
 Get element.
constexpr reference front () noexcept
 Get the first element.
constexpr const_reference front () const noexcept
 Get the first element.
constexpr reference back () noexcept
 Get the last element.
constexpr const_reference back () const noexcept
 Get the last element.

Static Public Attributes

static constexpr hi::axis axis = Axis

Friends

constexpr friend bool operator== (grid_layout_axis_constraints const &, grid_layout_axis_constraints const &) noexcept=default

Constructor & Destructor Documentation

◆ grid_layout_axis_constraints()

template<hi::axis Axis, typename T>
hi::v1::detail::grid_layout_axis_constraints< Axis, T >::grid_layout_axis_constraints ( cell_vector const & cells,
size_t num,
bool forward )
inlineconstexprnoexcept

Construct constraints for this axis.

Parameters
cellsThe cells
numThe number of cells in the direction of the current axis
forwardTrue if the axis is used from left-to-right or bottom-to-top, False if the axis is used from right-to-left or top-to-bottom.

Member Function Documentation

◆ back() [1/2]

template<hi::axis Axis, typename T>
const_reference hi::v1::detail::grid_layout_axis_constraints< Axis, T >::back ( ) const
inlinenodiscardconstexprnoexcept

Get the last element.

Note
It is undefined behavior to call this function on an empty axis.
Returns
A reference to the last cell.

◆ back() [2/2]

template<hi::axis Axis, typename T>
reference hi::v1::detail::grid_layout_axis_constraints< Axis, T >::back ( )
inlinenodiscardconstexprnoexcept

Get the last element.

Note
It is undefined behavior to call this function on an empty axis.
Returns
A reference to the last cell.

◆ begin() [1/2]

template<hi::axis Axis, typename T>
const_iterator hi::v1::detail::grid_layout_axis_constraints< Axis, T >::begin ( ) const
inlinenodiscardconstexprnoexcept

Iterator to the first cell on this axis.

◆ begin() [2/2]

template<hi::axis Axis, typename T>
iterator hi::v1::detail::grid_layout_axis_constraints< Axis, T >::begin ( )
inlinenodiscardconstexprnoexcept

Iterator to the first cell on this axis.

◆ cbegin()

template<hi::axis Axis, typename T>
const_iterator hi::v1::detail::grid_layout_axis_constraints< Axis, T >::cbegin ( ) const
inlinenodiscardconstexprnoexcept

Iterator to the first cell on this axis.

◆ cend()

template<hi::axis Axis, typename T>
const_iterator hi::v1::detail::grid_layout_axis_constraints< Axis, T >::cend ( ) const
inlinenodiscardconstexprnoexcept

Iterator to beyond the last cell on this axis.

◆ constraints()

template<hi::axis Axis, typename T>
std::tuple< float, float, float > hi::v1::detail::grid_layout_axis_constraints< Axis, T >::constraints ( cell_type const & cell) const
inlinenodiscardconstexprnoexcept

Get the minimum, preferred, maximum size of the span.

The returned minimum, preferred and maximum include the internal margin within the span.

Parameters
cellThe reference to the cell in the grid.
Returns
The minimum, preferred and maximum size.

◆ empty()

template<hi::axis Axis, typename T>
bool hi::v1::detail::grid_layout_axis_constraints< Axis, T >::empty ( ) const
inlinenodiscardconstexprnoexcept

Check if this axis is empty.

◆ end() [1/2]

template<hi::axis Axis, typename T>
const_iterator hi::v1::detail::grid_layout_axis_constraints< Axis, T >::end ( ) const
inlinenodiscardconstexprnoexcept

Iterator to beyond the last cell on this axis.

◆ end() [2/2]

template<hi::axis Axis, typename T>
iterator hi::v1::detail::grid_layout_axis_constraints< Axis, T >::end ( )
inlinenodiscardconstexprnoexcept

Iterator to beyond the last cell on this axis.

◆ front() [1/2]

template<hi::axis Axis, typename T>
const_reference hi::v1::detail::grid_layout_axis_constraints< Axis, T >::front ( ) const
inlinenodiscardconstexprnoexcept

Get the first element.

Note
It is undefined behavior to call this function on an empty axis.
Returns
A reference to the first cell.

◆ front() [2/2]

template<hi::axis Axis, typename T>
reference hi::v1::detail::grid_layout_axis_constraints< Axis, T >::front ( )
inlinenodiscardconstexprnoexcept

Get the first element.

Note
It is undefined behavior to call this function on an empty axis.
Returns
A reference to the first cell.

◆ layout()

template<hi::axis Axis, typename T>
void hi::v1::detail::grid_layout_axis_constraints< Axis, T >::layout ( float new_position,
float new_extent,
std::optional< float > external_guideline,
float guideline_width )
inlineconstexprnoexcept

Layout each cell along an axis.

The algorithm works as follows:

  1. Initialize each cell based on its preferred size.
  2. While the grid needs to be shrunk: a. Calculate the amount of cells that are allowed to shrink. b. Apply shrinkage to the cells that are allowed to, up to the minimum. c. If all the cells are maximum shrunk, stop.
  3. While the grid needs to be expanded: a. Calculate the amount of cells that are allowed to expand. b. Apply expansion to the cells that are allowed to, up to the maximum. c. If all the cells are maximum expanded, goto 4.
  4. Expand the largest cell to make it fit.

In an emergency widgets will get a size larger than its maximum. However widgets will never get a smaller size than its minimum.

Parameters
new_positionThe start of the grid along its axis.
new_extentThe size of the grid along its axis.
external_guidelineThe position of the guideline external from the grid.
guideline_widthThe width of the guideline.

◆ operator[]() [1/2]

template<hi::axis Axis, typename T>
const_reference hi::v1::detail::grid_layout_axis_constraints< Axis, T >::operator[] ( size_t index) const
inlinenodiscardconstexprnoexcept

Get element.

Note
It is undefined behavior to index beyond the number of cell on this axis.
Parameters
indexThe index of the cell.
Returns
A reference to the cell.

◆ operator[]() [2/2]

template<hi::axis Axis, typename T>
reference hi::v1::detail::grid_layout_axis_constraints< Axis, T >::operator[] ( size_t index)
inlinenodiscardconstexprnoexcept

Get element.

Note
It is undefined behavior to index beyond the number of cell on this axis.
Parameters
indexThe index of the cell.
Returns
A reference to the cell.

◆ rbegin()

template<hi::axis Axis, typename T>
reverse_iterator hi::v1::detail::grid_layout_axis_constraints< Axis, T >::rbegin ( )
inlinenodiscardconstexprnoexcept

Iterator to the first cell on this axis.

◆ rend()

template<hi::axis Axis, typename T>
reverse_iterator hi::v1::detail::grid_layout_axis_constraints< Axis, T >::rend ( )
inlinenodiscardconstexprnoexcept

Iterator to the first cell on this axis.

◆ size()

template<hi::axis Axis, typename T>
size_t hi::v1::detail::grid_layout_axis_constraints< Axis, T >::size ( ) const
inlinenodiscardconstexprnoexcept

Number of cell on this axis.


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