TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
tachyon::LayoutHelpers Struct Reference

#include <gui_core/layout/gui_layout_helpers.h>

Classes

struct  JustifySpacing
 Where justify-content puts the first of count items, measured from the main start, and the space between items, with freeSpace left over on the main axis. More...

Static Public Member Functions

static int2 ClampScrollOffsetToContent (int2 childOffset, const ElementRect &parent)
static int2 CalculateLeafSize (ITextSystem &textSystem, const Element &element, const ElementRect &elementRect, int32_t &minContentWidth)
 A leaf's MARGIN BOX at its natural (max-content) size.
static int32_t RecalculateContentHeight (ITextSystem &textSystem, const Element &element, const ElementRect &elementRect)
static void ApplyHorizontalStyleSize (ElementRect &elementRect, const int32_t contentWidth)
static void ApplyVerticalStyleSize (ElementRect &elementRect, const int32_t contentHeight)
static void ApplyHorizontalStyleOffset (ElementRect &elementRect)
static void ApplyVerticalStyleOffset (ElementRect &elementRect)
static void ApplyHorizontalPositionConstraints (OSWindowManager &osWindowManager, ElementStorage &storage, ElementRect &elementRect, const ElementRef &elementRef)
static void ApplyVerticalPositionConstraints (OSWindowManager &osWindowManager, ElementStorage &storage, ElementRect &elementRect, const ElementRef &elementRef)
template<int axis>
requires (axis == 0 || axis == 1)
static int32_t CalcLayoutAdd (std::span< const ElementRect > childRects, int32_t &count)
template<int axis>
requires (axis == 0 || axis == 1)
static int32_t FlexMinSize (const ElementRect &c)
 The smallest margin-box size an item may be flexed to on axis: its CSS min (border box) plus its margin, and never below its own chrome (margin + border + padding, which would give a negative border box) or, horizontally, its minContentWidth.
template<int axis>
requires (axis == 0 || axis == 1)
static int32_t FlexMaxSize (const ElementRect &c)
 The largest margin-box size an item may be flexed to on axis: its CSS max plus its margin (kUnbounded when unset), never below FlexMinSize.
template<int axis>
requires (axis == 0 || axis == 1)
static void ApplyFlexBasis (std::span< ElementRect > items)
 Sets each in-flow item's size on axis to its flex-basis, the starting main size before free space is shared out.
template<int axis>
requires (axis == 0 || axis == 1)
static int32_t ResolveFlexibleLengths (std::span< ElementRect > items, int32_t freeSpace)
 Resolves flexible lengths on axis (CSS "resolve flexible lengths"): positive freeSpace grows the in-flow items by flex-grow, negative shrinks them by flex-shrink x size.
template<int axis>
requires (axis == 0 || axis == 1)
static int32_t CalcLayoutMax (std::span< const ElementRect > childRects)
template<int axis>
requires (axis == 0 || axis == 1)
static void Place (std::span< ElementRect > childRects, int32_t start, int32_t spacing)
template<int axis>
requires (axis == 0 || axis == 1)
static int32_t FixedContentSize (const ElementRect &rect)
 Content size along axis of an element with a fixed size on that axis.
template<int axis>
requires (axis == 0 || axis == 1)
static void ReversePlace (std::span< ElementRect > childRects, int32_t start, int32_t spacing)
template<int axis, bool reverse>
requires (axis == 0 || axis == 1)
static void JustifyChildren (std::span< ElementRect > childRects, JustifyContent justify, int16_t gap, const IntRect &parentContentRect, int totalContentSize, int totalChildrenInFlow)
 Positions the children on the main axis per justify.
static JustifySpacing Justify (JustifyContent justify, int32_t freeSpace, int16_t gap, int count)
template<int axis>
requires (axis == 0 || axis == 1)
static void Align (AlignItems align, const IntRect &parentContentRect, ElementRect &childRect)

Member Function Documentation

◆ ClampScrollOffsetToContent()

int2 tachyon::LayoutHelpers::ClampScrollOffsetToContent ( int2 childOffset,
const ElementRect & parent )
static

◆ CalculateLeafSize()

int2 tachyon::LayoutHelpers::CalculateLeafSize ( ITextSystem & textSystem,
const Element & element,
const ElementRect & elementRect,
int32_t & minContentWidth )
static

A leaf's MARGIN BOX at its natural (max-content) size.

minContentWidth gets the margin box width flex shrink stops at: its text's min-content when the text overflows visibly, else 0.

◆ RecalculateContentHeight()

int32_t tachyon::LayoutHelpers::RecalculateContentHeight ( ITextSystem & textSystem,
const Element & element,
const ElementRect & elementRect )
static

◆ ApplyHorizontalStyleSize()

void tachyon::LayoutHelpers::ApplyHorizontalStyleSize ( ElementRect & elementRect,
const int32_t contentWidth )
static

◆ ApplyVerticalStyleSize()

