Skip to content

package ui

import "kaijuengine.com/engine/ui"

Constants

EventTypeInvalid

EventType(iota)

EventTypeEnter

EventTypeMove

EventTypeExit

EventTypeClick

EventTypeRightClick

EventTypeDoubleClick

EventTypeDown

EventTypeUp

EventTypeRightDown

EventTypeRightUp

EventTypeMiss

EventTypeDragStart

EventTypeDrop

EventTypeDropEnter

EventTypeDropExit

EventTypeDragEnd

EventTypeScroll

EventTypeRebuild

EventTypeDestroy

EventTypeFocus

EventTypeBlur

EventTypeSubmit

EventTypeChange

EventTypeRender

EventTypeKeyDown

EventTypeKeyUp

EventTypeEnd

InputTypeDefault

iota

InputTypeText

InputTypeNumber

InputTypePhone

InputTypeDatetime

InputTypeEmail

InputTypePassword

PositioningStatic

Positioning(iota)

PositioningAbsolute

PositioningFixed

PositioningRelative

PositioningSticky

FlexAlignAuto

FlexAlign(iota)

FlexAlignStart

FlexAlignEnd

FlexAlignCenter

FlexAlignStretch

PanelScrollDirectionNone

0x00

PanelScrollDirectionVertical

0x01

PanelScrollDirectionHorizontal

0x02

PanelScrollDirectionBoth

0x03

BorderStyleNone

iota

BorderStyleHidden

BorderStyleDotted

BorderStyleDashed

BorderStyleSolid

BorderStyleDouble

BorderStyleGroove

BorderStyleRidge

BorderStyleInset

BorderStyleOutset

ContentFitNone

iota

ContentFitWidth

ContentFitHeight

ContentFitBoth

OverflowScroll

iota

OverflowVisible

OverflowHidden

LayoutModeFlow

LayoutMode(iota)

LayoutModeGrid

LayoutModeFlex

FlexDirectionRow

FlexDirection(iota)

FlexDirectionRowReverse

FlexDirectionColumn

FlexDirectionColumnReverse

FlexWrapNoWrap

FlexWrap(iota)

FlexWrapWrap

FlexWrapWrapReverse

FlexJustifyStart

FlexJustify(iota)

FlexJustifyEnd

FlexJustifyCenter

FlexJustifySpaceBetween

FlexJustifySpaceAround

FlexJustifySpaceEvenly

FlexAlignContentStart

FlexAlignContent(iota)

FlexAlignContentEnd

FlexAlignContentCenter

FlexAlignContentStretch

FlexAlignContentSpaceBetween

FlexAlignContentSpaceAround

FlexAlignContentSpaceEvenly

DirtyTypeNone

iota

DirtyTypeLayout

DirtyTypeResize

DirtyTypeGenerated

DirtyTypeColorChange

DirtyTypeScissor

DirtyTypeParent

DirtyTypeParentLayout

DirtyTypeParentResize

DirtyTypeParentGenerated

DirtyTypeParentReGenerated

DirtyTypeParentColorChange

DirtyTypeParentScissor

ElementTypeLabel

ElementType(iota)

ElementTypePanel

ElementTypeButton

ElementTypeCheckbox

ElementTypeImage

ElementTypeInput

ElementTypeProgressBar

ElementTypeSelect

ElementTypeSlider

ElementTypeTextArea

ElementTypeVirtualList

EntityDataName

"ui"

LabelFontSize

14.0

Variables

Types

BasicStylizer

struct

type BasicStylizer struct {
    Parent weak.Pointer[UI]
}

BorderStyle

int32

type BorderStyle = int32

Button

Panel

type Button Panel

Button.Base

func (b *Button) Base() *UI

Button.ButtonData

func (b *Button) ButtonData() *buttonData

Button.Init

func (b *Button) Init(texture *rendering.Texture, text string)

Button.IsDisabled

func (b *Button) IsDisabled() bool

Button.Label

func (b *Button) Label() *Label

Button.SetColor

func (b *Button) SetColor(color matrix.Color)

Button.SetDisabled

func (b *Button) SetDisabled(disabled bool)

Checkbox

Panel

type Checkbox Panel

Checkbox.Base

func (cb *Checkbox) Base() *UI

Checkbox.CheckboxData

func (cb *Checkbox) CheckboxData() *checkboxData

Checkbox.Init

func (cb *Checkbox) Init()

Checkbox.IsChecked

func (cb *Checkbox) IsChecked() bool

Checkbox.IsDisabled

func (cb *Checkbox) IsDisabled() bool

Checkbox.SetChecked

func (cb *Checkbox) SetChecked(isChecked bool)

Checkbox.SetCheckedWithoutEvent

func (cb *Checkbox) SetCheckedWithoutEvent(isChecked bool)

Checkbox.SetDisabled

func (cb *Checkbox) SetDisabled(disabled bool)

ContentFit

int32

type ContentFit = int32

DirtyType

int

type DirtyType = int

ElementType

uint8

type ElementType = uint8

EventType

int

type EventType = int

FlexAlign

int

type FlexAlign = int

FlexAlignContent

int

type FlexAlignContent = int

FlexDirection

int

type FlexDirection = int

FlexJustify

int

type FlexJustify = int

FlexWrap

int

type FlexWrap = int

Group

struct

type Group struct {
    // Has unexported fields.
}

Group.Attach

func (group *Group) Attach(host *engine.Host)

Group.Detach

func (group *Group) Detach(host *engine.Host)

Group.HasRequests

func (group *Group) HasRequests() bool

Group.IsFocusedOnInput

func (group *Group) IsFocusedOnInput() bool

Group.SetThreaded

func (g *Group) SetThreaded()

Image

Panel

type Image Panel

Image.Base

func (s *Image) Base() *UI

Image.Frame

func (img *Image) Frame() int

Image.ImageData

func (s *Image) ImageData() *imageData

Image.Init

func (s *Image) Init(texture *rendering.Texture)

Image.InitFlipbook

func (s *Image) InitFlipbook(framesPerSecond float32, textures []*rendering.Texture)

Image.InitSpriteSheet

