Skip to content

package ui

import "kaiju/ui"

Constants

EventTypeInvalid

iota

EventTypeEnter

EventTypeExit

EventTypeClick

EventTypeDoubleClick

EventTypeDown

EventTypeUp

EventTypeMiss

EventTypeDragStart

EventTypeDragEnd

EventTypeDrop

EventTypeDropEnter

EventTypeDropExit

EventTypeScroll

EventTypeRebuild

EventTypeDestroy

EventTypeSubmit

EventTypeChange

EventTypeRender

EventTypeKeyDown

EventTypeKeyUp

EventTypeEnd

InputTypeDefault

iota

InputTypeText

InputTypeNumber

InputTypePhone

InputTypeDatetime

AnchorTopLeft

Anchor(1 + iota)

AnchorTopCenter

AnchorTopRight

AnchorLeft

AnchorCenter

AnchorRight

AnchorBottomLeft

AnchorBottomCenter

AnchorBottomRight

AnchorStretchLeft

AnchorStretchTop

AnchorStretchRight

AnchorStretchBottom

AnchorStretchCenter

PositioningStatic

Positioning(iota)

PositioningAbsolute

PositioningFixed

PositioningRelative

PositioningSticky

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

DirtyTypeNone

iota

DirtyTypeLayout

DirtyTypeResize

DirtyTypeGenerated

DirtyTypeColorChange

DirtyTypeScissor

DirtyTypeParent

DirtyTypeParentLayout

DirtyTypeParentResize

DirtyTypeParentGenerated

DirtyTypeParentReGenerated

DirtyTypeParentColorChange

DirtyTypeParentScissor

EntityDataName

"ui"

LabelFontSize

14.0

Types

Anchor

int32

type Anchor int32

Anchor.ConvertToBottom

func (a Anchor) ConvertToBottom() Anchor

Anchor.ConvertToCenter

func (a Anchor) ConvertToCenter() Anchor

Anchor.ConvertToLeft

func (a Anchor) ConvertToLeft() Anchor

Anchor.ConvertToRight

func (a Anchor) ConvertToRight() Anchor

Anchor.ConvertToTop

func (a Anchor) ConvertToTop() Anchor

Anchor.IsBottom

func (a Anchor) IsBottom() bool

Anchor.IsLeft

func (a Anchor) IsLeft() bool

Anchor.IsRight

func (a Anchor) IsRight() bool

Anchor.IsTop

func (a Anchor) IsTop() bool

BorderStyle

int32

type BorderStyle = int32

Button

Panel

type Button Panel

NewButton

func NewButton(host *engine.Host, texture *rendering.Texture, text string, anchor Anchor) *Button

Button.Label

func (b *Button) Label() *Label

Button.SetColor

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

Checkbox

Panel

type Checkbox Panel

Checkbox.IsChecked

func (cb Checkbox) IsChecked() bool

Checkbox.SetChecked

func (cb *Checkbox) SetChecked(isChecked bool)

ContentFit

int32

type ContentFit = int32

DirtyType

int

type DirtyType = int

EventType

int

type EventType = int

Group

struct

type Group struct {
    // Has unexported fields.
}

NewGroup

func NewGroup() *Group

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

Image

Panel

type Image Panel

NewImage

func NewImage(host *engine.Host, texture *rendering.Texture, anchor Anchor) *Image

Image.PlayAnimation

func (img *Image) PlayAnimation()

Image.SetFlipBookAnimation

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

Image.SetFrameRate

func (img *Image) SetFrameRate(framesPerSecond float32)

Image.SetTexture

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

Image.StopAnimation

func (img *Image) StopAnimation()

Input

Panel

type Input Panel

Input.Data

func (input *Input) Data() *localInputData

Input.Deselect

func (input *Input) Deselect()

Input.InsertText

func (input *Input) InsertText(text string)

Input.Select

func (input *Input) Select()

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.SetDescription

