Help us shape the future of Go! Take the 2026 Go Developer Survey

ui

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Code generated by internal/uibinarygen; DO NOT EDIT.

Package ui defines bounded author-owned presentation assets shared by the build pipeline and host. It has no dependency on a rendering library.

Index

Constants

View Source
const (
	LengthAuto uint8 = iota
	LengthPixels
	LengthPercent
)
View Source
const (
	PercentScale       = 10000
	MaxDimensionPixels = 2048
)
View Source
const (
	MaxAssetBytes                    = 64 * 1024
	MaxElements                      = 64
	MaxTextBytes                     = 4096
	MaxNameBytes                     = 128
	MaxRows                          = 256
	MaxTransitionMilliseconds        = 2000
	BackElementID             uint32 = MaxElements + 1
	AssetPrefix                      = "karty.ui/"
	FontAssetPrefix                  = "karty.font/"
	SectionName                      = "karty.ui.v1"
	SchemaComposition         uint32 = 2
	SchemaStyle               uint32 = 3
	SchemaImageStyle          uint32 = 4
	SchemaLayout              uint32 = 5
	SchemaResponsive          uint32 = 6
	SchemaControlTransition   uint32 = 7
	SchemaVisualHierarchy     uint32 = 8
	SchemaInteractionPolish   uint32 = 9
	SchemaWidgets             uint32 = 10
	SchemaSizing              uint32 = 11
	MinResponsiveWidth               = 240
	MaxResponsiveWidth               = 1024
)
View Source
const (
	StyleBackground uint32 = 1 << iota
	StyleBackgroundHover
	StyleBackgroundPressed
	StyleColor
	StylePadding
	StyleGap
	StyleFontSize
	StyleMinHeight
	StyleBackgroundImage
	StyleBackgroundImageHover
	StyleBackgroundImagePressed
	StyleBackgroundDisabled
	StyleBackgroundImageDisabled
	StyleColorHover
	StyleColorPressed
	StyleColorDisabled
	StyleFlexDirection
	StyleAlignItems
	StyleMinWidth
	StyleMaxWidth
	StyleMaxHeight
	StyleJustifyContent
	StyleFlexGrow
	StyleMargin
	StyleOverflow
	StyleTransitionDuration
	StyleTransitionEnter
	StyleTransitionExit
	StyleTextAlign
	StyleFontFamily
	StyleContentImage
)
View Source
const (
	Style2BackgroundFocus uint32 = 1 << iota
	Style2BackgroundImageFocus
	Style2ColorFocus
	Style2TransitionDelay
	Style2TransitionEasing
	Style2Position
	Style2Left
	Style2Right
	Style2Top
	Style2Bottom
	Style2ImageFit
	Style2Tint
	Style2Icon
	Style2IconSize
	Style2IconPosition
	Style2IconGap
	Style2Width
	Style2Height
)
View Source
const (
	FlexDirectionColumn uint8 = iota + 1
	FlexDirectionRow
)
View Source
const (
	AlignItemsStart uint8 = iota + 1
	AlignItemsCenter
	AlignItemsEnd
	AlignItemsStretch
)
View Source
const (
	JustifyContentStart uint8 = iota + 1
	JustifyContentCenter
	JustifyContentEnd
	JustifyContentSpaceBetween
)
View Source
const (
	OverflowVisible uint8 = iota + 1
	OverflowScroll
)
View Source
const (
	TransitionNone uint8 = iota
	TransitionLeft
	TransitionRight
	TransitionTop
	TransitionBottom
)
View Source
const (
	TransitionEasingLinear uint8 = iota + 1
	TransitionEasingOut
	TransitionEasingInOut
)
View Source
const (
	ImageFitStretch uint8 = iota + 1
	ImageFitContain
	ImageFitCover
)
View Source
const (
	IconPositionStart uint8 = iota + 1
	IconPositionEnd
)
View Source
const (
	TextAlignStart uint8 = iota + 1
	TextAlignCenter
	TextAlignEnd
)
View Source
const (
	FontFamilyBody uint8 = iota + 1
	FontFamilyDisplay
	FontFamilyMono
)
View Source
const (
	ImageScopeGame uint8 = iota + 1
	ImageScopeLevel
)
View Source
const BinaryVersion = 1
View Source
const PositionOverlay uint8 = 1

