Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::view::FlexStyle Struct Reference

#include <geometry.hpp>

Public Types

enum class  AlignContentSpace { none , space_between , space_around , space_evenly }
 True when align_content was set to one of the space-* values (space-between / space-around / space-evenly). More...
enum class  WritingDirection { inherit , ltr , rtl }
 Node writing direction. More...

Public Member Functions

void resolve_dimensions (float parent_w, float parent_h, float viewport_w, float viewport_h, float dpi=1.0f)
 Resolve viewport-relative dimensions and apply to float fields.
float margin_t () const
float margin_r () const
float margin_b () const
float margin_l () const
float effective_gap (FlexDirection dir) const
float basis_or_preferred (bool is_row) const

Public Attributes

FlexDirection direction = FlexDirection::column
FlexAlign align_items = FlexAlign::stretch
FlexAlign align_self = FlexAlign::auto_
 Override parent's align_items for this child.
FlexAlign align_content = FlexAlign::start
 align-content is the CSS / Yoga multi-line flex cross-axis distribution control.
AlignContentSpace align_content_space = AlignContentSpace::none
FlexJustify justify_content = FlexJustify::start
float gap = 0
 Shorthand for both row_gap and column_gap.
float row_gap = -1
 Gap between rows (-1 = use gap).
float column_gap = -1
 Gap between columns (-1 = use gap).
float padding = 0
float padding_top = -1
 Per-side padding (-1 = use uniform padding).
float padding_right = -1
float padding_bottom = -1
float padding_left = -1
float margin = 0
 Uniform margin around this view.
float margin_top = -1
 Per-side margin (-1 = use uniform margin).
float margin_right = -1
float margin_bottom = -1
float margin_left = -1
float flex_grow = 0
 0 = fixed size, >0 = share remaining space
float flex_shrink = 1
 1 = shrink proportionally if overflow
float flex_basis = -1
 Initial main size before grow/shrink (-1 = use preferred).
float min_width = 0
float min_height = 0
float preferred_width = 0
float preferred_height = 0
float max_width = 0
 0 = no maximum
float max_height = 0
 0 = no maximum
Dimension dim_width
 Viewport-relative dimension overrides.
Dimension dim_height
Dimension dim_min_width
Dimension dim_min_height
Dimension dim_max_width
Dimension dim_max_height
Dimension dim_flex_basis
Dimension dim_margin_top
 Per-edge margin / padding accept percent strings (and auto for margin only).
Dimension dim_margin_right
Dimension dim_margin_bottom
Dimension dim_margin_left
Dimension dim_padding_top
Dimension dim_padding_right
Dimension dim_padding_bottom
Dimension dim_padding_left
Dimension dim_margin_start
 Yoga logical-edge fan-out.
Dimension dim_margin_end
Dimension dim_padding_start
Dimension dim_padding_end
Dimension dim_start
Dimension dim_end
WritingDirection writing_direction = WritingDirection::inherit
FlexWrap flex_wrap = FlexWrap::no_wrap
 Tri-state wrap.
BoxSizing box_sizing = BoxSizing::border_box
 CSS box-sizing.
int order = 0
 Layout order (lower values first, default 0).
std::optional< float > aspect_ratio
 Aspect ratio (width / height).

Member Enumeration Documentation

◆ AlignContentSpace

True when align_content was set to one of the space-* values (space-between / space-around / space-evenly).

FlexAlign has no space variants because they are nonsensical for align_items / align_self; we encode them on a sibling enum here so the dispatcher can route to YGAlignSpaceBetween / SpaceAround / SpaceEvenly without overloading FlexAlign across two surfaces.

Enumerator
none 
space_between 
space_around 
space_evenly 

◆ WritingDirection

Node writing direction.

Controls how Yoga resolves YGEdgeStart / YGEdgeEnd (and how it lays out row-axis children when no explicit start/end edge is set). Defaults to inherit so the layout root's direction propagates down. The bridge accepts the direction_writing sub-key on setFlex (avoids collision with the existing direction key for flex-direction) and the canonical CSS / RN values 'ltr' / 'rtl' / 'inherit'.

Enumerator
inherit 
ltr 
rtl 

Member Function Documentation

◆ basis_or_preferred()

float pulp::view::FlexStyle::basis_or_preferred ( bool is_row) const
inline

◆ effective_gap()

float pulp::view::FlexStyle::effective_gap ( FlexDirection dir) const
inline

◆ margin_b()

float pulp::view::FlexStyle::margin_b ( ) const
inline

◆ margin_l()

float pulp::view::FlexStyle::margin_l ( ) const
inline

