gorlet

package
v0.0.0-...-6aa7f09 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OverflowVisible = Overflow(iota)
	OverflowHidden
	OverflowScroll
)

Variables

View Source
var Debug = false

Debug prints reference debug

Functions

func Build

func Build[T baseIniter[T]](v T) T

func DebugCounter

func DebugCounter() int64

DebugCounter returns the number of gorlets instantiated.

func Find

func Find[T any](e Entity, fn func(v *T))

Types

type AutoHeightLayout

type AutoHeightLayout struct {
	Spacing float32
}

func AutoHeight

func AutoHeight(spacing float32) *AutoHeightLayout

AutoHeight be resize to content.

func (AutoHeightLayout) Layout

func (l AutoHeightLayout) Layout(ent Entity)

type B

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

func (*B) Add

func (b *B) Add(e Entity)

func (*B) Begin

func (b *B) Begin(e Entity)

func (*B) BeginButton

func (b *B) BeginButton() *WButton

func (*B) BeginContainer

func (b *B) BeginContainer(l ...Layouter) *WContainer

func (*B) BeginFlex

func (b *B) BeginFlex(sizes ...float32) *WFlex

func (*B) BeginGrid

func (b *B) BeginGrid(cols, rows int) *WGrid

func (*B) BeginList

func (b *B) BeginList(spacing float32) *WList

func (*B) BeginMask

func (b *B) BeginMask() *WMask

func (*B) BeginPane

func (b *B) BeginPane() *WPane

func (*B) BeginPanel

func (b *B) BeginPanel() *WPanel

func (*B) Button

func (b *B) Button() *WButton

func (*B) ClientArea

func (b *B) ClientArea()

func (*B) ColorPicker

func (b *B) ColorPicker() *WColorPicker

func (*B) Container

func (b *B) Container() *WContainer

func (*B) Do

func (b *B) Do(fn BuildFunc)

func (*B) End

func (b *B) End()

End pops the current guilet from the stack.

func (*B) EndButton

func (b *B) EndButton()

func (*B) EndContainer

func (b *B) EndContainer()

func (*B) EndFlex

func (b *B) EndFlex()

func (*B) EndGrid

func (b *B) EndGrid()

func (*B) EndList

func (b *B) EndList()

func (*B) EndMask

func (b *B) EndMask()

func (*B) EndPane

func (b *B) EndPane()

func (*B) EndPanel

func (b *B) EndPanel()

func (*B) Label

func (b *B) Label(t string) *WLabel

func (*B) Pane

func (b *B) Pane() *WPane

func (*B) Root

func (b *B) Root() Entity

Might be wrong if it's not custom widget but we only need too in custom.

func (*B) SetRoot

func (b *B) SetRoot(e Entity)

func (*B) Slider

func (b *B) Slider(min, max float32) *WSlider

func (*B) Spinner

func (b *B) Spinner(lbl string) *WSpinner

func (*B) SpinnerVec3

func (b *B) SpinnerVec3() *WSpinnerVec3

func (*B) TextButton

func (b *B) TextButton(t string) *WTextButton

func (*B) Tree

func (b *B) Tree(n *TreeNode) *WTree

type BuildFunc

type BuildFunc func(*B)

type Direction

type Direction int

Direction for certain types of layouts

const (
	Horizontal Direction = iota
	Vertical
)

Layout direction

type Entity

type Entity interface {
	gorgeui.Entity
	event.Buser

	ID() string
	SetID(string)
	Find(string) Entity

	GetEntities() []gorge.Entity
	// contains filtered or unexported methods
}

type EventClick

type EventClick struct{} // need more info

EventClick is trigger when an event is clicked.

type EventValueChanged

type EventValueChanged struct{ Value any }

EventValueChanged triggered when an input value is changed.

type FlexLayout

type FlexLayout struct {
	Spacing   float32
	Direction Direction
	// contains filtered or unexported fields
}

FlexLayout will redimension children based on sizes.

func LayoutFlexHorizontal

func LayoutFlexHorizontal(sizes ...float32) *FlexLayout

LayoutFlexHorizontal automatically layout children horizontally based on sizes.

func LayoutFlexVertical

func LayoutFlexVertical(sizes ...float32) *FlexLayout

LayoutFlexVertical automatically layout children vertically based on sizes.

func (FlexLayout) Layout

func (l FlexLayout) Layout(ent Entity)

Layout implements layouter interface.

func (*FlexLayout) SetDirection

func (l *FlexLayout) SetDirection(d Direction)

func (*FlexLayout) SetSizes

func (l *FlexLayout) SetSizes(sizes ...float32)

SetSizes sets new sizes and recalculates flex.

func (*FlexLayout) SetSpacing

func (l *FlexLayout) SetSpacing(spacing float32)

func (*FlexLayout) String

func (f *FlexLayout) String() string

type GridLayout

type GridLayout struct {
	Cols    int
	Rows    int
	Spacing float32
}

GridLayout creates a grid layouter that organizes children in a grid

func LayoutGrid

func LayoutGrid(cols, rows int, spacing float32) *GridLayout

LayoutGrid creates a grid probably only needs one dimension.

func (*GridLayout) Layout

func (l *GridLayout) Layout(ent Entity)

Layout implements layouter interface.

func (*GridLayout) SetDimensions

func (l *GridLayout) SetDimensions(cols, rows int)

func (*GridLayout) SetSpacing

func (l *GridLayout) SetSpacing(spacing float32)

type LayoutFunc

type LayoutFunc func(ent Entity)

LayoutFunc type of func to be attached in UI element to update layout.

func (LayoutFunc) Layout

func (fn LayoutFunc) Layout(ent Entity)

Layout implements layouter interface.

type Layouter

type Layouter interface {
	Layout(Entity)
}

Layouter interface for layouting entities.

type ListLayout

type ListLayout struct {
	// Spacing between elements
	Spacing   float32
	Direction Direction
}

ListLayout layouter that will rearrange children vertically.

func LayoutList

func LayoutList(spacing float32) *ListLayout

LayoutList returns a func that will automatically layout children vertically based on sizes.

func (*ListLayout) Layout

func (l *ListLayout) Layout(ent Entity)

Layout implements layouter

func (*ListLayout) SetDirection

func (l *ListLayout) SetDirection(v Direction)

func (*ListLayout) SetSpacing

func (l *ListLayout) SetSpacing(v float32)

type MultiLayout

type MultiLayout []Layouter

func LayoutMulti

func LayoutMulti(ls ...Layouter) MultiLayout

func (MultiLayout) Layout

func (l MultiLayout) Layout(ent Entity)

func (MultiLayout) String

func (l MultiLayout) String() string

type Observer

type Observer struct {
	Type  reflect.Type // Func type
	Funcs []observerFunc
}

func (*Observer) Call

func (o *Observer) Call(v any)

type Overflow

type Overflow int

func (Overflow) String

func (o Overflow) String() string

type Path

type Path struct {
	gorge.MeshData
	// contains filtered or unexported fields
}

func NewPath

func NewPath() *Path

func (*Path) CurveTo

func (p *Path) CurveTo(b, c gm.Vec2)

func (*Path) LineTo

func (p *Path) LineTo(x, y float32)

func (*Path) MoveTo

func (p *Path) MoveTo(x, y float32)

func (*Path) Reset

func (p *Path) Reset()

type TreeNode

type TreeNode struct {
	Name     string
	Children []*TreeNode
}

type WButton

type WButton struct {
	Widget[WButton]
	// contains filtered or unexported fields
}

func Button

func Button(children ...gorge.Entity) *WButton

func (*WButton) Build

func (w *WButton) Build(b *B)

func (*WButton) Color

func (w *WButton) Color(vs ...float32) *WButton

func (*WButton) FadeFactor

func (w *WButton) FadeFactor(f float32) *WButton

func (*WButton) Highlight

func (w *WButton) Highlight(vs ...float32) *WButton

func (*WButton) OnClick

func (w *WButton) OnClick(fn func()) *WButton

func (*WButton) Pressed

func (w *WButton) Pressed(vs ...float32) *WButton

type WColorPicker

type WColorPicker struct {
	Widget[WColorPicker]
	// contains filtered or unexported fields
}

func ColorPicker

func ColorPicker() *WColorPicker

func (*WColorPicker) Build

func (w *WColorPicker) Build(b *B)

func (*WColorPicker) OnChange

func (w *WColorPicker) OnChange(fn func(gm.Vec4)) *WColorPicker

func (*WColorPicker) SetValue

func (w *WColorPicker) SetValue(c gm.Vec4) *WColorPicker

type WContainer

type WContainer struct {
	Widget[WContainer]
	// contains filtered or unexported fields
}

func Container

func Container(c ...gorge.Entity) *WContainer

func (*WContainer) Build

func (w *WContainer) Build(b *B)

func (*WContainer) SetLayout

func (w *WContainer) SetLayout(l ...Layouter) *WContainer

type WCustom

type WCustom struct {
	Widget[WCustom]
	Layout Layouter
	// contains filtered or unexported fields
}

func Custom

func Custom(fn BuildFunc) *WCustom

func (*WCustom) Observe

func (w *WCustom) Observe(k string, ifn any)

func (*WCustom) ObserveType

func (w *WCustom) ObserveType(k string, typ reflect.Type, fn func(any))

func (*WCustom) Observer

func (w *WCustom) Observer(k string) *Observer

Observer returns the observer

func (*WCustom) Set

func (w *WCustom) Set(k string, v any) *WCustom

func (*WCustom) SetLayout

func (w *WCustom) SetLayout(li ...Layouter) *WCustom

func (*WCustom) String

func (w *WCustom) String() string

type WFlex

type WFlex struct {
	Widget[WFlex]
	// contains filtered or unexported fields
}

func Flex

func Flex(vs ...float32) *WFlex

func (*WFlex) Build

func (w *WFlex) Build(b *B)

func (*WFlex) SetDirection

func (w *WFlex) SetDirection(v Direction) *WFlex

func (*WFlex) SetSizes

func (w *WFlex) SetSizes(vs ...float32) *WFlex

func (*WFlex) SetSpacing

func (w *WFlex) SetSpacing(v float32) *WFlex

type WGrid

type WGrid struct {
	Widget[WGrid]
	// contains filtered or unexported fields
}

func Grid

func Grid(c ...gorge.Entity) *WGrid

func (*WGrid) Build

func (w *WGrid) Build(b *B)

func (*WGrid) SetCols

func (w *WGrid) SetCols(cols int) *WGrid

func (*WGrid) SetDimensions

func (w *WGrid) SetDimensions(cols, rows int) *WGrid

func (*WGrid) SetRows

func (w *WGrid) SetRows(rows int) *WGrid

func (*WGrid) SetSpacing

func (w *WGrid) SetSpacing(c float32) *WGrid

type WLabel

type WLabel struct {
	Widget[WLabel]
	// contains filtered or unexported fields
}

func Label

func Label(t string) *WLabel

func (*WLabel) Build

func (w *WLabel) Build(b *B)

func (*WLabel) SetAutoSize

func (w *WLabel) SetAutoSize(b bool) *WLabel

func (*WLabel) SetColor

func (w *WLabel) SetColor(vs ...float32) *WLabel

func (*WLabel) SetFont

func (w *WLabel) SetFont(font *text.Font) *WLabel

func (*WLabel) SetFontScale

func (w *WLabel) SetFontScale(v float32) *WLabel

func (*WLabel) SetOverflow

func (w *WLabel) SetOverflow(o text.Overflow) *WLabel

func (*WLabel) SetText

func (w *WLabel) SetText(text string) *WLabel

func (*WLabel) SetTextAlign

func (w *WLabel) SetTextAlign(a ...text.Align) *WLabel

func (*WLabel) SetTextf

func (w *WLabel) SetTextf(f string, args ...any) *WLabel

type WList

type WList struct {
	Widget[WList]
	// contains filtered or unexported fields
}

func List

func List(c ...gorge.Entity) *WList

func (*WList) Build

func (w *WList) Build(b *B)

func (*WList) SetAutoHeight

func (w *WList) SetAutoHeight(b bool) *WList

func (*WList) SetDirection

func (w *WList) SetDirection(dir Direction) *WList

func (*WList) SetSpacing

func (w *WList) SetSpacing(v float32) *WList

type WMask

type WMask struct {
	Widget[WMask]
	// contains filtered or unexported fields
}

func Mask

func Mask(c ...gorge.Entity) *WMask

func (*WMask) Build

func (w *WMask) Build(b *B)

func (*WMask) SetBorderRadius

func (w *WMask) SetBorderRadius(r float32) *WMask

type WPane

type WPane struct {
	Widget[WPane]
	// contains filtered or unexported fields
}

func Pane

func Pane(c ...gorge.Entity) *WPane

func (*WPane) Build

func (w *WPane) Build(b *B)

func (*WPane) SetBorderColor

func (w *WPane) SetBorderColor(vs ...float32) *WPane

func (*WPane) SetBorderRadius

func (w *WPane) SetBorderRadius(r float32) *WPane

func (*WPane) SetColor

func (w *WPane) SetColor(vs ...float32) *WPane

func (*WPane) SetLayout

func (w *WPane) SetLayout(l ...Layouter) *WPane

func (*WPane) SetMaterial

func (w *WPane) SetMaterial(mat gorge.Materialer) *WPane

func (*WPane) SetTexture

func (w *WPane) SetTexture(tex gorge.Texturer) *WPane

