Documentation ¶
Overview ¶
Package widget provides graphical user interface widgets.
TODO: give an overview and some example code.
Index ¶
- Constants
- func RunWindow(s screen.Screen, root node.Node, opts *RunWindowOptions) error
- func WithLayoutData(n node.Node, layoutData interface{}) node.Node
- type Axis
- type Flow
- type FlowLayoutData
- type Image
- type Label
- type Padder
- type RunWindowOptions
- type Sheet
- type Sizer
- type Space
- type Text
- type Uniform
Constants ¶
const ( AxisNone = Axis(0) AxisHorizontal = Axis(1) AxisVertical = Axis(2) AxisBoth = Axis(3) // AxisBoth equals AxisHorizontal | AxisVertical. )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Axis ¶
type Axis uint8
Axis is zero, one or both of the horizontal and vertical axes. For example, a widget may be scrollable in one of the four AxisXxx values.
func (Axis) Horizontal ¶
type Flow ¶
type Flow struct { node.ContainerEmbed Axis Axis }
Flow is a container widget that lays out its children in sequence along an axis, either horizontally or vertically. The children's laid out size may differ from their natural size, along or across that axis, if a child's LayoutData is a FlowLayoutData.
type FlowLayoutData ¶
type FlowLayoutData struct { // AlongWeight is the relative weight for distributing any space surplus or // deficit along the Flow's axis. For example, if an AxisHorizontal Flow's // Rect width was 100 pixels greater than the sum of its children's natural // widths, and three children had non-zero FlowLayoutData.AlongWeight // values 6, 3 and 1 (and their FlowLayoutData.ExpandAlong values were // true) then those children's laid out widths would be larger than their // natural widths by 60, 30 and 10 pixels. // // A negative AlongWeight is equivalent to zero. AlongWeight int // ExpandAlong is whether the child's laid out size should increase along // the Flow's axis, based on AlongWeight, if there is a space surplus (the // children's measured size total less than the parent's size). To allow // size decreases as well as increases, set ShrinkAlong. ExpandAlong bool // ShrinkAlong is whether the child's laid out size should decrease along // the Flow's axis, based on AlongWeight, if there is a space deficit (the // children's measured size total more than the parent's size). To allow // size increases as well as decreases, set ExpandAlong. ShrinkAlong bool // ExpandAcross is whether the child's laid out size should increase along // the Flow's cross-axis if there is a space surplus (the child's measured // size is less than the parent's size). To allow size decreases as well as // increases, set ShrinkAcross. // // For example, if an AxisHorizontal Flow's Rect height was 80 pixels, any // child whose FlowLayoutData.ExpandAcross was true would also be laid out // with at least an 80 pixel height. ExpandAcross bool // ShrinkAcross is whether the child's laid out size should decrease along // the Flow's cross-axis if there is a space deficit (the child's measured // size is more than the parent's size). To allow size increases as well as // decreases, set ExpandAcross. // // For example, if an AxisHorizontal Flow's Rect height was 80 pixels, any // child whose FlowLayoutData.ShrinkAcross was true would also be laid out // with at most an 80 pixel height. ShrinkAcross bool }
FlowLayoutData is the node LayoutData type for a Flow's children.
type Image ¶
Image is a leaf widget that paints an image.Image.
type Padder ¶
type Padder struct { node.ShellEmbed Axis Axis Margin unit.Value }
Padder is a shell widget that adds a margin to the inner widget's measured size. That margin may be added horizontally (left and right), vertically (top and bottom) or both, determined by the Padder's axis.
That marginal space is not considered part of the inner widget's geometry. For example, to make that space 'clickable', construct the Padder inside of an event handling widget instead of vice versa.
type RunWindowOptions ¶
type RunWindowOptions struct { NewWindowOptions screen.NewWindowOptions Theme theme.Theme }
RunWindowOptions are optional arguments to RunWindow.
type Sheet ¶
type Sheet struct { node.ShellEmbed // contains filtered or unexported fields }
Sheet is a shell widget that provides *image.RGBA pixel buffers (analogous to blank sheets of paper) for its descendent widgets to paint on, via their PaintBase methods. Such buffers may be cached and their contents re-used for multiple paints, which can make scrolling and animation smoother and more efficient.
A simple app may have only one Sheet, near the root of its widget tree. A more complicated app may have multiple Sheets. For example, consider a text editor consisting of a small header bar and a large text widget. Those two nodes may be backed by two separate Sheets, since scrolling the latter should not scroll the former.
func (*Sheet) OnLifecycleEvent ¶
type Sizer ¶
Sizer is a shell widget that overrides its child's measured size.
type Space ¶
Space is leaf widget that occupies empty space. For example, aligning two widgets to the left and right edges of a container can be achieved by placing a third Space widget between them, whose LayoutData makes that Space expand to occupy any excess space. Similarly, a widget can be centered in its container by adding an expanding Space before and after.
type Uniform ¶
type Uniform struct { node.ShellEmbed ThemeColor theme.Color }
Uniform is a shell widget that paints a uniform color, analogous to an image.Uniform.
func NewUniform ¶
NewUniform returns a new Uniform widget of the given color.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package flex provides a container widget that lays out its children following the CSS flexbox algorithm.
|
Package flex provides a container widget that lays out its children following the CSS flexbox algorithm. |
Package glwidget provides a widget containing a GL ES framebuffer.
|
Package glwidget provides a widget containing a GL ES framebuffer. |
Package node provides the structure for a tree of heterogenous widget nodes.
|
Package node provides the structure for a tree of heterogenous widget nodes. |
Package theme provides widget themes.
|
Package theme provides widget themes. |