Documentation
¶
Overview ¶
Package scene provides tools for flexible GUI building.
Index ¶
- func Dispose[S, T any](root Element[S, T])
- func Draw[S, T any](root Element[S, T], screen S)
- func Update[S, T any](root Element[S, T], bbox basic.Rect)
- type Attrs
- type BaseElement
- func (e *BaseElement[S, T, P]) Actuate()
- func (e *BaseElement[S, T, P]) Arrange(bbox basic.Rect)
- func (e *BaseElement[S, T, P]) Attrs() Attrs
- func (e *BaseElement[S, T, P]) Dispose()
- func (e *BaseElement[S, T, P]) Draw(screen S)
- func (e *BaseElement[S, T, P]) Exclude()
- func (e *BaseElement[S, T, P]) Inhibit()
- func (e *BaseElement[S, T, P]) Init(traitFunc TraitFunc[T], propsFunc PropsFunc[P])
- func (e *BaseElement[S, T, P]) IsOff() bool
- func (e *BaseElement[S, T, P]) Prepare()
- func (e *BaseElement[S, T, P]) Props() P
- func (e *BaseElement[S, T, P]) Refresh()
- func (e *BaseElement[S, T, P]) Trait() T
- func (e *BaseElement[S, T, P]) Update()
- type Element
- type PropsFunc
- type TraitFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attrs ¶ added in v0.5.0
type Attrs struct { // MaxHeight specifies maximum height of element. MaxHeight basic.Opt[basic.Float] // MaxWidth specifies maximum width of element. MaxWidth basic.Opt[basic.Float] // MinHeight specifies minimum height of element. MinHeight basic.Opt[basic.Float] // MinWidth specifies minimum width of element. MinWidth basic.Opt[basic.Float] // PreHeight specifies preliminary height of element. PreHeight basic.Opt[basic.Float] // PreWidth specifies preliminary width of element. PreWidth basic.Opt[basic.Float] }
Attrs associated with element.
type BaseElement ¶
type BaseElement[S, T, P any] struct { // contains filtered or unexported fields }
BaseElement is the base implementation of the Element interface with props of type P.
BaseElement is intended for internal use only as part of real element.
func (*BaseElement[S, T, P]) Actuate ¶
func (e *BaseElement[S, T, P]) Actuate()
Actuate implements the Element interface.
func (*BaseElement[S, T, P]) Arrange ¶
func (e *BaseElement[S, T, P]) Arrange(bbox basic.Rect)
Arrange implements the Element interface.
func (*BaseElement[S, T, P]) Attrs ¶ added in v0.5.0
func (e *BaseElement[S, T, P]) Attrs() Attrs
Attrs implements the Element interface.
func (*BaseElement[S, T, P]) Dispose ¶
func (e *BaseElement[S, T, P]) Dispose()
Dispose implements the Element interface.
func (*BaseElement[S, T, P]) Draw ¶
func (e *BaseElement[S, T, P]) Draw(screen S)
Draw implements the Element interface.
func (*BaseElement[S, T, P]) Exclude ¶
func (e *BaseElement[S, T, P]) Exclude()
Exclude implements the Element interface.
func (*BaseElement[S, T, P]) Inhibit ¶
func (e *BaseElement[S, T, P]) Inhibit()
Inhibit implements the Element interface.
func (*BaseElement[S, T, P]) Init ¶ added in v0.5.0
func (e *BaseElement[S, T, P]) Init(traitFunc TraitFunc[T], propsFunc PropsFunc[P])
Init initializes element.
Init does not validate input parameters.
func (*BaseElement[S, T, P]) IsOff ¶ added in v0.5.0
func (e *BaseElement[S, T, P]) IsOff() bool
IsOff implements the Element interface.
This method should only be overloaded if element can be off internally.
func (*BaseElement[S, T, P]) Prepare ¶
func (e *BaseElement[S, T, P]) Prepare()
Prepare implements the Element interface.
func (*BaseElement[S, T, P]) Props ¶ added in v0.5.0
func (e *BaseElement[S, T, P]) Props() P
Props returns element props.
Props result is valid only after refresh stage.
func (*BaseElement[S, T, P]) Refresh ¶
func (e *BaseElement[S, T, P]) Refresh()
Refresh implements the Element interface.
func (*BaseElement[S, T, P]) Trait ¶ added in v0.5.0
func (e *BaseElement[S, T, P]) Trait() T
Trait implements the Element interface.
func (*BaseElement[S, T, P]) Update ¶
func (e *BaseElement[S, T, P]) Update()
Update implements the Element interface.
type Element ¶
type Element[S, T any] interface { // Trait returns trait of element. // // Trait result is valid only after refresh stage. Trait() T // IsOff reports whether element is off. // // IsOff result is valid only after refresh stage. IsOff() bool // Attrs returns attrs of element. // // Attrs result is valid only after prepare stage. Attrs() Attrs // Refresh refreshes element, e.g. by recalculating its trait and props. // // Containers should refresh all items at this stage, regardless of their statuses. Refresh() // Prepare prepares element for this iteration, e.g. by precalculating some parameters. // // Containers should prepare visible items and exclude hidden ones at this stage. Prepare() // Exclude excludes element for this iteration, e.g. by cleaning up some resources for idle time. // // Containers should exclude all items at this stage, regardless of their statuses. Exclude() // Arrange arranges element content within given bounding box, e.g. by executing layout algorithm. // // Containers should arrange visible items at this stage. Arrange(bbox basic.Rect) // Actuate actuates element, e.g. by handling input. // // Containers should actuate interactive items and inhibit other ones at this stage. // // Containers should iterate through items in reverse order at this stage. Actuate() // Inhibit inhibits element, e.g. by ignoring input. // // Containers should inhibit all items at this stage, regardless of their statuses. // // Containers should iterate through items in reverse order at this stage. Inhibit() // Update updates element. // // Containers should update visible items at this stage. Update() // Draw draws element on given screen. // // Containers should draw visible items at this stage. Draw(screen S) // Dispose disposes element. // // Containers should dispose all items at this stage, regardless of their statuses. Dispose() }
Element of scene displayed on screen of type S and extended by trait of type T.
Element can be in one of following statuses:
- Interactive: element is displayed and interacts;
- Visible: element is displayed, but may not interact (interactive elements are visible);
- Hidden: element is not displayed and does not interact (off elements are hidden).
Directories
¶
Path | Synopsis |
---|---|
Package element subpackages provide commonly used GUI elements.
|
Package element subpackages provide commonly used GUI elements. |
flexbox
Package flexbox provides container of GUI elements that uses Flex Layout Algorithm for placing them.
|
Package flexbox provides container of GUI elements that uses Flex Layout Algorithm for placing them. |
nothing
Package nothing provides empty GUI element.
|
Package nothing provides empty GUI element. |
overlay
Package overlay provides container of GUI elements that places them one of top of the other considering side anchors.
|
Package overlay provides container of GUI elements that places them one of top of the other considering side anchors. |
padding
Package padding provides wrapper of GUI element that adds extra empty space around it.
|
Package padding provides wrapper of GUI element that adds extra empty space around it. |
pageset
Package pageset provides container of GUI elements that allows to switch them like pages.
|
Package pageset provides container of GUI elements that allows to switch them like pages. |
turnoff
Package turnoff provides wrapper of GUI element that allows turn it off.
|
Package turnoff provides wrapper of GUI element that allows turn it off. |
x
Package x subpackages provides extra GUI elements (experimental).
|
Package x subpackages provides extra GUI elements (experimental). |