void tachyon::LayoutHelpers::ApplyVerticalStyleSize ( ElementRect & elementRect,
const int32_t contentHeight )
static

◆ ApplyHorizontalStyleOffset()

void tachyon::LayoutHelpers::ApplyHorizontalStyleOffset ( ElementRect & elementRect)
static

◆ ApplyVerticalStyleOffset()

void tachyon::LayoutHelpers::ApplyVerticalStyleOffset ( ElementRect & elementRect)
static

◆ ApplyHorizontalPositionConstraints()

void tachyon::LayoutHelpers::ApplyHorizontalPositionConstraints ( OSWindowManager & osWindowManager,
ElementStorage & storage,
ElementRect & elementRect,
const ElementRef & elementRef )
static

◆ ApplyVerticalPositionConstraints()

void tachyon::LayoutHelpers::ApplyVerticalPositionConstraints ( OSWindowManager & osWindowManager,
ElementStorage & storage,
ElementRect & elementRect,
const ElementRef & elementRef )
static

◆ CalcLayoutAdd()

template<int axis>
requires (axis == 0 || axis == 1)
int32_t tachyon::LayoutHelpers::CalcLayoutAdd ( std::span< const ElementRect > childRects,
int32_t & count )
inlinestatic

◆ FlexMinSize()

template<int axis>
requires (axis == 0 || axis == 1)
int32_t tachyon::LayoutHelpers::FlexMinSize ( const ElementRect & c)
inlinestatic

The smallest margin-box size an item may be flexed to on axis: its CSS min (border box) plus its margin, and never below its own chrome (margin + border + padding, which would give a negative border box) or, horizontally, its minContentWidth.

◆ FlexMaxSize()

template<int axis>
requires (axis == 0 || axis == 1)
int32_t tachyon::LayoutHelpers::FlexMaxSize ( const ElementRect & c)
inlinestatic

The largest margin-box size an item may be flexed to on axis: its CSS max plus its margin (kUnbounded when unset), never below FlexMinSize.

◆ ApplyFlexBasis()

template<int axis>
requires (axis == 0 || axis == 1)
void tachyon::LayoutHelpers::ApplyFlexBasis ( std::span< ElementRect > items)
inlinestatic

Sets each in-flow item's size on axis to its flex-basis, the starting main size before free space is shared out.

An explicit size on the axis wins over the basis.

◆ ResolveFlexibleLengths()

template<int axis>
requires (axis == 0 || axis == 1)
int32_t tachyon::LayoutHelpers::ResolveFlexibleLengths ( std::span< ElementRect > items,
int32_t freeSpace )
inlinestatic

Resolves flexible lengths on axis (CSS "resolve flexible lengths"): positive freeSpace grows the in-flow items by flex-grow, negative shrinks them by flex-shrink x size.

Each item stays within [FlexMinSize, FlexMaxSize]; an item that hits a limit is frozen there and what it couldn't take is shared among the rest. Items with an explicit size on axis don't shrink. Shares use floor-boundary rounding so they sum exactly. Returns the total size change applied.

◆ CalcLayoutMax()

template<int axis>
requires (axis == 0 || axis == 1)
int32_t tachyon::LayoutHelpers::CalcLayoutMax ( std::span< const ElementRect > childRects)
inlinestatic

◆ Place()

template<int axis>
requires (axis == 0 || axis == 1)
void tachyon::LayoutHelpers::Place ( std::span< ElementRect > childRects,
int32_t start,
int32_t spacing )
inlinestatic

◆ FixedContentSize()

template<int axis>
requires (axis == 0 || axis == 1)
int32_t tachyon::LayoutHelpers::FixedContentSize ( const ElementRect & rect)
inlinestatic

Content size along axis of an element with a fixed size on that axis.

The fixed size is the border box, so only padding and border come off (the margin lies outside it).

◆ ReversePlace()

template<int axis>
requires (axis == 0 || axis == 1)
void tachyon::LayoutHelpers::ReversePlace ( std::span< ElementRect > childRects,
int32_t start,
int32_t spacing )
inlinestatic

◆ JustifyChildren()

template<int axis, bool reverse>
requires (axis == 0 || axis == 1)
void tachyon::LayoutHelpers::JustifyChildren ( std::span< ElementRect > childRects,
JustifyContent justify,
int16_t gap,
const IntRect & parentContentRect,
int totalContentSize,
int totalChildrenInFlow )
inlinestatic

Positions the children on the main axis per justify.

totalContentSize includes the gaps between in-flow children. reverse places children from the far edge (row-/column-reverse), whose main start is that edge - so flex-end packs toward the near one.

◆ Justify()

JustifySpacing tachyon::LayoutHelpers::Justify ( JustifyContent justify,
int32_t freeSpace,
int16_t gap,
int count )
inlinestatic

◆ Align()

template<int axis>
requires (axis == 0 || axis == 1)
void tachyon::LayoutHelpers::Align ( AlignItems align,
const IntRect & parentContentRect,
ElementRect & childRect )
inlinestatic

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