func (s *Image) InitSpriteSheet(framesPerSecond float32, texture *rendering.Texture, jsonStr string)

Image.PlayAnimation

func (img *Image) PlayAnimation()

Image.SetFlipBookAnimation

func (img *Image) SetFlipBookAnimation(framesPerSecond float32, textures ...*rendering.Texture)

Image.SetFrame

func (img *Image) SetFrame(index int)

Image.SetFrameRate

func (img *Image) SetFrameRate(framesPerSecond float32)

Image.SetSpriteSheet

func (img *Image) SetSpriteSheet(framesPerSecond float32, texture *rendering.Texture, jsonStr string)

Image.SetTexture

func (img *Image) SetTexture(texture *rendering.Texture)

Image.StopAnimation

func (img *Image) StopAnimation()

Input

Panel

type Input Panel

Input.Base

func (input *Input) Base() *UI

Input.Focus

func (input *Input) Focus()

Input.FontFace

func (input *Input) FontFace() rendering.FontFace

Input.FontSize

func (input *Input) FontSize() float32

Input.Init

func (input *Input) Init(placeholderText string)

Input.InputData

func (input *Input) InputData() *inputData

Input.InsertText

func (input *Input) InsertText(text string)

Input.IsDisabled

func (input *Input) IsDisabled() bool

Input.IsFocused

func (input *Input) IsFocused() bool

Input.IsRequired

func (input *Input) IsRequired() bool

Input.IsValid

func (input *Input) IsValid() bool

Input.RemoveFocus

func (input *Input) RemoveFocus()

Input.SelectAll

func (input *Input) SelectAll()

Input.SetBGColor

func (input *Input) SetBGColor(newColor matrix.Color)

Input.SetCursorColor

func (input *Input) SetCursorColor(newColor matrix.Color)

Input.SetCursorOffset

func (input *Input) SetCursorOffset(offset int)

Input.SetDescription

func (input *Input) SetDescription(text string)

Input.SetDisabled

func (input *Input) SetDisabled(disabled bool)

Input.SetFGColor

func (input *Input) SetFGColor(newColor matrix.Color)

Input.SetFontFace

func (input *Input) SetFontFace(face rendering.FontFace)

Input.SetFontSize

func (input *Input) SetFontSize(fontSize float32)

Input.SetFontStyle

func (input *Input) SetFontStyle(style string)

Input.SetFontWeight

func (input *Input) SetFontWeight(weight string)

Input.SetLineHeight

func (input *Input) SetLineHeight(lineHeight float32)

Input.SetNextFocusedElement

func (input *Input) SetNextFocusedElement(next *UI)

Input.SetNextFocusedInput

func (input *Input) SetNextFocusedInput(next *Input)

Input.SetPlaceholder

func (input *Input) SetPlaceholder(text string)

Input.SetRequired

func (input *Input) SetRequired(required bool)

Input.SetSelectColor

func (input *Input) SetSelectColor(newColor matrix.Color)

Input.SetText

func (input *Input) SetText(text string)

Input.SetTextWithoutEvent

func (input *Input) SetTextWithoutEvent(text string)

Input.SetTitle

func (input *Input) SetTitle(text string)

Input.SetType

func (input *Input) SetType(inputType InputType)

Input.SetWrap

func (input *Input) SetWrap(wrap bool)

Input.Text

func (input *Input) Text() string

InputType

int32

type InputType = int32

Label

UI

type Label UI

Label.Base

func (l *Label) Base() *UI

Label.BoldRange

func (label *Label) BoldRange(start, end int)

Label.CalculateMaxWidth

func (label *Label) CalculateMaxWidth() float32

Label.ClearColorRanges

func (label *Label) ClearColorRanges()

ClearColorRanges drops every persisted color range overlay on this label and re-runs the base color pass. Use this when a consumer wants to wipe all overlays without changing the underlying text.

Label.Clone

func (label *Label) Clone(to *Label)

Label.ColorRange

func (label *Label) ColorRange(start, end int, newColor, bgColor matrix.Color)

Label.EnforceBGColor

func (label *Label) EnforceBGColor(color matrix.Color)

Label.EnforceFGColor

func (label *Label) EnforceFGColor(color matrix.Color)

Label.FontFace

func (label *Label) FontFace() rendering.FontFace

Label.FontSize

func (label *Label) FontSize() float32

Label.Hide

func (label *Label) Hide()

Label.Init

func (label *Label) Init(text string)

Label.Justify

func (label *Label) Justify() rendering.FontJustify

Label.LabelData

func (l *Label) LabelData() *labelData

Label.LetterSpacing

func (label *Label) LetterSpacing() float32

Label.LineHeight

func (label *Label) LineHeight() float32

Label.MaxWidth

func (label *Label) MaxWidth() float32

Label.Measure

func (label *Label) Measure() matrix.Vec2

Label.SetBGColor

func (label *Label) SetBGColor(newColor matrix.Color)

Label.SetBaseline

func (label *Label) SetBaseline(baseline rendering.FontBaseline)

Label.SetColor

func (label *Label) SetColor(newColor matrix.Color)

Label.SetFontFace

func (label *Label) SetFontFace(face rendering.FontFace)

Label.SetFontSize

func (label *Label) SetFontSize(size float32)

Label.SetFontStyle

func (label *Label) SetFontStyle(style string)

Label.SetFontWeight

func (label *Label) SetFontWeight(weight string)

Label.SetJustify

func (label *Label) SetJustify(justify rendering.FontJustify)

Label.SetLetterSpacing

func (label *Label) SetLetterSpacing(spacing float32)

Label.SetLineHeight

func (label *Label) SetLineHeight(height float32)

Label.SetMaxWidth

func (label *Label) SetMaxWidth(maxWidth float32)

Label.SetText

func (label *Label) SetText(text string)

Label.SetWidthAutoHeight

func (label *Label) SetWidthAutoHeight(width float32)

Label.SetWrap

func (label *Label) SetWrap(wrapText bool)

Label.Show

func (label *Label) Show()

Label.Text

func (label *Label) Text() string

Label.UnEnforceBGColor

