layout

package
v0.0.46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerNode

type ContainerNode struct {
	Children []Node
	BgColor  fltk_bridge.Color
	Padding  int
	Spacing  int

	IsHorizontal bool
	// contains filtered or unexported fields
}

ContainerNode holds multiple child nodes and manages their layout.

func NewContainerNode

func NewContainerNode() *ContainerNode

func (*ContainerNode) AddChild

func (c *ContainerNode) AddChild(node Node)

func (*ContainerNode) Bounds

func (c *ContainerNode) Bounds() Rect

func (*ContainerNode) Draw

func (c *ContainerNode) Draw(viewport Rect)

func (*ContainerNode) Layout

func (c *ContainerNode) Layout(x, y int)

func (*ContainerNode) Measure

func (c *ContainerNode) Measure(maxWidth int) (int, int)

type Engine

type Engine struct {
	Root Node
}

Engine acts as the top-level renderer for a Virtual Layout Tree.

func NewEngine

func NewEngine(root Node) *Engine

func (*Engine) Render

func (e *Engine) Render(viewport Rect)

Render recalculates bounds if needed and draws only the nodes within the viewport. Uses FLTK's PushClip and PopClip for hardware-level dirty rect culling.

type LayoutView

type LayoutView struct {
	// contains filtered or unexported fields
}

LayoutView wraps an Engine into a standard Viewable component, so it can receive events via On() and be added via AddSubview().

func NewLayoutView

func NewLayoutView(x, y, w, h int, engine *Engine) *LayoutView

NewLayoutView creates a LayoutView.

func (*LayoutView) On

func (lv *LayoutView) On(event fltk_bridge.Event, handler func(fltk_bridge.Event) bool)

On delegates event binding to the underlying UIView

func (*LayoutView) Raw

func (lv *LayoutView) Raw() fltk_bridge.Widget

func (*LayoutView) View

func (lv *LayoutView) View() *view.UIView

type Node

type Node interface {
	Measure(maxWidth int) (int, int)
	Layout(x, y int)
	Draw(viewport Rect)
	Bounds() Rect
}

Node is an element in the Virtual Layout Tree. It decouples Measure, Layout, and Draw phases for high performance.

type Rect

type Rect struct {
	X, Y, W, H int
}

Rect represents a bounding box in 2D space.

func (Rect) Intersects

func (r Rect) Intersects(other Rect) bool

Intersects checks if two rectangles overlap.

type TextNode

type TextNode struct {
	Text       string
	Font       fltk_bridge.Font
	FontSize   int
	Color      fltk_bridge.Color
	Align      fltk_bridge.Align
	LineHeight int
	// contains filtered or unexported fields
}

TextNode is a leaf node that renders text using cached text segments.

func NewTextNode

func NewTextNode(text string, font fltk_bridge.Font, fontSize int, color fltk_bridge.Color) *TextNode

func (*TextNode) Bounds

func (n *TextNode) Bounds() Rect

func (*TextNode) Draw

func (n *TextNode) Draw(viewport Rect)

func (*TextNode) Layout

func (n *TextNode) Layout(x, y int)

func (*TextNode) Measure

func (n *TextNode) Measure(maxWidth int) (int, int)

type ViewNode

type ViewNode struct {
	View view.Viewable

	// Optional fixed size constraints. If 0, it uses the widget's current size.
	FixedWidth  int
	FixedHeight int
	// contains filtered or unexported fields
}

ViewNode is a leaf node that wraps an existing Viewable component. It manages the position and size of the underlying FLTK widget during layout.

func NewViewNode

func NewViewNode(v view.Viewable, w, h int) *ViewNode

func (*ViewNode) Bounds

func (n *ViewNode) Bounds() Rect

func (*ViewNode) Draw

func (n *ViewNode) Draw(viewport Rect)

func (*ViewNode) Layout

func (n *ViewNode) Layout(x, y int)

func (*ViewNode) Measure

func (n *ViewNode) Measure(maxWidth int) (int, int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL