Documentation ¶
Overview ¶
ux is a package that supplies basic components built on the ui package.
The components in the ux package are structured in the following way: - XSettings: common options for the X component that can be specified globally - X: the X component options that can be built into a component - XBase: the built X component
The options and built component can be passed as children to other components, anything that implements HasComponent can be. When passing options (which would be the most common use case) it is built by the parent while the parent is being built.
Each Kind can have a Template defined, and each component has a kind or can be given a custom kind that dictates which template it uses. For example ux defines one kind of Button but you can define `const KindFAB ux.Kind = 45` and then pass `Kind: KindFAB` to `Button` and also define the FAB template on the theme.
Index ¶
- type Base
- type Button
- type ButtonBase
- func (b *ButtonBase) Action(name string) *input.Action
- func (b *ButtonBase) ClickAction(name string) *input.Action
- func (b *ButtonBase) Clicked() bool
- func (b *ButtonBase) EnterAction(name string) *input.Action
- func (b *ButtonBase) Entered() bool
- func (b *ButtonBase) GetComponent(theme *Theme) *ui.Base
- type ButtonSettings
- type Checkbox
- type CheckboxSettings
- type Computed
- type Constant
- type Counter
- type Dialog
- type DialogSettings
- type Dropdown
- type DropdownBase
- type DropdownSettings
- type Dynamic
- type Editable
- type EditableSettings
- type HasComponent
- type Icon
- type IconSettings
- type Kind
- type Listener
- type Live
- type Relative
- type RelativeBase
- type RelativeOnEvent
- type RelativePlacement
- type RelativeSettings
- type Settings
- type Theme
- type Trigger
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Button ¶
type Button struct { Base Settings ButtonSettings Text string TextValue Value[string] TextPlacement ui.Placement LeftIcon *Icon RightIcon *Icon OnClick Listener[*ButtonBase] OnEnter Listener[*ButtonBase] OnAction Listener[*ButtonBase] OnPointer func(ev *ui.PointerEvent) }
func (Button) Build ¶
func (b Button) Build(theme *Theme) *ButtonBase
type ButtonBase ¶
type ButtonBase struct { Component *ui.Base Text Value[string] Options Button TextVisual *ui.VisualText // contains filtered or unexported fields }
func (*ButtonBase) ClickAction ¶
func (b *ButtonBase) ClickAction(name string) *input.Action
func (*ButtonBase) Clicked ¶
func (b *ButtonBase) Clicked() bool
func (*ButtonBase) EnterAction ¶
func (b *ButtonBase) EnterAction(name string) *input.Action
func (*ButtonBase) Entered ¶
func (b *ButtonBase) Entered() bool
func (*ButtonBase) GetComponent ¶
func (b *ButtonBase) GetComponent(theme *Theme) *ui.Base
type ButtonSettings ¶
type ButtonSettings struct {
Padding ui.AmountBounds
}
type CheckboxSettings ¶
type Computed ¶
type Computed[V comparable] struct { // contains filtered or unexported fields }
A value that is computed when GetChanged is invoked and it returns a new value then last time. Set has no effect.
func NewComputed ¶
func NewComputed[V comparable](getValue func() V) *Computed[V]
func (*Computed[V]) GetChanged ¶
func (w *Computed[V]) GetChanged() *V
type Constant ¶
type Constant[V any] struct { // contains filtered or unexported fields }
A value that is changed by set.
func NewConstant ¶
func (*Constant[V]) GetChanged ¶
func (c *Constant[V]) GetChanged() *V
type Dialog ¶
type Dialog struct { Title string TitleValue Value[string] Children []HasComponent RetainOrderOnDrag bool HideMaximize bool HideClose bool AllowOutside bool DisableDragging bool DisableResize bool DisableResizeLeft bool DisableResizeBottomLeft bool DisableResizeBottom bool DisableResizeBottomRight bool DisableResizeRight bool OnResize func(b ui.Bounds) OnDrag func(b ui.Bounds) OnMaximize func() OnMinimize func() OnClose func() }
type DialogSettings ¶
type DialogSettings struct { BarHeight ui.Amount BarPadding ui.AmountBounds ChildrenPadding ui.AmountBounds DragTransparency float32 }
type Dropdown ¶
type Dropdown[I any] struct { Items []I PlaceholderText string Placeholder HasComponent Value I ItemText func(item I) string ItemComponent func(item I) HasComponent OnChange func(item I) ValueCompare func(a, b I) bool DropdownSettings }
type DropdownBase ¶
type DropdownBase[I any] struct { }
type DropdownSettings ¶
type DropdownSettings struct { TriggerOnDown bool TriggerOnEnter bool TriggerOnFocus bool ShowAnimation ui.AnimationFactory HideAnimation ui.AnimationFactory }
type Dynamic ¶
type Dynamic[V comparable] struct { // contains filtered or unexported fields }
A value that is computed when GetChanged is invoked but also supports setting.
func NewDynamic ¶
func NewDynamic[V comparable](get func() V, set func(V)) *Dynamic[V]
func (*Dynamic[V]) GetChanged ¶
func (d *Dynamic[V]) GetChanged() *V
type EditableSettings ¶
type EditableSettings struct { }
type HasComponent ¶
type IconSettings ¶
type IconSettings struct { }
type Listener ¶
type Listener[E any] func(ev E)
A listener is a function where multiple can be added.
type Live ¶
type Live[V any] struct { // contains filtered or unexported fields }
A value that is expected to change every time GetChanged is invoked.
func (*Live[V]) GetChanged ¶
func (d *Live[V]) GetChanged() *V
type Relative ¶
type Relative struct { RelativeSettings Placement RelativePlacement RelativeTo HasComponent Content HasComponent OnShow Listener[*RelativeBase] OnHide Listener[*RelativeBase] }
func (Relative) Build ¶
func (r Relative) Build(theme *Theme) *RelativeBase
type RelativeBase ¶
type RelativeBase struct { Component *ui.Base RelativeTo *ui.Base Content *ui.Base Enabled Value[bool] Visible Value[bool] Options Relative // contains filtered or unexported fields }
func (*RelativeBase) GetComponent ¶
func (rb *RelativeBase) GetComponent(theme *Theme) *ui.Base
func (*RelativeBase) Hide ¶
func (rb *RelativeBase) Hide()
func (*RelativeBase) Show ¶
func (rb *RelativeBase) Show()
func (*RelativeBase) Toggle ¶
func (rb *RelativeBase) Toggle()
func (*RelativeBase) Trigger ¶
func (rb *RelativeBase) Trigger(on RelativeOnEvent)
type RelativeOnEvent ¶
type RelativeOnEvent int
const ( RelativeOnNone RelativeOnEvent = (1 << iota) >> 1 RelativeOnPointerEnter RelativeOnPointerLeave RelativeOnFocus RelativeOnBlur RelativeOnClick RelativeOnEscape RelativeOnSpace RelativeOnOutside RelativeOnKeyDown )
type RelativePlacement ¶
type RelativePlacement struct { Anchor ui.AmountPoint Align ui.AmountPoint Offset ui.AmountPoint Distance float32 MatchWidth, MatchHeight bool }
type RelativeSettings ¶
type RelativeSettings struct { HideOn RelativeOnEvent ShowOn RelativeOnEvent ToggleOn RelativeOnEvent ShowAnimation ui.AnimationFactory HideAnimation ui.AnimationFactory }
type Settings ¶
type Settings struct { Button ButtonSettings Dialog DialogSettings Checkbox CheckboxSettings Editable EditableSettings Icon IconSettings Dropdown DropdownSettings }
type Trigger ¶
type Trigger float32
A trigger used for input actions.
func (Trigger) Init ¶
func (t Trigger) Init(inputs input.InputSystem)
func (Trigger) InputCount ¶
type Value ¶
type Value[V any] interface { // If the value has changed since the last time this method was called // a non-nil value will be returned pointing to the new value. GetChanged() *V // Sets the value. Set(value V) }
A value that can be tracked for changes.
func CoalesceValue ¶
Returns a Value[V] given an optional value and its constant alternative if a value was not given.