Documentation
¶
Overview ¶
Package ui provides types and functions for creating an interactive User Interface.
Index ¶
- Constants
- func NewController(locator ResourceLocator, graphics Graphics, initFn InitFunc) app.Controller
- func NewWindow(appWindow app.Window, locator ResourceLocator, graphics Graphics) (*Window, WindowHandler)
- type Bounds
- func (b Bounds) Contains(position Position) bool
- func (b Bounds) Grow(size Size) Bounds
- func (b Bounds) Intersect(other Bounds) Bounds
- func (b Bounds) Resize(width, height int) Bounds
- func (b Bounds) Shrink(size Size) Bounds
- func (b Bounds) String() string
- func (b Bounds) Translate(delta Position) Bounds
- type Canvas
- type Color
- func Aqua() Color
- func Black() Color
- func Blue() Color
- func Fuchsia() Color
- func Gray() Color
- func Green() Color
- func Lime() Color
- func Maroon() Color
- func Navy() Color
- func Olive() Color
- func Purple() Color
- func RGB(r, g, b uint8) Color
- func RGBA(r, g, b, a uint8) Color
- func Red() Color
- func Silver() Color
- func Teal() Color
- func Transparent() Color
- func White() Color
- func Yellow() Color
- type Context
- func (c *Context) CreateElement() *Element
- func (c *Context) GetFont(family, subFamily string) (Font, bool)
- func (c *Context) OpenFontCollection(uri string) (*FontCollection, error)
- func (c *Context) OpenImage(uri string) (Image, error)
- func (c *Context) Schedule(fn func())
- func (c *Context) Window() *Window
- type Element
- func (e *Element) AppendChild(child *Element)
- func (e *Element) AppendSibling(sibling *Element)
- func (e *Element) Bounds() Bounds
- func (e *Element) ContentBounds() Bounds
- func (e *Element) Context() *Context
- func (e *Element) Destroy()
- func (e *Element) Detach()
- func (e *Element) Enabled() bool
- func (e *Element) Essence() Essence
- func (e *Element) FirstChild() *Element
- func (e *Element) ID() string
- func (e *Element) IdealSize() Size
- func (e *Element) InjectEssence(target interface{})
- func (e *Element) LastChild() *Element
- func (e *Element) Layout() Layout
- func (e *Element) LayoutConfig() LayoutConfig
- func (e *Element) LeftSibling() *Element
- func (e *Element) Margin() Spacing
- func (e *Element) Materialized() bool
- func (e *Element) Padding() Spacing
- func (e *Element) Parent() *Element
- func (e *Element) PrependChild(child *Element)
- func (e *Element) RemoveChild(child *Element)
- func (e *Element) RightSibling() *Element
- func (e *Element) SetBounds(bounds Bounds)
- func (e *Element) SetEnabled(enabled bool)
- func (e *Element) SetEssence(essence Essence)
- func (e *Element) SetID(id string)
- func (e *Element) SetIdealSize(size Size)
- func (e *Element) SetLayout(layout Layout)
- func (e *Element) SetLayoutConfig(layoutConfig LayoutConfig)
- func (e *Element) SetMargin(margin Spacing)
- func (e *Element) SetMaterialized(materialized bool)
- func (e *Element) SetPadding(padding Spacing)
- func (e *Element) SetVisible(visible bool)
- func (e *Element) Visible() bool
- type ElementMouseHandler
- type ElementRenderHandler
- type ElementResizeHandler
- type Essence
- type FileResourceLocator
- type Font
- type FontCollection
- type Graphics
- type Image
- type InitFunc
- type KeyCode
- type KeyModifier
- type KeyModifierSet
- type KeyboardEvent
- type KeyboardEventType
- type Layout
- type LayoutConfig
- type MouseButton
- type MouseEvent
- type MouseEventType
- type Position
- type ResourceLocator
- type Size
- type Spacing
- type Window
- type WindowHandler
Constants ¶
const ( KeyboardEventTypeKeyDown = app.KeyboardEventTypeKeyDown KeyboardEventTypeKeyUp = app.KeyboardEventTypeKeyUp KeyboardEventTypeRepeat = app.KeyboardEventTypeRepeat KeyboardEventTypeType = app.KeyboardEventTypeType )
const ( KeyCodeEscape = app.KeyCodeEscape KeyCodeEnter = app.KeyCodeEnter KeyCodeSpace = app.KeyCodeSpace KeyCodeTab = app.KeyCodeTab KeyCodeCaps = app.KeyCodeCaps KeyCodeLeftShift = app.KeyCodeLeftShift KeyCodeRightShift = app.KeyCodeRightShift KeyCodeLeftControl = app.KeyCodeLeftControl KeyCodeRightControl = app.KeyCodeRightControl KeyCodeLeftAlt = app.KeyCodeLeftAlt KeyCodeRightAlt = app.KeyCodeRightAlt KeyCodeBackspace = app.KeyCodeBackspace KeyCodeInsert = app.KeyCodeInsert KeyCodeDelete = app.KeyCodeDelete KeyCodeHome = app.KeyCodeHome KeyCodeEnd = app.KeyCodeEnd KeyCodePageUp = app.KeyCodePageUp KeyCodePageDown = app.KeyCodePageDown KeyCodeArrowLeft = app.KeyCodeArrowLeft KeyCodeArrowRight = app.KeyCodeArrowRight KeyCodeArrowUp = app.KeyCodeArrowUp KeyCodeArrowDown = app.KeyCodeArrowDown KeyCodeMinus = app.KeyCodeMinus KeyCodeEqual = app.KeyCodeEqual KeyCodeLeftBracket = app.KeyCodeLeftBracket KeyCodeRightBracket = app.KeyCodeRightBracket KeyCodeSemicolon = app.KeyCodeSemicolon KeyCodeComma = app.KeyCodeComma KeyCodePeriod = app.KeyCodePeriod KeyCodeSlash = app.KeyCodeSlash KeyCodeBackslash = app.KeyCodeBackslash KeyCodeApostrophe = app.KeyCodeApostrophe KeyCodeGraveAccent = app.KeyCodeGraveAccent KeyCodeA = app.KeyCodeA KeyCodeB = app.KeyCodeB KeyCodeC = app.KeyCodeC KeyCodeD = app.KeyCodeD KeyCodeE = app.KeyCodeE KeyCodeF = app.KeyCodeF KeyCodeG = app.KeyCodeG KeyCodeH = app.KeyCodeH KeyCodeI = app.KeyCodeI KeyCodeJ = app.KeyCodeJ KeyCodeK = app.KeyCodeK KeyCodeL = app.KeyCodeL KeyCodeM = app.KeyCodeM KeyCodeN = app.KeyCodeN KeyCodeO = app.KeyCodeO KeyCodeP = app.KeyCodeP KeyCodeQ = app.KeyCodeQ KeyCodeR = app.KeyCodeR KeyCodeS = app.KeyCodeS KeyCodeT = app.KeyCodeT KeyCodeU = app.KeyCodeU KeyCodeV = app.KeyCodeV KeyCodeW = app.KeyCodeW KeyCodeX = app.KeyCodeX KeyCodeY = app.KeyCodeY KeyCodeZ = app.KeyCodeZ KeyCode0 = app.KeyCode0 KeyCode1 = app.KeyCode1 KeyCode2 = app.KeyCode2 KeyCode3 = app.KeyCode3 KeyCode4 = app.KeyCode4 KeyCode5 = app.KeyCode5 KeyCode6 = app.KeyCode6 KeyCode7 = app.KeyCode7 KeyCode8 = app.KeyCode8 KeyCode9 = app.KeyCode9 KeyCodeF1 = app.KeyCodeF1 KeyCodeF2 = app.KeyCodeF2 KeyCodeF3 = app.KeyCodeF3 KeyCodeF4 = app.KeyCodeF4 KeyCodeF5 = app.KeyCodeF5 KeyCodeF6 = app.KeyCodeF6 KeyCodeF7 = app.KeyCodeF7 KeyCodeF8 = app.KeyCodeF8 KeyCodeF9 = app.KeyCodeF9 KeyCodeF10 = app.KeyCodeF10 KeyCodeF11 = app.KeyCodeF11 KeyCodeF12 = app.KeyCodeF12 )
const ( KeyModifierControl = app.KeyModifierControl KeyModifierShift = app.KeyModifierShift KeyModifierAlt = app.KeyModifierAlt KeyModifierCapsLock = app.KeyModifierCapsLock )
const ( MouseEventTypeDown = app.MouseEventTypeDown MouseEventTypeUp = app.MouseEventTypeUp MouseEventTypeMove = app.MouseEventTypeMove MouseEventTypeDrag = app.MouseEventTypeDrag MouseEventTypeDragCancel = app.MouseEventTypeDragCancel MouseEventTypeEnter = app.MouseEventTypeEnter MouseEventTypeLeave = app.MouseEventTypeLeave )
const ( MouseButtonLeft = app.MouseButtonLeft MouseButtonMiddle = app.MouseButtonMiddle MouseButtonRight = app.MouseButtonRight )
Variables ¶
This section is empty.
Functions ¶
func NewController ¶
func NewController(locator ResourceLocator, graphics Graphics, initFn InitFunc) app.Controller
NewController creates a new app.Controller that integrates with the ui package to render a user interface.
func NewWindow ¶
func NewWindow(appWindow app.Window, locator ResourceLocator, graphics Graphics) (*Window, WindowHandler)
NewWindow creates a new Window instance that integrates with the specified app.Window.
Types ¶
type Bounds ¶
Bounds represents a content area on the screen. It consists of a Position and Size.
func (Bounds) Contains ¶
Contains returns whether the specified Position is contained by this Bounds.
func (Bounds) Grow ¶
Grow returns a new Bounds that has a size that is larger by the given amount compared to these Bounds.
func (Bounds) Intersect ¶
Intersect returns a new Bounds that is the intersection of the specified Bounds and these Bounds.
func (Bounds) Resize ¶
Resize returns a new Bounds that is with a new Size of the specified dimensions.
func (Bounds) Shrink ¶
Shrink returns a new Bounds that has a size that is smaller by the given amount compared to these Bounds.
type Canvas ¶
type Canvas interface {
// Push records the current state and creates a new
// state layer. Changes done in the new layer will
// not affect the former layer.
Push()
// Pop restores the former state layer and configures
// the drawing state accordingly.
Pop()
// Translate moves the drawing position by the specified
// delta amount.
Translate(delta Position)
// Clip sets new clipping bounds. Pixels from draw operations
// that are outside the clipping bounds will not be drawn.
//
// Initially the clipping bounds are equal to the window size.
Clip(bounds Bounds)
// SolidColor returns the Color that is used for fill operations.
SolidColor() Color
// SetSolidColor sets a new Color to be used for fill operations.
SetSolidColor(color Color)
// StrokeColor returns the Color that is used for outline draw
// operations.
StrokeColor() Color
// SetStrokeColor sets a new Color to be used for outline draw
// operations.
SetStrokeColor(color Color)
// StrokeSize returns the size that will be used for outlines.
StrokeSize() int
// SetStrokeSize sets a new size to be used for drawing outlines.
SetStrokeSize(size int)
// Font returns the Font that is to be used for text draw
// operations.
Font() Font
// SetFont sets a new Font to be used for text draw operations.
SetFont(font Font)
// FontSize returns the size at which text will be drawn.
FontSize() int
// SetFontSize changes the size at which text will be drawn.
SetFontSize(size int)
// DrawRectangle draws the outlines of a rectangle.
DrawRectangle(position Position, size Size)
// FillRectangle draws the solid part of a rectangle.
FillRectangle(position Position, size Size)
// DrawRoundRectangle draws the outlines of a rounded rectangle.
DrawRoundRectangle(position Position, size Size, radius int)
// FillRoundRectangle draws the solid part of a rounded rectangle.
FillRoundRectangle(position Position, size Size, radius int)
// DrawCircle draws the outlines of a circle.
DrawCircle(position Position, radius int)
// FillCircle draws the solid part of a circle.
FillCircle(position Position, radius int)
// DrawTriangle draws the outlines of a triangle.
DrawTriangle(a, b, c Position)
// FillTriangle draws the solid part of a triangle.
FillTriangle(a, b, c Position)
// DrawLine draws a line segment.
DrawLine(start, end Position)
// DrawImage draws the specified Image.
DrawImage(image Image, position Position, size Size)
// DrawText draws a text string.
DrawText(text string, position Position)
// TextSize returns the size it would take to draw the
// specified text string.
TextSize(text string) Size
}
Canvas is an interface that represents a mechanism through which a Control can render itself to the screen.
type Color ¶
Color represents a 32bit color (8 bits per channel).
func RGB ¶
RGB creates a new Color off of the specified R (Red), G (Green), B (Blue) components. The alpha of the Color is set to 255 (opaque).
func RGBA ¶
RGBA creates a new Color off of the specified R (Red), G (Green), B (Blue), A (Alpha) components.
func (Color) Opaque ¶
Opaque returns whether this color is opaque. (i.e. has an alpha with the maximum value)
func (Color) Translucent ¶
Translucent returns whether this color is translucent.
A translucent color is one that is not fully visible (i.e. has an alpha value smaller than the maximum).
func (Color) Transparent ¶
Transparent returns whether this color is transparent.
A transparent color is one that is not at all visible (i.e. has an alpha value equal to zero).
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context represents the lifecycle and resource allocation of an Element hierarchy.
func (*Context) CreateElement ¶
CreateElement creates a new Element instance.
The returned Element is not attached to anything and will not be drawn or processed in any way until it is attached to the Element hierarchy.
Depending on what you allocate within the context of this Element, make sure to Delete this Element once done. Alternatively, as long as the Element is part of a hierarchy, you could leave that to the View that owns the hierarchy, which will clean everything in its hierarchy, once closed.
func (*Context) GetFont ¶
GetFont returns the Font with the specified family and sub-family name from the loaded family collections. If such a font cannot be found, the result will be indicated in the boolean flag.
func (*Context) OpenFontCollection ¶
func (c *Context) OpenFontCollection(uri string) (*FontCollection, error)
OpenFontCollection opens the FontCollection at the specified URI location.
The URI is interpreted according to the used ResourceLocator.
As the FontCollection consumes resources, its lifecycle becomes linked to this Context. Once the owner of this Context is destroyed, the collection will be released. Keep in mind that just dereferencing the owner is not sufficient, as cleanup would not be performed in such cases.
func (*Context) OpenImage ¶
OpenImage opens the Image at the specified URI location.
The URI is interpreted according to the used ResourceLocator.
As the Image resource consumes resources, its lifecycle becomes linked to this Context. Once the owner of this Context is destroyed, the image will be released. Keep in mind that just dereferencing the owner is not sufficient, as cleanup would not be performed in such cases.
func (*Context) Schedule ¶
func (c *Context) Schedule(fn func())
Schedule appends the specified function to be called from the main thread (main goroutine).
This function is safe for concurrent use, though such use would not guarantee any order for the functions that are being concurrently added.
This function can be called from both the main thread, as well as from other goroutines.
There is a limit on the number of functions that can be queued within a given frame iteration. Once the buffer is full, new functions will be dropped.
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
Element represents a hierarchical entity on the screen. It need not necessarily be a control and could just be an intermediate element used to group Controls.
func (*Element) AppendChild ¶
AppendChild adds the specified Element as the right-most child of this Element. If the appended Element already has a parent, it is first detached from that parent.
func (*Element) AppendSibling ¶
AppendSibling attaches an Element to the right of the current one.
func (*Element) Bounds ¶
Bounds returns the bounds of this Element relative to its parent. If it is a top-most Element, then the bounds are relative to the Window's content area.
func (*Element) ContentBounds ¶
ContentBounds returns the bounds of the content area of this Element relative to the Element itself. The content bounds are calculated based on the Element's bounds and padding.
func (*Element) Destroy ¶
func (e *Element) Destroy()
Destroy removes this Element from the hierarchy, as well as any child Elements and releases all allocated resources.
func (*Element) Detach ¶
func (e *Element) Detach()
Detach removes this Element from the hierarchy but does not release any resources.
func (*Element) Essence ¶
Essence returns the Essence that is responsible for the behavior of this Element.
func (*Element) FirstChild ¶
FirstChild returns the first (left-most) child Element of this Element. If this Element does not have any children then this method returns nil.
func (*Element) ID ¶
ID returns the ID of this Element. If an ID was not specified, then an emptry string is returned.
func (*Element) IdealSize ¶
IdealSize returns the ideal dimensions for this Element, which could (but not necessarily) be taken into consideration by layout containers.
func (*Element) InjectEssence ¶
func (e *Element) InjectEssence(target interface{})
InjectEssence assigns the Essence of this Element to the target. If the target is not a pointer to the correct type, this method panics.
func (*Element) LastChild ¶
LastChild returns the last (right-most) child Element of this Element. If this Element does not have any children then this method returns nil.
func (*Element) LayoutConfig ¶
func (e *Element) LayoutConfig() LayoutConfig
LayoutConfig returns the layout configuration for this Element. The actual implementation of the LayoutConfig interface depends on the owner Element. If this Element does not have any layout preference, then nil is returned.
func (*Element) LeftSibling ¶
LeftSibling returns the left sibling Element of this Element. If this Element is the left-most child of its parent or does not have a parent then this method returns nil.
func (*Element) Margin ¶
Margin returns the spacing that should be maintained around this Element. The margin does not reflect the Element's active area and is only a setting that is used by layouts to further adjust the Element's position.
func (*Element) Materialized ¶
Materialized controls whether this Element is at all present. If an Element is not materialized, then it is not rendered, does not receive events, and is not considered during layout evaluations. In essence, it is almost as though it has been removed, except that it is still part of the hierarchy.
func (*Element) Padding ¶
Padding returns the spacing that should be maintained inside an Element between its outer bounds and its content area. This setting could affect the layouting of child Elements and clipping during rendering.
func (*Element) Parent ¶
Parent returns the parent Element in the hierarchy. If this is the top-most Element then nil is returned.
func (*Element) PrependChild ¶
PrependChild adds the specified Element as the left-most child of this Element. If the preprended Element already has a parent, it is first detached from that parent.
func (*Element) RemoveChild ¶
RemoveChild removes the specified Element from the list of children held by this Element. If the specified Element is not a child of this Element, then nothing happens.
func (*Element) RightSibling ¶
RightSibling returns the right sibling Element of this Element. If this Element is the right-most child of its parent or does not have a parent then this method returns nil.
func (*Element) SetBounds ¶
SetBounds configures this Element's bounds relative to its parent. If it is a top-most element, then the bounds are relative to the Window's content area.
func (*Element) SetEnabled ¶
SetEnabled specifies whether this Element should be enabled for user interaction.
func (*Element) SetEssence ¶
SetEssence changes the Essence that is to control the behavior and represent the purpose of this Element. Specifying nil indicates that this is a plain Element that will not handle events in any special way.
func (*Element) SetID ¶
SetID changes the ID of this Element. If this Element represents a Control, then this ID would affect the ID of that owner Control.
func (*Element) SetIdealSize ¶
SetIdealSize changes this Element's ideal dimensions.
func (*Element) SetLayout ¶
SetLayout changes this Element's layout. If specified, this Element's children will be positioned according to the specified Layout. If nil is specified, then child Elements are not repositioned in any way and will use their configured bounds as positioning and size.
func (*Element) SetLayoutConfig ¶
func (e *Element) SetLayoutConfig(layoutConfig LayoutConfig)
SetLayoutConfig changes this Element's layout configuration. The provided implementation should match the requirements of the parent layout Element, otherwise they will not be taken into consideration. If nil is specified, then default layouting should be used.
func (*Element) SetMargin ¶
SetMargin sets the amount of space that should be left around the Element when positioned by a layout container.
func (*Element) SetMaterialized ¶
SetMaterialized specifies whether this Element should be considered in any way for rendering, events and layout calculations.
func (*Element) SetPadding ¶
SetPadding configures this Element's content area spacing.
func (*Element) SetVisible ¶
SetVisible controls whether this Element should be rendered.
type ElementMouseHandler ¶
type ElementMouseHandler interface {
OnMouseEvent(element *Element, event MouseEvent) bool
}
ElementMouseHandler is a type of ElementHandler that can be used to receive events when the mouse has interacted with a given Element.
type ElementRenderHandler ¶
ElementRenderHandler is a type of ElementHandler that can be used to receive events when a given Element is being rendered and to perform a custom rendering for the Element.
type ElementResizeHandler ¶
ElementResizeHandler is a type of ElementHandler that can be used to receive events when an Element has been resized.
type Essence ¶
type Essence interface{}
Essence represents the behavior that is attached to an Element. For example, the actual value behind the interface could be a specific UI control and/or a handler.
type FileResourceLocator ¶
type FileResourceLocator struct{}
FileResourceLocator is an implementation of ResourceLocator that uses the local filesystem to open resources.
func (FileResourceLocator) OpenResource ¶
func (l FileResourceLocator) OpenResource(uri string) (io.ReadCloser, error)
type Font ¶
type Font interface {
// Family returns the family name of this Font.
// (e.g. Roboto, Open Sans)
Family() string
// SubFamily returns the sub-family name of this Font.
// (e.g. Italic, Bold)
SubFamily() string
}
Font represents a text Font.
type FontCollection ¶
type FontCollection struct {
// contains filtered or unexported fields
}
FontCollection represents a collection of Fonts.
func (*FontCollection) Fonts ¶
func (c *FontCollection) Fonts() []Font
Fonts returns all Fonts contained by this collection.
type Graphics ¶
type Graphics interface {
// Create initializes the graphics API.
Create()
// Resize indicates a new draw area size to the
// graphics API.
Resize(size Size)
// ResizeFramebuffer indicates a new framebuffer size
// to the graphics API. This can be useful when the size
// and the resolution don't match (higher dpi).
ResizeFramebuffer(size Size)
// CreateImage creates a new Image that can be used
// in draw operations.
CreateImage(img image.Image) (Image, error)
// ReleaseImage releases any resources allocated for the
// given Image resource.
ReleaseImage(resource Image) error
// CreateFront creates a new Font that can be used
// in text draw operations.
CreateFont(font *opentype.Font) (Font, error)
// ReleaseFont releases any resources allocated for the
// given Font resource.
ReleaseFont(font Font) error
// Begin prepares the graphics API for drawing.
Begin()
// Canvas returns a Canvas instance that can be
// used to issue various draw operations.
Canvas() Canvas
// End flushes any accumulated state in the graphics
// API to the screen.
End()
// Destroy releases any resources allocated by the
// graphics API.
Destroy()
}
Graphics is an interface through which the framework can issue drawing calls.
type Image ¶
type Image interface {
// Size returns the dimensions of this Image.
Size() Size
}
Image represents a 2D image.
type InitFunc ¶
type InitFunc func(window *Window)
InitFunc can be used to initialize the Window with the respective Element hierarchy.
type KeyModifierSet ¶
type KeyModifierSet = app.KeyModifierSet
KeyModifierSet is used to indicate which modifier keys were active at the event occurrence.
type KeyboardEvent ¶
type KeyboardEvent struct {
// Type specifies the keyboard event type.
Type KeyboardEventType
// Code returns the code of the keyboard key.
Code KeyCode
// Rune returns the character that was typed in case
// of an KeyboardEventTypeType event.
Rune rune
// Modifiers contains a set of modifier keys that were
// pressed during the event.
Modifiers KeyModifierSet
}
KeyboardEvent is used to propagate events related to keyboard actions.
func (KeyboardEvent) String ¶
func (e KeyboardEvent) String() string
String returns a string representation for this keyboard event.
type KeyboardEventType ¶
type KeyboardEventType = app.KeyboardEventType
KeyboardEventType is used to specify the type of keyboard action that occurred.
type Layout ¶
type Layout interface {
// Apply applies this layout to the specified Element.
Apply(element *Element)
}
Layout represents an algorithm through which child Elements are positioned on the screen relative to their parent.
type LayoutConfig ¶
type LayoutConfig interface{}
LayoutConfig represents a layout configuration for an Element. The actual implementation of this interface is determined by the parent Element's layout model.
type MouseEvent ¶
type MouseEvent struct {
// Index indicates which mouse triggered the event. By default
// the index for a the primary mouse is 0.
// This is applicable for devices with multiple pointers
// (mobile) or in case a second mouse is emulated
// (e.g. with a game controller).
Index int
// Position specifies the moust position relative to the receiver.
Position Position
// Type specifies the mouse event type.
Type MouseEventType
// Button specifies the button for which the event is
// applicable.
Button MouseButton
}
MouseEvent represents an event related to a mouse action.
func (MouseEvent) String ¶
func (e MouseEvent) String() string
String returns a string representation for this mouse event.
type MouseEventType ¶
type MouseEventType = app.MouseEventType
MouseEventType represents the type of mouse event.
type Position ¶
Position represents a position on the screen that can either be absolute or relative, depending on the context.
func NewPosition ¶
NewPosition creates a new Position with the specified coordinates.
type ResourceLocator ¶
type ResourceLocator interface {
// OpenResource opens the resource at the specified
// URI address.
OpenResource(uri string) (io.ReadCloser, error)
}
ResourceLocator represents a logic by which resources can be opened based off of a URI address.
This allows resources (e.g. Images, Fonts) to be accessed from the filesystem, from the network, or from a custom bundle file.
type Size ¶
Size represents the dimensions of something on the screen.
type Spacing ¶
Spacing represents a spacing around or inside a given screen entity (e.g. Element).
func (Spacing) Horizontal ¶
Horizontal returns the horizontal amount of spacing.
type Window ¶
Window represents an application window.
func (*Window) Context ¶
Context returns the Context for this Window.
Note that anything allocated through this Context will not be released until this Window is closed.
func (*Window) FindElementByID ¶
FindElementByID looks through the Element hierarchy tree for an Element with the specified ID.
func (*Window) GetElementByID ¶
GetElementByID looks through the Element hierarchy tree for an Element with the specified ID. Unlike FindElementByID, this method panics if such an Element cannot be found.
type WindowHandler ¶
type WindowHandler interface {
// OnResize is called whenever the native window has
// been resized.
OnResize(size Size)
// OnFramebufferResize is called whenever the native window's
// framebuffer has been resized.
OnFramebufferResize(size Size)
// OnKeyboardEvent is called whenever a native key event
// has been registered.
OnKeyboardEvent(event KeyboardEvent) bool
// OnMouseEvent is called whenever a native mouse event
// has been registered.
OnMouseEvent(event MouseEvent) bool
// OnRender is called whenever the Window should redraw
// itself.
OnRender()
// OnCloseRequested is called whenever the end-user has
// indicated that they would like to close the appplication.
// (e.g. using the close button on the application)
OnCloseRequested()
}
WindowHandler is an interface that is used by the framework to communicate with Window implementations critical events.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package component features a framework, inspired by React and Redux, that allows you to extend the basic ui package with custom Components on top of plain ui Elements.
|
Package component features a framework, inspired by React and Redux, that allows you to extend the basic ui package with custom Components on top of plain ui Elements. |
|
Package mat provides a collection of Components that can be used to construct a higher-order user interface.
|
Package mat provides a collection of Components that can be used to construct a higher-order user interface. |
|
Package optional contains primitive types and ui types that can have an unspecified state.
|
Package optional contains primitive types and ui types that can have an unspecified state. |