type WPanel

type WPanel struct {
	Widget[WPanel]
	// contains filtered or unexported fields
}

func Panel

func Panel(cs ...gorge.Entity) *WPanel

Panel creates a new panel widget.

func (*WPanel) Build

func (w *WPanel) Build(b *B)

func (*WPanel) SetBorderColor

func (w *WPanel) SetBorderColor(vs ...float32) *WPanel

func (*WPanel) SetColor

func (w *WPanel) SetColor(vs ...float32) *WPanel

func (*WPanel) SetLayout

func (w *WPanel) SetLayout(l ...Layouter) *WPanel

func (*WPanel) SetOverflow

func (w *WPanel) SetOverflow(o Overflow) *WPanel

func (*WPanel) SetScrollSize

func (w *WPanel) SetScrollSize(s ...float32) *WPanel

type WQuad

type WQuad struct {
	Widget[WQuad]
	// contains filtered or unexported fields
}

func Quad

func Quad(c ...gorge.Entity) *WQuad

func (*WQuad) Build

func (w *WQuad) Build(b *B)

func (*WQuad) SetColor

func (w *WQuad) SetColor(vs ...float32)

type WScroll

type WScroll struct {
	Widget[WScroll]
	// contains filtered or unexported fields
}

func Scroll

func Scroll(c ...gorge.Entity) *WScroll

func (*WScroll) Build

func (w *WScroll) Build(b *B)

func (*WScroll) SetScrollSize

func (w *WScroll) SetScrollSize(v ...float32) *WScroll

type WScrollbar

type WScrollbar struct {
	Widget[WScrollbar]
	// contains filtered or unexported fields
}

func Scrollbar

func Scrollbar(dir Direction) *WScrollbar

func (*WScrollbar) Build

func (w *WScrollbar) Build(b *B)

func (*WScrollbar) OnChange

func (w *WScrollbar) OnChange(fn func(v float32)) *WScrollbar

func (*WScrollbar) SetMax

func (w *WScrollbar) SetMax(v float32) *WScrollbar

func (*WScrollbar) SetValue

func (w *WScrollbar) SetValue(v float32) *WScrollbar

type WSlider

type WSlider struct {
	Widget[WSlider]
	// contains filtered or unexported fields
}

func Slider

func Slider(min, max float32) *WSlider

func (*WSlider) Build

func (w *WSlider) Build(b *B)

func (*WSlider) OnChange

func (w *WSlider) OnChange(f func(float32)) *WSlider

func (*WSlider) SetFontScale

func (w *WSlider) SetFontScale(v float32) *WSlider

func (*WSlider) SetFormat

func (w *WSlider) SetFormat(f string) *WSlider

func (*WSlider) SetMax

func (w *WSlider) SetMax(v float32) *WSlider

func (*WSlider) SetMin

func (w *WSlider) SetMin(v float32) *WSlider

func (*WSlider) SetValue

func (w *WSlider) SetValue(v float32) *WSlider

type WSpinner

type WSpinner struct {
	Widget[WSpinner]
	// contains filtered or unexported fields
}

func Spinner

func Spinner(lbl string) *WSpinner

func (*WSpinner) Build

func (w *WSpinner) Build(b *B)

func (*WSpinner) OnChange

func (w *WSpinner) OnChange(fn func(float32)) *WSpinner

func (*WSpinner) SetLabel

func (w *WSpinner) SetLabel(t string) *WSpinner

func (*WSpinner) SetLabelColor

func (w *WSpinner) SetLabelColor(c ...float32) *WSpinner

func (*WSpinner) SetLabelTextColor

func (w *WSpinner) SetLabelTextColor(c ...float32) *WSpinner

func (*WSpinner) SetTextColor

func (w *WSpinner) SetTextColor(c ...float32) *WSpinner

func (*WSpinner) SetValue

func (w *WSpinner) SetValue(v float32) *WSpinner

type WSpinnerVec3

type WSpinnerVec3 struct {
	Widget[WSpinnerVec3]
	// contains filtered or unexported fields
}

func SpinnerVec3

func SpinnerVec3() *WSpinnerVec3

func (*WSpinnerVec3) Build

func (w *WSpinnerVec3) Build(b *B)

func (*WSpinnerVec3) OnChange

func (w *WSpinnerVec3) OnChange(fn func(v gm.Vec3)) *WSpinnerVec3

func (*WSpinnerVec3) SetValue

func (w *WSpinnerVec3) SetValue(v gm.Vec3) *WSpinnerVec3

type WTextButton

