Documentation ¶
Index ¶
- Variables
- func RunApp(w Widget) error
- func UseCleanup(cleanup func())
- func UseEffect(setup func() func(), dependencies []any)
- func UseEvent(fn func(context EventContext))
- func UseRawState[T any](initialValue T) (T, func(T))
- func UseRawStateFunc[T any](initialValue func() T) (T, func(func(T) T))
- func UseRef[T any](initialValue *T) *T
- func UseRefFunc[T any](initialValue func() *T) *T
- func UseSetup(setup func())
- func UseState[T comparable](initialValue T) (T, func(T))
- func UseStateFunc[T comparable](initialValue func() T) (T, func(func(T) T))
- func UseTriggerRender() func()
- type Canvas
- func (c *Canvas) FillBackground(x, y, width, height int, background Color)
- func (c *Canvas) GetCell(x, y int) Cell
- func (c *Canvas) OverlayCanvas(x, y int, topCanvas Canvas)
- func (c *Canvas) OverlayImage(x, y int, image image.Image)
- func (c *Canvas) SetCell(x, y int, cell Cell)
- func (c *Canvas) Size() Size
- type Cell
- type CellTextStyle
- type Color
- type ConstraintViolationErr
- type Constraints
- type Dimension
- func (d Dimension) Add(other Dimension) Dimension
- func (d Dimension) AddInt(other int) Dimension
- func (d Dimension) Int() int
- func (d Dimension) IsInf() bool
- func (d Dimension) IsNeg() bool
- func (d Dimension) IsZero() bool
- func (d Dimension) String() string
- func (d Dimension) Sub(other Dimension) Dimension
- func (d Dimension) SubInt(other int) Dimension
- type EdgeInserts
- type Element
- func (e *Element) Children() map[int]*Element
- func (e *Element) MarkNeedsBuild()
- func (e *Element) MarkNeedsPaint()
- func (e *Element) Parent() *Element
- func (e *Element) RenderData() any
- func (e *Element) RenderParentData() any
- func (e *Element) SetRenderData(renderData any)
- func (e *Element) SetRenderParentData(renderParentData any)
- type Equality
- type EventContext
- type LayoutContext
- type PaintContext
- type Pos
- type RenderViewport
- type RenderWidget
- type Size
- func (s Size) Add(other Size) Size
- func (s Size) AddEdgeInserts(edgeInserts EdgeInserts) Size
- func (s Size) Clamp(constraints Constraints) Size
- func (s Size) HasInf() bool
- func (s Size) HasNeg() bool
- func (s Size) HasZero() bool
- func (s Size) LooseConstraints() Constraints
- func (s Size) String() string
- func (s Size) Sub(other Size) Size
- func (s Size) SubEdgeInserts(edgeInserts EdgeInserts) Size
- func (s Size) TightConstraints() Constraints
- type StateWidget
- type Widget
Constants ¶
This section is empty.
Variables ¶
var ( DimensionZero = Dimension{0} DimensionInfinite = Dimension{math.MaxInt} )
var ( SizeZero = Size{ Width: DimensionZero, Height: DimensionZero, } SizeInfinite = Size{ Width: DimensionInfinite, Height: DimensionInfinite, } )
Functions ¶
func UseCleanup ¶
func UseCleanup(cleanup func())
A hook that runs a cleanup function when the widget is unmounted/destroyed.
func UseEffect ¶
func UseEffect(setup func() func(), dependencies []any)
A hook that lets you synchronize a widget with an external system. The setup function will be run when the widget is first mounted, and also whenever the effect's dependencies change. Setup can optionally return a cleanup function, which will be run when the widget is unmounted and also before a dependency change setup is triggered.
func UseEvent ¶
func UseEvent(fn func(context EventContext))
func UseRawState ¶
func UseRawState[T any](initialValue T) (T, func(T))
Like UseState, but will not check if a new value is equal to the old and will always trigger a rerender when set. Only use this if your state contains incomparable values.
func UseRawStateFunc ¶
func UseRawStateFunc[T any](initialValue func() T) (T, func(func(T) T))
Like UseRawState, but uses functions to retrieve the initialization and setter values.
func UseRef ¶
func UseRef[T any](initialValue *T) *T
A hook that lets you reference a value that’s not needed for rendering. If the value you're using is needed for rendering (which is the case the majority of the time), then use one of the UseState hooks.
func UseRefFunc ¶
func UseRefFunc[T any](initialValue func() *T) *T
The most primitive hook to associate persistent data with a widget. A getter function is passed in that will be run once to retrieve the initial value and a reference to the variable is returned by the hook.
If you need to pass in the initial value directly, use UseRef instead. If the value you're using is needed for rendering (which is the case the majority of the time), then use one of the UseState hooks.
func UseSetup ¶
func UseSetup(setup func())
A hook that runs a setup function when the widget is first mounted
func UseState ¶
func UseState[T comparable](initialValue T) (T, func(T))
func UseStateFunc ¶
func UseStateFunc[T comparable](initialValue func() T) (T, func(func(T) T))
func UseTriggerRender ¶
func UseTriggerRender() func()
A hook used to queue a widget render. This should almost never be needed for standard use cases; try using one of the UseState hooks instead.
Types ¶
type Canvas ¶
type Canvas struct {
// contains filtered or unexported fields
}
func (*Canvas) FillBackground ¶
func (*Canvas) OverlayCanvas ¶
type Cell ¶
type Cell struct { // Default rune represents no change in text Rune rune Background, Foreground Color TextStyle *CellTextStyle }
type CellTextStyle ¶
type Color ¶
type Color struct {
R, G, B, A uint8
}
func ColorFromImageColor ¶
func ColorFromImageColor(c imageColor.Color) Color
type ConstraintViolationErr ¶
type ConstraintViolationErr struct {
// contains filtered or unexported fields
}
func (*ConstraintViolationErr) Error ¶
func (err *ConstraintViolationErr) Error() string
type Constraints ¶
func (Constraints) Check ¶
func (c Constraints) Check(size Size) bool
type Dimension ¶
type Dimension struct {
// contains filtered or unexported fields
}
type EdgeInserts ¶
func EdgeInsertsAll ¶
func EdgeInsertsAll(value int) EdgeInserts
func EdgeInsertsSymmetric ¶
func EdgeInsertsSymmetric(vertical int, horizontal int) EdgeInserts
func (EdgeInserts) String ¶
func (ei EdgeInserts) String() string
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
func (*Element) MarkNeedsBuild ¶
func (e *Element) MarkNeedsBuild()
func (*Element) MarkNeedsPaint ¶
func (e *Element) MarkNeedsPaint()
func (*Element) RenderData ¶
func (*Element) RenderParentData ¶
func (*Element) SetRenderData ¶
func (*Element) SetRenderParentData ¶
type EventContext ¶
type LayoutContext ¶
type LayoutContext struct { Constraints Constraints LayoutChild func(key int, c Widget, constraints Constraints) (Size, error) PositionChild func(key int, pos Pos) error }
type PaintContext ¶
type RenderViewport ¶
type RenderWidget ¶
type RenderWidget interface { Widget Layout(context LayoutContext) (Size, error) Paint(context PaintContext) error }
type Size ¶
func SizeSquare ¶
func SizeSquareVisual ¶
func (Size) AddEdgeInserts ¶
func (s Size) AddEdgeInserts(edgeInserts EdgeInserts) Size
Creates a Size with the original size plus edge inserts
func (Size) Clamp ¶
func (s Size) Clamp(constraints Constraints) Size
func (Size) LooseConstraints ¶
func (s Size) LooseConstraints() Constraints
Creates constraints that forbid sizes larger than this size
func (Size) SubEdgeInserts ¶
func (s Size) SubEdgeInserts(edgeInserts EdgeInserts) Size
Creates a Size with the original size plus edge inserts
func (Size) TightConstraints ¶
func (s Size) TightConstraints() Constraints
Creates constraints that is respected only by this size