◆ margin_r()

float pulp::view::FlexStyle::margin_r ( ) const
inline

◆ margin_t()

float pulp::view::FlexStyle::margin_t ( ) const
inline

◆ resolve_dimensions()

void pulp::view::FlexStyle::resolve_dimensions ( float parent_w,
float parent_h,
float viewport_w,
float viewport_h,
float dpi = 1.0f )
inline

Resolve viewport-relative dimensions and apply to float fields.

Call before layout pass with the viewport size.

Member Data Documentation

◆ align_content

FlexAlign pulp::view::FlexStyle::align_content = FlexAlign::start

align-content is the CSS / Yoga multi-line flex cross-axis distribution control.

Yoga supports it natively via YGNodeStyleSetAlignContent. Default matches Yoga's default (FlexStart) — note this differs from CSS's normal/stretch defaults but matches Yoga / RN. The usual space-between/space-around/space-evenly / flex-start/flex-end/center/stretch values all map to the existing FlexAlign enum + the FlexJustify space-* values via to_yg_align_content in yoga_layout.cpp.

◆ align_content_space

AlignContentSpace pulp::view::FlexStyle::align_content_space = AlignContentSpace::none

◆ align_items

FlexAlign pulp::view::FlexStyle::align_items = FlexAlign::stretch

◆ align_self

FlexAlign pulp::view::FlexStyle::align_self = FlexAlign::auto_

Override parent's align_items for this child.

◆ aspect_ratio

std::optional<float> pulp::view::FlexStyle::aspect_ratio

Aspect ratio (width / height).

When set, Yoga sizes the cross axis to match main_axis / aspect_ratio (or the inverse, depending on which dimension is constrained). Imports use aspectRatio for image cards, video tiles, fixed-ratio frames, and hero images. std::optional distinguishes "unset" from a literal 0 value (which would be invalid anyway, but the optional makes the intent explicit at the dispatcher boundary). Accepts plain numbers (1.5), width/height parsed by web-compat-style-decl.js (16/9 -> 1.778), and auto which clears the slot.

◆ box_sizing

BoxSizing pulp::view::FlexStyle::box_sizing = BoxSizing::border_box

CSS box-sizing.

Default is border_box to match Yoga 3.x's own default and the web-import convention that most pasted JSX already assumes via * { box-sizing: border-box }. Setting content-box opts in to CSS-spec behavior: width = 100; padding = 10 → outer width = 120 instead of 100.

◆ column_gap

float pulp::view::FlexStyle::column_gap = -1

Gap between columns (-1 = use gap).

◆ dim_end

Dimension pulp::view::FlexStyle::dim_end

◆ dim_flex_basis

Dimension pulp::view::FlexStyle::dim_flex_basis

◆ dim_height

Dimension pulp::view::FlexStyle::dim_height

◆ dim_margin_bottom

Dimension pulp::view::FlexStyle::dim_margin_bottom

◆ dim_margin_end

Dimension pulp::view::FlexStyle::dim_margin_end

◆ dim_margin_left

Dimension pulp::view::FlexStyle::dim_margin_left

◆ dim_margin_right

Dimension pulp::view::FlexStyle::dim_margin_right

◆ dim_margin_start

Dimension pulp::view::FlexStyle::dim_margin_start

Yoga logical-edge fan-out.

CSS / RN logical edges (marginStart / marginEnd / paddingStart / paddingEnd / start / end) flip with the writing direction: in LTR, start is the left edge; in RTL, start is the right edge. Yoga resolves this natively via YGEdgeStart / YGEdgeEnd once the node's writing direction is set (see writing_direction below). yoga_layout.cpp dispatches on dim_*.unit: • px → YGNodeStyleSetMargin/Padding/Position(YGEdgeStart|End) • percent → YGNodeStyleSetMargin/Padding/PositionPercent(...) • auto_ → YGNodeStyleSetMarginAuto(...) (margin only; Yoga does not support auto on padding or position) These fields supplement, not replace, the per-side dim_margin_left / dim_margin_right etc. — yoga applies both and the *_start/end pair wins for the resolved start/end edge.

◆ dim_margin_top

Dimension pulp::view::FlexStyle::dim_margin_top

Per-edge margin / padding accept percent strings (and auto for margin only).

yoga_layout.cpp dispatches on dim_*.unit to YGNodeStyleSetMargin{Percent,Auto} / YGNodeStyleSetPaddingPercent for the non-px paths. Yoga's padding does not support auto (only margin does — see Yoga docs), so the bridge rejects auto on padding edges.

◆ dim_max_height