func (input *Input) SetDescription(text string)

Input.SetFGColor

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

Input.SetFontSize

func (input *Input) SetFontSize(fontSize float32)

Input.SetNextFocusedInput

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

Input.SetPlaceholder

func (input *Input) SetPlaceholder(text string)

Input.SetSelectColor

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

Input.SetText

func (input *Input) SetText(text string)

Input.SetTextColor

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

Input.SetTitle

func (input *Input) SetTitle(text string)

Input.SetType

func (input *Input) SetType(inputType InputType)

Input.Text

func (input *Input) Text() string

InputType

int32

type InputType = int32

Label

struct

type Label struct {
    // Has unexported fields.
}

NewLabel

func NewLabel(host *engine.Host, text string, anchor Anchor) *Label

Label.AddEvent

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

Label.BoldRange

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

Label.CalculateMaxWidth

func (label *Label) CalculateMaxWidth() float32

Label.Clean

func (ui *Label) Clean()

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.Entity

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

Label.Event

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

Label.ExecuteEvent

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

Label.FontFace

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

Label.FontSize

func (label *Label) FontSize() float32

Label.GenerateScissor

func (ui *Label) GenerateScissor()

Label.Host

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

Label.Layout

func (ui *Label) Layout() *Layout

Label.LineHeight

func (label *Label) LineHeight() float32

Label.MaxWidth

func (label *Label) MaxWidth() float32

Label.Measure

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

Label.RemoveEvent

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

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.SetDirty

func (ui *Label) SetDirty(dirtyType DirtyType)

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.SetGroup

func (ui *Label) SetGroup(group *Group)

Label.SetJustify

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

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.ShaderData

func (ui *Label) ShaderData() *ShaderData

Label.Text

func (label *Label) Text() string

Label.UnEnforceBGColor

func (label *Label) UnEnforceBGColor()

Label.UnEnforceFGColor

func (label *Label) UnEnforceFGColor()

Label.Update

func (ui *Label) Update(deltaTime float64)

Layout

struct

type Layout struct {
    // Has unexported fields.
}

Layout.AddFunction

func (l *Layout) AddFunction(fn func(layout *Layout)) LayoutFuncId

Layout.Anchor

func (l *Layout) Anchor() Anchor

Layout.AnchorTo

func (l *Layout) AnchorTo(anchorPosition Anchor)

Layout.Border

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

Layout.CalcOffset

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

Layout.ClearFunctions

func (l *Layout) ClearFunctions()

Layout.ContentSize

func (l *Layout) ContentSize() (float32, float32)

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.RemoveFunction

func (l *Layout) RemoveFunction(id LayoutFuncId)

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.SetBorder

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

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.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.SetStretch

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

Layout.SetStretchRatio

func (l *Layout) SetStretchRatio(leftRatio, topRatio, rightRatio, bottomRatio float32)

Layout.SetZ

func (l *Layout) SetZ(z float32)

Layout.Stretch

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

Layout.Ui

func (l *Layout) Ui() UI

Layout.Z

func (l *Layout) Z() float32

LayoutFuncId

int64

type LayoutFuncId = int64

LayoutFunctions

struct

type LayoutFunctions struct {
    // Has unexported fields.
}

NewEvent

func NewEvent() LayoutFunctions

LayoutFunctions.Add

func (lf *LayoutFunctions) Add(call func(layout *Layout)) LayoutFuncId

LayoutFunctions.Clear

func (lf *LayoutFunctions) Clear()

LayoutFunctions.Execute

func (lf *LayoutFunctions) Execute(layout *Layout)

LayoutFunctions.IsEmpty

func (lf *LayoutFunctions) IsEmpty() bool

LayoutFunctions.Remove

func (e *LayoutFunctions) Remove(id LayoutFuncId)

Overflow

int

type Overflow = int

Panel

struct

type Panel struct {
    // Has unexported fields.
}