func (label *Label) UnEnforceBGColor()

Label.UnEnforceFGColor

func (label *Label) UnEnforceFGColor()

Layout

struct

type Layout struct {
    Stylizer LayoutStylizer
    // Has unexported fields.
}

Layout.AlignSelf

func (l *Layout) AlignSelf() FlexAlign

Layout.Border

func (l *Layout) Border() matrix.Vec4

Layout.CalcOffset

func (l *Layout) CalcOffset() matrix.Vec2

Layout.ClearStyles

func (l *Layout) ClearStyles()

Layout.ContentSize

func (l *Layout) ContentSize() matrix.Vec2

Layout.FlexBasis

func (l *Layout) FlexBasis() float32

Layout.FlexBasisAuto

func (l *Layout) FlexBasisAuto() bool

Layout.FlexBasisPercent

func (l *Layout) FlexBasisPercent() bool

Layout.FlexGrow

func (l *Layout) FlexGrow() float32

Layout.FlexOrder

func (l *Layout) FlexOrder() int

Layout.FlexShrink

func (l *Layout) FlexShrink() float32

Layout.GridColumnEnd

func (l *Layout) GridColumnEnd() int

Layout.GridColumnStart

func (l *Layout) GridColumnStart() int

Layout.GridRowEnd

func (l *Layout) GridRowEnd() int

Layout.GridRowStart

func (l *Layout) GridRowStart() int

Layout.InnerOffset

func (l *Layout) InnerOffset() matrix.Vec4

Layout.LocalInnerOffset

func (l *Layout) LocalInnerOffset() matrix.Vec4

Layout.Margin

func (l *Layout) Margin() matrix.Vec4

Layout.Offset

func (l *Layout) Offset() matrix.Vec2

Layout.Padding

func (l *Layout) Padding() matrix.Vec4

Layout.PixelSize

func (l *Layout) PixelSize() matrix.Vec2

Layout.Positioning

func (l *Layout) Positioning() Positioning

Layout.Scale

func (l *Layout) Scale(width, height float32) bool

Layout.ScaleHeight

func (l *Layout) ScaleHeight(height float32) bool

Layout.ScaleWidth

func (l *Layout) ScaleWidth(width float32) bool

Layout.SetAlignSelf

func (l *Layout) SetAlignSelf(align FlexAlign)

Layout.SetBorder

func (l *Layout) SetBorder(left, top, right, bottom float32)

Layout.SetFlexBasis

func (l *Layout) SetFlexBasis(basis float32, percent bool)

Layout.SetFlexBasisAuto

func (l *Layout) SetFlexBasisAuto()

Layout.SetFlexGrow

func (l *Layout) SetFlexGrow(grow float32)

Layout.SetFlexOrder

func (l *Layout) SetFlexOrder(order int)

Layout.SetFlexShrink

func (l *Layout) SetFlexShrink(shrink float32)

Layout.SetGridColumn

func (l *Layout) SetGridColumn(start, end int)

Layout.SetGridRow

func (l *Layout) SetGridRow(start, end int)

Layout.SetInnerOffset

func (l *Layout) SetInnerOffset(left, top, right, bottom float32)

Layout.SetInnerOffsetBottom

func (l *Layout) SetInnerOffsetBottom(offset float32)

Layout.SetInnerOffsetLeft

func (l *Layout) SetInnerOffsetLeft(offset float32)

Layout.SetInnerOffsetRight

func (l *Layout) SetInnerOffsetRight(offset float32)

Layout.SetInnerOffsetTop

func (l *Layout) SetInnerOffsetTop(offset float32)

Layout.SetLocalInnerOffset

func (l *Layout) SetLocalInnerOffset(left, top, right, bottom float32)

Layout.SetMargin

func (l *Layout) SetMargin(left, top, right, bottom float32)

Layout.SetOffset

func (l *Layout) SetOffset(x, y float32)

Layout.SetOffsetX

func (l *Layout) SetOffsetX(x float32)

Layout.SetOffsetY

func (l *Layout) SetOffsetY(y float32)

Layout.SetPadding

func (l *Layout) SetPadding(left, top, right, bottom float32)

Layout.SetPositioning

func (l *Layout) SetPositioning(pos Positioning)

Layout.SetRowLayoutOffset

func (l *Layout) SetRowLayoutOffset(offset matrix.Vec2)

Layout.SetZ

func (l *Layout) SetZ(z float32)

Layout.Ui

func (l *Layout) Ui() *UI

Layout.Z

func (l *Layout) Z() float32

LayoutMode

int

type LayoutMode = int

LayoutStylizer

interface

type LayoutStylizer interface {
    ProcessStyle(layout *Layout) []error
}

LeftStylizer

struct

type LeftStylizer struct{ BasicStylizer }

LeftStylizer.ProcessStyle

func (s LeftStylizer) ProcessStyle(layout *Layout) []error

Manager

struct

type Manager struct {
    Host  *engine.Host
    Group Group

    // Has unexported fields.
}

Manager.Add

func (man *Manager) Add() *UI

Manager.Clear

func (man *Manager) Clear()

Manager.DisableUpdate

func (man *Manager) DisableUpdate()

Manager.EnableUpdate

func (man *Manager) EnableUpdate()

Manager.Hovered

func (man *Manager) Hovered() []*UI

Manager.Init

func (man *Manager) Init(host *engine.Host)

Manager.IsUpdateDisabled

func (man *Manager) IsUpdateDisabled() bool

Manager.Remove

func (man *Manager) Remove(ui *UI)

Manager.Reserve

func (man *Manager) Reserve(additionalElements int)

Manager.RootBackgroundColor

func (man *Manager) RootBackgroundColor() matrix.Color

RootBackgroundColor is the opaque backdrop that the top of the UI tree composites against when computing calculated ("used") colors for halo-free font rendering. It is the color a root-level transparent element resolves to. Defaults to opaque black; a zero (fully transparent) value is treated as opaque black so the calculated-color chain is always grounded on an opaque backdrop.

Manager.SetRootBackgroundColor

func (man *Manager) SetRootBackgroundColor(c matrix.Color)