Variables

View Source
var ErrTemplate = errors.New("invalid UI template")

Functions

func Encode

func Encode(template Template) ([]byte, error)

Encode emits a bounded KUI1 binary asset with semantic schema version 1.

func EncodeComposition

func EncodeComposition(template Template) ([]byte, error)

func ValidateStyle added in v0.0.5

func ValidateStyle(style Style, kind string) error

ValidateStyle checks a resolved style against a widget's complete current presentation contract. Authoring compilers may use this to omit invalid declarations; serialized templates still undergo strict versioned validation.

Types

type Element

type Element struct {
	ID          uint32
	Parent      uint32
	Name        string
	Kind        string
	Text        string
	Action      uint32
	Value       string
	Min         int32
	Max         int32
	Placeholder string
	Tooltip     string
	Style       Style
	// ResponsiveStyle is the fully resolved style selected at or below the
	// template's ResponsiveMaxWidth. A zero Set inherits Style unchanged.
	ResponsiveStyle Style
}

func (Element) ValidValue added in v0.0.5

func (element Element) ValidValue(value string) bool

ValidValue checks a control's canonical wire value. Selection membership is checked by the host against the complete staged tree and its current rows.

type Image

type Image struct {
	Scope   uint8
	Name    string
	AssetID uint32
	Top     uint16
	Right   uint16
	Bottom  uint16
	Left    uint16
}

Image is a compiler-resolved nine-slice reference. Game images use a logical name; level images use the stable numeric ID from their owning .kld.

type Length added in v0.0.5

type Length struct {
	Unit  uint8
	Value uint16
}

Length stores logical pixels or hundredths of a percent; zero means auto. A style presence bit distinguishes an explicit auto override from omission.

type Style

type Style struct {
	Set                     uint32
	Set2                    uint32
	Background              uint32
	BackgroundHover         uint32
	BackgroundPressed       uint32
	Color                   uint32
	Padding                 uint16
	Gap                     uint16
	FontSize                uint16
	MinHeight               uint16
	BackgroundImage         Image
	BackgroundImageHover    Image
	BackgroundImagePressed  Image
	BackgroundDisabled      uint32
	BackgroundImageDisabled Image
	ColorHover              uint32
	ColorPressed            uint32
	ColorDisabled           uint32
	FlexDirection           uint8
	AlignItems              uint8
	MinWidth                uint16
	MaxWidth                uint16
	MaxHeight               uint16
	JustifyContent          uint8
	FlexGrow                uint8
	Margin                  uint16
	Overflow                uint8
	TransitionDuration      uint16
	TransitionEnter         uint8
	TransitionExit          uint8
	TextAlign               uint8
	FontFamily              uint8
	ContentImage            Image
	BackgroundFocus         uint32
	BackgroundImageFocus    Image
	ColorFocus              uint32
	TransitionDelay         uint16
	TransitionEasing        uint8
	Position                uint8
	Left                    uint16
	Right                   uint16
	Top                     uint16
	Bottom                  uint16
	ImageFit                uint8
	Tint                    uint32
	Icon                    Image
	IconSize                uint16
	IconPosition            uint8
	IconGap                 uint16
	Width                   Length
	Height                  Length
}

Style is a compact, compiler-resolved presentation value. Set distinguishes an authored zero/transparent value from an omitted property.

type Template

type Template struct {
	Version            uint32
	Modal              bool
	Back               bool
	Panel              Style
	ResponsiveMaxWidth uint16
	ResponsivePanel    Style
	Elements           []Element
}

Template version 1 is a vertical panel of named labels, buttons, and lists. A modal panel captures game input. Schema 9 also permits actionable nonmodal HUD controls; older nonmodal templates retain their noninteractive contract.

func Decode

func Decode(data []byte) (Template, error)

func DecodeComposition

func DecodeComposition(data []byte) (Template, error)

DecodeComposition accepts all versioned retained-tree presentation schemas.

func (Template) Validate

func (template Template) Validate() error

func (Template) ValidateComposition

func (template Template) ValidateComposition() error

ValidateComposition also accepts composition, style, layout, and responsive schemas. Legacy packaging continues using Validate, which accepts schema 1 only.

Jump to

Keyboard shortcuts

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