definition

package
v0.0.0-...-0d67019 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindingFromMap

func BindingFromMap[T types.Bindable](
	ctx types.Context,
	data map[string]any,
	key string,
) (
	res T,
	ok bool,
)

func ElementById

func ElementById[T any](def *Definition, id string) (elem T, ok bool)

func FunctionFromMap

func FunctionFromMap[T any](
	ctx types.Context,
	data map[string]any,
	key string,
) (
	res T,
	ok bool,
)

func GioConstantFromMap

func GioConstantFromMap[T gioConst](
	data map[string]any,
	key string,
) (
	res T,
	ok bool,
)

func MapValue

func MapValue[T any](
	data map[string]any,
	key string,
) (
	res T,
	ok bool,
)

func MapValueBool

func MapValueBool[T ~bool](
	data map[string]any,
	key string,
) (
	res T,
	ok bool,
)

func MapValueColor

func MapValueColor(
	data map[string]any,
	key string,
) (
	res color.NRGBA,
	ok bool,
)

func MapValueFloat

func MapValueFloat[T constraints.Float](
	data map[string]any,
	key string,
) (
	res T,
	ok bool,
)

func MapValueFont

func MapValueFont(
	ctx types.Context,
	data map[string]any,
	fontKey string,
	fontStyleKey string,
	fontWeightKey string,
) (
	res giofont.FontFace,
	ok bool,
)

func MapValueInt

func MapValueInt[T constraints.Integer](
	data map[string]any,
	key string,
) (
	res T,
	ok bool,
)

func MapValueString

func MapValueString[T ~string](
	data map[string]any,
	key string,
) (
	res T,
	ok bool,
)

func RegisterUIElement

func RegisterUIElement(e types.UIElement, constructor ConstructorFn)

Types

type ConstructorFn

type ConstructorFn func(types.Context, map[string]any) (DefinitionType, error)

type Definition

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

func New

func New(
	ctx types.Context,
	filesystem embed.FS,
	name string,
) (def *Definition, err error)

func (Definition) ElementById

func (d Definition) ElementById(id string) (elem types.UIElement, ok bool)

func (Definition) Root

func (d Definition) Root() types.UIElement

type DefinitionType

type DefinitionType interface {
	types.UIElement
	AddChild(types.UIElement, ...float32) bool
}

func Instantiate

func Instantiate(
	ctx types.Context,
	name string,
	data map[string]any,
) (
	res DefinitionType,
	err error,
)

Jump to

Keyboard shortcuts

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