SetRootBackgroundColor overrides the backdrop used for calculated colors and re-renders the root elements so the new value propagates down the tree.

Manager.Shutdown

func (man *Manager) Shutdown()

Shutdown synchronously detaches the Manager from its host: removes its update from UIUpdater, detaches its Group from UILateUpdater, and removes its window-resize handler. It also clears any UI elements still owned by the Manager so the next Init starts clean.

This is safe to call when Manager hasn't been Init'd yet (no-op). It is also idempotent — calling it twice in a row tears down nothing the second time. After Shutdown the Manager can be Init'd again on the same or a different host.

Without this, calling Init twice on the same Manager (which happens when a workspace is disabled then re-enabled in the editor) leaves the previous update callback registered, so two goroutines race on the same Manager's iteration slices and panic with index-out-of-range.

Overflow

int

type Overflow = int

Panel

UI

type Panel UI

FirstPanelOnEntity

func FirstPanelOnEntity(entity *engine.Entity) *Panel

Panel.AddChild

func (p *Panel) AddChild(target *UI)

Panel.AllowClickThrough

func (p *Panel) AllowClickThrough()

Panel.Background

func (p *Panel) Background() *rendering.Texture

Panel.Base

func (p *Panel) Base() *UI

Panel.BorderColor

func (p *Panel) BorderColor() [4]matrix.Color

Panel.BorderSize

func (p *Panel) BorderSize() matrix.Vec4

Panel.BorderStyle

func (p *Panel) BorderStyle() [4]BorderStyle

Panel.CalculatedBGColor

func (p *Panel) CalculatedBGColor() matrix.Color

CalculatedBGColor returns this panel's opaque "used" background color: its own fill (which may be partially or fully transparent) alpha-composited over its parent's calculated background, recursively up to the manager's opaque root backdrop. This is the actual color a child element or its text visually sits on. The font renderer uses it as the glyph-edge blend target so anti-aliasing produces no halo, regardless of how transparent the intervening panels are.

It is computed live by walking ancestors (cheap: tree depth is small and this only runs while the UI is dirty/cleaning). The result is opaque whenever the root backdrop is opaque (the default), which is why text composited onto it can be rendered fully opaque and halo-free.

Panel.Child

func (p *Panel) Child(index int) *UI

Panel.ClearLayoutStyles

func (p *Panel) ClearLayoutStyles()

Panel.Color

func (p *Panel) Color() matrix.Color

Panel.DisableDragScroll

func (p *Panel) DisableDragScroll()

Panel.DontFitContent

func (p *Panel) DontFitContent()

Panel.DontFitContentHeight

func (p *Panel) DontFitContentHeight()

Panel.DontFitContentWidth

func (p *Panel) DontFitContentWidth()

Panel.EnableDragScroll

func (p *Panel) EnableDragScroll()

Panel.EnforceColor

func (p *Panel) EnforceColor(color matrix.Color)

Panel.FitContent

func (p *Panel) FitContent()

Panel.FitContentHeight

func (p *Panel) FitContentHeight()

Panel.FitContentWidth

func (p *Panel) FitContentWidth()

Panel.FittingContent

func (p *Panel) FittingContent() bool

Panel.FittingContentHeight

func (p *Panel) FittingContentHeight() bool

Panel.FittingContentWidth

func (p *Panel) FittingContentWidth() bool

Panel.Freeze

func (p *Panel) Freeze()

Panel.GetAspectRatio

func (p *Panel) GetAspectRatio() float32

Panel.GetMaxSize

func (p *Panel) GetMaxSize() matrix.Vec2

Panel.GetMinSize

func (p *Panel) GetMinSize() matrix.Vec2

Panel.GetUsesBorderBox

func (p *Panel) GetUsesBorderBox() bool

Panel.GridCellWidth

func (p *Panel) GridCellWidth() float32

GridCellWidth returns the computed width of a single grid column (based on current panel dimensions, column count, and gap). Used by CSS width % processing so children (e.g. div{width:100%}) fit their grid cell instead of full parent.

Panel.GridColumns

func (p *Panel) GridColumns() int

Panel.GridGap

func (p *Panel) GridGap() matrix.Vec2

Panel.HasBackground

func (p *Panel) HasBackground() bool

Panel.HasEnforcedColor

func (p *Panel) HasEnforcedColor() bool

Panel.Init

func (panel *Panel) Init(texture *rendering.Texture, elmType ElementType)

Panel.InsertChild

func (p *Panel) InsertChild(target *UI, idx int)

Panel.IsFlex

func (p *Panel) IsFlex() bool

Panel.IsFrozen

func (p *Panel) IsFrozen() bool

Panel.IsGrid

func (p *Panel) IsGrid() bool

Panel.IsScrolling

func (p *Panel) IsScrolling() bool

Panel.MaxScroll

func (p *Panel) MaxScroll() matrix.Vec2

Panel.OutlineColor

func (p *Panel) OutlineColor() matrix.Color

Panel.OutlineOffset

func (p *Panel) OutlineOffset() float32

Panel.OutlineOutset

func (p *Panel) OutlineOutset() float32

Panel.OutlineWidth

func (p *Panel) OutlineWidth() float32

Panel.Overflow

func (p *Panel) Overflow() Overflow

Panel.PanelData

func (p *Panel) PanelData() *panelData

Panel.RemoveBackground

func (p *Panel) RemoveBackground()

Panel.RemoveChild

func (p *Panel) RemoveChild(target *UI)

Panel.ResetScroll

func (p *Panel) ResetScroll()

Panel.ScrollDirection

func (p *Panel) ScrollDirection() PanelScrollDirection

Panel.ScrollToChild

func (p *Panel) ScrollToChild(child *UI)

Panel.ScrollX

func (p *Panel) ScrollX() float32

Panel.ScrollY

func (p *Panel) ScrollY() float32

Panel.SetAspectRatio

func (p *Panel) SetAspectRatio(r float32)

Panel.SetBackground

func (p *Panel) SetBackground(tex *rendering.Texture)

Panel.SetBorderColor

func (p *Panel) SetBorderColor(left, top, right, bottom matrix.Color)