FirstPanelOnEntity

func FirstPanelOnEntity(entity *engine.Entity) *Panel

NewPanel

func NewPanel(host *engine.Host, texture *rendering.Texture, anchor Anchor) *Panel

Panel.AddChild

func (p *Panel) AddChild(target UI)

Panel.AddEvent

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

Panel.Background

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

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.Child

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

Panel.Clean

func (ui *Panel) Clean()

Panel.ConvertToButton

func (p *Panel) ConvertToButton() *Button

Panel.ConvertToCheckbox

func (p *Panel) ConvertToCheckbox() *Checkbox

Panel.ConvertToInput

func (p *Panel) ConvertToInput(placeholderText string) *Input

Panel.ConvertToSlider

func (p *Panel) ConvertToSlider() *Slider

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.Entity

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

Panel.Event

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

Panel.ExecuteEvent

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

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.Freeze

func (p *Panel) Freeze()

Panel.GenerateScissor

func (ui *Panel) GenerateScissor()

Panel.HasEnforcedColor

func (p *Panel) HasEnforcedColor() bool

Panel.Host

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

Panel.InsertChild

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

Panel.IsFrozen

func (p *Panel) IsFrozen() bool

Panel.IsScrolling

func (p *Panel) IsScrolling() bool

Panel.Layout

func (ui *Panel) Layout() *Layout

Panel.Overflow

func (p *Panel) Overflow() Overflow

Panel.RemoveBackground

func (p *Panel) RemoveBackground()

Panel.RemoveChild

func (p *Panel) RemoveChild(target UI)

Panel.RemoveEvent

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

Panel.ResetScroll

func (p *Panel) ResetScroll()

Panel.ScrollDirection

func (p *Panel) ScrollDirection() PanelScrollDirection

Panel.ScrollX

func (p *Panel) ScrollX() float32

Panel.ScrollY

func (p *Panel) ScrollY() 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.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.SetDirty

func (ui *Panel) SetDirty(dirtyType DirtyType)

Panel.SetGroup

func (ui *Panel) SetGroup(group *Group)

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.SetSpeed

func (p *Panel) SetSpeed(speed float32)

Panel.SetUseBlending

func (p *Panel) SetUseBlending(useBlending bool)

Panel.ShaderData

func (ui *Panel) ShaderData() *ShaderData

Panel.UnEnforceColor

func (p *Panel) UnEnforceColor()

Panel.UnFreeze

func (p *Panel) UnFreeze()

Panel.Update

func (ui *Panel) Update(deltaTime float64)

PanelScrollDirection

int32

type PanelScrollDirection = int32

Positioning

int

type Positioning = int

ProgressBar

Panel

type ProgressBar Panel

NewProgressBar

func NewProgressBar(host *engine.Host, fgTexture, bgTexture *rendering.Texture, anchor Anchor) *ProgressBar

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

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
}

ShaderData.Size

func (s ShaderData) Size() int

Slider

Panel

type Slider Panel

Slider.Delta

func (slider Slider) Delta() float32

Slider.SetBGColor

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

Slider.SetFGColor

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

Slider.SetValue

func (slider *Slider) SetValue(value float32)

Slider.Value

func (slider Slider) Value() float32

UI

interface

type UI interface {
    Entity() *engine.Entity
    ExecuteEvent(evtType EventType) bool
    AddEvent(evtType EventType, evt func()) events.Id
    RemoveEvent(evtType EventType, evtId events.Id)
    Event(evtType EventType) *events.Event
    Update(deltaTime float64)
    SetDirty(dirtyType DirtyType)
    Layout() *Layout
    ShaderData() *ShaderData
    Clean()
    SetGroup(group *Group)
    Host() *engine.Host
    GenerateScissor()

    // Has unexported methods.
}

AllOnEntity

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

FirstOnEntity

func FirstOnEntity(entity *engine.Entity) UI