type WTextButton struct {
	Widget[WTextButton]
	// contains filtered or unexported fields
}

func TextButton

func TextButton(t string) *WTextButton

func (*WTextButton) Build

func (w *WTextButton) Build(b *B)

func (*WTextButton) FadeFactor

func (w *WTextButton) FadeFactor(f float32) *WTextButton

func (*WTextButton) OnClick

func (w *WTextButton) OnClick(fn func()) *WTextButton

func (*WTextButton) SetColor

func (w *WTextButton) SetColor(vs ...float32) *WTextButton

func (*WTextButton) SetFontScale

func (w *WTextButton) SetFontScale(s float32) *WTextButton

func (*WTextButton) SetHighlightColor

func (w *WTextButton) SetHighlightColor(vs ...float32) *WTextButton

func (*WTextButton) SetPressedColor

func (w *WTextButton) SetPressedColor(vs ...float32) *WTextButton

func (*WTextButton) SetText

func (w *WTextButton) SetText(t string) *WTextButton

type WTree

type WTree struct {
	Widget[WTree]
	// contains filtered or unexported fields
}

func Tree

func Tree(n *TreeNode) *WTree

Need to pass some kind of data like strings and string children

func (*WTree) Build

func (w *WTree) Build(b *B)

func (*WTree) SetClosed

func (w *WTree) SetClosed(v bool) *WTree

func (*WTree) SetOffset

func (w *WTree) SetOffset(v float32) *WTree

type Widget

type Widget[T any] struct {
	gorgeui.RectComponent
	gorgeui.ElementComponent

	gorge.Container
	// contains filtered or unexported fields
}

func (*Widget[T]) Add

func (w *Widget[T]) Add(cs ...gorge.Entity) *T

func (*Widget[T]) Attached

func (w *Widget[T]) Attached(e gorgeui.Entity)

func (*Widget[T]) CalcMax

func (w *Widget[T]) CalcMax() gm.Vec2

CalcMax calculates children bounds and positions and return min max Calc maximum of the children

func (*Widget[T]) FillParent

func (w *Widget[T]) FillParent() *T

func (*Widget[T]) Find

func (w *Widget[T]) Find(id string) Entity

Find returns the first entity in the graph that matches the predicate.

func (*Widget[T]) GetClientArea

func (w *Widget[T]) GetClientArea() Entity

func (*Widget[T]) HandleEvent

func (w *Widget[T]) HandleEvent(evt event.Event)

HandleEvent handles events.

func (*Widget[T]) ID

func (w *Widget[T]) ID() string

func (*Widget[T]) IntersectFromScreen

func (w *Widget[T]) IntersectFromScreen(pos gm.Vec2) ray.Result

IntersectFromScreen intersects the entity rect from screen coordinates.

func (*Widget[T]) IsMasked

func (w *Widget[T]) IsMasked() bool

IsMasked returns true if the widget is masked so it won't receive further events outside of its bounds.

func (*Widget[T]) Remove

func (w *Widget[T]) Remove(cs ...gorge.Entity) *T

func (*Widget[T]) SetAnchor

func (w *Widget[T]) SetAnchor(vs ...float32) *T

func (*Widget[T]) SetBorder

func (w *Widget[T]) SetBorder(vs ...float32) *T

func (*Widget[T]) SetClientArea

func (w *Widget[T]) SetClientArea(a Entity) *T

func (*Widget[T]) SetDisableRaycast

func (w *Widget[T]) SetDisableRaycast(b bool) *T

func (*Widget[T]) SetDragEvents

func (w *Widget[T]) SetDragEvents(b bool) *T

func (*Widget[T]) SetHeight

func (w *Widget[T]) SetHeight(v float32) *T

func (*Widget[T]) SetID

func (w *Widget[T]) SetID(id string)

func (*Widget[T]) SetMargin

func (w *Widget[T]) SetMargin(vs ...float32) *T

func (*Widget[T]) SetName

func (w *Widget[T]) SetName(name string) *T

func (*Widget[T]) SetPivot

func (w *Widget[T]) SetPivot(vs ...float32) *T

func (*Widget[T]) SetPosition

func (w *Widget[T]) SetPosition(x, y, z float32) *T

func (*Widget[T]) SetRect

func (w *Widget[T]) SetRect(vs ...float32) *T

func (*Widget[T]) SetSize

func (w *Widget[T]) SetSize(v ...float32) *T

func (*Widget[T]) SetWidth

func (w *Widget[T]) SetWidth(v float32) *T

func (*Widget[T]) String

func (w *Widget[T]) String() string

Jump to

Keyboard shortcuts

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