Panel.SetBorderRadius

func (p *Panel) SetBorderRadius(topLeft, topRight, bottomRight, bottomLeft float32)

Panel.SetBorderRadiusBottomLeft

func (p *Panel) SetBorderRadiusBottomLeft(r float32)

Panel.SetBorderRadiusBottomRight

func (p *Panel) SetBorderRadiusBottomRight(r float32)

Panel.SetBorderRadiusTopLeft

func (p *Panel) SetBorderRadiusTopLeft(r float32)

Panel.SetBorderRadiusTopRight

func (p *Panel) SetBorderRadiusTopRight(r float32)

Panel.SetBorderSize

func (p *Panel) SetBorderSize(left, top, right, bottom float32)

Panel.SetBorderStyle

func (p *Panel) SetBorderStyle(left, top, right, bottom BorderStyle)

Panel.SetColor

func (p *Panel) SetColor(bgColor matrix.Color)

Panel.SetFlex

func (p *Panel) SetFlex()

Panel.SetFlexAlignContent

func (p *Panel) SetFlexAlignContent(align FlexAlignContent)

Panel.SetFlexAlignItems

func (p *Panel) SetFlexAlignItems(align FlexAlign)

Panel.SetFlexDirection

func (p *Panel) SetFlexDirection(direction FlexDirection)

Panel.SetFlexJustify

func (p *Panel) SetFlexJustify(justify FlexJustify)

Panel.SetFlexWrap

func (p *Panel) SetFlexWrap(wrap FlexWrap)

Panel.SetFlowLayout

func (p *Panel) SetFlowLayout()

Panel.SetGrid

func (p *Panel) SetGrid(columns int)

SetGrid enables CSS Grid-like layout with the given number of columns. Children will be placed in row-major order into the grid cells. Column widths are computed by dividing available width by columns (accounting for gaps). Use SetGridGap to control spacing between items. This works with the existing fit content and scrolling systems.

Panel.SetGridAutoColumns

func (p *Panel) SetGridAutoColumns(width float32)

Panel.SetGridAutoRows

func (p *Panel) SetGridAutoRows(height float32)

Panel.SetGridGap

func (p *Panel) SetGridGap(x, y float32)

Panel.SetGridTemplateColumns

func (p *Panel) SetGridTemplateColumns(columns []float32)

SetGridTemplateColumns configures explicit grid column widths. Positive values are fixed pixels, negative values are fr units.

Panel.SetMaterial

func (p *Panel) SetMaterial(mat *rendering.Material)

Panel.SetMaxHeight

func (p *Panel) SetMaxHeight(h float32)

Panel.SetMaxWidth

func (p *Panel) SetMaxWidth(w float32)

Panel.SetMinHeight

func (p *Panel) SetMinHeight(h float32)

Panel.SetMinWidth

func (p *Panel) SetMinWidth(w float32)

Panel.SetOutline

func (p *Panel) SetOutline(width, offset float32, color matrix.Color)

Panel.SetOverflow

func (p *Panel) SetOverflow(overflow Overflow)

Panel.SetScrollDirection

func (p *Panel) SetScrollDirection(direction PanelScrollDirection)

Panel.SetScrollX

func (p *Panel) SetScrollX(value float32)

Panel.SetScrollY

func (p *Panel) SetScrollY(value float32)

Panel.SetScrollbarsVisible

func (p *Panel) SetScrollbarsVisible(visible bool)

SetScrollbarsVisible toggles whether this panel's scroll bars are ever shown. Scrolling (wheel, drag, programmatic SetScrollY/SetScrollX) still works when hidden; only the visual bars are suppressed. Used by views that drive their scroll externally (e.g. a line-number gutter slaved to a sibling's scroll).

Panel.SetUseBlending

func (p *Panel) SetUseBlending(useBlending bool)

Panel.SetUsesBorderBox

func (p *Panel) SetUsesBorderBox(v bool)

Panel.UnEnforceColor

func (p *Panel) UnEnforceColor()

Panel.UnFreeze

func (p *Panel) UnFreeze()

PanelScrollDirection

int32

type PanelScrollDirection = int32

Positioning

int

type Positioning = int

ProgressBar

Panel

type ProgressBar Panel

ProgressBar.Base

func (p *ProgressBar) Base() *UI

ProgressBar.Init

func (p *ProgressBar) Init(fgTexture, bgTexture *rendering.Texture)

ProgressBar.SetBGColor

func (b *ProgressBar) SetBGColor(bgColor matrix.Color)

ProgressBar.SetFGColor

func (b *ProgressBar) SetFGColor(fgColor matrix.Color)

ProgressBar.SetValue

func (b *ProgressBar) SetValue(value float32)

ProgressBar.Value

func (b *ProgressBar) Value() float32

RightStylizer

struct

type RightStylizer struct{ BasicStylizer }

RightStylizer.ProcessStyle

func (s RightStylizer) ProcessStyle(layout *Layout) []error

Select

Panel

type Select Panel

Select.AddOption

func (s *Select) AddOption(name, value string)

Select.Base

func (s *Select) Base() *UI

Select.ClearOptions

func (s *Select) ClearOptions()

Select.Init

func (s *Select) Init(text string, options []SelectOption)

Select.IsDisabled

func (s *Select) IsDisabled() bool

Select.Name

func (s *Select) Name() string

Select.PickOption

func (s *Select) PickOption(index int)

Select.PickOptionByLabel

func (s *Select) PickOptionByLabel(label string)

Select.PickOptionByLabelWithoutEvent

func (s *Select) PickOptionByLabelWithoutEvent(label string)

Select.PickOptionWithoutEvent

func (s *Select) PickOptionWithoutEvent(index int) bool

Select.SelectData

func (s *Select) SelectData() *selectData

Select.SetColor

func (s *Select) SetColor(newColor matrix.Color)

Select.SetDisabled

func (s *Select) SetDisabled(disabled bool)

Select.SetOptionsColor

func (s *Select) SetOptionsColor(newColor matrix.Color)

Select.SetTextColor

func (s *Select) SetTextColor(newColor matrix.Color)

Select.Value

func (s *Select) Value() string

