Documentation
¶
Overview ¶
Package goda is a CSS Flexbox layout engine written in pure Go. It calculates positions and dimensions for UI elements based on CSS Flexbox properties such as flex-direction, justify-content, align-items, and more.
Node Identity ¶
Nodes carry an optional id string and a list of class names:
node := goda.New("my_id")
node.AddClass("highlight")
node.AddClass("card")
fmt.Println(node.GetID()) // "my_id"
fmt.Println(node.HasClass("card")) // true
QML-like Extended CSS Syntax ¶
Use RenderFrom to build an entire node tree from a string:
source := `
.card {
display: flex;
flex-direction: column;
padding: 12;
}
#root[card] {
width: 800;
height: 600;
gap: 8;
#header {
height: 64;
flex-shrink: 0;
}
#body {
flex: 1;
}
}
`
roots, err := goda.RenderFrom(source)
root := roots[0]
goda.CalculateNodeLayout(root, 800, 600, goda.DirectionLTR)
Use ExportAs to serialize back to a string:
out := root.ExportAs() roots2, _ := goda.RenderFrom(out) // round-trips
Builder Pattern ¶
All property setters return the receiver (*Node), enabling a fluent builder pattern for constructing layout trees:
root := goda.New().
SetWidth(800).
SetHeight(600).
SetFlexDirection(goda.FlexDirectionRow).
SetJustifyContent(goda.JustifySpaceBetween).
SetAlignItems(goda.AlignCenter).
SetPadding(goda.EdgeAll, 16).
SetGap(goda.GutterAll, 8)
child := goda.New().
SetWidth(100).
SetHeight(50).
SetFlexGrow(1).
SetMargin(goda.EdgeAll, 8).
SetAlignSelf(goda.AlignCenter)
root.InsertChildNode(child, 0)
goda.CalculateNodeLayout(root, 800, 600, goda.DirectionLTR)
fmt.Println(child.GetLeft(), child.GetTop())
fmt.Println(child.GetWidth(), child.GetHeight())
Consuming Layout Results ¶
After CalculateNodeLayout, use LayoutOut() to get all computed layout values in a single struct designed for GUI library consumption:
goda.CalculateNodeLayout(root, 800, 600, goda.DirectionLTR)
lo := root.LayoutOut()
// All at once:
renderer.DrawBox(lo.Left, lo.Top, lo.Width, lo.Height)
renderer.SetMargins(lo.Margin.Top, lo.Margin.Right, lo.Margin.Bottom, lo.Margin.Left)
// Individual accessors still work:
fmt.Printf("Pos:(%f,%f) Size:%fx%f Overflow:%v Dir:%v\n",
lo.Left, lo.Top, lo.Width, lo.Height, lo.HadOverflow, lo.Direction)
// Child layout:
childLo := child.LayoutOut()
renderer.DrawBox(childLo.Left, childLo.Top, childLo.Width, childLo.Height)
CSS String Properties ¶
Use ParseStyle to convert a CSS-like string into a map, or ApplyStyleString to parse and apply in one call:
css := `
display: flex;
flex-direction: row;
width: 800;
height: 600;
padding: 16;
gap: 8;
`
root := goda.New().ApplyStyleString(css)
// Or parse first, inspect, then apply:
props := goda.ParseStyle(css) root.ApplyStyle(props)
Declarations use "key: value" syntax separated by ";" or newlines. Lines starting with "//" or "/*" are treated as comments and ignored. Unknown CSS properties (e.g. "color", "font-size") are silently skipped.
Length values support px, rem, and em units. rem resolves against the root node's font size estimate; em resolves against the node's own estimate (default 16 for both). Use SetFontSizeEstimate to customize:
root := goda.New().SetFontSizeEstimate(14)
child := goda.New().
ApplyStyleString("width: 10rem; padding: 2em;").
SetFontSizeEstimate(12) // em=12px here, rem=14px from root
CSS Map Properties ¶
Use ApplyStyle with a map[string]string to set multiple properties at once:
root := goda.New().ApplyStyle(map[string]string{
"display": "flex",
"flex-direction": "row",
"justify-content": "space-between",
"align-items": "center",
"width": "800",
"height": "600",
"padding": "16",
"gap": "8",
})
All three APIs chain seamlessly with the builder pattern:
child := goda.New().
ApplyStyleString("width: 100; height: 50;").
SetFlexGrow(1).
ApplyStyle(map[string]string{"align-self": "center"})
Supported CSS Properties ¶
Layout:
display "flex" | "none" | "contents" | "grid" direction "ltr" | "rtl" | "inherit" position "static" | "relative" | "absolute" overflow "visible" | "hidden" | "scroll" box-sizing "border-box" | "content-box"
Flex:
flex-direction "row" | "row-reverse" | "column" | "column-reverse"
flex-wrap "nowrap" | "wrap" | "wrap-reverse"
justify alias for justify-content
justify-content "flex-start" | "center" | "flex-end" | "space-between" |
"space-around" | "space-evenly" | "start" | "end"
justify-items same as justify-content + "stretch" | "auto"
justify-self same as justify-content + "stretch" | "auto"
align-content same as align-items
align-items "flex-start" | "center" | "flex-end" | "stretch" |
"baseline" | "start" | "end" | "auto"
align-self same as align-items + "auto"
Flex factors:
flex number flex-grow number flex-shrink number flex-basis number | "auto" | number% | "max-content" | "fit-content" | "stretch"
Dimensions:
width number | "auto" | number% | numberpx | "max-content" | "fit-content" | "stretch" height same as width min-width same as width max-width same as width min-height same as height max-height same as height
Spacing:
margin number margin-top number margin-right number margin-bottom number margin-left number margin-horizontal number margin-vertical number padding number padding-top number padding-right number padding-bottom number padding-left number padding-horizontal number padding-vertical number
Border & Gap:
border number border-top number border-right number border-bottom number border-left number gap number column-gap number row-gap number
Other:
aspect-ratio number
Complete Example ¶
config := goda.ConfigNewDefault()
config.SetPointScaleFactor(2.0)
root := goda.NewWithConfig(config).ApplyStyleString(`
width: 800;
height: 600;
flex-direction: column;
justify-content: center;
align-items: stretch;
padding: 20;
gap: 12;
`)
header := goda.New().ApplyStyleString("height: 60;")
body := goda.New().
SetFlexGrow(1).
SetFlexDirection(goda.FlexDirectionRow).
SetGap(goda.GutterAll, 16)
sidebar := goda.New().
ApplyStyle(map[string]string{"width": "200"}).
SetFlexShrink(0)
content := goda.New().
SetFlexGrow(1).
SetMinWidth(300)
root.InsertChildNode(header, 0)
root.InsertChildNode(body, 1)
body.InsertChildNode(sidebar, 0)
body.InsertChildNode(content, 1)
goda.CalculateNodeLayout(root, 800, 600, goda.DirectionLTR)
Index ¶
- Constants
- Variables
- func CalculateLayout(node *Node, ownerWidth, ownerHeight float32, ownerDirection Direction)
- func CalculateLayoutInternal(node *Node, availableWidth, availableHeight float32, ownerDirection Direction, ...) bool
- func CalculateNodeLayout(node *Node, availableWidth, availableHeight float32, ownerDirection Direction)
- func IsUndefinedFloat(v float32) bool
- func ParseStyle(css string) map[string]string
- func RoundValueToPixelGrid(value float64, pointScaleFactor float64, forceCeil, forceFloor bool) float32
- type Align
- type BaselineFunc
- type BoxSizing
- type CloneNodeFunc
- type Config
- func (c *Config) AddErrata(errata Errata)
- func (c *Config) CloneNode(node *Node, owner *Node, childIndex int) *Node
- func (c *Config) GetContext() interface{}
- func (c *Config) GetEnabledExperiments() uint64
- func (c *Config) GetErrata() Errata
- func (c *Config) GetPointScaleFactor() float32
- func (c *Config) GetVersion() uint32
- func (c *Config) HasErrata(errata Errata) bool
- func (c *Config) IsExperimentalFeatureEnabled(feature ExperimentalFeature) bool
- func (c *Config) Log(node *Node, level LogLevel, format string, args ...interface{})
- func (c *Config) RemoveErrata(errata Errata)
- func (c *Config) SetCloneNodeCallback(callback CloneNodeFunc)
- func (c *Config) SetContext(ctx interface{})
- func (c *Config) SetErrata(errata Errata)
- func (c *Config) SetExperimentalFeatureEnabled(feature ExperimentalFeature, enabled bool)
- func (c *Config) SetLogger(logger LoggerFunc)
- func (c *Config) SetPointScaleFactor(factor float32)
- func (c *Config) SetUseWebDefaults(use bool)
- func (c *Config) SetUseWebDefaultsBool(b bool)
- func (c *Config) UseWebDefaults() bool
- type Dimension
- type Direction
- type DirtiedFunc
- type Display
- type Edge
- type Edges
- type Errata
- type ExperimentalFeature
- type FlexDirection
- type FlexLine
- type FlexLineRunningLayout
- type FloatOptional
- type GridLine
- type GridLineType
- type GridTrackList
- type GridTrackSize
- type GridTrackType
- type Gutter
- type Justify
- type LayoutData
- type LayoutOut
- type LayoutResults
- func (l *LayoutResults) Border(edge PhysicalEdge) float32
- func (l *LayoutResults) Dimension(axis Dimension) float32
- func (l *LayoutResults) Direction() Direction
- func (l *LayoutResults) HadOverflow() bool
- func (l *LayoutResults) Margin(edge PhysicalEdge) float32
- func (l *LayoutResults) MeasuredDimension(axis Dimension) float32
- func (l *LayoutResults) Padding(edge PhysicalEdge) float32
- func (l *LayoutResults) Position(edge PhysicalEdge) float32
- func (l *LayoutResults) RawDimension(axis Dimension) float32
- func (l *LayoutResults) SetBorder(edge PhysicalEdge, v float32)
- func (l *LayoutResults) SetDimension(axis Dimension, v float32)
- func (l *LayoutResults) SetDirection(d Direction)
- func (l *LayoutResults) SetHadOverflow(v bool)
- func (l *LayoutResults) SetMargin(edge PhysicalEdge, v float32)
- func (l *LayoutResults) SetMeasuredDimension(axis Dimension, v float32)
- func (l *LayoutResults) SetPadding(edge PhysicalEdge, v float32)
- func (l *LayoutResults) SetPosition(edge PhysicalEdge, v float32)
- func (l *LayoutResults) SetRawDimension(axis Dimension, v float32)
- type LayoutableIterator
- type LogLevel
- type LoggerFunc
- type MeasureFunc
- type MeasureMode
- type Node
- func (n *Node) AddClass(class string)
- func (n *Node) AlwaysFormsContainingBlock() bool
- func (n *Node) ApplyStyle(props map[string]string) *Node
- func (n *Node) ApplyStyleString(css string) *Node
- func (n *Node) Baseline(width, height float32) float32
- func (n *Node) ClearChildren()
- func (n *Node) Clone() *Node
- func (n *Node) CloneChildrenIfNeeded()
- func (n *Node) CloneContentsChildrenIfNeeded()
- func (n *Node) CopyStyleFrom(src *Node) *Node
- func (n *Node) DimensionWithMargin(axis FlexDirection, widthSize float32) float32
- func (n *Node) ExportAs() string
- func (n *Node) GetAlignContent() Align
- func (n *Node) GetAlignItems() Align
- func (n *Node) GetAlignSelf() Align
- func (n *Node) GetAspectRatio() float32
- func (n *Node) GetBorder(edge Edge) float32
- func (n *Node) GetBottom() float32
- func (n *Node) GetBoxSizing() BoxSizing
- func (n *Node) GetChild(index int) *Node
- func (n *Node) GetChildCount() int
- func (n *Node) GetChildren() []*Node
- func (n *Node) GetClasses() []string
- func (n *Node) GetConfig() *Config
- func (n *Node) GetContext() interface{}
- func (n *Node) GetDirection() Direction
- func (n *Node) GetDirtiedFunc() DirtiedFunc
- func (n *Node) GetDisplay() Display
- func (n *Node) GetEdgePosition(edge Edge) Value
- func (n *Node) GetFlex() float32
- func (n *Node) GetFlexBasis() Value
- func (n *Node) GetFlexDirection() FlexDirection
- func (n *Node) GetFlexGrow() float32
- func (n *Node) GetFlexShrink() float32
- func (n *Node) GetFlexWrap() Wrap
- func (n *Node) GetFontSizeEstimate() float32
- func (n *Node) GetGap(gutter Gutter) Value
- func (n *Node) GetGridColumnEnd() int32
- func (n *Node) GetGridColumnStart() int32
- func (n *Node) GetGridRowEnd() int32
- func (n *Node) GetGridRowStart() int32
- func (n *Node) GetHadOverflow() bool
- func (n *Node) GetHasNewLayout() bool
- func (n *Node) GetHeight() float32
- func (n *Node) GetHeightValue() Value
- func (n *Node) GetID() string
- func (n *Node) GetIsReferenceBaseline() bool
- func (n *Node) GetJustifyContent() Justify
- func (n *Node) GetJustifyItems() Justify
- func (n *Node) GetJustifySelf() Justify
- func (n *Node) GetLayout() *LayoutResults
- func (n *Node) GetLayoutBorder(edge Edge) float32
- func (n *Node) GetLayoutChildCount() int
- func (n *Node) GetLayoutDirection() Direction
- func (n *Node) GetLayoutMargin(edge Edge) float32
- func (n *Node) GetLayoutPadding(edge Edge) float32
- func (n *Node) GetLayoutVal() LayoutResults
- func (n *Node) GetLeft() float32
- func (n *Node) GetLineIndex() int
- func (n *Node) GetMargin(edge Edge) Value
- func (n *Node) GetMaxHeight() Value
- func (n *Node) GetMaxWidth() Value
- func (n *Node) GetMinContentHeight() FloatOptional
- func (n *Node) GetMinContentHeightValue() float32
- func (n *Node) GetMinContentWidth() FloatOptional
- func (n *Node) GetMinContentWidthValue() float32
- func (n *Node) GetMinHeight() Value
- func (n *Node) GetMinWidth() Value
- func (n *Node) GetNodeType() NodeType
- func (n *Node) GetNodeType_Public() NodeType
- func (n *Node) GetOverflow() Overflow
- func (n *Node) GetOwner() *Node
- func (n *Node) GetPadding(edge Edge) Value
- func (n *Node) GetParent() *Node
- func (n *Node) GetPositionType() PositionType
- func (n *Node) GetProcessedDimension(dim Dimension) StyleSizeLength
- func (n *Node) GetRawHeight() float32
- func (n *Node) GetRawWidth() float32
- func (n *Node) GetResolvedDimension(dir Direction, dim Dimension, referenceLength, ownerWidth float32) FloatOptional
- func (n *Node) GetRight() float32
- func (n *Node) GetStyle() Style
- func (n *Node) GetTop() float32
- func (n *Node) GetWidth() float32
- func (n *Node) GetWidthValue() Value
- func (n *Node) HasBaselineFunc() bool
- func (n *Node) HasClass(class string) bool
- func (n *Node) HasContentsChildren() bool
- func (n *Node) HasDefiniteLength(dim Dimension, ownerSize float32) bool
- func (n *Node) HasErrata(errata Errata) bool
- func (n *Node) HasLayoutableChildren() bool
- func (n *Node) HasMeasureFunc() bool
- func (n *Node) HasMinContentMeasureFunc() bool
- func (n *Node) InsertChild(child *Node, index int)
- func (n *Node) InsertChildNode(child *Node, index int) *Node
- func (n *Node) IsDirty() bool
- func (n *Node) IsLayoutDimensionDefined(axis FlexDirection) bool
- func (n *Node) IsNodeFlexible() bool
- func (n *Node) IsReferenceBaseline() bool
- func (n *Node) LayoutOut() LayoutOut
- func (n *Node) LayoutableSlice() []*Node
- func (n *Node) MarkDirty() *Node
- func (n *Node) MarkDirtyAndPropagate()
- func (n *Node) Measure(availableWidth float32, widthMode MeasureMode, availableHeight float32, ...) Size
- func (n *Node) MeasureMinContent(availableWidth float32, widthMode MeasureMode, availableHeight float32, ...) Size
- func (n *Node) ProcessDimensions()
- func (n *Node) ProcessFlexBasis() StyleSizeLength
- func (n *Node) RelativePosition(axis FlexDirection, dir Direction, axisSize float32) float32
- func (n *Node) RemoveAllChildren() *Node
- func (n *Node) RemoveChild(child *Node) bool
- func (n *Node) RemoveChildAt(index int)
- func (n *Node) RemoveChildNode(child *Node) *Node
- func (n *Node) ReplaceChild(oldChild, newChild *Node)
- func (n *Node) ReplaceChildAt(child *Node, index int)
- func (n *Node) ResolveDirection(ownerDir Direction) Direction
- func (n *Node) ResolveFlexBasis(dir Direction, flexDir FlexDirection, referenceLength, ownerWidth float32) FloatOptional
- func (n *Node) ResolveFlexGrow() float32
- func (n *Node) ResolveFlexShrink() float32
- func (n *Node) SetAlignContent(a Align) *Node
- func (n *Node) SetAlignItems(a Align) *Node
- func (n *Node) SetAlignSelf(a Align) *Node
- func (n *Node) SetAlwaysFormsContainingBlock(v bool)
- func (n *Node) SetAspectRatio(value float32) *Node
- func (n *Node) SetBaselineFunc(f BaselineFunc)
- func (n *Node) SetBorder(edge Edge, value float32) *Node
- func (n *Node) SetBoxSizing(b BoxSizing) *Node
- func (n *Node) SetChildren(children []*Node)
- func (n *Node) SetChildrenList(children []*Node) *Node
- func (n *Node) SetClasses(classes []string)
- func (n *Node) SetConfig(config *Config)
- func (n *Node) SetContext(ctx interface{})
- func (n *Node) SetDirection(d Direction) *Node
- func (n *Node) SetDirtiedFunc(f DirtiedFunc)
- func (n *Node) SetDirty(isDirty bool)
- func (n *Node) SetDisplay(d Display) *Node
- func (n *Node) SetEdgePosition(edge Edge, value float32) *Node
- func (n *Node) SetEdgePositionAuto(edge Edge) *Node
- func (n *Node) SetEdgePositionPercent(edge Edge, value float32) *Node
- func (n *Node) SetFlex(f float32) *Node
- func (n *Node) SetFlexBasis(f float32) *Node
- func (n *Node) SetFlexBasisAuto() *Node
- func (n *Node) SetFlexBasisFitContent() *Node
- func (n *Node) SetFlexBasisMaxContent() *Node
- func (n *Node) SetFlexBasisPercent(f float32) *Node
- func (n *Node) SetFlexBasisStretch() *Node
- func (n *Node) SetFlexDirection(fd FlexDirection) *Node
- func (n *Node) SetFlexGrow(f float32) *Node
- func (n *Node) SetFlexShrink(f float32) *Node
- func (n *Node) SetFlexWrap(w Wrap) *Node
- func (n *Node) SetFontSizeEstimate(v float32) *Node
- func (n *Node) SetGap(gutter Gutter, value float32) *Node
- func (n *Node) SetGapPercent(gutter Gutter, value float32) *Node
- func (n *Node) SetGridAutoColumn(index int, trackType GridTrackType, value float32) *Node
- func (n *Node) SetGridAutoColumnMinMax(index int, minType GridTrackType, minVal float32, maxType GridTrackType, ...) *Node
- func (n *Node) SetGridAutoColumnsCount(count int) *Node
- func (n *Node) SetGridAutoRow(index int, trackType GridTrackType, value float32) *Node
- func (n *Node) SetGridAutoRowMinMax(index int, minType GridTrackType, minVal float32, maxType GridTrackType, ...) *Node
- func (n *Node) SetGridAutoRowsCount(count int) *Node
- func (n *Node) SetGridColumnEnd(v int32) *Node
- func (n *Node) SetGridColumnEndAuto() *Node
- func (n *Node) SetGridColumnEndSpan(span int32) *Node
- func (n *Node) SetGridColumnStart(v int32) *Node
- func (n *Node) SetGridColumnStartAuto() *Node
- func (n *Node) SetGridColumnStartSpan(span int32) *Node
- func (n *Node) SetGridRowEnd(v int32) *Node
- func (n *Node) SetGridRowEndAuto() *Node
- func (n *Node) SetGridRowEndSpan(span int32) *Node
- func (n *Node) SetGridRowStart(v int32) *Node
- func (n *Node) SetGridRowStartAuto() *Node
- func (n *Node) SetGridRowStartSpan(span int32) *Node
- func (n *Node) SetGridTemplateColumn(index int, trackType GridTrackType, value float32) *Node
- func (n *Node) SetGridTemplateColumnMinMax(index int, minType GridTrackType, minVal float32, maxType GridTrackType, ...) *Node
- func (n *Node) SetGridTemplateColumnsCount(count int) *Node
- func (n *Node) SetGridTemplateRow(index int, trackType GridTrackType, value float32) *Node
- func (n *Node) SetGridTemplateRowMinMax(index int, minType GridTrackType, minVal float32, maxType GridTrackType, ...) *Node
- func (n *Node) SetGridTemplateRowsCount(count int) *Node
- func (n *Node) SetHasNewLayout(v bool)
- func (n *Node) SetHeight(value float32) *Node
- func (n *Node) SetHeightAuto() *Node
- func (n *Node) SetHeightFitContent() *Node
- func (n *Node) SetHeightMaxContent() *Node
- func (n *Node) SetHeightPercent(value float32) *Node
- func (n *Node) SetHeightStretch() *Node
- func (n *Node) SetID(id string)
- func (n *Node) SetIsReferenceBaseline(v bool)
- func (n *Node) SetIsReferenceBaseline_Public(v bool) *Node
- func (n *Node) SetJustifyContent(j Justify) *Node
- func (n *Node) SetJustifyItems(j Justify) *Node
- func (n *Node) SetJustifySelf(j Justify) *Node
- func (n *Node) SetLayout(l LayoutResults)
- func (n *Node) SetLayoutBorder(v float32, edge PhysicalEdge)
- func (n *Node) SetLayoutComputedFlexBasis(fb FloatOptional)
- func (n *Node) SetLayoutComputedFlexBasisGeneration(g uint32)
- func (n *Node) SetLayoutDimension(v float32, dim Dimension)
- func (n *Node) SetLayoutDirection(dir Direction)
- func (n *Node) SetLayoutHadOverflow(v bool)
- func (n *Node) SetLayoutLastOwnerDirection(dir Direction)
- func (n *Node) SetLayoutMargin(v float32, edge PhysicalEdge)
- func (n *Node) SetLayoutMeasuredDimension(v float32, dim Dimension)
- func (n *Node) SetLayoutPadding(v float32, edge PhysicalEdge)
- func (n *Node) SetLayoutPosition(v float32, edge PhysicalEdge)
- func (n *Node) SetLineIndex(i int)
- func (n *Node) SetMargin(edge Edge, value float32) *Node
- func (n *Node) SetMarginAuto(edge Edge) *Node
- func (n *Node) SetMarginPercent(edge Edge, value float32) *Node
- func (n *Node) SetMaxHeight(value float32) *Node
- func (n *Node) SetMaxHeightFitContent() *Node
- func (n *Node) SetMaxHeightMaxContent() *Node
- func (n *Node) SetMaxHeightPercent(value float32) *Node
- func (n *Node) SetMaxHeightStretch() *Node
- func (n *Node) SetMaxWidth(value float32) *Node
- func (n *Node) SetMaxWidthFitContent() *Node
- func (n *Node) SetMaxWidthMaxContent() *Node
- func (n *Node) SetMaxWidthPercent(value float32) *Node
- func (n *Node) SetMaxWidthStretch() *Node
- func (n *Node) SetMeasureFunc(f MeasureFunc)
- func (n *Node) SetMinContentHeight(v FloatOptional)
- func (n *Node) SetMinContentHeightValue(v float32) *Node
- func (n *Node) SetMinContentMeasureFunc(f MeasureFunc)
- func (n *Node) SetMinContentWidth(v FloatOptional)
- func (n *Node) SetMinContentWidthFunc(f MeasureFunc) *Node
- func (n *Node) SetMinContentWidthValue(v float32) *Node
- func (n *Node) SetMinHeight(value float32) *Node
- func (n *Node) SetMinHeightFitContent() *Node
- func (n *Node) SetMinHeightMaxContent() *Node
- func (n *Node) SetMinHeightPercent(value float32) *Node
- func (n *Node) SetMinHeightStretch() *Node
- func (n *Node) SetMinWidth(value float32) *Node
- func (n *Node) SetMinWidthFitContent() *Node
- func (n *Node) SetMinWidthMaxContent() *Node
- func (n *Node) SetMinWidthPercent(value float32) *Node
- func (n *Node) SetMinWidthStretch() *Node
- func (n *Node) SetNodeType(v NodeType)
- func (n *Node) SetNodeType_Public(nt NodeType) *Node
- func (n *Node) SetOverflow(o Overflow) *Node
- func (n *Node) SetOwner(owner *Node)
- func (n *Node) SetPadding(edge Edge, value float32) *Node
- func (n *Node) SetPaddingPercent(edge Edge, value float32) *Node
- func (n *Node) SetPosition(dir Direction, ownerWidth, ownerHeight float32)
- func (n *Node) SetPositionType(p PositionType) *Node
- func (n *Node) SetStyle(s Style)
- func (n *Node) SetWidth(value float32) *Node
- func (n *Node) SetWidthAuto() *Node
- func (n *Node) SetWidthFitContent() *Node
- func (n *Node) SetWidthMaxContent() *Node
- func (n *Node) SetWidthPercent(value float32) *Node
- func (n *Node) SetWidthStretch() *Node
- func (n *Node) Style() *Style
- func (n *Node) SwapChildNode(child *Node, index int) *Node
- type NodeType
- type Overflow
- type PhysicalEdge
- type PositionType
- type Rect
- type Size
- type SizingMode
- type Style
- func (s *Style) AlignContent() Align
- func (s *Style) AlignItems() Align
- func (s *Style) AlignSelf() Align
- func (s *Style) AspectRatio() FloatOptional
- func (s *Style) Border(edge Edge) StyleLength
- func (s *Style) BoxSizing() BoxSizing
- func (s *Style) ComputeBorderForAxis(axis FlexDirection) float32
- func (s *Style) ComputeFlexEndBorder(axis FlexDirection, dir Direction) float32
- func (s *Style) ComputeFlexEndMargin(axis FlexDirection, dir Direction, widthSize float32) float32
- func (s *Style) ComputeFlexEndPadding(axis FlexDirection, dir Direction, widthSize float32) float32
- func (s *Style) ComputeFlexEndPaddingAndBorder(axis FlexDirection, dir Direction, widthSize float32) float32
- func (s *Style) ComputeFlexEndPosition(axis FlexDirection, dir Direction, axisSize float32) float32
- func (s *Style) ComputeFlexStartBorder(axis FlexDirection, dir Direction) float32
- func (s *Style) ComputeFlexStartMargin(axis FlexDirection, dir Direction, widthSize float32) float32
- func (s *Style) ComputeFlexStartPadding(axis FlexDirection, dir Direction, widthSize float32) float32
- func (s *Style) ComputeFlexStartPaddingAndBorder(axis FlexDirection, dir Direction, widthSize float32) float32
- func (s *Style) ComputeFlexStartPosition(axis FlexDirection, dir Direction, axisSize float32) float32
- func (s *Style) ComputeGapForAxis(axis FlexDirection, ownerSize float32) float32
- func (s *Style) ComputeGapForDimension(dim Dimension, ownerSize float32) float32
- func (s *Style) ComputeInlineEndBorder(axis FlexDirection, dir Direction) float32
- func (s *Style) ComputeInlineEndMargin(axis FlexDirection, dir Direction, widthSize float32) float32
- func (s *Style) ComputeInlineEndPadding(axis FlexDirection, dir Direction, widthSize float32) float32
- func (s *Style) ComputeInlineEndPaddingAndBorder(axis FlexDirection, dir Direction, widthSize float32) float32
- func (s *Style) ComputeInlineEndPosition(axis FlexDirection, dir Direction, axisSize float32) float32
- func (s *Style) ComputeInlineStartBorder(axis FlexDirection, dir Direction) float32
- func (s *Style) ComputeInlineStartMargin(axis FlexDirection, dir Direction, widthSize float32) float32
- func (s *Style) ComputeInlineStartPadding(axis FlexDirection, dir Direction, widthSize float32) float32
- func (s *Style) ComputeInlineStartPaddingAndBorder(axis FlexDirection, dir Direction, widthSize float32) float32
- func (s *Style) ComputeInlineStartPosition(axis FlexDirection, dir Direction, axisSize float32) float32
- func (s *Style) ComputeMarginForAxis(axis FlexDirection, widthSize float32) float32
- func (s *Style) ComputePaddingAndBorderForDimension(dir Direction, dim Dimension, widthSize float32) float32
- func (s *Style) Copy() Style
- func (s *Style) Dimension(axis Dimension) StyleSizeLength
- func (s *Style) Direction() Direction
- func (s *Style) Display() Display
- func (s *Style) Equals(other *Style) bool
- func (s *Style) Flex() FloatOptional
- func (s *Style) FlexBasis() StyleSizeLength
- func (s *Style) FlexDirection() FlexDirection
- func (s *Style) FlexEndMarginIsAuto(axis FlexDirection, dir Direction) bool
- func (s *Style) FlexGrow() FloatOptional
- func (s *Style) FlexShrink() FloatOptional
- func (s *Style) FlexStartMarginIsAuto(axis FlexDirection, dir Direction) bool
- func (s *Style) FlexWrap() Wrap
- func (s *Style) Gap(gutter Gutter) StyleLength
- func (s *Style) GridAutoColumns() GridTrackList
- func (s *Style) GridAutoRows() GridTrackList
- func (s *Style) GridColumnEnd() GridLine
- func (s *Style) GridColumnStart() GridLine
- func (s *Style) GridRowEnd() GridLine
- func (s *Style) GridRowStart() GridLine
- func (s *Style) GridTemplateColumns() GridTrackList
- func (s *Style) GridTemplateRows() GridTrackList
- func (s *Style) HorizontalInsetsDefined() bool
- func (s *Style) InlineEndMarginIsAuto(axis FlexDirection, dir Direction) bool
- func (s *Style) InlineStartMarginIsAuto(axis FlexDirection, dir Direction) bool
- func (s *Style) IsFlexEndPositionAuto(axis FlexDirection, dir Direction) bool
- func (s *Style) IsFlexEndPositionDefined(axis FlexDirection, dir Direction) bool
- func (s *Style) IsFlexStartPositionAuto(axis FlexDirection, dir Direction) bool
- func (s *Style) IsFlexStartPositionDefined(axis FlexDirection, dir Direction) bool
- func (s *Style) IsInlineEndPositionAuto(axis FlexDirection, dir Direction) bool
- func (s *Style) IsInlineEndPositionDefined(axis FlexDirection, dir Direction) bool
- func (s *Style) IsInlineStartPositionAuto(axis FlexDirection, dir Direction) bool
- func (s *Style) IsInlineStartPositionDefined(axis FlexDirection, dir Direction) bool
- func (s *Style) JustifyContent() Justify
- func (s *Style) JustifyItems() Justify
- func (s *Style) JustifySelf() Justify
- func (s *Style) Margin(edge Edge) StyleLength
- func (s *Style) MaxDimension(axis Dimension) StyleSizeLength
- func (s *Style) MinDimension(axis Dimension) StyleSizeLength
- func (s *Style) Overflow() Overflow
- func (s *Style) Padding(edge Edge) StyleLength
- func (s *Style) Position(edge Edge) StyleLength
- func (s *Style) PositionType() PositionType
- func (s *Style) ResizeGridAutoColumns(count int)
- func (s *Style) ResizeGridAutoRows(count int)
- func (s *Style) ResizeGridTemplateColumns(count int)
- func (s *Style) ResizeGridTemplateRows(count int)
- func (s *Style) ResolvedMaxDimension(direction Direction, axis Dimension, referenceLength, ownerWidth float32) FloatOptional
- func (s *Style) ResolvedMinDimension(direction Direction, axis Dimension, referenceLength, ownerWidth float32) FloatOptional
- func (s *Style) SetAlignContent(v Align)
- func (s *Style) SetAlignItems(v Align)
- func (s *Style) SetAlignSelf(v Align)
- func (s *Style) SetAspectRatio(v FloatOptional)
- func (s *Style) SetBorder(edge Edge, v StyleLength)
- func (s *Style) SetBoxSizing(v BoxSizing)
- func (s *Style) SetDimension(axis Dimension, v StyleSizeLength)
- func (s *Style) SetDirection(v Direction)
- func (s *Style) SetDisplay(v Display)
- func (s *Style) SetFlex(v FloatOptional)
- func (s *Style) SetFlexBasis(v StyleSizeLength)
- func (s *Style) SetFlexDirection(v FlexDirection)
- func (s *Style) SetFlexGrow(v FloatOptional)
- func (s *Style) SetFlexShrink(v FloatOptional)
- func (s *Style) SetFlexWrap(v Wrap)
- func (s *Style) SetGap(gutter Gutter, v StyleLength)
- func (s *Style) SetGridAutoColumnAt(index int, v GridTrackSize)
- func (s *Style) SetGridAutoColumns(v GridTrackList)
- func (s *Style) SetGridAutoRowAt(index int, v GridTrackSize)
- func (s *Style) SetGridAutoRows(v GridTrackList)
- func (s *Style) SetGridColumnEnd(v GridLine)
- func (s *Style) SetGridColumnStart(v GridLine)
- func (s *Style) SetGridRowEnd(v GridLine)
- func (s *Style) SetGridRowStart(v GridLine)
- func (s *Style) SetGridTemplateColumnAt(index int, v GridTrackSize)
- func (s *Style) SetGridTemplateColumns(v GridTrackList)
- func (s *Style) SetGridTemplateRowAt(index int, v GridTrackSize)
- func (s *Style) SetGridTemplateRows(v GridTrackList)
- func (s *Style) SetJustifyContent(v Justify)
- func (s *Style) SetJustifyItems(v Justify)
- func (s *Style) SetJustifySelf(v Justify)
- func (s *Style) SetMargin(edge Edge, v StyleLength)
- func (s *Style) SetMaxDimension(axis Dimension, v StyleSizeLength)
- func (s *Style) SetMinDimension(axis Dimension, v StyleSizeLength)
- func (s *Style) SetOverflow(v Overflow)
- func (s *Style) SetPadding(edge Edge, v StyleLength)
- func (s *Style) SetPosition(edge Edge, v StyleLength)
- func (s *Style) SetPositionType(v PositionType)
- func (s *Style) VerticalInsetsDefined() bool
- type StyleLength
- func (l StyleLength) IsAuto() bool
- func (l StyleLength) IsDefined() bool
- func (l StyleLength) IsPercent() bool
- func (l StyleLength) IsPoints() bool
- func (l StyleLength) IsUndefined() bool
- func (l StyleLength) Resolve(referenceLength float32) FloatOptional
- func (l StyleLength) ToValue() Value
- func (l StyleLength) Value() FloatOptional
- type StyleSizeLength
- func StyleSizeLengthAuto() StyleSizeLength
- func StyleSizeLengthFitContent() StyleSizeLength
- func StyleSizeLengthMaxContent() StyleSizeLength
- func StyleSizeLengthOfStretch() StyleSizeLength
- func StyleSizeLengthPercent(v float32) StyleSizeLength
- func StyleSizeLengthPoints(v float32) StyleSizeLength
- func StyleSizeLengthStretch(fraction float32) StyleSizeLength
- func StyleSizeLengthUndefined() StyleSizeLength
- func (l StyleSizeLength) Equals(other StyleSizeLength) bool
- func (l StyleSizeLength) IsAuto() bool
- func (l StyleSizeLength) IsDefined() bool
- func (l StyleSizeLength) IsFitContent() bool
- func (l StyleSizeLength) IsMaxContent() bool
- func (l StyleSizeLength) IsPercent() bool
- func (l StyleSizeLength) IsPoints() bool
- func (l StyleSizeLength) IsStretch() bool
- func (l StyleSizeLength) IsUndefined() bool
- func (l StyleSizeLength) Resolve(referenceLength float32) FloatOptional
- func (l StyleSizeLength) ToValue() Value
- func (l StyleSizeLength) Value() FloatOptional
- type Unit
- type Value
- type Wrap
Constants ¶
const ( LayoutPassInitial = iota LayoutPassAbsLayout LayoutPassStretch LayoutPassMultilineStretch LayoutPassFlexLayout LayoutPassMeasureChild LayoutPassAbsMeasureChild LayoutPassFlexMeasure LayoutPassGridLayout LayoutPassCount )
Variables ¶
var ( ValueZero = Value{0, UnitPoint} ValueUndefined = Value{Undefined, UnitUndefined} ValueAuto = Value{Undefined, UnitAuto} )
var Undefined = float32(math.NaN())
Undefined is the NaN sentinel value used throughout the layout engine to represent unset or "auto" dimensions.
Functions ¶
func CalculateLayout ¶
CalculateLayout is the public entry point for performing layout on a node tree.
func CalculateLayoutInternal ¶
func CalculateLayoutInternal(node *Node, availableWidth, availableHeight float32, ownerDirection Direction, widthMode, heightMode SizingMode, ownerWidth, ownerHeight float32, performLayout bool, reason int, layoutMarkerData *LayoutData, depth int, generationCount uint32) bool
CalculateLayoutInternal is the caching wrapper around the layout implementation.
func CalculateNodeLayout ¶
func CalculateNodeLayout(node *Node, availableWidth, availableHeight float32, ownerDirection Direction)
CalculateNodeLayout performs layout on the given node tree.
func IsUndefinedFloat ¶
IsUndefinedFloat returns true if v is the NaN sentinel value.
func ParseStyle ¶
ParseStyle parses a CSS-like string into a map of property-value pairs. Declarations are separated by ";" or newlines. Keys and values are split by ":". Lines starting with "//" or "/*" are treated as comments. Only supported properties are included in the result.
Example:
props := goda.ParseStyle(`
display: flex;
flex-direction: row;
width: 800;
height: 600;
padding: 16;
gap: 8;
`)
node.ApplyStyle(props)
Types ¶
type BaselineFunc ¶
BaselineFunc is the signature for a custom baseline function.
type CloneNodeFunc ¶
CloneNodeFunc is the signature for a custom node cloning callback.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config holds global layout configuration.
func ConfigNew ¶
func ConfigNew(logger LoggerFunc) *Config
ConfigNew creates a new Config with the given logger.
func ConfigNewDefault ¶
func ConfigNewDefault() *Config
ConfigNewDefault creates a new Config with the default no-op logger.
func GetDefaultConfig ¶
func GetDefaultConfig() *Config
func NewConfig ¶
func NewConfig(logger LoggerFunc) *Config
func (*Config) GetContext ¶
func (c *Config) GetContext() interface{}
func (*Config) GetEnabledExperiments ¶
func (*Config) GetPointScaleFactor ¶
func (*Config) GetVersion ¶
func (*Config) IsExperimentalFeatureEnabled ¶
func (c *Config) IsExperimentalFeatureEnabled(feature ExperimentalFeature) bool
func (*Config) RemoveErrata ¶
func (*Config) SetCloneNodeCallback ¶
func (c *Config) SetCloneNodeCallback(callback CloneNodeFunc)
func (*Config) SetContext ¶
func (c *Config) SetContext(ctx interface{})
func (*Config) SetExperimentalFeatureEnabled ¶
func (c *Config) SetExperimentalFeatureEnabled(feature ExperimentalFeature, enabled bool)
func (*Config) SetLogger ¶
func (c *Config) SetLogger(logger LoggerFunc)
func (*Config) SetPointScaleFactor ¶
func (*Config) SetUseWebDefaults ¶
func (*Config) SetUseWebDefaultsBool ¶
func (*Config) UseWebDefaults ¶
type DirtiedFunc ¶
type DirtiedFunc func(node *Node)
DirtiedFunc is called when a node becomes dirty.
type Errata ¶
type Errata int
Errata is a bitmask of legacy behavior flags.
const ( ErrataNone Errata = 0 ErrataStretchFlexBasis Errata = 1 << 0 ErrataAbsolutePositionWithoutInsetsExcludesPadding Errata = 1 << 1 ErrataAbsolutePercentAgainstInnerSize Errata = 1 << 2 ErrataMinSizeUndefinedInsteadOfAuto Errata = 1 << 3 ErrataAll Errata = 1<<31 - 1 ErrataClassic Errata = ErrataAll & ^ErrataMinSizeUndefinedInsteadOfAuto )
type ExperimentalFeature ¶
type ExperimentalFeature int
ExperimentalFeature represents feature flags for optional behavior.
const ( ExperimentalFeatureWebFlexBasis ExperimentalFeature = iota ExperimentalFeatureFixFlexBasisFitContent )
type FlexDirection ¶
type FlexDirection int
FlexDirection represents the CSS flex-direction property.
const ( FlexDirectionColumn FlexDirection = iota FlexDirectionColumnReverse FlexDirectionRow FlexDirectionRowReverse )
func (FlexDirection) String ¶
func (f FlexDirection) String() string
type FlexLine ¶
type FlexLine struct {
ItemsInFlow []*Node
SizeConsumed float32
NumberOfAutoMargins int
Layout FlexLineRunningLayout
}
FlexLine represents a single line of flex items.
type FlexLineRunningLayout ¶
type FlexLineRunningLayout struct {
TotalFlexGrowFactors float32
TotalFlexShrinkScaledFactors float32
RemainingFreeSpace float32
MainDim float32
CrossDim float32
}
FlexLineRunningLayout holds transient layout state for a flex line.
type FloatOptional ¶
type FloatOptional struct {
// contains filtered or unexported fields
}
FloatOptional represents an optional float32 value that may be undefined.
func NewFloatOptional ¶
func NewFloatOptional(v float32) FloatOptional
func (FloatOptional) Equals ¶
func (f FloatOptional) Equals(other FloatOptional) bool
func (FloatOptional) IsDefined ¶
func (f FloatOptional) IsDefined() bool
func (FloatOptional) IsUndefined ¶
func (f FloatOptional) IsUndefined() bool
func (FloatOptional) Unwrap ¶
func (f FloatOptional) Unwrap() float32
func (FloatOptional) UnwrapOrDefault ¶
func (f FloatOptional) UnwrapOrDefault(defaultValue float32) float32
type GridLine ¶
type GridLine struct {
Type GridLineType
Integer int32
}
GridLine represents a CSS Grid line placement value.
func GridLineAuto ¶
func GridLineAuto() GridLine
func GridLineFromInteger ¶
func GridLineSpan ¶
type GridLineType ¶
type GridLineType int
GridLineType describes the type of a CSS Grid line placement.
const ( GridLineTypeAuto GridLineType = iota GridLineTypeInteger GridLineTypeSpan )
type GridTrackList ¶
type GridTrackList []GridTrackSize
GridTrackList is a slice of GridTrackSize representing a track listing.
type GridTrackSize ¶
type GridTrackSize struct {
MinSizingFunction StyleSizeLength
MaxSizingFunction StyleSizeLength
BaseSize float32
GrowthLimit float32
InfinitelyGrowable bool
}
GridTrackSize represents a CSS Grid track sizing function.
func GridTrackSizeAuto ¶
func GridTrackSizeAuto() GridTrackSize
func GridTrackSizeFr ¶
func GridTrackSizeFr(fraction float32) GridTrackSize
func GridTrackSizeLength ¶
func GridTrackSizeLength(points float32) GridTrackSize
func GridTrackSizeMinmax ¶
func GridTrackSizeMinmax(minFn, maxFn StyleSizeLength) GridTrackSize
func GridTrackSizePercent ¶
func GridTrackSizePercent(percentage float32) GridTrackSize
type GridTrackType ¶
type GridTrackType int
GridTrackType describes a CSS Grid track sizing function type.
const ( GridTrackTypeAuto GridTrackType = iota GridTrackTypePoints GridTrackTypePercent GridTrackTypeFr GridTrackTypeMinmax )
func (GridTrackType) String ¶
func (g GridTrackType) String() string
type Justify ¶
type Justify int
Justify represents CSS justify-content/justify-items/justify-self values.
type LayoutData ¶
type LayoutData struct {
Layouts int
Measures int
MaxMeasureCache uint32
CachedLayouts int
CachedMeasures int
MeasureCallbacks int
MeasureCallbackReasons [LayoutPassCount]int
}
LayoutData tracks layout performance counters.
type LayoutOut ¶
type LayoutOut struct {
Rect
Margin Edges
Border Edges
Padding Edges
Direction Direction
HadOverflow bool
}
LayoutOut is the public layout output for a node after CalculateNodeLayout. It bundles position, size, box-model edges, and layout metadata into one struct for easy consumption by GUI libraries.
Example:
goda.CalculateNodeLayout(root, 800, 600, goda.DirectionLTR) lo := root.LayoutOut() renderer.DrawBox(lo.Left, lo.Top, lo.Width, lo.Height, lo.Margin, lo.Padding)
type LayoutResults ¶
type LayoutResults struct {
// contains filtered or unexported fields
}
LayoutResults holds the computed layout output for a Node.
func NewLayoutResults ¶
func NewLayoutResults() LayoutResults
func (*LayoutResults) Border ¶
func (l *LayoutResults) Border(edge PhysicalEdge) float32
func (*LayoutResults) Dimension ¶
func (l *LayoutResults) Dimension(axis Dimension) float32
func (*LayoutResults) Direction ¶
func (l *LayoutResults) Direction() Direction
func (*LayoutResults) HadOverflow ¶
func (l *LayoutResults) HadOverflow() bool
func (*LayoutResults) Margin ¶
func (l *LayoutResults) Margin(edge PhysicalEdge) float32
func (*LayoutResults) MeasuredDimension ¶
func (l *LayoutResults) MeasuredDimension(axis Dimension) float32
func (*LayoutResults) Padding ¶
func (l *LayoutResults) Padding(edge PhysicalEdge) float32
func (*LayoutResults) Position ¶
func (l *LayoutResults) Position(edge PhysicalEdge) float32
func (*LayoutResults) RawDimension ¶
func (l *LayoutResults) RawDimension(axis Dimension) float32
func (*LayoutResults) SetBorder ¶
func (l *LayoutResults) SetBorder(edge PhysicalEdge, v float32)
func (*LayoutResults) SetDimension ¶
func (l *LayoutResults) SetDimension(axis Dimension, v float32)
func (*LayoutResults) SetDirection ¶
func (l *LayoutResults) SetDirection(d Direction)
func (*LayoutResults) SetHadOverflow ¶
func (l *LayoutResults) SetHadOverflow(v bool)
func (*LayoutResults) SetMargin ¶
func (l *LayoutResults) SetMargin(edge PhysicalEdge, v float32)
func (*LayoutResults) SetMeasuredDimension ¶
func (l *LayoutResults) SetMeasuredDimension(axis Dimension, v float32)
func (*LayoutResults) SetPadding ¶
func (l *LayoutResults) SetPadding(edge PhysicalEdge, v float32)
func (*LayoutResults) SetPosition ¶
func (l *LayoutResults) SetPosition(edge PhysicalEdge, v float32)
func (*LayoutResults) SetRawDimension ¶
func (l *LayoutResults) SetRawDimension(axis Dimension, v float32)
type LayoutableIterator ¶
type LayoutableIterator struct {
// contains filtered or unexported fields
}
LayoutableIterator iterates over children of a node that participate in layout, transparently flattening DisplayContents children.
func NewLayoutableIterator ¶
func NewLayoutableIterator(n *Node) *LayoutableIterator
func (*LayoutableIterator) Current ¶
func (it *LayoutableIterator) Current() *Node
func (*LayoutableIterator) Next ¶
func (it *LayoutableIterator) Next() bool
func (*LayoutableIterator) Reset ¶
func (it *LayoutableIterator) Reset(n *Node)
type LoggerFunc ¶
type LoggerFunc func(config *Config, node *Node, level LogLevel, format string, args ...interface{}) int
LoggerFunc is the signature for a custom logger.
var DefaultLogger LoggerFunc = func(config *Config, node *Node, level LogLevel, format string, args ...interface{}) int { if level == LogLevelError || level == LogLevelFatal { return 0 } return 0 }
DefaultLogger is a no-op logger that suppresses error/fatal messages.
type MeasureFunc ¶
type MeasureFunc func(node *Node, width float32, widthMode MeasureMode, height float32, heightMode MeasureMode) Size
MeasureFunc is the signature for a custom measure function.
type MeasureMode ¶
type MeasureMode int
MeasureMode describes how a measurement constraint is applied.
const ( MeasureModeUndefined MeasureMode = iota MeasureModeExactly MeasureModeAtMost )
func (MeasureMode) String ¶
func (m MeasureMode) String() string
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is the fundamental unit of the layout tree. Each Node has a Style and computed LayoutResults.
func New ¶
New creates a new Node with default configuration. Optionally accepts an id string as the first argument: New("my_id").
func NewNodeWithConfig ¶
func NewWithConfig ¶
NewWithConfig creates a new Node with the given configuration.
func RenderFrom ¶
RenderFrom parses an extended CSS / QML-like string and returns the root nodes. Class definitions (e.g. ".myClass { ... }") define reusable style blocks. Node definitions (e.g. "#myId[class1, class2] { ... }") create nodes with optional class references whose styles are applied as defaults.
Children are nested inside braces:
#root {
width: 800;
#child {
flex: 1;
}
}
Comments (// and /* */) are supported anywhere.
func (*Node) AlwaysFormsContainingBlock ¶
func (*Node) ApplyStyle ¶
ApplyStyle applies CSS-like properties from a map. Keys use kebab-case (e.g. "flex-direction", "justify-content") or camelCase. Values are parsed as CSS values: numbers, percentages ("50%"), or keywords. Unknown properties are silently ignored. Returns the receiver for chaining.
Example:
node.ApplyStyle(map[string]string{
"display": "flex",
"flex-direction": "row",
"width": "800",
"height": "600",
"padding": "16",
"gap": "8",
})
func (*Node) ApplyStyleString ¶
ApplyStyleString parses a CSS-like string and applies the properties. This is a convenience combining ParseStyle and ApplyStyle. Returns the receiver for chaining.
Example:
node.ApplyStyleString(`
display: flex;
flex-direction: row;
width: 800;
height: 600;
padding: 16;
gap: 8;
`)
func (*Node) ClearChildren ¶
func (n *Node) ClearChildren()
func (*Node) CloneChildrenIfNeeded ¶
func (n *Node) CloneChildrenIfNeeded()
func (*Node) CloneContentsChildrenIfNeeded ¶
func (n *Node) CloneContentsChildrenIfNeeded()
func (*Node) CopyStyleFrom ¶
CopyStyleFrom copies all style properties from the source node (deep copy).
func (*Node) DimensionWithMargin ¶
func (n *Node) DimensionWithMargin(axis FlexDirection, widthSize float32) float32
func (*Node) ExportAs ¶
ExportAs serializes the node tree into the same extended CSS format that RenderFrom can parse. Only non-default style properties are included.
func (*Node) GetAlignContent ¶
func (*Node) GetAlignItems ¶
func (*Node) GetAlignSelf ¶
func (*Node) GetAspectRatio ¶
func (*Node) GetBoxSizing ¶
func (*Node) GetChildCount ¶
func (*Node) GetChildren ¶
func (*Node) GetClasses ¶
func (*Node) GetContext ¶
func (n *Node) GetContext() interface{}
func (*Node) GetDirection ¶
func (*Node) GetDirtiedFunc ¶
func (n *Node) GetDirtiedFunc() DirtiedFunc
func (*Node) GetDisplay ¶
func (*Node) GetEdgePosition ¶
func (*Node) GetFlexBasis ¶
func (*Node) GetFlexDirection ¶
func (n *Node) GetFlexDirection() FlexDirection
func (*Node) GetFlexGrow ¶
func (*Node) GetFlexShrink ¶
func (*Node) GetFlexWrap ¶
func (*Node) GetFontSizeEstimate ¶
func (*Node) GetGridColumnEnd ¶
func (*Node) GetGridColumnStart ¶
func (*Node) GetGridRowEnd ¶
func (*Node) GetGridRowStart ¶
func (*Node) GetHadOverflow ¶
func (*Node) GetHasNewLayout ¶
func (*Node) GetHeightValue ¶
func (*Node) GetIsReferenceBaseline ¶
func (*Node) GetJustifyContent ¶
func (*Node) GetJustifyItems ¶
func (*Node) GetJustifySelf ¶
func (*Node) GetLayout ¶
func (n *Node) GetLayout() *LayoutResults
func (*Node) GetLayoutBorder ¶
func (*Node) GetLayoutChildCount ¶
func (*Node) GetLayoutDirection ¶
func (*Node) GetLayoutMargin ¶
func (*Node) GetLayoutPadding ¶
func (*Node) GetLayoutVal ¶
func (n *Node) GetLayoutVal() LayoutResults
func (*Node) GetLineIndex ¶
func (*Node) GetMaxHeight ¶
func (*Node) GetMaxWidth ¶
func (*Node) GetMinContentHeight ¶
func (n *Node) GetMinContentHeight() FloatOptional
func (*Node) GetMinContentHeightValue ¶
func (*Node) GetMinContentWidth ¶
func (n *Node) GetMinContentWidth() FloatOptional
func (*Node) GetMinContentWidthValue ¶
func (*Node) GetMinHeight ¶
func (*Node) GetMinWidth ¶
func (*Node) GetNodeType ¶
func (*Node) GetNodeType_Public ¶
func (*Node) GetOverflow ¶
func (*Node) GetPadding ¶
func (*Node) GetPositionType ¶
func (n *Node) GetPositionType() PositionType
func (*Node) GetProcessedDimension ¶
func (n *Node) GetProcessedDimension(dim Dimension) StyleSizeLength
func (*Node) GetRawHeight ¶
func (*Node) GetRawWidth ¶
func (*Node) GetResolvedDimension ¶
func (n *Node) GetResolvedDimension(dir Direction, dim Dimension, referenceLength, ownerWidth float32) FloatOptional
func (*Node) GetWidthValue ¶
func (*Node) HasBaselineFunc ¶
func (*Node) HasContentsChildren ¶
func (*Node) HasDefiniteLength ¶
func (*Node) HasLayoutableChildren ¶
func (*Node) HasMeasureFunc ¶
func (*Node) HasMinContentMeasureFunc ¶
func (*Node) InsertChild ¶
func (*Node) InsertChildNode ¶
InsertChildNode inserts a child node at the given index. Returns the parent node for chaining.
func (*Node) IsLayoutDimensionDefined ¶
func (n *Node) IsLayoutDimensionDefined(axis FlexDirection) bool
func (*Node) IsNodeFlexible ¶
func (*Node) IsReferenceBaseline ¶
func (*Node) LayoutOut ¶
LayoutOut returns the computed layout as a single convenience struct. Call this after CalculateNodeLayout to get position, dimensions, and box-model edges in one shot.
func (*Node) LayoutableSlice ¶
func (*Node) MarkDirty ¶
MarkDirty marks the node as dirty. Only valid for leaf nodes with measure functions.
func (*Node) MarkDirtyAndPropagate ¶
func (n *Node) MarkDirtyAndPropagate()
func (*Node) Measure ¶
func (n *Node) Measure(availableWidth float32, widthMode MeasureMode, availableHeight float32, heightMode MeasureMode) Size
func (*Node) MeasureMinContent ¶
func (n *Node) MeasureMinContent(availableWidth float32, widthMode MeasureMode, availableHeight float32, heightMode MeasureMode) Size
func (*Node) ProcessDimensions ¶
func (n *Node) ProcessDimensions()
func (*Node) ProcessFlexBasis ¶
func (n *Node) ProcessFlexBasis() StyleSizeLength
func (*Node) RelativePosition ¶
func (n *Node) RelativePosition(axis FlexDirection, dir Direction, axisSize float32) float32
func (*Node) RemoveAllChildren ¶
RemoveAllChildren removes all children from the node.
func (*Node) RemoveChild ¶
func (*Node) RemoveChildAt ¶
func (*Node) RemoveChildNode ¶
RemoveChildNode removes a child node. Returns the parent for chaining.
func (*Node) ReplaceChild ¶
func (*Node) ReplaceChildAt ¶
func (*Node) ResolveDirection ¶
func (*Node) ResolveFlexBasis ¶
func (n *Node) ResolveFlexBasis(dir Direction, flexDir FlexDirection, referenceLength, ownerWidth float32) FloatOptional
func (*Node) ResolveFlexGrow ¶
func (*Node) ResolveFlexShrink ¶
func (*Node) SetAlignContent ¶
func (*Node) SetAlignItems ¶
func (*Node) SetAlignSelf ¶
func (*Node) SetAlwaysFormsContainingBlock ¶
func (*Node) SetAspectRatio ¶
func (*Node) SetBaselineFunc ¶
func (n *Node) SetBaselineFunc(f BaselineFunc)
func (*Node) SetBoxSizing ¶
func (*Node) SetChildrenList ¶
SetChildrenList replaces all children with the given list.
func (*Node) SetClasses ¶
func (*Node) SetContext ¶
func (n *Node) SetContext(ctx interface{})
func (*Node) SetDirection ¶
func (*Node) SetDirtiedFunc ¶
func (n *Node) SetDirtiedFunc(f DirtiedFunc)
func (*Node) SetDisplay ¶
func (*Node) SetEdgePositionAuto ¶
func (*Node) SetEdgePositionPercent ¶
func (*Node) SetFlexBasis ¶
func (*Node) SetFlexBasisAuto ¶
func (*Node) SetFlexBasisFitContent ¶
func (*Node) SetFlexBasisMaxContent ¶
func (*Node) SetFlexBasisPercent ¶
func (*Node) SetFlexBasisStretch ¶
func (*Node) SetFlexDirection ¶
func (n *Node) SetFlexDirection(fd FlexDirection) *Node
func (*Node) SetFlexGrow ¶
func (*Node) SetFlexShrink ¶
func (*Node) SetFlexWrap ¶
func (*Node) SetFontSizeEstimate ¶
FontSizeEstimate controls how rem and em units are resolved in CSS strings. Default is 16. For em, uses the node's own estimate; for rem, walks up to the root node's estimate.
func (*Node) SetGridAutoColumn ¶
func (n *Node) SetGridAutoColumn(index int, trackType GridTrackType, value float32) *Node
func (*Node) SetGridAutoColumnMinMax ¶
func (n *Node) SetGridAutoColumnMinMax(index int, minType GridTrackType, minVal float32, maxType GridTrackType, maxVal float32) *Node
func (*Node) SetGridAutoColumnsCount ¶
func (*Node) SetGridAutoRow ¶
func (n *Node) SetGridAutoRow(index int, trackType GridTrackType, value float32) *Node
func (*Node) SetGridAutoRowMinMax ¶
func (n *Node) SetGridAutoRowMinMax(index int, minType GridTrackType, minVal float32, maxType GridTrackType, maxVal float32) *Node
func (*Node) SetGridAutoRowsCount ¶
func (*Node) SetGridColumnEnd ¶
func (*Node) SetGridColumnEndAuto ¶
func (*Node) SetGridColumnEndSpan ¶
func (*Node) SetGridColumnStart ¶
func (*Node) SetGridColumnStartAuto ¶
func (*Node) SetGridColumnStartSpan ¶
func (*Node) SetGridRowEnd ¶
func (*Node) SetGridRowEndAuto ¶
func (*Node) SetGridRowEndSpan ¶
func (*Node) SetGridRowStart ¶
func (*Node) SetGridRowStartAuto ¶
func (*Node) SetGridRowStartSpan ¶
func (*Node) SetGridTemplateColumn ¶
func (n *Node) SetGridTemplateColumn(index int, trackType GridTrackType, value float32) *Node
func (*Node) SetGridTemplateColumnMinMax ¶
func (n *Node) SetGridTemplateColumnMinMax(index int, minType GridTrackType, minVal float32, maxType GridTrackType, maxVal float32) *Node
func (*Node) SetGridTemplateColumnsCount ¶
func (*Node) SetGridTemplateRow ¶
func (n *Node) SetGridTemplateRow(index int, trackType GridTrackType, value float32) *Node
func (*Node) SetGridTemplateRowMinMax ¶
func (n *Node) SetGridTemplateRowMinMax(index int, minType GridTrackType, minVal float32, maxType GridTrackType, maxVal float32) *Node
func (*Node) SetGridTemplateRowsCount ¶
func (*Node) SetHasNewLayout ¶
func (*Node) SetHeightAuto ¶
func (*Node) SetHeightFitContent ¶
func (*Node) SetHeightMaxContent ¶
func (*Node) SetHeightPercent ¶
func (*Node) SetHeightStretch ¶
func (*Node) SetIsReferenceBaseline ¶
func (*Node) SetIsReferenceBaseline_Public ¶
func (*Node) SetJustifyContent ¶
func (*Node) SetJustifyItems ¶
func (*Node) SetJustifySelf ¶
func (*Node) SetLayout ¶
func (n *Node) SetLayout(l LayoutResults)
func (*Node) SetLayoutBorder ¶
func (n *Node) SetLayoutBorder(v float32, edge PhysicalEdge)
func (*Node) SetLayoutComputedFlexBasis ¶
func (n *Node) SetLayoutComputedFlexBasis(fb FloatOptional)
func (*Node) SetLayoutComputedFlexBasisGeneration ¶
func (*Node) SetLayoutDimension ¶
func (*Node) SetLayoutDirection ¶
func (*Node) SetLayoutHadOverflow ¶
func (*Node) SetLayoutLastOwnerDirection ¶
func (*Node) SetLayoutMargin ¶
func (n *Node) SetLayoutMargin(v float32, edge PhysicalEdge)
func (*Node) SetLayoutMeasuredDimension ¶
func (*Node) SetLayoutPadding ¶
func (n *Node) SetLayoutPadding(v float32, edge PhysicalEdge)
func (*Node) SetLayoutPosition ¶
func (n *Node) SetLayoutPosition(v float32, edge PhysicalEdge)
func (*Node) SetLineIndex ¶
func (*Node) SetMarginAuto ¶
func (*Node) SetMaxHeight ¶
func (*Node) SetMaxHeightFitContent ¶
func (*Node) SetMaxHeightMaxContent ¶
func (*Node) SetMaxHeightPercent ¶
func (*Node) SetMaxHeightStretch ¶
func (*Node) SetMaxWidth ¶
func (*Node) SetMaxWidthFitContent ¶
func (*Node) SetMaxWidthMaxContent ¶
func (*Node) SetMaxWidthPercent ¶
func (*Node) SetMaxWidthStretch ¶
func (*Node) SetMeasureFunc ¶
func (n *Node) SetMeasureFunc(f MeasureFunc)
func (*Node) SetMinContentHeight ¶
func (n *Node) SetMinContentHeight(v FloatOptional)
func (*Node) SetMinContentHeightValue ¶
func (*Node) SetMinContentMeasureFunc ¶
func (n *Node) SetMinContentMeasureFunc(f MeasureFunc)
func (*Node) SetMinContentWidth ¶
func (n *Node) SetMinContentWidth(v FloatOptional)
func (*Node) SetMinContentWidthFunc ¶
func (n *Node) SetMinContentWidthFunc(f MeasureFunc) *Node
func (*Node) SetMinContentWidthValue ¶
func (*Node) SetMinHeight ¶
func (*Node) SetMinHeightFitContent ¶
func (*Node) SetMinHeightMaxContent ¶
func (*Node) SetMinHeightPercent ¶
func (*Node) SetMinHeightStretch ¶
func (*Node) SetMinWidth ¶
func (*Node) SetMinWidthFitContent ¶
func (*Node) SetMinWidthMaxContent ¶
func (*Node) SetMinWidthPercent ¶
func (*Node) SetMinWidthStretch ¶
func (*Node) SetNodeType ¶
func (*Node) SetNodeType_Public ¶
Convenience methods.
func (*Node) SetOverflow ¶
func (*Node) SetPosition ¶
func (*Node) SetPositionType ¶
func (n *Node) SetPositionType(p PositionType) *Node
func (*Node) SetWidthAuto ¶
func (*Node) SetWidthFitContent ¶
func (*Node) SetWidthMaxContent ¶
func (*Node) SetWidthPercent ¶
func (*Node) SetWidthStretch ¶
type PhysicalEdge ¶
type PhysicalEdge int
PhysicalEdge represents a fixed physical edge (not logical).
const ( PhysicalEdgeLeft PhysicalEdge = iota PhysicalEdgeTop PhysicalEdgeRight PhysicalEdgeBottom )
type PositionType ¶
type PositionType int
PositionType represents the CSS position property.
const ( PositionTypeStatic PositionType = iota PositionTypeRelative PositionTypeAbsolute )
func (PositionType) String ¶
func (p PositionType) String() string
type Rect ¶
type Rect struct {
Left float32
Top float32
Right float32
Bottom float32
Width float32
Height float32
}
Rect holds the computed position and size of a laid-out node. These values are only meaningful after CalculateNodeLayout is called.
type SizingMode ¶
type SizingMode int
SizingMode controls how dimensions are resolved during layout.
const ( SizingModeStretchFit SizingMode = iota SizingModeMaxContent SizingModeFitContent )
type Style ¶
type Style struct {
// contains filtered or unexported fields
}
Style holds all CSS properties for a single Node.
func (*Style) AlignContent ¶
func (*Style) AlignItems ¶
func (*Style) AspectRatio ¶
func (s *Style) AspectRatio() FloatOptional
func (*Style) Border ¶
func (s *Style) Border(edge Edge) StyleLength
func (*Style) ComputeBorderForAxis ¶
func (s *Style) ComputeBorderForAxis(axis FlexDirection) float32
func (*Style) ComputeFlexEndBorder ¶
func (s *Style) ComputeFlexEndBorder(axis FlexDirection, dir Direction) float32
func (*Style) ComputeFlexEndMargin ¶
func (s *Style) ComputeFlexEndMargin(axis FlexDirection, dir Direction, widthSize float32) float32
func (*Style) ComputeFlexEndPadding ¶
func (s *Style) ComputeFlexEndPadding(axis FlexDirection, dir Direction, widthSize float32) float32
func (*Style) ComputeFlexEndPaddingAndBorder ¶
func (s *Style) ComputeFlexEndPaddingAndBorder(axis FlexDirection, dir Direction, widthSize float32) float32
func (*Style) ComputeFlexEndPosition ¶
func (s *Style) ComputeFlexEndPosition(axis FlexDirection, dir Direction, axisSize float32) float32
func (*Style) ComputeFlexStartBorder ¶
func (s *Style) ComputeFlexStartBorder(axis FlexDirection, dir Direction) float32
Border helpers
func (*Style) ComputeFlexStartMargin ¶
func (s *Style) ComputeFlexStartMargin(axis FlexDirection, dir Direction, widthSize float32) float32
Margin helpers
func (*Style) ComputeFlexStartPadding ¶
func (s *Style) ComputeFlexStartPadding(axis FlexDirection, dir Direction, widthSize float32) float32
Padding helpers
func (*Style) ComputeFlexStartPaddingAndBorder ¶
func (s *Style) ComputeFlexStartPaddingAndBorder(axis FlexDirection, dir Direction, widthSize float32) float32
func (*Style) ComputeFlexStartPosition ¶
func (s *Style) ComputeFlexStartPosition(axis FlexDirection, dir Direction, axisSize float32) float32
func (*Style) ComputeGapForAxis ¶
func (s *Style) ComputeGapForAxis(axis FlexDirection, ownerSize float32) float32
func (*Style) ComputeGapForDimension ¶
func (*Style) ComputeInlineEndBorder ¶
func (s *Style) ComputeInlineEndBorder(axis FlexDirection, dir Direction) float32
func (*Style) ComputeInlineEndMargin ¶
func (s *Style) ComputeInlineEndMargin(axis FlexDirection, dir Direction, widthSize float32) float32
func (*Style) ComputeInlineEndPadding ¶
func (s *Style) ComputeInlineEndPadding(axis FlexDirection, dir Direction, widthSize float32) float32
func (*Style) ComputeInlineEndPaddingAndBorder ¶
func (s *Style) ComputeInlineEndPaddingAndBorder(axis FlexDirection, dir Direction, widthSize float32) float32
func (*Style) ComputeInlineEndPosition ¶
func (s *Style) ComputeInlineEndPosition(axis FlexDirection, dir Direction, axisSize float32) float32
func (*Style) ComputeInlineStartBorder ¶
func (s *Style) ComputeInlineStartBorder(axis FlexDirection, dir Direction) float32
func (*Style) ComputeInlineStartMargin ¶
func (s *Style) ComputeInlineStartMargin(axis FlexDirection, dir Direction, widthSize float32) float32
func (*Style) ComputeInlineStartPadding ¶
func (s *Style) ComputeInlineStartPadding(axis FlexDirection, dir Direction, widthSize float32) float32
func (*Style) ComputeInlineStartPaddingAndBorder ¶
func (s *Style) ComputeInlineStartPaddingAndBorder(axis FlexDirection, dir Direction, widthSize float32) float32
func (*Style) ComputeInlineStartPosition ¶
func (s *Style) ComputeInlineStartPosition(axis FlexDirection, dir Direction, axisSize float32) float32
func (*Style) ComputeMarginForAxis ¶
func (s *Style) ComputeMarginForAxis(axis FlexDirection, widthSize float32) float32
func (*Style) ComputePaddingAndBorderForDimension ¶
func (*Style) Dimension ¶
func (s *Style) Dimension(axis Dimension) StyleSizeLength
func (*Style) Flex ¶
func (s *Style) Flex() FloatOptional
func (*Style) FlexBasis ¶
func (s *Style) FlexBasis() StyleSizeLength
func (*Style) FlexDirection ¶
func (s *Style) FlexDirection() FlexDirection
func (*Style) FlexEndMarginIsAuto ¶
func (s *Style) FlexEndMarginIsAuto(axis FlexDirection, dir Direction) bool
func (*Style) FlexGrow ¶
func (s *Style) FlexGrow() FloatOptional
func (*Style) FlexShrink ¶
func (s *Style) FlexShrink() FloatOptional
func (*Style) FlexStartMarginIsAuto ¶
func (s *Style) FlexStartMarginIsAuto(axis FlexDirection, dir Direction) bool
func (*Style) Gap ¶
func (s *Style) Gap(gutter Gutter) StyleLength
func (*Style) GridAutoColumns ¶
func (s *Style) GridAutoColumns() GridTrackList
func (*Style) GridAutoRows ¶
func (s *Style) GridAutoRows() GridTrackList
func (*Style) GridColumnEnd ¶
func (*Style) GridRowEnd ¶
func (*Style) GridRowStart ¶
func (*Style) GridTemplateColumns ¶
func (s *Style) GridTemplateColumns() GridTrackList
Grid container properties
func (*Style) GridTemplateRows ¶
func (s *Style) GridTemplateRows() GridTrackList
func (*Style) HorizontalInsetsDefined ¶
func (*Style) InlineEndMarginIsAuto ¶
func (s *Style) InlineEndMarginIsAuto(axis FlexDirection, dir Direction) bool
func (*Style) InlineStartMarginIsAuto ¶
func (s *Style) InlineStartMarginIsAuto(axis FlexDirection, dir Direction) bool
func (*Style) IsFlexEndPositionAuto ¶
func (s *Style) IsFlexEndPositionAuto(axis FlexDirection, dir Direction) bool
func (*Style) IsFlexEndPositionDefined ¶
func (s *Style) IsFlexEndPositionDefined(axis FlexDirection, dir Direction) bool
func (*Style) IsFlexStartPositionAuto ¶
func (s *Style) IsFlexStartPositionAuto(axis FlexDirection, dir Direction) bool
func (*Style) IsFlexStartPositionDefined ¶
func (s *Style) IsFlexStartPositionDefined(axis FlexDirection, dir Direction) bool
func (*Style) IsInlineEndPositionAuto ¶
func (s *Style) IsInlineEndPositionAuto(axis FlexDirection, dir Direction) bool
func (*Style) IsInlineEndPositionDefined ¶
func (s *Style) IsInlineEndPositionDefined(axis FlexDirection, dir Direction) bool
func (*Style) IsInlineStartPositionAuto ¶
func (s *Style) IsInlineStartPositionAuto(axis FlexDirection, dir Direction) bool
func (*Style) IsInlineStartPositionDefined ¶
func (s *Style) IsInlineStartPositionDefined(axis FlexDirection, dir Direction) bool
func (*Style) JustifyContent ¶
func (*Style) JustifyItems ¶
func (*Style) JustifySelf ¶
func (*Style) Margin ¶
func (s *Style) Margin(edge Edge) StyleLength
func (*Style) MaxDimension ¶
func (s *Style) MaxDimension(axis Dimension) StyleSizeLength
func (*Style) MinDimension ¶
func (s *Style) MinDimension(axis Dimension) StyleSizeLength
func (*Style) Padding ¶
func (s *Style) Padding(edge Edge) StyleLength
func (*Style) Position ¶
func (s *Style) Position(edge Edge) StyleLength
func (*Style) PositionType ¶
func (s *Style) PositionType() PositionType
func (*Style) ResizeGridAutoColumns ¶
func (*Style) ResizeGridAutoRows ¶
func (*Style) ResizeGridTemplateColumns ¶
func (*Style) ResizeGridTemplateRows ¶
func (*Style) ResolvedMaxDimension ¶
func (s *Style) ResolvedMaxDimension(direction Direction, axis Dimension, referenceLength, ownerWidth float32) FloatOptional
ResolvedMaxDimension returns the resolved maximum size for the given axis.
func (*Style) ResolvedMinDimension ¶
func (s *Style) ResolvedMinDimension(direction Direction, axis Dimension, referenceLength, ownerWidth float32) FloatOptional
ResolvedMinDimension returns the resolved minimum size for the given axis.
func (*Style) SetAlignContent ¶
func (*Style) SetAlignItems ¶
func (*Style) SetAlignSelf ¶
func (*Style) SetAspectRatio ¶
func (s *Style) SetAspectRatio(v FloatOptional)
func (*Style) SetBorder ¶
func (s *Style) SetBorder(edge Edge, v StyleLength)
func (*Style) SetBoxSizing ¶
func (*Style) SetDimension ¶
func (s *Style) SetDimension(axis Dimension, v StyleSizeLength)
func (*Style) SetDirection ¶
func (*Style) SetDisplay ¶
func (*Style) SetFlex ¶
func (s *Style) SetFlex(v FloatOptional)
func (*Style) SetFlexBasis ¶
func (s *Style) SetFlexBasis(v StyleSizeLength)
func (*Style) SetFlexDirection ¶
func (s *Style) SetFlexDirection(v FlexDirection)
func (*Style) SetFlexGrow ¶
func (s *Style) SetFlexGrow(v FloatOptional)
func (*Style) SetFlexShrink ¶
func (s *Style) SetFlexShrink(v FloatOptional)
func (*Style) SetFlexWrap ¶
func (*Style) SetGap ¶
func (s *Style) SetGap(gutter Gutter, v StyleLength)
func (*Style) SetGridAutoColumnAt ¶
func (s *Style) SetGridAutoColumnAt(index int, v GridTrackSize)
func (*Style) SetGridAutoColumns ¶
func (s *Style) SetGridAutoColumns(v GridTrackList)
func (*Style) SetGridAutoRowAt ¶
func (s *Style) SetGridAutoRowAt(index int, v GridTrackSize)
func (*Style) SetGridAutoRows ¶
func (s *Style) SetGridAutoRows(v GridTrackList)
func (*Style) SetGridColumnEnd ¶
func (*Style) SetGridColumnStart ¶
func (*Style) SetGridRowEnd ¶
func (*Style) SetGridRowStart ¶
func (*Style) SetGridTemplateColumnAt ¶
func (s *Style) SetGridTemplateColumnAt(index int, v GridTrackSize)
func (*Style) SetGridTemplateColumns ¶
func (s *Style) SetGridTemplateColumns(v GridTrackList)
func (*Style) SetGridTemplateRowAt ¶
func (s *Style) SetGridTemplateRowAt(index int, v GridTrackSize)
func (*Style) SetGridTemplateRows ¶
func (s *Style) SetGridTemplateRows(v GridTrackList)
func (*Style) SetJustifyContent ¶
func (*Style) SetJustifyItems ¶
func (*Style) SetJustifySelf ¶
func (*Style) SetMargin ¶
func (s *Style) SetMargin(edge Edge, v StyleLength)
func (*Style) SetMaxDimension ¶
func (s *Style) SetMaxDimension(axis Dimension, v StyleSizeLength)
func (*Style) SetMinDimension ¶
func (s *Style) SetMinDimension(axis Dimension, v StyleSizeLength)
func (*Style) SetOverflow ¶
func (*Style) SetPadding ¶
func (s *Style) SetPadding(edge Edge, v StyleLength)
func (*Style) SetPosition ¶
func (s *Style) SetPosition(edge Edge, v StyleLength)
func (*Style) SetPositionType ¶
func (s *Style) SetPositionType(v PositionType)
func (*Style) VerticalInsetsDefined ¶
type StyleLength ¶
type StyleLength struct {
// contains filtered or unexported fields
}
StyleLength represents a CSS length value (for margins, padding, borders, positions). It supports point, percent, auto, and undefined units.
func StyleLengthAuto ¶
func StyleLengthAuto() StyleLength
func StyleLengthPercent ¶
func StyleLengthPercent(v float32) StyleLength
func StyleLengthPoints ¶
func StyleLengthPoints(v float32) StyleLength
func StyleLengthUndefined ¶
func StyleLengthUndefined() StyleLength
func (StyleLength) IsAuto ¶
func (l StyleLength) IsAuto() bool
func (StyleLength) IsDefined ¶
func (l StyleLength) IsDefined() bool
func (StyleLength) IsPercent ¶
func (l StyleLength) IsPercent() bool
func (StyleLength) IsPoints ¶
func (l StyleLength) IsPoints() bool
func (StyleLength) IsUndefined ¶
func (l StyleLength) IsUndefined() bool
func (StyleLength) Resolve ¶
func (l StyleLength) Resolve(referenceLength float32) FloatOptional
func (StyleLength) ToValue ¶
func (l StyleLength) ToValue() Value
func (StyleLength) Value ¶
func (l StyleLength) Value() FloatOptional
type StyleSizeLength ¶
type StyleSizeLength struct {
// contains filtered or unexported fields
}
StyleSizeLength represents a CSS size value for dimensions (width, height, flex-basis). It supports all units including max-content, fit-content, and stretch.
func StyleSizeLengthAuto ¶
func StyleSizeLengthAuto() StyleSizeLength
func StyleSizeLengthFitContent ¶
func StyleSizeLengthFitContent() StyleSizeLength
func StyleSizeLengthMaxContent ¶
func StyleSizeLengthMaxContent() StyleSizeLength
func StyleSizeLengthOfStretch ¶
func StyleSizeLengthOfStretch() StyleSizeLength
func StyleSizeLengthPercent ¶
func StyleSizeLengthPercent(v float32) StyleSizeLength
func StyleSizeLengthPoints ¶
func StyleSizeLengthPoints(v float32) StyleSizeLength
func StyleSizeLengthStretch ¶
func StyleSizeLengthStretch(fraction float32) StyleSizeLength
func StyleSizeLengthUndefined ¶
func StyleSizeLengthUndefined() StyleSizeLength
func (StyleSizeLength) Equals ¶
func (l StyleSizeLength) Equals(other StyleSizeLength) bool
func (StyleSizeLength) IsAuto ¶
func (l StyleSizeLength) IsAuto() bool
func (StyleSizeLength) IsDefined ¶
func (l StyleSizeLength) IsDefined() bool
func (StyleSizeLength) IsFitContent ¶
func (l StyleSizeLength) IsFitContent() bool
func (StyleSizeLength) IsMaxContent ¶
func (l StyleSizeLength) IsMaxContent() bool
func (StyleSizeLength) IsPercent ¶
func (l StyleSizeLength) IsPercent() bool
func (StyleSizeLength) IsPoints ¶
func (l StyleSizeLength) IsPoints() bool
func (StyleSizeLength) IsStretch ¶
func (l StyleSizeLength) IsStretch() bool
func (StyleSizeLength) IsUndefined ¶
func (l StyleSizeLength) IsUndefined() bool
func (StyleSizeLength) Resolve ¶
func (l StyleSizeLength) Resolve(referenceLength float32) FloatOptional
func (StyleSizeLength) ToValue ¶
func (l StyleSizeLength) ToValue() Value
func (StyleSizeLength) Value ¶
func (l StyleSizeLength) Value() FloatOptional
Source Files
¶
- absolute.go
- align.go
- api.go
- api_css.go
- api_grid.go
- api_layout.go
- api_node.go
- api_style.go
- baseline.go
- cache.go
- compare.go
- config.go
- distribute.go
- doc.go
- engine.go
- flex.go
- flexbasis.go
- flexline.go
- grid_types.go
- iterator.go
- justify.go
- layout.go
- log.go
- measure.go
- node.go
- pixelgrid.go
- render.go
- style.go
- stylelen.go
- trailing.go
- types.go
- value.go