Dimension pulp::view::FlexStyle::dim_max_height

◆ dim_max_width

Dimension pulp::view::FlexStyle::dim_max_width

◆ dim_min_height

Dimension pulp::view::FlexStyle::dim_min_height

◆ dim_min_width

Dimension pulp::view::FlexStyle::dim_min_width

◆ dim_padding_bottom

Dimension pulp::view::FlexStyle::dim_padding_bottom

◆ dim_padding_end

Dimension pulp::view::FlexStyle::dim_padding_end

◆ dim_padding_left

Dimension pulp::view::FlexStyle::dim_padding_left

◆ dim_padding_right

Dimension pulp::view::FlexStyle::dim_padding_right

◆ dim_padding_start

Dimension pulp::view::FlexStyle::dim_padding_start

◆ dim_padding_top

Dimension pulp::view::FlexStyle::dim_padding_top

◆ dim_start

Dimension pulp::view::FlexStyle::dim_start

◆ dim_width

Dimension pulp::view::FlexStyle::dim_width

Viewport-relative dimension overrides.

Non-default units or non-zero values are resolved before layout and override the corresponding float fields. Yoga's native percent / auto APIs are dispatched on these in yoga_layout.cpp::apply_flex_style when unit != px. resolve_dimensions() resolves preferred/min dimensions for the local scalar fields; max-* and flex-basis stay as Dimension values so they can reach Yoga's YGNodeStyleSet{MaxWidth,MaxHeight,FlexBasis}Percent and YGNodeStyleSetFlexBasisAuto instead of being truncated to plain floats.

◆ direction

FlexDirection pulp::view::FlexStyle::direction = FlexDirection::column

◆ flex_basis

float pulp::view::FlexStyle::flex_basis = -1

Initial main size before grow/shrink (-1 = use preferred).

◆ flex_grow

float pulp::view::FlexStyle::flex_grow = 0

0 = fixed size, >0 = share remaining space

◆ flex_shrink

float pulp::view::FlexStyle::flex_shrink = 1

1 = shrink proportionally if overflow

◆ flex_wrap

FlexWrap pulp::view::FlexStyle::flex_wrap = FlexWrap::no_wrap

Tri-state wrap.

CSS / RN allow wrap-reverse (overflows wrap UP instead of DOWN, or RIGHT instead of LEFT depending on flex-direction). Yoga has YGWrapWrapReverse for this. Bridge accepts numeric (0/1 for backward compat) and the CSS keyword strings ("wrap" / "wrap-reverse" / "nowrap" / "no-wrap").

◆ gap

float pulp::view::FlexStyle::gap = 0

Shorthand for both row_gap and column_gap.

◆ justify_content

FlexJustify pulp::view::FlexStyle::justify_content = FlexJustify::start

◆ margin

float pulp::view::FlexStyle::margin = 0

Uniform margin around this view.

◆ margin_bottom

float pulp::view::FlexStyle::margin_bottom = -1

◆ margin_left

float pulp::view::FlexStyle::margin_left = -1

◆ margin_right

float pulp::view::FlexStyle::margin_right = -1

◆ margin_top

float pulp::view::FlexStyle::margin_top = -1

Per-side margin (-1 = use uniform margin).

◆ max_height

float pulp::view::FlexStyle::max_height = 0

0 = no maximum

◆ max_width

float pulp::view::FlexStyle::max_width = 0

0 = no maximum

◆ min_height

float pulp::view::FlexStyle::min_height = 0

◆ min_width

float pulp::view::FlexStyle::min_width = 0

◆ order

int pulp::view::FlexStyle::order = 0

Layout order (lower values first, default 0).

◆ padding

float pulp::view::FlexStyle::padding = 0

◆ padding_bottom

float pulp::view::FlexStyle::padding_bottom = -1

◆ padding_left

float pulp::view::FlexStyle::padding_left = -1

◆ padding_right

float pulp::view::FlexStyle::padding_right = -1

◆ padding_top

float pulp::view::FlexStyle::padding_top = -1

Per-side padding (-1 = use uniform padding).

◆ preferred_height

float pulp::view::FlexStyle::preferred_height = 0

◆ preferred_width

float pulp::view::FlexStyle::preferred_width = 0

◆ row_gap

float pulp::view::FlexStyle::row_gap = -1

Gap between rows (-1 = use gap).

◆ writing_direction

WritingDirection pulp::view::FlexStyle::writing_direction = WritingDirection::inherit

The documentation for this struct was generated from the following file:
  • /home/runner/work/pulp/pulp/core/view/include/pulp/view/geometry.hpp