SelectOption

struct

type SelectOption struct {
    Name  string
    Value string

    // Has unexported fields.
}

SelectOptionCheckStylizer

struct

type SelectOptionCheckStylizer struct{ BasicStylizer }

SelectOptionCheckStylizer.ProcessStyle

func (s SelectOptionCheckStylizer) ProcessStyle(layout *Layout) []error

SelectOptionStylizer

struct

type SelectOptionStylizer struct{ BasicStylizer }

SelectOptionStylizer.ProcessStyle

func (s SelectOptionStylizer) ProcessStyle(layout *Layout) []error

SelectOptionTextStylizer

struct

type SelectOptionTextStylizer struct{ BasicStylizer }

SelectOptionTextStylizer.ProcessStyle

func (s SelectOptionTextStylizer) ProcessStyle(layout *Layout) []error

SelectTextStylizer

struct

type SelectTextStylizer struct{ BasicStylizer }

SelectTextStylizer.ProcessStyle

func (s SelectTextStylizer) ProcessStyle(layout *Layout) []error

ShaderData

struct

type ShaderData struct {
    rendering.ShaderDataBase
    UVs          matrix.Vec4
    FgColor      matrix.Color
    BgColor      matrix.Color
    Scissor      matrix.Vec4
    Size2D       matrix.Vec4
    BorderRadius matrix.Vec4
    BorderSize   matrix.Vec4
    BorderColor  [4]matrix.Color
    BorderLen    matrix.Vec2
    OutlineColor matrix.Color
    OutlineSize  matrix.Vec2
}

ShaderData.Size

func (s ShaderData) Size() int

Slider

Panel

type Slider Panel

Slider.Base

func (s *Slider) Base() *UI

Slider.Delta

func (slider *Slider) Delta() float32

Slider.Init

func (s *Slider) Init()

Slider.IsDisabled

func (slider *Slider) IsDisabled() bool

Slider.SetBGColor

func (slider *Slider) SetBGColor(bgColor matrix.Color)

Slider.SetDisabled

func (slider *Slider) SetDisabled(disabled bool)

Slider.SetFGColor

func (slider *Slider) SetFGColor(fgColor matrix.Color)

Slider.SetValue

func (slider *Slider) SetValue(value float32)

Slider.SetValueWithoutEvent

func (slider *Slider) SetValueWithoutEvent(value float32)

Slider.SliderData

func (s *Slider) SliderData() *sliderData

Slider.Value

func (slider *Slider) Value() float32

StretchCenterStylizer

struct

type StretchCenterStylizer struct{ BasicStylizer }

StretchCenterStylizer.ProcessStyle

func (s StretchCenterStylizer) ProcessStyle(layout *Layout) []error

StretchHeightStylizer

struct

type StretchHeightStylizer struct{ BasicStylizer }

StretchHeightStylizer.ProcessStyle

func (s StretchHeightStylizer) ProcessStyle(layout *Layout) []error

StretchWidthStylizer

struct

type StretchWidthStylizer struct{ BasicStylizer }

StretchWidthStylizer.ProcessStyle

func (s StretchWidthStylizer) ProcessStyle(layout *Layout) []error

TextArea

Panel

type TextArea Panel

TextArea.ApplyColorRange

func (textarea *TextArea) ApplyColorRange(start, end int, fg, bg matrix.Color)

ApplyColorRange colors a [start,end) rune range using flat (whole-document) rune offsets, for backward compatibility with the old single-string API. It maps the flat range onto the affected lines.

TextArea.Base

func (textarea *TextArea) Base() *UI

TextArea.ClearColorRanges

func (textarea *TextArea) ClearColorRanges()

TextArea.ClearLineColorSpans

func (textarea *TextArea) ClearLineColorSpans(line int)

TextArea.CursorPosition

func (textarea *TextArea) CursorPosition() (line, col int)

TextArea.Data

func (textarea *TextArea) Data() *textareaData

TextArea.Focus

func (textarea *TextArea) Focus()

TextArea.FontFace

func (textarea *TextArea) FontFace() rendering.FontFace

TextArea.FontSize

func (textarea *TextArea) FontSize() float32

TextArea.Init

func (textarea *TextArea) Init(placeholderText string)

TextArea.InsertText

func (textarea *TextArea) InsertText(text string)

TextArea.IsDisabled

func (textarea *TextArea) IsDisabled() bool

TextArea.IsFocused

func (textarea *TextArea) IsFocused() bool

TextArea.IsReadOnly

func (textarea *TextArea) IsReadOnly() bool

TextArea.IsRequired

func (textarea *TextArea) IsRequired() bool

TextArea.IsValid

func (textarea *TextArea) IsValid() bool

TextArea.Line

func (textarea *TextArea) Line(i int) string

Line returns the text of logical line i (without its newline).

TextArea.LineCount

func (textarea *TextArea) LineCount() int

LineCount is the number of logical lines in the document.

TextArea.LineHeight

func (textarea *TextArea) LineHeight() float32

LineHeight is the rendered height of a single line (the fixed row height in no-wrap mode), which a companion gutter should match.

TextArea.MaxScrollY

func (textarea *TextArea) MaxScrollY() float32

MaxScrollY is the maximum vertical scroll offset.

TextArea.Redo

func (textarea *TextArea) Redo()

TextArea.RemoveFocus

func (textarea *TextArea) RemoveFocus()

TextArea.ScrollToLine

func (textarea *TextArea) ScrollToLine(line int, align VirtualAlign)

TextArea.ScrollY

func (textarea *TextArea) ScrollY() float32

ScrollY is the current vertical scroll offset (pixels from the top).

TextArea.SelectAll

func (textarea *TextArea) SelectAll()

TextArea.SelectedText

func (textarea *TextArea) SelectedText() string

SelectedText returns the currently selected text (empty if no selection).

TextArea.SetBGColor

func (textarea *TextArea) SetBGColor(newColor matrix.Color)

TextArea.SetCursorColor

func (textarea *TextArea) SetCursorColor(newColor matrix.Color)

TextArea.SetCursorLineColumn

