Documentation ¶
Overview ¶
Package ui provides types and functions for creating an interactive User Interface.
NOTE: Some types are a near perfect clone of similar types from the app package. However, there can be subtle differences in the behavior or semantic behind them, which is the reason why they are not aliases and care should be taken when transitioning between them.
Index ¶
- func WrappedLocator(delegate resource.ReadLocator) resource.ReadLocator
- 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
- func (c Canvas) Clip()
- func (c Canvas) ClipRect(position, size sprec.Vec2)
- func (c *Canvas) DrawBounds(element *Element, padding bool) DrawBounds
- func (c Canvas) DrawSurface(surface Surface, position, size sprec.Vec2)
- func (c *Canvas) ElapsedTime() time.Duration
- func (c Canvas) Fill(fill Fill)
- func (c Canvas) FillText(text string, position sprec.Vec2, typography Typography)deprecated
- func (c Canvas) FillTextLine(text []rune, position sprec.Vec2, typography Typography)
- func (c Canvas) Pop()
- func (c Canvas) Push()
- func (c Canvas) ResetTransform()
- func (c Canvas) Rotate(angle sprec.Angle)
- func (c Canvas) Scale(amount sprec.Vec2)
- func (c Canvas) SetClipRect(left, right, top, bottom float32)deprecated
- func (c Canvas) SetTransform(transform sprec.Mat4)
- func (c Canvas) Stroke()
- func (c Canvas) Translate(delta sprec.Vec2)
- type Character
- type ClipboardAction
- type ClipboardEvent
- type Color
- func Aqua() Color
- func Black() Color
- func Blue() Color
- func ColorWithAlpha(color Color, a uint8) Color
- func Fuchsia() Color
- func Gray() Color
- func Green() Color
- func Lime() Color
- func Maroon() Color
- func MixColors(first, second Color, alpha float32) 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) CreateContext() *Context
- func (c *Context) CreateFont(font *opentype.Font) (*Font, error)
- func (c *Context) CreateFontCollection(collection *opentype.Collection) (*FontCollection, error)
- func (c *Context) CreateImage(img image.Image) (*Image, error)
- func (c *Context) Destroy()
- func (c *Context) GetFont(family, subFamily string) (*Font, bool)
- func (c *Context) OpenFont(uri string) (*Font, error)
- 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 Controller
- func (c *Controller) OnClipboardEvent(window app.Window, event app.ClipboardEvent) bool
- func (c *Controller) OnCloseRequested(window app.Window) bool
- func (c *Controller) OnCreate(appWindow app.Window)
- func (c *Controller) OnDestroy(window app.Window)
- func (c *Controller) OnFramebufferResize(window app.Window, width, height int)
- func (c *Controller) OnKeyboardEvent(window app.Window, event app.KeyboardEvent) bool
- func (c *Controller) OnMouseEvent(window app.Window, event app.MouseEvent) bool
- func (c *Controller) OnRender(window app.Window)
- func (c *Controller) OnResize(window app.Window, width, height int)
- type DrawBounds
- type Element
- func (e *Element) AbsoluteBounds() Bounds
- 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) Destroy()
- func (e *Element) Detach()
- func (e *Element) Enabled() bool
- func (e *Element) Essence() Essence
- func (e *Element) FirstChild() *Element
- func (e *Element) Focusable() bool
- func (e *Element) HierarchyEnabled() bool
- func (e *Element) HierarchyVisible() bool
- func (e *Element) ID() string
- func (e *Element) IdealSize() Size
- func (e *Element) Invalidate()
- func (e *Element) IsFocused() bool
- func (e *Element) LastChild() *Element
- func (e *Element) Layout() Layout
- func (e *Element) LayoutConfig() LayoutConfig
- func (e *Element) LeftSibling() *Element
- func (e *Element) Padding() Spacing
- func (e *Element) Parent() *Element
- func (e *Element) PrependChild(child *Element)
- func (e *Element) PrependSibling(sibling *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) SetFocusable(focusable bool)
- 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) SetPadding(padding Spacing)
- func (e *Element) SetVisible(visible bool)
- func (e *Element) Visible() bool
- func (e *Element) Window() *Window
- type ElementClipboardHandler
- type ElementHistoryHandler
- type ElementKeyboardHandler
- type ElementMouseHandler
- type ElementRenderHandler
- type ElementResizeHandler
- type ElementStateHandler
- type Essence
- type FilepathPayload
- type Fill
- type FillLayout
- type FillRule
- type Font
- func (f *Font) Destroy()
- func (f *Font) Family() string
- func (f *Font) LineHeight(fontSize float32) float32
- func (f *Font) LineIterator(characters []rune, fontSize float32) *LineIterator
- func (f *Font) LineWidth(characters []rune, fontSize float32) float32
- func (f *Font) SubFamily() string
- func (f *Font) TextSize(text string, fontSize float32) sprec.Vec2
- type FontCollection
- type Image
- type InitFunc
- type KeyCode
- type KeyModifier
- type KeyModifierSet
- type KeyboardAction
- type KeyboardEvent
- type Layout
- type LayoutConfig
- type LineIterator
- type MouseAction
- type MouseButton
- type MouseEvent
- type Position
- type ShaderCollection
- type Size
- type Spacing
- type Surface
- type Typography
- type Window
- func (w *Window) BubbleFocus()
- func (w *Window) Context() *Context
- func (w *Window) Copy() bool
- func (w *Window) CreateElement() *Element
- func (w *Window) Cut() bool
- func (w *Window) DiscardFocus()
- func (w *Window) FindElementByID(id string) (*Element, bool)
- func (w *Window) GetElementByID(id string) *Element
- func (w *Window) GrantFocus(element *Element)
- func (w *Window) IsElementFocused(element *Element) bool
- func (w *Window) Paste() bool
- func (w *Window) Redo() bool
- func (w *Window) Root() *Element
- func (w *Window) Save() bool
- func (w *Window) SetCloseInterceptor(interceptor func() bool)
- func (w *Window) SetSize(size Size)
- func (w *Window) Size() Size
- func (w *Window) Undo() bool
- type WindowHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WrappedLocator ¶ added in v0.11.0
func WrappedLocator(delegate resource.ReadLocator) resource.ReadLocator
WrapResourceLocator returns a new resource.ReadLocator that is capable of providing ui built-in resources as well as custom user resources.
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 struct {
// contains filtered or unexported fields
}
Canvas represents a mechanism through which an Element can render itself to the screen.
func (Canvas) Clip ¶
func (c Canvas) Clip()
Clip creates a new clipping area according to the currently constructed Path and the clip area of parent layers.
func (Canvas) ClipRect ¶ added in v0.13.0
ClipRect creates a clipping rectangle region. This clipping mechanism is slighly faster than using Clip with a Path and is used by the UI framework for clipping Element contents.
Note: This clipping model does not nest, hence you can escape the boundaries of your Element depending on the provided values. In most cases, the Clip method should be used instead.
func (*Canvas) DrawBounds ¶ added in v0.11.0
func (c *Canvas) DrawBounds(element *Element, padding bool) DrawBounds
DrawBounds returns the bounds to be used for drawing for the specified element.
func (Canvas) DrawSurface ¶ added in v0.3.0
DrawSurface renders the specified surface. The surface's Render method will be called when needed and is expected to return a texture representing the rendered frame.
func (*Canvas) ElapsedTime ¶ added in v0.12.0
ElapsedTime returns the amount of time that has passed since the last render iteration.
This should only be used by elements that are constantly being invalidated (i.e. do real-time rendering), as otherwise this duration would be incorrect since a non-dirty element could be omitted during some frames.
func (Canvas) Fill ¶ added in v0.5.0
func (c Canvas) Fill(fill Fill)
Fill fills the currently constructed Path according to the fill settings.
func (Canvas) FillText
deprecated
added in
v0.5.0
func (c Canvas) FillText(text string, position sprec.Vec2, typography Typography)
FillText draws a solid text at the specified position using the provided typography settings.
Deprecated: Use FillTextLine
func (Canvas) FillTextLine ¶ added in v0.13.0
func (c Canvas) FillTextLine(text []rune, position sprec.Vec2, typography Typography)
FillTextLine draws a solid text line at the specified position using the provided typography settings.
func (Canvas) Pop ¶
func (c Canvas) Pop()
Pop restores the drawing state based on the parent layer. If this is the first layer, then this method panics.
func (Canvas) Push ¶
func (c Canvas) Push()
Push records the current state and creates a new state layer. Changes done in the new layer will not affect the parent layer.
You may create up to 256 layers including the starting one after which the method panics.
func (Canvas) ResetTransform ¶ added in v0.4.0
func (c Canvas) ResetTransform()
ResetTransform restores the transform to the value it had after the last Push. If this is the first layer, then it is set to the identity matrix.
func (Canvas) Rotate ¶ added in v0.5.0
Rotate rotates the drawing coordinate system by the specified angle.
func (Canvas) Scale ¶ added in v0.5.0
Scale scales the drawing coordinate system by the specified amount in both directions.
func (Canvas) SetClipRect
deprecated
added in
v0.5.0
func (c Canvas) SetClipRect(left, right, top, bottom float32)
SetClipRect creates a clipping rectangle region. This clipping mechanism is slighly faster than using Clip with a Path and is used by the UI framework for clipping Element contents.
Note: This clipping model does not nest, hence you can escape the boundaries of your Element depending on the provided values. In most cases, the Clip method should be used instead.
Deprecated: Use ClipRect instead
func (Canvas) SetTransform ¶ added in v0.4.0
SetTransform changes the transform relative to the former layer transform.
type Character ¶ added in v0.13.0
type Character struct { // Rune contains the representation of the character. Rune rune // Kern indicates the offset from the previous character. Kern float32 // Width holds the horizontal size of the character. Width float32 }
Character contains information on a character from a text iteration.
type ClipboardAction ¶ added in v0.13.0
type ClipboardAction int
ClipboardAction indicates the type of clipboard operation.
const ( ClipboardActionCut ClipboardAction = 1 + iota ClipboardActionCopy ClipboardActionPaste )
func (ClipboardAction) String ¶ added in v0.13.0
func (a ClipboardAction) String() string
String returns a string representation of this action.
type ClipboardEvent ¶ added in v0.13.0
type ClipboardEvent struct { // Action represents the type of clipboard event. Action ClipboardAction // Text contains the text stored in the clipboard in case of a Paste action. Text string }
ClipboardEvent indicates an event related to a clipboard action.
type Color ¶
Color represents a 32bit color (8 bits per channel).
func ColorWithAlpha ¶ added in v0.3.0
ColorWithAlpha returns a new color that is based on the specified color but with adjusted alpha channel.
func MixColors ¶ added in v0.5.0
MixColors returns a mixture of the two colors where alpha determines the amount of the second color.
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) Overlay ¶ added in v0.8.0
Overlay returns a new Color that is the result of overlaying the specified color over the current color. The specified color should have an alpha that is lower than 100% for there to be any useful result.
func (Color) Translucent ¶
Translucent returns whether this color is translucent.
A translucent color is one that is partially 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) CreateContext ¶ added in v0.4.0
CreateContext returns a new Context that is a child of the current Context and as such can reuse resources held by the current context.
func (*Context) CreateFont ¶ added in v0.4.0
CreateFont creates a new Font resource.
The Font will be destroyed once this Context is destroyed.
func (*Context) CreateFontCollection ¶ added in v0.4.0
func (c *Context) CreateFontCollection(collection *opentype.Collection) (*FontCollection, error)
CreateFontCollection creates a new FontCollection resource.
The FontCollection will be destroyed once this Context is destroyed.
func (*Context) CreateImage ¶ added in v0.3.0
CreateImage creates a new Image resource.
The Image will be destroyed once this Context is destroyed.
func (*Context) Destroy ¶ added in v0.4.0
func (c *Context) Destroy()
Destroy releases all resources held by this Context.
func (*Context) GetFont ¶
GetFont returns the Font with the specified family and sub-family name from all of the created or loaded fonts and/or family collections.
func (*Context) OpenFont ¶ added in v0.4.0
OpenFont opens the Font at the specified URI location.
The URI is interpreted according to the used ResourceLocator.
The Font will be destroyed once this Context is destroyed.
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.
The FontCollection will be destroyed once this Context is destroyed.
func (*Context) OpenImage ¶
OpenImage opens the Image at the specified URI location.
The URI is interpreted according to the used ResourceLocator.
The Image will be destroyed once this Context is destroyed.
func (*Context) Schedule ¶
func (c *Context) Schedule(fn func())
Schedule appends the specified function to be called from the UI thread (UI 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 UI thread, as well as from other goroutines.
There is a limit to the number of functions that can be queued within a given frame iteration. Once the buffer is full, new functions will be dropped.
type Controller ¶ added in v0.12.0
type Controller struct { app.NopController // contains filtered or unexported fields }
func NewController ¶
func NewController(locator resource.ReadLocator, shaders ShaderCollection, initFn InitFunc) *Controller
NewController creates a new app.Controller that integrates with the ui package to render a user interface.
func (*Controller) OnClipboardEvent ¶ added in v0.13.0
func (c *Controller) OnClipboardEvent(window app.Window, event app.ClipboardEvent) bool
func (*Controller) OnCloseRequested ¶ added in v0.12.0
func (c *Controller) OnCloseRequested(window app.Window) bool
func (*Controller) OnCreate ¶ added in v0.12.0
func (c *Controller) OnCreate(appWindow app.Window)
func (*Controller) OnDestroy ¶ added in v0.12.0
func (c *Controller) OnDestroy(window app.Window)
func (*Controller) OnFramebufferResize ¶ added in v0.12.0
func (c *Controller) OnFramebufferResize(window app.Window, width, height int)
func (*Controller) OnKeyboardEvent ¶ added in v0.12.0
func (c *Controller) OnKeyboardEvent(window app.Window, event app.KeyboardEvent) bool
func (*Controller) OnMouseEvent ¶ added in v0.12.0
func (c *Controller) OnMouseEvent(window app.Window, event app.MouseEvent) bool
func (*Controller) OnRender ¶ added in v0.12.0
func (c *Controller) OnRender(window app.Window)
type DrawBounds ¶ added in v0.11.0
DrawBounds represents a rectangle area to be used for drawing.
func (DrawBounds) Height ¶ added in v0.11.0
func (b DrawBounds) Height() float32
Height returns the height of the draw area.
func (DrawBounds) Width ¶ added in v0.11.0
func (b DrawBounds) Width() float32
Width returns the width of the draw area.
func (DrawBounds) X ¶ added in v0.11.0
func (b DrawBounds) X() float32
X returns the left side of the draw area.
func (DrawBounds) Y ¶ added in v0.11.0
func (b DrawBounds) Y() float32
Y returns the top side of the draw area.
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) AbsoluteBounds ¶ added in v0.8.0
AbsoluteBounds returns the absolute bounds of the Element.
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) Focusable ¶ added in v0.3.0
Focusable returns whether this Element can receive keyboard events. When an element if focusable and a mouse down event is received, it becomes the focused element and will begin to receive keyboard events.
func (*Element) HierarchyEnabled ¶ added in v0.8.0
HierarchyEnabled checks whether this Element and all parent Elements are enabled.
func (*Element) HierarchyVisible ¶ added in v0.8.0
HierarchyVisible checks whether this Element and all parent Elements are visible.
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) Invalidate ¶ added in v0.8.0
func (e *Element) Invalidate()
Invalidate marks this element as dirty and needing to be redrawn.
func (*Element) IsFocused ¶ added in v0.13.0
IsFocused returns whether this Element is currently focused.
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) 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) PrependSibling ¶ added in v0.8.0
PrependSibling attaches an Element to the left of the current one.
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) SetFocusable ¶ added in v0.3.0
SetFocusable controls whether this Element should receive keyboard events.
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) SetPadding ¶
SetPadding configures this Element's content area spacing.
func (*Element) SetVisible ¶
SetVisible controls whether this Element should be rendered.
type ElementClipboardHandler ¶ added in v0.13.0
type ElementClipboardHandler interface {
OnClipboardEvent(element *Element, event ClipboardEvent) bool
}
ElementClipboardHandler is a type of EventHandler that can be used to receive events when an element is focused and clipboard actions are performed.
type ElementHistoryHandler ¶ added in v0.13.0
type ElementHistoryHandler interface { OnUndo(element *Element) bool OnRedo(element *Element) bool }
ElementHistoryHandler is a type of ElementHandler that can be used to receive undo and redo related events.
type ElementKeyboardHandler ¶ added in v0.3.0
type ElementKeyboardHandler interface {
OnKeyboardEvent(element *Element, event KeyboardEvent) bool
}
ElementKeyboardHandler is a type of EventHandler that can be used to receive events when an element is focused and keyboard actions are performed.
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 ElementStateHandler ¶ added in v0.13.0
ElementStateHandler is a type of ElementHandler that can be used to receive state related events.
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 FilepathPayload ¶ added in v0.3.0
type FilepathPayload = app.FilepathPayload
FilepathPayload is a type of Payload that occurs when files have been dragged and dropped into the window.
type Fill ¶ added in v0.3.0
type Fill struct { // Rule specifies the mechanism through which it is determined // which point is part of the shape in an overlapping or concave // polygon. Rule FillRule // Color specifies the color to use to fill the shape. Color Color // Image specifies an optional image to be used for filling // the shape. Image *Image // ImageOffset determines the offset of the origin of the // image relative to the current translation context. ImageOffset sprec.Vec2 // ImageSize determines the size of the drawn image. In // essence, this size performs scaling. ImageSize sprec.Vec2 }
Fill configures how a solid shape is to be drawn.
type FillLayout ¶ added in v0.3.0
type FillLayout struct{}
FillLayout resizes the children to fill the content space of the Element.
func NewFillLayout ¶ added in v0.3.0
func NewFillLayout() *FillLayout
NewFillLayout returns a new FillLayout instance.
func (*FillLayout) Apply ¶ added in v0.3.0
func (l *FillLayout) Apply(element *Element)
Apply applies this layout to the specified Element.
type FillRule ¶ added in v0.3.0
type FillRule int
FillRule represents the mechanism through which it is determined which point is part of the shape in an overlapping or concave polygon.
const ( // FillRuleSimple is the fastest approach and should be used // with non-overlapping concave shapes. FillRuleSimple FillRule = iota // FillRuleNonZero will fill areas that are covered by the // shape, regardless if it overlaps. FillRuleNonZero // FillRuleEvenOdd will fill areas that are covered by the // shape and it does not overlap or overlaps an odd number // of times. FillRuleEvenOdd )
type Font ¶
type Font struct {
// contains filtered or unexported fields
}
Font represents a text Font.
func (*Font) Destroy ¶ added in v0.4.0
func (f *Font) Destroy()
Destroy releases all resources related to this Font.
func (*Font) LineHeight ¶ added in v0.13.0
LineHeight returns the height of a single line based on the font size.
func (*Font) LineIterator ¶ added in v0.13.0
func (f *Font) LineIterator(characters []rune, fontSize float32) *LineIterator
LineIterator returns a new LineIterator over the specified text for the specified font size.
type FontCollection ¶
type FontCollection struct {
// contains filtered or unexported fields
}
FontCollection represents a collection of Fonts.
func (*FontCollection) Destroy ¶ added in v0.4.0
func (c *FontCollection) Destroy()
Destroy releases all resources held by this FontCollection.
func (*FontCollection) Fonts ¶
func (c *FontCollection) Fonts() []*Font
Fonts returns all Fonts contained by this collection.
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
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 KeyCode ¶
type KeyCode int
KeyCode represents a keyboard key.
const ( KeyCodeEscape KeyCode = KeyCode(app.KeyCodeEscape) KeyCodeEnter KeyCode = KeyCode(app.KeyCodeEnter) KeyCodeSpace KeyCode = KeyCode(app.KeyCodeSpace) KeyCodeTab KeyCode = KeyCode(app.KeyCodeTab) KeyCodeCaps KeyCode = KeyCode(app.KeyCodeCaps) KeyCodeLeftShift KeyCode = KeyCode(app.KeyCodeLeftShift) KeyCodeRightShift KeyCode = KeyCode(app.KeyCodeRightShift) KeyCodeLeftControl KeyCode = KeyCode(app.KeyCodeLeftControl) KeyCodeRightControl KeyCode = KeyCode(app.KeyCodeRightControl) KeyCodeLeftAlt KeyCode = KeyCode(app.KeyCodeLeftAlt) KeyCodeRightAlt KeyCode = KeyCode(app.KeyCodeRightAlt) KeyCodeLeftSuper KeyCode = KeyCode(app.KeyCodeLeftSuper) KeyCodeRightSuper KeyCode = KeyCode(app.KeyCodeRightSuper) KeyCodeBackspace KeyCode = KeyCode(app.KeyCodeBackspace) KeyCodeInsert KeyCode = KeyCode(app.KeyCodeInsert) KeyCodeDelete KeyCode = KeyCode(app.KeyCodeDelete) KeyCodeHome KeyCode = KeyCode(app.KeyCodeHome) KeyCodeEnd KeyCode = KeyCode(app.KeyCodeEnd) KeyCodePageUp KeyCode = KeyCode(app.KeyCodePageUp) KeyCodePageDown KeyCode = KeyCode(app.KeyCodePageDown) KeyCodeArrowLeft KeyCode = KeyCode(app.KeyCodeArrowLeft) KeyCodeArrowRight KeyCode = KeyCode(app.KeyCodeArrowRight) KeyCodeArrowUp KeyCode = KeyCode(app.KeyCodeArrowUp) KeyCodeArrowDown KeyCode = KeyCode(app.KeyCodeArrowDown) KeyCodeMinus KeyCode = KeyCode(app.KeyCodeMinus) KeyCodeEqual KeyCode = KeyCode(app.KeyCodeEqual) KeyCodeLeftBracket KeyCode = KeyCode(app.KeyCodeLeftBracket) KeyCodeRightBracket KeyCode = KeyCode(app.KeyCodeRightBracket) KeyCodeSemicolon KeyCode = KeyCode(app.KeyCodeSemicolon) KeyCodeComma KeyCode = KeyCode(app.KeyCodeComma) KeyCodePeriod KeyCode = KeyCode(app.KeyCodePeriod) KeyCodeSlash KeyCode = KeyCode(app.KeyCodeSlash) KeyCodeBackslash KeyCode = KeyCode(app.KeyCodeBackslash) KeyCodeApostrophe KeyCode = KeyCode(app.KeyCodeApostrophe) KeyCodeGraveAccent KeyCode = KeyCode(app.KeyCodeGraveAccent) KeyCodeA KeyCode = KeyCode(app.KeyCodeA) KeyCodeB KeyCode = KeyCode(app.KeyCodeB) KeyCodeC KeyCode = KeyCode(app.KeyCodeC) KeyCodeD KeyCode = KeyCode(app.KeyCodeD) KeyCodeE KeyCode = KeyCode(app.KeyCodeE) KeyCodeF KeyCode = KeyCode(app.KeyCodeF) KeyCodeG KeyCode = KeyCode(app.KeyCodeG) KeyCodeH KeyCode = KeyCode(app.KeyCodeH) KeyCodeI KeyCode = KeyCode(app.KeyCodeI) KeyCodeJ KeyCode = KeyCode(app.KeyCodeJ) KeyCodeK KeyCode = KeyCode(app.KeyCodeK) KeyCodeL KeyCode = KeyCode(app.KeyCodeL) KeyCodeM KeyCode = KeyCode(app.KeyCodeM) KeyCodeN KeyCode = KeyCode(app.KeyCodeN) KeyCodeO KeyCode = KeyCode(app.KeyCodeO) KeyCodeP KeyCode = KeyCode(app.KeyCodeP) KeyCodeQ KeyCode = KeyCode(app.KeyCodeQ) KeyCodeR KeyCode = KeyCode(app.KeyCodeR) KeyCodeS KeyCode = KeyCode(app.KeyCodeS) KeyCodeT KeyCode = KeyCode(app.KeyCodeT) KeyCodeU KeyCode = KeyCode(app.KeyCodeU) KeyCodeV KeyCode = KeyCode(app.KeyCodeV) KeyCodeW KeyCode = KeyCode(app.KeyCodeW) KeyCodeX KeyCode = KeyCode(app.KeyCodeX) KeyCodeY KeyCode = KeyCode(app.KeyCodeY) KeyCodeZ KeyCode = KeyCode(app.KeyCodeZ) KeyCode0 KeyCode = KeyCode(app.KeyCode0) KeyCode1 KeyCode = KeyCode(app.KeyCode1) KeyCode2 KeyCode = KeyCode(app.KeyCode2) KeyCode3 KeyCode = KeyCode(app.KeyCode3) KeyCode4 KeyCode = KeyCode(app.KeyCode4) KeyCode5 KeyCode = KeyCode(app.KeyCode5) KeyCode6 KeyCode = KeyCode(app.KeyCode6) KeyCode7 KeyCode = KeyCode(app.KeyCode7) KeyCode8 KeyCode = KeyCode(app.KeyCode8) KeyCode9 KeyCode = KeyCode(app.KeyCode9) KeyCodeF1 KeyCode = KeyCode(app.KeyCodeF1) KeyCodeF2 KeyCode = KeyCode(app.KeyCodeF2) KeyCodeF3 KeyCode = KeyCode(app.KeyCodeF3) KeyCodeF4 KeyCode = KeyCode(app.KeyCodeF4) KeyCodeF5 KeyCode = KeyCode(app.KeyCodeF5) KeyCodeF6 KeyCode = KeyCode(app.KeyCodeF6) KeyCodeF7 KeyCode = KeyCode(app.KeyCodeF7) KeyCodeF8 KeyCode = KeyCode(app.KeyCodeF8) KeyCodeF9 KeyCode = KeyCode(app.KeyCodeF9) KeyCodeF10 KeyCode = KeyCode(app.KeyCodeF10) KeyCodeF11 KeyCode = KeyCode(app.KeyCodeF11) KeyCodeF12 KeyCode = KeyCode(app.KeyCodeF12) )
type KeyModifier ¶
type KeyModifier int
KeyModifier represents a modifier key.
const ( KeyModifierControl KeyModifier = 1 << (iota + 1) KeyModifierShift KeyModifierAlt KeyModifierCapsLock KeyModifierSuper )
func (KeyModifier) String ¶ added in v0.13.0
func (m KeyModifier) String() string
String returns a string representation of this key modifier.
type KeyModifierSet ¶
type KeyModifierSet int
KeyModifierSet is used to indicate which modifier keys were active at the event occurrence.
func KeyModifiers ¶ added in v0.13.0
func KeyModifiers(entries ...KeyModifier) KeyModifierSet
KeyModifiers constructs a KeyModifierSet by combining the specified modifier entries.
func (KeyModifierSet) Contains ¶ added in v0.13.0
func (s KeyModifierSet) Contains(modifier KeyModifier) bool
Contains returns whether the set contains the specified modifier
func (KeyModifierSet) String ¶ added in v0.13.0
func (s KeyModifierSet) String() string
String returns a string representation of this key modifier set.
type KeyboardAction ¶ added in v0.13.0
type KeyboardAction int
KeyboardEventType is used to specify the type of keyboard action that occurred.
const ( KeyboardActionDown KeyboardAction = KeyboardAction(app.KeyboardActionDown) KeyboardActionUp KeyboardAction = KeyboardAction(app.KeyboardActionUp) KeyboardActionRepeat KeyboardAction = KeyboardAction(app.KeyboardActionRepeat) KeyboardActionType KeyboardAction = KeyboardAction(app.KeyboardActionType) )
func (KeyboardAction) String ¶ added in v0.13.0
func (a KeyboardAction) String() string
String returns a string representation of this event type,
type KeyboardEvent ¶
type KeyboardEvent struct { // Action specifies the keyboard event type. Action KeyboardAction // 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 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 LineIterator ¶ added in v0.13.0
type LineIterator struct {
// contains filtered or unexported fields
}
LineIterator represents an optimal way of evaluating the size of a text once character at a time.
func (*LineIterator) Character ¶ added in v0.13.0
func (i *LineIterator) Character() Character
Character returns the last iterated character.
func (*LineIterator) Next ¶ added in v0.13.0
func (i *LineIterator) Next() bool
Next evaluates a character from the text and returns whether there was any character.
type MouseAction ¶ added in v0.13.0
type MouseAction int
MouseAction represents the type of mouse event.
const ( MouseActionDown MouseAction = MouseAction(app.MouseActionDown) MouseActionUp MouseAction = MouseAction(app.MouseActionUp) MouseActionMove MouseAction = MouseAction(app.MouseActionMove) MouseActionEnter MouseAction = MouseAction(app.MouseActionEnter) MouseActionLeave MouseAction = MouseAction(app.MouseActionLeave) MouseActionScroll MouseAction = MouseAction(app.MouseActionScroll) MouseActionDrop MouseAction = MouseAction(app.MouseActionDrop) )
func (MouseAction) String ¶ added in v0.13.0
func (a MouseAction) String() string
String returns a string representation of this event type.
type MouseButton ¶
type MouseButton int
MouseButton represents the mouse button.
const ( MouseButtonLeft MouseButton = MouseButton(app.MouseButtonLeft) MouseButtonMiddle MouseButton = MouseButton(app.MouseButtonMiddle) MouseButtonRight MouseButton = MouseButton(app.MouseButtonRight) )
func (MouseButton) String ¶ added in v0.13.0
func (b MouseButton) String() string
String returns a string representation of this button.
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 // Action specifies the mouse event type. Action MouseAction // Button specifies the button for which the event is // applicable. Button MouseButton // X contains the horizontal coordinate of the event. X int // Y contains the vertical coordinate of the event. Y int // ScrollX determines the amount of horizontal scroll. ScrollX float32 // ScrollY determines the amount of vertical scroll. ScrollY float32 // Modifiers contains active key modifiers. Modifiers KeyModifierSet // Payload contains the data that was dropped. Payload interface{} }
MouseEvent represents an event related to a mouse action.
func (MouseEvent) Position ¶
func (e MouseEvent) Position() Position
Position is a helper function that returns the position of the event based off of the X and Y coordinates.
func (MouseEvent) String ¶
func (e MouseEvent) String() string
String returns a string representation for this 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 ShaderCollection ¶ added in v0.4.0
type ShaderCollection struct { ShapeShadedSet func() render.ProgramCode ShapeBlankSet func() render.ProgramCode ContourSet func() render.ProgramCode TextSet func() render.ProgramCode }
ShaderCollection holds the set of shaders to be used for rendering.
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 SymmetricSpacing ¶ added in v0.12.0
SymmetricSpacing returns a Spacing that is horizontally and vertically symmetric.
func UniformSpacing ¶ added in v0.12.0
UniformSpacing returns a Spacing that is equal all around.
func (Spacing) Horizontal ¶
Horizontal returns the horizontal amount of spacing.
func (Spacing) Size ¶ added in v0.8.0
Size returns the amount of spacing used in both horizontal and vertical direction.
type Typography ¶ added in v0.3.0
type Typography struct { // Font specifies the font to be used. Font *Font // Size specifies the font size. Size float32 // Color indicates the color of the text. Color Color }
Typography configures how text is to be drawn.
type Window ¶
Window represents an application window.
func (*Window) BubbleFocus ¶ added in v0.13.0
func (w *Window) BubbleFocus()
BubbleFocus releases focus from the current element and tries to find a parent that is focusable in order to grant it focus.
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) CreateElement ¶ added in v0.8.0
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.
func (*Window) DiscardFocus ¶ added in v0.3.0
func (w *Window) DiscardFocus()
DiscardFocus removes the focus from any Element.
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.
func (*Window) GrantFocus ¶ added in v0.10.0
GrantFocus grants the focus to the specified Element.
func (*Window) IsElementFocused ¶ added in v0.3.0
IsElementFocused returns whether the specified element is the currently focused Element.
func (*Window) SetCloseInterceptor ¶ added in v0.13.0
SetCloseInterceptor configures a handler to be notified of close requests by the user. This is not called on manual Close operations.
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 // OnClipboardEvent is called whenever a clipboard paste operation // is being performed. OnClipboardEvent(event ClipboardEvent) 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 application. // (e.g. using the close button on the application) OnCloseRequested() bool }
WindowHandler is an interface that is used by the framework to communicate with Window implementations critical events.
Source Files ¶
- bounds.go
- canvas.go
- canvas_layer.go
- canvas_mesh.go
- canvas_path.go
- canvas_renderer.go
- canvas_uniform.go
- clipboard.go
- color.go
- config.go
- context.go
- controller.go
- doc.go
- element.go
- font.go
- font_factory.go
- image.go
- image_factory.go
- keyboard.go
- layout.go
- logger.go
- mouse.go
- position.go
- resource_manager.go
- resources.go
- size.go
- spacing.go
- util.go
- window.go
Directories ¶
Path | Synopsis |
---|---|
Package component features a framework, inspired by React, that allows one to construct a user interface hierarchy through the usage of declarative DSL.
|
Package component features a framework, inspired by React, that allows one to construct a user interface hierarchy through the usage of declarative DSL. |
Package i18n provides experimental internationalization features.
|
Package i18n provides experimental internationalization features. |
Package layout provides a default layout scheme that can, but need not, be used with the ui framework.
|
Package layout provides a default layout scheme that can, but need not, be used with the ui framework. |
Package mvc adds utilities on top of the component package that allow one to model a user interface that uses a type of MVC pattern.
|
Package mvc adds utilities on top of the component package that allow one to model a user interface that uses a type of MVC pattern. |
Package state contains utilities for managing state transitions.
|
Package state contains utilities for managing state transitions. |
Package std provides a collection of standard components that can be used with the ui framework.
|
Package std provides a collection of standard components that can be used with the ui framework. |