avyos.dev/pkg/graphics/widget

package widget

Overview

No package-level documentation is provided.

Export GroupCount
Constants0
Variables0
Functions0
Types3

Types

BaseWidget

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

BaseWidget provides common functionality for widgets.

Functions

NewBaseWidget

func NewBaseWidget() BaseWidget

NewBaseWidget creates a new base widget.

Methods

Bounds

func (w *BaseWidget) Bounds() image.Rectangle

Bounds returns the widget's bounds.

IsDirty

func (w *BaseWidget) IsDirty() bool

IsDirty returns true if the widget needs to be redrawn.

IsFocused

func (w *BaseWidget) IsFocused() bool

IsFocused returns true if the widget has focus.

IsVisible

func (w *BaseWidget) IsVisible() bool

IsVisible returns true if the widget is visible.

MarkClean

func (w *BaseWidget) MarkClean()

MarkClean marks the widget as not needing a redraw.

MarkDirty

func (w *BaseWidget) MarkDirty()

MarkDirty marks the widget as needing a redraw.

MinSize

func (w *BaseWidget) MinSize() image.Point

MinSize returns the minimum size the widget needs.

SelfDirty

func (w *BaseWidget) SelfDirty() bool

SelfDirty returns true if the widget itself needs a redraw. Containers can use this to distinguish their own dirty state from children.

SetBounds

func (w *BaseWidget) SetBounds(r image.Rectangle)

SetBounds sets the widget's bounds.

SetFocused

func (w *BaseWidget) SetFocused(focused bool)

SetFocused sets the focus state of the widget.

SetMinSize

func (w *BaseWidget) SetMinSize(size image.Point)

SetMinSize sets the minimum size for the widget.

SetVisible

func (w *BaseWidget) SetVisible(visible bool)

SetVisible sets the visibility of the widget.

TextAlign

type TextAlign int

TextAlign represents text alignment.

Constants

AlignLeft, AlignCenter, AlignRight

const (
	AlignLeft TextAlign = iota
	AlignCenter
	AlignRight
)

Widget

type Widget interface {
	Draw(buf *core.Buffer)
	Bounds() image.Rectangle
	SetBounds(r image.Rectangle)
	MinSize() image.Point
	HandleEvent(ev input.Event) bool
	SetFocused(focused bool)
	IsFocused() bool
	IsDirty() bool
	MarkClean()
	SetVisible(visible bool)
	IsVisible() bool
}

Widget is the interface that all widgets must implement.