func (textarea *TextArea) SetCursorLineColumn(line, col int)

TextArea.SetCursorOffset

func (textarea *TextArea) SetCursorOffset(offset int)

TextArea.SetDisabled

func (textarea *TextArea) SetDisabled(disabled bool)

TextArea.SetFGColor

func (textarea *TextArea) SetFGColor(newColor matrix.Color)

TextArea.SetFontFace

func (textarea *TextArea) SetFontFace(face rendering.FontFace)

TextArea.SetFontSize

func (textarea *TextArea) SetFontSize(fontSize float32)

TextArea.SetFontStyle

func (textarea *TextArea) SetFontStyle(style string)

TextArea.SetFontWeight

func (textarea *TextArea) SetFontWeight(weight string)

TextArea.SetHighlightCurrentLine

func (textarea *TextArea) SetHighlightCurrentLine(enabled bool, color matrix.Color)

TextArea.SetLetterSpacing

func (textarea *TextArea) SetLetterSpacing(spacing float32)

TextArea.SetLineColorSpans

func (textarea *TextArea) SetLineColorSpans(line int, spans []TextColorSpan)

SetLineColorSpans replaces the color spans for a single line (rune columns within the line). This is the per-line API the widget layer's virtualized highlighter uses.

TextArea.SetLineHeight

func (textarea *TextArea) SetLineHeight(lineHeight float32)

TextArea.SetLineSpansBulk

func (textarea *TextArea) SetLineSpansBulk(spans map[int][]TextColorSpan)

SetLineSpansBulk replaces ALL per-line color spans in one shot (one refresh). The map is keyed by line index; values are per-line rune-column spans. This is the entry point the widget-layer virtualized highlighter uses so it can push a freshly tokenized document without O(visible^2) per-line refreshes.

TextArea.SetNextFocusedElement

func (textarea *TextArea) SetNextFocusedElement(next *UI)

TextArea.SetOnScroll

func (textarea *TextArea) SetOnScroll(fn func())

SetOnScroll registers an observer fired whenever the vertical scroll position changes. The widget layer uses it to keep a companion gutter in lockstep.

TextArea.SetOnVisibleRangeChanged

func (textarea *TextArea) SetOnVisibleRangeChanged(fn func(first, last int))

TextArea.SetPlaceholder

func (textarea *TextArea) SetPlaceholder(text string)

TextArea.SetReadOnly

func (textarea *TextArea) SetReadOnly(readOnly bool)

TextArea.SetRequired

func (textarea *TextArea) SetRequired(required bool)

TextArea.SetScrollY

func (textarea *TextArea) SetScrollY(y float32)

SetScrollY sets the vertical scroll offset (clamped to the content).

TextArea.SetScrollbarsVisible

func (textarea *TextArea) SetScrollbarsVisible(visible bool)

SetScrollbarsVisible toggles the built-in scroll bars. A code editor that paints its own scroll/marker track hides these and drives scrolling through SetScrollY instead.

TextArea.SetSelectColor

func (textarea *TextArea) SetSelectColor(newColor matrix.Color)

TextArea.SetText

func (textarea *TextArea) SetText(text string)

TextArea.SetTextWithoutEvent

func (textarea *TextArea) SetTextWithoutEvent(text string)

TextArea.SetWrap

func (textarea *TextArea) SetWrap(wrap bool)

TextArea.Text

func (textarea *TextArea) Text() string

TextArea.TextAreaData

func (textarea *TextArea) TextAreaData() *textareaData

TextArea.Undo

func (textarea *TextArea) Undo()

TextArea.ViewportHeight

func (textarea *TextArea) ViewportHeight() float32

ViewportHeight is the visible height of the scrolling text area (excluding the internal padding), i.e. how much of the document is on screen at once.

TextArea.VisibleLineRange

func (textarea *TextArea) VisibleLineRange() (first, last int)

VisibleLineRange returns the first and last line indices currently realized.

TextColorSpan

struct

type TextColorSpan struct {
    Start, End int
    FG, BG     matrix.Color
}

TextColorSpan colors a [Start,End) rune range WITHIN a single line. It is a pure data carrier used by the widget layer (syntax highlighting, markers).

TriangleStylizer

struct

type TriangleStylizer struct{ BasicStylizer }

TriangleStylizer.ProcessStyle

func (t TriangleStylizer) ProcessStyle(layout *Layout) []error

UI

struct

type UI struct {
    // Has unexported fields.
}

AllOnEntity

func AllOnEntity(entity *engine.Entity) []*UI

FirstOnEntity

func FirstOnEntity(entity *engine.Entity) *UI

UI.AddEvent

func (ui *UI) AddEvent(evtType EventType, evt func()) events.Id

UI.Clean

func (ui *UI) Clean()

UI.Clone

func (ui *UI) Clone(parent *engine.Entity) *UI

UI.Entity

func (ui *UI) Entity() *engine.Entity

UI.Event

func (ui *UI) Event(evtType EventType) *events.Event

UI.ExecuteEvent

func (ui *UI) ExecuteEvent(evtType EventType) bool

UI.FindByName

func (ui *UI) FindByName(name string) *UI

UI.GenerateScissor

func (ui *UI) GenerateScissor()

UI.Hide

func (ui *UI) Hide()

UI.Host

func (ui *UI) Host() *engine.Host

UI.IsActive

func (ui *UI) IsActive() bool

UI.IsDisabled

func (ui *UI) IsDisabled() bool

UI.IsDown

func (ui *UI) IsDown() bool

UI.IsInFrontOf

func (ui *UI) IsInFrontOf(other *UI) bool

UI.IsType

func (ui *UI) IsType(elmType ElementType) bool

UI.IsValid

func (ui *UI) IsValid() bool

UI.Layout

func (ui *UI) Layout() *Layout

UI.RemoveEvent

func (ui *UI) RemoveEvent(evtType EventType, evtId events.Id)

UI.SetDirty

func (ui *UI) SetDirty(dirtyType DirtyType)

UI.SetDisabled

func (ui *UI) SetDisabled(disabled bool)

UI.SetDontClean

func (ui *UI) SetDontClean(val bool)

