Documentation
¶
Index ¶
- Constants
- type Alignment
- type Axis
- type Callback
- type ClickCallback
- type ClickListCallback
- type ClickTCallback
- type Context
- func (ctx *Context) AddOverlay(overlay Overlay)
- func (ctx *Context) ClearOverlays()
- func (ctx *Context) DelOverlay(overlay Overlay) (deleted bool)
- func (ctx *Context) Focus(w Widget)
- func (ctx *Context) HasOverlay(overlay Overlay) bool
- func (ctx *Context) IsFocused(w Widget) bool
- func (ctx *Context) IsMouseIn(area geom.Rect) bool
- func (ctx *Context) OnFrame(window *glen.Window, delta time.Duration)
- type Flex
- type FlexItem
- type Grid
- type Grid2
- type Input
- type Label
- type List
- type Overlay
- type Position
- type Rect
- type Rigid
- type Spacing
- type Split
- type Tabs
- type Text
- type Tree
- type TreeWidget
- type Widget
- func Checkbox(disabled, checked *bool, ok, nok Widget, onChange func(checked bool)) Widget
- func OnClick(disabled *bool, btn glen.MouseButton, w Widget, callback ClickCallback) Widget
- func OnDrag(btn glen.MouseButton, w Widget, ...) Widget
- func OnHover(disabled, hovered *bool, w Widget, callbackOn, callbackOff func(ctx *Context)) Widget
- func Pan(axis Axis, widget Widget) Widget
- func Slider(axis Axis, disabled, sliding *bool, ratio *float32, background, handle Widget, ...) Widget
- func Space(size geom.Vec2) Widget
- func Stack(widgets ...Widget) Widget
- func StackOnTop(w1, w2 Widget) Widget
- func Tooltip(disabled *bool, widget, tip Widget, delay time.Duration) Widget
- func (w Widget) Contain(widget Widget) Widget
- func (w Widget) ContainRatio(ratio geom.Vec2) Widget
- func (w Widget) ContainSize(size geom.Vec2) Widget
- func (w Widget) Equal(widget Widget) bool
- func (w Widget) Fixed(size geom.Vec2) Widget
- func (w Widget) FixedRatio(ratio geom.Vec2) Widget
- func (w Widget) Inset(inset float32) Widget
- func (w Widget) InsetV(inset geom.Vec2) Widget
- func (w Widget) Place(pos Position) Widget
- type WidgetList
- type Wrap
Constants ¶
const ( TopLeft Position = 0 TopCenter = 0b1_0_10_01 TopRight = 0b1_0_01_01 LeftCenter = 0b0_1_01_10 Center = 0b1_1_10_10 RightCenter = 0b1_1_01_10 BottomLeft = 0b0_1_01_01 BottomCenter = 0b1_1_10_01 BottomRight = 0b1_1_01_01 )
|.|.|..|..| ^ ^ ^ ^ | | | centerY | | centerX | bottom right
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClickCallback ¶
func OnDoubleClick ¶
func OnDoubleClick(wait time.Duration, btn glen.MouseButton, onSingleClick, onDoubleClick ClickCallback) ClickCallback
type ClickTCallback ¶
func OnDoubleClickT ¶
func OnDoubleClickT[T any]( wait time.Duration, btn glen.MouseButton, onSingleClick, onDoubleClick ClickTCallback[T], ) ClickTCallback[T]
type Context ¶
type Context struct {
Window *glen.Window
Renderer *shape2d.Renderer
Instances []shape2d.Instance
Callbacks []Callback
Ready bool
Root Widget
Background glen.Color
// contains filtered or unexported fields
}
func (*Context) AddOverlay ¶
func (*Context) ClearOverlays ¶
func (ctx *Context) ClearOverlays()
func (*Context) DelOverlay ¶
func (*Context) HasOverlay ¶
type Grid ¶
type Grid struct {
Columns int
Rows int
// Cell returns the size of all cells in the grid.
Cell func(cols, rows int, area geom.Rect) geom.Vec2
}
func (Grid) Widget ¶
func (g Grid) Widget(list WidgetList) Widget
type Label ¶
type Label struct {
Tint glen.Color
Font glen.TextureFont
Alignment Alignment
}
Label is best used with static strings as it caches their representation.
func (Label) WidgetRunes ¶
type List ¶
type Rect ¶
type Spacing ¶
type Spacing uint8
const ( // SpaceEnd puts any remaining space at the end. SpaceEnd Spacing = iota // SpaceStart puts any remaining space at the start. SpaceStart // SpaceAround puts any remaining space evenly at the start and the end. SpaceAround // SpaceBetween puts any remaining space evenly between children. SpaceBetween // SpaceEvenly puts any remaining space evenly between start, children and end. SpaceEvenly )
type Split ¶
type Split struct {
Axis Axis
MouseButton glen.MouseButton
}
type Text ¶
type Text struct {
Tint glen.Color
Font glen.TextureFont
Alignment Alignment
}
func (Text) WidgetFunc ¶
func (Text) WidgetRunes ¶
type Tree ¶
type Tree[T comparable] struct { Axis Axis Alignment Alignment MouseButton glen.MouseButton }
func (Tree[T]) Widget ¶
func (tr Tree[T]) Widget( tree TreeWidget[T], onBusy Widget, onClick ClickTCallback[T], ) Widget
type TreeWidget ¶
type Widget ¶
Widget defines a function that renders a UI component within a given rectangular area and returns its occupied size. Calling Widget with a nil Context will not render anything but return its size nonetheless.
func OnClick ¶
func OnClick(disabled *bool, btn glen.MouseButton, w Widget, callback ClickCallback) Widget
OnClick does not trigger a Context refresh upon click.
func OnDrag ¶
func OnDrag(btn glen.MouseButton, w Widget, onStart func(ctx *Context, area geom.Rect, pos geom.Vec2) (dragArea geom.Rect), onStop func(ctx *Context, pos geom.Vec2), onDrag func(ctx *Context, area geom.Rect, delta geom.Vec2)) Widget
OnDrag triggers its callbacks upon dragging in the provided widget area.
func StackOnTop ¶
Stack w2 on top of w1. w1's area is w2's size.
type WidgetList ¶
WidgetList represents a list of widgets. Return nil to indicate the end of the list.
func OnClickList ¶
func OnClickList(btn glen.MouseButton, list WidgetList, callback ClickListCallback) WidgetList
OnClickList does not trigger a Context refresh upon click.
func Slice ¶
func Slice(widgets ...Widget) WidgetList