UI.SetVisibility

func (ui *UI) SetVisibility(visible bool)

UI.ShaderData

func (ui *UI) ShaderData() *ShaderData

UI.Show

func (ui *UI) Show()

UI.ToButton

func (u *UI) ToButton() *Button

UI.ToCheckbox

func (u *UI) ToCheckbox() *Checkbox

UI.ToImage

func (u *UI) ToImage() *Image

UI.ToInput

func (u *UI) ToInput() *Input

UI.ToLabel

func (u *UI) ToLabel() *Label

UI.ToPanel

func (u *UI) ToPanel() *Panel

UI.ToProgressBar

func (u *UI) ToProgressBar() *ProgressBar

UI.ToSelect

func (u *UI) ToSelect() *Select

UI.ToSlider

func (u *UI) ToSlider() *Slider

UI.ToTextArea

func (u *UI) ToTextArea() *TextArea

UI.ToVirtualList

func (u *UI) ToVirtualList() *VirtualList

UI.Type

func (ui *UI) Type() ElementType

UI.Update

func (ui *UI) Update(deltaTime float64)

UIElementData

interface

type UIElementData interface {
    // Has unexported methods.
}

VirtualAlign

int

type VirtualAlign = int

VirtualAlign selects how ScrollToIndex positions a row within the viewport.

const ( // VirtualAlignStart aligns the row's top with the viewport top. VirtualAlignStart VirtualAlign = iota // VirtualAlignCenter centers the row vertically in the viewport. VirtualAlignCenter // VirtualAlignEnd aligns the row's bottom with the viewport bottom. VirtualAlignEnd // VirtualAlignNearest scrolls the minimum amount to make the row visible. VirtualAlignNearest )

VirtualList

Panel

type VirtualList Panel

VirtualList is a vertically-scrolling list that only materializes the rows currently in view, recycling a small pool of row elements as the user scrolls. That is what lets a list of 100k rows cost the same to render as a list of 30: at any moment only a viewport-worth of row elements are active.

It is content-agnostic and not generic: the owner supplies a VirtualListDelegate that knows the row count and how to create/bind/unbind a row element by index, and supplies row heights either as a single fixed value (SetFixedRowHeight, the O(1) no-wrap path) or per-row (SetRowHeightFunc, the variable/wrapped path). The rewritten TextArea is the first consumer (one row per text line); Select's option list is a natural follow-up.

All access is on the main thread, in the layout/update loop — no locks.

VirtualList.Base

func (vl *VirtualList) Base() *UI

VirtualList.Content

func (vl *VirtualList) Content() *Panel

Content returns the inner panel that holds the row elements. Consumers may parent overlays (cursors, selection rects) to it so they scroll with the rows.

VirtualList.Data

func (vl *VirtualList) Data() *virtualListData

VirtualList.Init

func (vl *VirtualList) Init()

VirtualList.InvalidateRow

func (vl *VirtualList) InvalidateRow(index int)

InvalidateRow re-measures a single row's height (variable mode) and reflows so the rows below it shift to their new positions.

VirtualList.RefreshVisible

func (vl *VirtualList) RefreshVisible()

RefreshVisible re-binds the rows currently on screen without changing the window (use when row content/styling changed but heights did not).

VirtualList.ReloadData

func (vl *VirtualList) ReloadData()

ReloadData re-reads the row count and rebinds the visible rows. Call after the backing data changes (count or content).

VirtualList.RowAt

func (vl *VirtualList) RowAt(y float32) int

RowAt is the row index whose vertical span contains content-space y.

VirtualList.RowHeight

func (vl *VirtualList) RowHeight(index int) float32

RowHeight is the height of row index.

VirtualList.RowOffset

func (vl *VirtualList) RowOffset(index int) float32

RowOffset is the y of the top of row index in content space.

VirtualList.ScrollToIndex

func (vl *VirtualList) ScrollToIndex(index int, align VirtualAlign)

ScrollToIndex scrolls so row index is visible according to align.

VirtualList.SetContentWidth

func (vl *VirtualList) SetContentWidth(w float32)

SetContentWidth sets a minimum content width; the content panel is sized to max(viewportWidth, w). Used for horizontal scrolling of long, unwrapped rows. Pass 0 to track the viewport width (no horizontal scroll).

VirtualList.SetDelegate

func (vl *VirtualList) SetDelegate(d VirtualListDelegate)

VirtualList.SetFixedRowHeight

func (vl *VirtualList) SetFixedRowHeight(h float32)

SetFixedRowHeight switches the list to fixed-height rows (every row is h tall). This is the O(1) path used for code (no soft wrap, one line per row).

VirtualList.SetOverscan

func (vl *VirtualList) SetOverscan(rows int)

VirtualList.SetRowHeightFunc

func (vl *VirtualList) SetRowHeightFunc(fn func(index int) float32)

SetRowHeightFunc switches the list to variable-height rows, measuring each row's height via fn. Used for wrapped / chat content.

VirtualList.TotalHeight

func (vl *VirtualList) TotalHeight() float32

TotalHeight is the full scrollable content height.

VirtualList.ViewportHeight

func (vl *VirtualList) ViewportHeight() float32

ViewportHeight is the visible content height of the list.

VirtualList.VisibleRange

func (vl *VirtualList) VisibleRange() (first, last int)

VisibleRange returns the [first,last] data indices currently realized. If the list is empty last < first.

VirtualListDelegate

interface

type VirtualListDelegate interface {
    // RowCount is the total number of rows in the backing data.
    RowCount() int
    // CreateRow builds a fresh, reusable row element. It is called only when
    // the recycle pool is empty (at most a viewport-worth of times), and the
    // returned element is reused across many data indices via BindRow.
    CreateRow(man *Manager) *UI
    // BindRow populates an existing row element for the given data index.
    BindRow(index int, row *UI)
    // UnbindRow is called before a row leaves the viewport and returns to the
    // pool. Optional cleanup hook (clear text, hide children, etc.).
    UnbindRow(index int, row *UI)
}

VirtualListDelegate is the data source + row lifecycle for a VirtualList. Implementations own the backing data and answer purely by index.