tomo

package module
v0.48.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2024 License: GPL-3.0 Imports: 9 Imported by: 12

README

tomo

Go Reference

Tomo is a lightweight GUI toolkit written in pure Go. This repository defines the API that other components of the toolkit agree upon. In order to use Tomo in an application, use Nasin, which builds an application framework on top of Tomo.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do added in v0.16.0

func Do(callback func())

Do performs a callback function in the event loop thread as soon as possible.

func MimeIconTexture added in v0.42.0

func MimeIconTexture(mime data.Mime, size IconSize) canvas.Texture

MimeIconTexture returns a canvas.Texture of the icon corresponding to a MIME type. It may be closed and therefore rendered invalid if the icon set changes, so it is necessary to subscribe to the IconSetChange event in order to get a new icon texture when this happens.

func NewCanvas added in v0.35.0

func NewCanvas(bounds image.Rectangle) canvas.CanvasCloser

NewCanvas creates a new canvas with the specified bounds. When no longer in use, it must be freed using Close().

func NewTexture added in v0.24.0

func NewTexture(source image.Image) canvas.TextureCloser

NewTexture creates a new canvas.Texture from an image. When no longer in use, it must be freed using Close().

func SetBackend added in v0.44.0

func SetBackend(back Backend)

SetBackend sets the Backend that functions in this package will call upon. This function will panic if there is already a Backend running.

func Stop

func Stop()

Stop stops the currently running Backend.

Types

type Align

type Align int

Align lists basic alignment types.

const (
	AlignStart  Align = iota // similar to left-aligned text
	AlignMiddle              // similar to center-aligned text
	AlignEnd                 // similar to right-aligned text
	AlignEven                // similar to justified text
)

func (Align) String added in v0.42.0

func (align Align) String() string

type Attr added in v0.39.0

type Attr interface {
	// Equals returns true if both Attrs can reasonably be declared equal.
	Equals(Attr) bool
	Kind() AttrKind
	// contains filtered or unexported methods
}

Attr modifies one thing about a Box's style.

type AttrAlign added in v0.39.0

type AttrAlign struct{ X, Y Align }

AttrAlign sets the layout alignment, if the Box is a ContentBox.

func AAlign added in v0.40.0

func AAlign(x, y Align) AttrAlign

AAlign is a convenience constructor for AttrAlign.

func (AttrAlign) Equals added in v0.41.0

func (this AttrAlign) Equals(other Attr) bool

Equals returns true if both Attrs can reasonably be declared equal.

func (AttrAlign) Kind added in v0.42.0

func (AttrAlign) Kind() AttrKind

type AttrBorder added in v0.39.0

type AttrBorder []Border

AttrBorder sets the Border of a Box.

func ABorder added in v0.40.0

func ABorder(borders ...Border) AttrBorder

ABorder is a convenience constructor for AttrBorder.

func (AttrBorder) Equals added in v0.41.0

func (this AttrBorder) Equals(other Attr) bool

Equals returns true if both Attrs can reasonably be declared equal.

func (AttrBorder) Kind added in v0.42.0

func (AttrBorder) Kind() AttrKind

type AttrColor added in v0.39.0

type AttrColor struct{ color.Color }

AttrColor sets the background color of a Box.

func AColor added in v0.40.0

func AColor(col color.Color) AttrColor

AColor is a convenience constructor for AttrColor.

func (AttrColor) Equals added in v0.41.0

func (this AttrColor) Equals(other Attr) bool

Equals returns true if both Attrs can reasonably be declared equal.

func (AttrColor) Kind added in v0.42.0

func (AttrColor) Kind() AttrKind

type AttrCursor added in v0.47.0

type AttrCursor Cursor

AttrCursor sets the mouse cursor shape.

func ACursor added in v0.47.0

func ACursor(cursor Cursor) AttrCursor

ACursor is a convenience constructor for AttrCursor.

func (AttrCursor) Equals added in v0.47.0

func (this AttrCursor) Equals(other Attr) bool

Equals returns true if both Attrs can reasonably be declared equal.

func (AttrCursor) Kind added in v0.47.0

func (AttrCursor) Kind() AttrKind

type AttrDotColor added in v0.39.0

type AttrDotColor struct{ color.Color }

AttrDotColor sets the text selection color, if the Box is a TextBox.

func ADotColor added in v0.40.0

func ADotColor(col color.Color) AttrDotColor

ADotColor is a convenience constructor for AttrDotColor.

func (AttrDotColor) Equals added in v0.41.0

func (this AttrDotColor) Equals(other Attr) bool

Equals returns true if both Attrs can reasonably be declared equal.

func (AttrDotColor) Kind added in v0.42.0

func (AttrDotColor) Kind() AttrKind

type AttrFace added in v0.39.0

type AttrFace Face

AttrFace sets the type face, if the Box is a TextBox.

func AFace added in v0.40.0

func AFace(face Face) AttrFace

AFace is a convenience constructor for AttrFace.

func (AttrFace) Equals added in v0.41.0

func (this AttrFace) Equals(other Attr) bool

Equals returns true if both Attrs can reasonably be declared equal.

func (AttrFace) Kind added in v0.42.0

func (AttrFace) Kind() AttrKind

type AttrGap added in v0.39.0

type AttrGap image.Point

AttrGap sets the gap between child Boxes, if the Box is a ContainerBox.

func AGap added in v0.40.0

func AGap(x, y int) AttrGap

AGap is a convenience constructor for AttrGap.

func (AttrGap) Equals added in v0.41.0

func (this AttrGap) Equals(other Attr) bool

Equals returns true if both Attrs can reasonably be declared equal.

func (AttrGap) Kind added in v0.42.0

func (AttrGap) Kind() AttrKind

type AttrKind added in v0.42.0

type AttrKind int

AttrKind enumerates all attribute kinds. Each Attr- type has one of these.

const (
	AttrKindColor AttrKind = iota
	AttrKindTexture
	AttrKindTextureMode
	AttrKindBorder
	AttrKindMinimumSize
	AttrKindPadding
	AttrKindGap
	AttrKindTextColor
	AttrKindDotColor
	AttrKindFace
	AttrKindWrap
	AttrKindAlign
	AttrKindOverflow
	AttrKindLayout
	AttrKindCursor
)

type AttrLayout added in v0.41.0

type AttrLayout struct{ Layout }

AttrLayout sets the Layout, if the Box is a ContentBox.

func ALayout added in v0.41.0

func ALayout(layout Layout) AttrLayout

ALayout is a convenience constructor for AttrLayout.

func (AttrLayout) Equals added in v0.41.0

func (this AttrLayout) Equals(other Attr) bool

Equals returns true if both Attrs can reasonably be declared equal.

func (AttrLayout) Kind added in v0.42.0

func (AttrLayout) Kind() AttrKind

type AttrMinimumSize added in v0.39.0

type AttrMinimumSize image.Point

AttrMinimumSize sets the minimum size of a Box.

func AMinimumSize added in v0.40.0

func AMinimumSize(x, y int) AttrMinimumSize

AMinimumSize is a convenience constructor for AttrMinimumSize.

func (AttrMinimumSize) Equals added in v0.41.0

func (this AttrMinimumSize) Equals(other Attr) bool

Equals returns true if both Attrs can reasonably be declared equal.

func (AttrMinimumSize) Kind added in v0.42.0

func (AttrMinimumSize) Kind() AttrKind

type AttrOverflow added in v0.41.0

type AttrOverflow struct{ X, Y bool }

AttrOverflow sets the overflow, if the Box is a ContentBox.

func AOverflow added in v0.41.0

func AOverflow(x, y bool) AttrOverflow

AOverflow is a convenience constructor for AttrOverflow.

func (AttrOverflow) Equals added in v0.41.0

func (this AttrOverflow) Equals(other Attr) bool

Equals returns true if both Attrs can reasonably be declared equal.

func (AttrOverflow) Kind added in v0.42.0

func (AttrOverflow) Kind() AttrKind

type AttrPadding added in v0.39.0

type AttrPadding Inset

AttrPadding sets the inner padding of a Box.

func APadding added in v0.40.0

func APadding(sides ...int) AttrPadding

APadding is a convenience constructor for AttrPadding.

func (AttrPadding) Equals added in v0.41.0

func (this AttrPadding) Equals(other Attr) bool

Equals returns true if both Attrs can reasonably be declared equal.

func (AttrPadding) Kind added in v0.42.0

func (AttrPadding) Kind() AttrKind

type AttrTextColor added in v0.39.0

type AttrTextColor struct{ color.Color }

AttrTextColor sets the text color, if the Box is a TextBox.

func ATextColor added in v0.40.0

func ATextColor(col color.Color) AttrTextColor

ATextColor is a convenience constructor for AttrTextColor.

func (AttrTextColor) Equals added in v0.41.0

func (this AttrTextColor) Equals(other Attr) bool

Equals returns true if both Attrs can reasonably be declared equal.

func (AttrTextColor) Kind added in v0.42.0

func (AttrTextColor) Kind() AttrKind

type AttrTexture added in v0.39.0

type AttrTexture struct{ canvas.Texture }

AttrTexture sets the texture of a Box.

func ATexture added in v0.40.0

func ATexture(texture canvas.Texture) AttrTexture

ATexture is a convenience constructor for AttrTexture.

func (AttrTexture) Equals added in v0.41.0

func (this AttrTexture) Equals(other Attr) bool

Equals returns true if both Attrs can reasonably be declared equal.

func (AttrTexture) Kind added in v0.42.0

func (AttrTexture) Kind() AttrKind

type AttrTextureMode added in v0.40.0

type AttrTextureMode TextureMode

AttrTextureMode sets the rendering mode of a Box's texture.

func ATextureMode added in v0.40.0

func ATextureMode(mode TextureMode) AttrTextureMode

ATextureMode is a convenience constructor for AttrTextureMode.

func (AttrTextureMode) Equals added in v0.41.0

func (this AttrTextureMode) Equals(other Attr) bool

Equals returns true if both Attrs can reasonably be declared equal.

func (AttrTextureMode) Kind added in v0.42.0

func (AttrTextureMode) Kind() AttrKind

type AttrWrap added in v0.41.0

type AttrWrap bool

AttrWrap sets whether or not the text wraps, if the Box is a TextBox.

func AWrap added in v0.41.0

func AWrap(wrap bool) AttrWrap

AWrap is a convenience constructor for AttrWrap.

func (AttrWrap) Equals added in v0.41.0

func (this AttrWrap) Equals(other Attr) bool

Equals returns true if both Attrs can reasonably be declared equal.

func (AttrWrap) Kind added in v0.42.0

func (AttrWrap) Kind() AttrKind

type Backend

type Backend interface {
	// These methods create new Objects. The backend must reject any Object
	// that was not made by it.
	NewBox() Box
	NewTextBox() TextBox
	NewCanvasBox() CanvasBox
	NewSurfaceBox() (SurfaceBox, error)
	NewContainerBox() ContainerBox

	// NewWindow creates a normal Window and returns it.
	NewWindow(WindowKind, image.Rectangle) (Window, error)

	// NewTexture creates a new canvs.Texture from an image. The backend
	// must reject any texture that was not made by it.
	NewTexture(image.Image) canvas.TextureCloser

	// NewCanvas creates a new canvas.Canvas with the specified bounds. The
	// backend must reject any canvas that was not made by it.
	NewCanvas(image.Rectangle) canvas.CanvasCloser

	// ColorRGBA returns the RGBA of a color according to the current style,
	// as specified in color.Color.RGBA. It may be rendered invalid if the
	// visual style changes, but the Backend must send a StyleChange event
	// to all managed boxes when this happens.
	ColorRGBA(id Color) (r, g, b, a uint32)

	// IconTexture returns the canvas.Texture of an Icon. It may be closed
	// and therefore rendered invalid if the icon set changes, but the
	// Backend must send an IconSetChange event to all managed boxes when
	// this happens.
	IconTexture(Icon, IconSize) canvas.Texture

	// MimeIconTexture returns the canvas.Texture of an icon corresponding
	// to the specified MIME type. It may be closed and therefore rendered
	// invalid if the icon set changes, but the Backend must send an
	// IconSetChange event to all managed boxes when this happens.
	MimeIconTexture(data.Mime, IconSize) canvas.Texture

	// Run runs the event loop until Stop is called, or the Backend
	// experiences a fatal error.
	Run() error

	// Stop must unblock Run. This behavior may only be called from within
	// tomo.Stop.
	Stop()

	// Do performs a callback function in the event loop thread as soon as
	// possible. This method must be safe to call concurrently.
	Do(func())
}

Backend is any Tomo implementation. Backends handle window creation, layout, rendering, and events so that there can be as many platform-specific optimizations as possible.

type Border

type Border struct {
	Width Inset
	Color [4]color.Color
}

Border represents a single border of a Box.

func (Border) String added in v0.42.0

func (border Border) String() string

type Box

type Box interface {
	Object

	// Window returns the Window this Box is a part of.
	Window() Window
	// Bounds returns the outer bounding image.Rectangle of the Box relative
	// to the Window.
	Bounds() image.Rectangle
	// InnerBounds returns the inner bounding image.Rectangle of the box. It
	// is the value of Bounds inset by the Box's border and padding.
	InnerBounds() image.Rectangle
	// Role returns this Box's role as set by SetRole.
	Role() Role
	// SetRole sets what role this Box takes on. It is used by the Backend
	// for applying styling.
	SetRole(Role)
	// Tag returns whether or not a named tag exists. These are used by the
	// Backend for applying styling, among other things. There are some
	// special tags that are only and always extant during certain user
	// input states:
	//   - hovered: The mouse pointer is within the Box
	//   - focused: The Box has keyboard focus
	//   - pressed: The Box is being pressed by config.ButtonChordInteract
	Tag(string) bool
	// SetTag adds or removes a named tag.
	SetTag(string, bool)

	// SetAttr sets a style attribute, overriding the currently applied
	// style.
	SetAttr(Attr)
	// UnsetAttr reverts a style attribute to whatever is specified by the
	// currently applied style.
	UnsetAttr(AttrKind)

	// SetDNDData sets the data that will be picked up if this Box is
	// dragged. If this is nil (which is the default), this Box will not be
	// picked up.
	SetDNDData(data.Data)
	// SetDNDAccept sets the types of data which can be dropped onto this
	// Box. If none are specified (which is the default), this Box will
	// reject all drops.
	SetDNDAccept(...data.Mime)
	// SetFocused sets whether or not this Box has keyboard focus. If set to
	// true, this method will steal focus away from whichever Object
	// currently has focus.
	SetFocused(bool)
	// SetFocusable sets whether or not this Box can receive keyboard focus.
	// If set to false and the Box is already focused. the focus is removed.
	SetFocusable(bool)

	// These are event subscription behaviors that allow callbacks to be
	// connected to particular events. Multiple callbacks may be connected
	// to the same event at once. Callbacks can be removed by closing the
	// returned event.Cookie.
	OnFocusEnter(func()) event.Cookie
	OnFocusLeave(func()) event.Cookie
	OnStyleChange(func()) event.Cookie
	OnIconSetChange(func()) event.Cookie
	OnDNDEnter(func()) event.Cookie
	OnDNDLeave(func()) event.Cookie
	OnDNDDrop(func(data.Data)) event.Cookie
	OnMouseEnter(func()) event.Cookie
	OnMouseLeave(func()) event.Cookie
	// These event subscription behaviors require their callbacks to return
	// a bool value. Under normal circumstances, these events are propagated
	// to the Box which is most directly affected by them, and then to all
	// of its parents from the bottom-up. Returning true from the callback
	// will cause the propagation to stop immediately, thereby "catching"
	// the event.
	//
	// Generally, if the event was successfully handled, the callbacks ought
	// to return true. Additionally, when subscribing to an event that is
	// often paired with a second one (for example, KeyDown and KeyUp), it
	// is good practice to subscribe to both and return true/false under the
	// same circumstances.
	OnMouseMove(func() bool) event.Cookie
	OnButtonDown(func(button input.Button) bool) event.Cookie
	OnButtonUp(func(button input.Button) bool) event.Cookie
	OnScroll(func(deltaX, deltaY float64) bool) event.Cookie
	OnKeyDown(func(key input.Key, numberPad bool) bool) event.Cookie
	OnKeyUp(func(key input.Key, numberPad bool) bool) event.Cookie
}

Box is a basic box with no content. Implementations of Box, as well as any interface that embed Box, may only originate from a Backend.

func NewBox

func NewBox() Box

NewBox creates and returns a basic Box.

type BoxArranger added in v0.39.0

type BoxArranger interface {
	BoxQuerier

	// SetBounds sets the bounds of a Box.
	SetBounds(index int, bounds image.Rectangle)
}

BoxArranger is a BoxQuerier that allows arranging child boxes according to a layout.

type BoxQuerier added in v0.39.0

type BoxQuerier interface {
	// Len returns the amount of Boxes.
	Len() int
	// MinimumSize returns the minimum size of a Box.
	MinimumSize(index int) image.Point
	// RecommendedWidth returns the recommended width for a given height for
	// a Box, if supported. Otherwise, it should just return the minimum
	// width of that Box. The result of this behavior may or may not be
	// respected, depending on the situation.
	RecommendedWidth(index int, height int) int
	// RecommendedHeight returns the recommended height for a given width
	// for a Box, if supported. Otherwise, it should just return the minimum
	// width of that Box. The result of this behavior may or may not be
	// respected, depending on the situation.
	RecommendedHeight(index int, width int) int
}

BoxQuerier allows the attributes of a ContainerBox's children to be queried.

type CanvasBox

type CanvasBox interface {
	Box

	// SetDrawer sets the canvas.Drawer that will be called upon to draw the
	// Box's content when it is invalidated. The Canvas passed to the Drawer
	// will have these properties:
	//   - It will have the same origin (0, 0) as the Window which contains
	//     the CanvasBox.
	//   - Its Bounds will describe the portion of the CanvasBox visible on
	//     screen. Therefore, it should not be used to determine the
	//     position of anything drawn within it. The Bounds of the CanvasBox
	//     should be used for this purpose.
	SetDrawer(canvas.Drawer)

	// Invalidate causes the CanvasBox's area to be redrawn at the end of
	// the event cycle, even if it wouldn't otherwise be. This will call the
	// canvas.Drawer specified by SetDrawer.
	Invalidate()
}

CanvasBox is a Box that can be drawn to.

func NewCanvasBox

func NewCanvasBox() CanvasBox

NewCanvasBox creates and returns a Box that can display custom graphics.

type Color added in v0.33.0

type Color int

Color represents a color ID.

const (
	ColorBackground Color = iota
	ColorForeground
	ColorRaised
	ColorSunken
	ColorAccent
)

func (Color) RGBA added in v0.33.0

func (id Color) RGBA() (r, g, b, a uint32)

RGBA satisfies the color.Color interface. The result of this method may be rendered invalid if the visual style changes, so it is often necessary to subscribe to the StyleChange event in order to get new RGBA values when this happens.

func (Color) String added in v0.33.0

func (id Color) String() string

type ContainerBox

type ContainerBox interface {
	ContentBox

	// Add appends a child Object. If the Object is already a child of
	// another Object, it will be removed from that Object first.
	Add(Object)
	// Remove removes a child Object, if it is a child of this Box.
	Remove(Object)
	// Insert inserts a child Object before a specified Object. If the
	// before Object is nil or is not contained within this Box, the
	// inserted Object is appended.
	Insert(child Object, before Object)
	// Clear removes all child Objects.
	Clear()
	// Len returns the amount of child Objects.
	Len() int
	// At returns the child Object at the specified index.
	At(int) Object
	// SetInputMask sets whether or not user input events will be sent to
	// this Box's children. If false, which is the default, input events
	// will be sent to this Box as well as all of its children. If true,
	// any input events that would otherwise go to this Box's children are
	// sent to it instead. This prevents children from performing event
	// catching as described in the documentation for Box.
	SetInputMask(bool)
}

ContentBox is a box that can contain child Objects. It arranges them according to a layout rule.

func NewContainerBox

func NewContainerBox() ContainerBox

NewContainerBox creates and returns a Box that can contain other boxes.

type ContentBox added in v0.7.3

type ContentBox interface {
	Box

	// ContentBounds returns the bounds of the inner content of the Box
	// relative to the Box's InnerBounds.
	ContentBounds() image.Rectangle
	// ScrollTo shifts the origin of the Box's content to the origin of the
	// Box's InnerBounds, offset by the given image.Point.
	ScrollTo(image.Point)

	// OnContentBoundsChange specifies a function to be called when the
	// Box's ContentBounds or InnerBounds changes.
	OnContentBoundsChange(func()) event.Cookie
}

ContentBox is a box that has some kind of content.

type ContentObject added in v0.32.0

type ContentObject interface {
	Object

	// ContentBounds returns the bounds of the inner content of the Box
	// relative to the Box's InnerBounds.
	ContentBounds() image.Rectangle
	// ScrollTo shifts the origin of the Box's content to the origin of the
	// Box's InnerBounds, offset by the given point.
	ScrollTo(image.Point)
	// OnContentBoundsChange specifies a function to be called when the
	// Box's ContentBounds or InnerBounds changes.
	OnContentBoundsChange(func()) event.Cookie
}

ContentObject is an Object that contains some kind of content.

type Cursor added in v0.47.0

type Cursor string

Cursor represents a mouse cursor shape.

const (
	CursorUnknown      Cursor = ""
	CursorDefault      Cursor = "Default"
	CursorText         Cursor = "Text"
	CursorPointer      Cursor = "Pointer"
	CursorHelp         Cursor = "Help"
	CursorProgress     Cursor = "Progress"
	CursorWait         Cursor = "Wait"
	CursorCopy         Cursor = "Copy"
	CursorAlias        Cursor = "Alias"
	CursorNoDrop       Cursor = "NoDrop"
	CursorNotAllowed   Cursor = "NotAllowed"
	CursorAllScroll    Cursor = "AllScroll"
	CursorRowResize    Cursor = "RowResize"
	CursorColResize    Cursor = "ColResize"
	CursorEResize      Cursor = "EResize"
	CursorNEResize     Cursor = "NEResize"
	CursorNWResize     Cursor = "NWResize"
	CursorNResize      Cursor = "NResize"
	CursorSEResize     Cursor = "SEResize"
	CursorSWResize     Cursor = "SWResize"
	CursorSResize      Cursor = "SResize"
	CursorWResize      Cursor = "WResize"
	CursorVerticalText Cursor = "VerticalText"
	CursorCrosshair    Cursor = "Crosshair"
	CursorCell         Cursor = "Cell"
)

A list of standard cursor shapes. This is based off of the XDG Cursor Conventions Specification (https://www.freedesktop.org/wiki/Specifications/cursor-spec/).

type Face added in v0.42.0

type Face struct {
	// Font specifies the font name. This should be searched for in a list
	// of installed fonts.
	Font string
	// Size is the point size of the face.
	Size float64
	// Weight is the weight of the face. If zero, it should be interpreted
	// as normal (equivalent to 400).
	Weight int
	// Italic is how italicized the face is. It ranges from 0 to 1. It is
	// different from Slant in that it may alter the design of the glyphs
	// instead of simply skewing them.
	Italic float64
	// Slant is how slanted the face is. It ranges from 0 to 1. It is
	// different from Italic in that it simply skews the glyphs without
	// altering their design.
	Slant float64
}

Face represents a typeface.

func (Face) String added in v0.42.0

func (face Face) String() string

type Icon added in v0.33.0

type Icon string

Icon represents an icon ID.

const (
	// IconUnknown should be a blank space the size of a regular Icon.
	IconUnknown Icon = ""

	// actions
	IconAddressBookNew  Icon = "AddressBookNew"
	IconApplicationExit Icon = "ApplicationExit"
	IconAppointmentNew  Icon = "AppointmentNew"
	IconCallStart       Icon = "CallStart"
	IconCallStop        Icon = "CallStop"
	IconContactNew      Icon = "ContactNew"
	// actions: dialog
	IconDialogOkay   Icon = "DialogOkay"
	IconDialogCancel Icon = "DialogCancel"
	// actions: edit
	IconEditClear       Icon = "EditClear"
	IconEditCopy        Icon = "EditCopy"
	IconEditCut         Icon = "EditCut"
	IconEditDelete      Icon = "EditDelete"
	IconEditFind        Icon = "EditFind"
	IconEditFindReplace Icon = "EditFindReplace"
	IconEditPaste       Icon = "EditPaste"
	IconEditRedo        Icon = "EditRedo"
	IconEditSelectAll   Icon = "EditSelectAll"
	IconEditUndo        Icon = "EditUndo"
	// actions: file
	IconFileNew          Icon = "FileNew"
	IconDirectoryNew     Icon = "DirectoryNew"
	IconFileOpen         Icon = "FileOpen"
	IconFileOpenRecent   Icon = "FileOpenRecent"
	IconFilePageSetup    Icon = "FilePageSetup"
	IconFilePrint        Icon = "FilePrint"
	IconFilePrintPreview Icon = "FilePrintPreview"
	IconFilePermissions  Icon = "FilePermissions"
	IconFileProperties   Icon = "FileProperties"
	IconFileRename       Icon = "FileRename"
	IconFileRevert       Icon = "FileRevert"
	IconFileSave         Icon = "FileSave"
	IconFileSaveAs       Icon = "FileSaveAs"
	IconFileSend         Icon = "FileSend"
	// actions: format
	IconFormatIndentLess        Icon = "FormatIndentLess"
	IconFormatIndentMore        Icon = "FormatIndentMore"
	IconFormatAlignCenter       Icon = "FormatAlignCenter"
	IconFormatAlignEven         Icon = "FormatAlignEven"
	IconFormatAlignLeft         Icon = "FormatAlignLeft"
	IconFormatAlignRight        Icon = "FormatAlignRight"
	IconFormatTextDirectionLtr  Icon = "FormatTextDirectionLtr"
	IconFormatTextDirectionRtl  Icon = "FormatTextDirectionRtl"
	IconFormatTextBold          Icon = "FormatTextBold"
	IconFormatTextItalic        Icon = "FormatTextItalic"
	IconFormatTextUnderline     Icon = "FormatTextUnderline"
	IconFormatTextStrikethrough Icon = "FormatTextStrikethrough"
	// actions: go
	IconGoBottom   Icon = "GoBottom"
	IconGoDown     Icon = "GoDown"
	IconGoFirst    Icon = "GoFirst"
	IconGoHome     Icon = "GoHome"
	IconGoJump     Icon = "GoJump"
	IconGoLast     Icon = "GoLast"
	IconGoNext     Icon = "GoNext"
	IconGoPrevious Icon = "GoPrevious"
	IconGoTop      Icon = "GoTop"
	IconGoUp       Icon = "GoUp"
	// actions: help
	IconHelpAbout    Icon = "HelpAbout"
	IconHelpContents Icon = "HelpContents"
	IconHelpFaq      Icon = "HelpFaq"
	// actions: insert
	IconInsertImage  Icon = "InsertImage"
	IconInsertLink   Icon = "InsertLink"
	IconInsertObject Icon = "InsertObject"
	IconInsertText   Icon = "InsertText"
	// actions: list
	IconListAdd      Icon = "ListAdd"
	IconListRemove   Icon = "ListRemove"
	IconListChoose   Icon = "ListChoose"
	IconListExpand   Icon = "ListExpand"
	IconListContract Icon = "ListContract"
	// actions: mail
	IconMailForward       Icon = "MailForward"
	IconMailMarkImportant Icon = "MailMarkImportant"
	IconMailMarkJunk      Icon = "MailMarkJunk"
	IconMailMarkNotJunk   Icon = "MailMarkNotJunk"
	IconMailMarkRead      Icon = "MailMarkRead"
	IconMailMarkUnread    Icon = "MailMarkUnread"
	IconMailMessageNew    Icon = "MailMessageNew"
	IconMailReplyAll      Icon = "MailReplyAll"
	IconMailReplySender   Icon = "MailReplySender"
	IconMailSend          Icon = "MailSend"
	IconMailReceive       Icon = "MailReceive"
	// actions: media
	IconMediaEject         Icon = "MediaEject"
	IconMediaPlaybackPause Icon = "MediaPlaybackPause"
	IconMediaPlaybackStart Icon = "MediaPlaybackStart"
	IconMediaPlaybackStop  Icon = "MediaPlaybackStop"
	IconMediaRecord        Icon = "MediaRecord"
	IconMediaSeekBackward  Icon = "MediaSeekBackward"
	IconMediaSeekForward   Icon = "MediaSeekForward"
	IconMediaSkipBackward  Icon = "MediaSkipBackward"
	IconMediaSkipForward   Icon = "MediaSkipForward"
	// actions: object
	IconObjectFlipHorizontal Icon = "ObjectFlipHorizontal"
	IconObjectFlipVertical   Icon = "ObjectFlipVertical"
	IconObjectRotateLeft     Icon = "ObjectRotateLeft"
	IconObjectRotateRight    Icon = "ObjectRotateRight"
	// actions: process
	IconProcessStop Icon = "ProcessStop"
	// actions: system
	IconSystemLockScreen Icon = "SystemLockScreen"
	IconSystemLogOut     Icon = "SystemLogOut"
	IconSystemRun        Icon = "SystemRun"
	IconSystemSearch     Icon = "SystemSearch"
	IconSystemReboot     Icon = "SystemReboot"
	IconSystemShutdown   Icon = "SystemShutdown"
	// actions: tools
	IconToolsCheckSpelling Icon = "ToolsCheckSpelling"
	// actions: value
	IconValueIncrement Icon = "ValueIncrement"
	IconValueDecrement Icon = "ValueDecrement"
	IconValueReset     Icon = "ValueReset"
	// actions: view
	IconViewFullscreen     Icon = "ViewFullscreen"
	IconViewRefresh        Icon = "ViewRefresh"
	IconViewRestore        Icon = "ViewRestore"
	IconViewSortAscending  Icon = "ViewSortAscending"
	IconViewSortDescending Icon = "ViewSortDescending"
	// actions: window
	IconWindowClose Icon = "WindowClose"
	IconWindowNew   Icon = "WindowNew"
	// actions: zoom
	IconZoomFitBest  Icon = "ZoomFitBest"
	IconZoomIn       Icon = "ZoomIn"
	IconZoomOriginal Icon = "ZoomOriginal"
	IconZoomOut      Icon = "ZoomOut"

	// applications
	// Keep these in sync with nasin.ApplicationRole!
	IconApplication                  Icon = "Application" // generic
	IconApplicationWebBrowser        Icon = "ApplicationWebBrowser"
	IconApplicationMesssanger        Icon = "ApplicationMesssanger"
	IconApplicationPhone             Icon = "ApplicationPhone"
	IconApplicationMail              Icon = "ApplicationMail"
	IconApplicationTerminalEmulator  Icon = "ApplicationTerminalEmulator"
	IconApplicationFileBrowser       Icon = "ApplicationFileBrowser"
	IconApplicationTextEditor        Icon = "ApplicationTextEditor"
	IconApplicationDocumentViewer    Icon = "ApplicationDocumentViewer"
	IconApplicationWordProcessor     Icon = "ApplicationWordProcessor"
	IconApplicationSpreadsheet       Icon = "ApplicationSpreadsheet"
	IconApplicationSlideshow         Icon = "ApplicationSlideshow"
	IconApplicationCalculator        Icon = "ApplicationCalculator"
	IconApplicationPreferences       Icon = "ApplicationPreferences"
	IconApplicationProcessManager    Icon = "ApplicationProcessManager"
	IconApplicationSystemInformation Icon = "ApplicationSystemInformation"
	IconApplicationManual            Icon = "ApplicationManual"
	IconApplicationCamera            Icon = "ApplicationCamera"
	IconApplicationImageViewer       Icon = "ApplicationImageViewer"
	IconApplicationMediaPlayer       Icon = "ApplicationMediaPlayer"
	IconApplicationImageEditor       Icon = "ApplicationImageEditor"
	IconApplicationAudioEditor       Icon = "ApplicationAudioEditor"
	IconApplicationVideoEditor       Icon = "ApplicationVideoEditor"
	IconApplicationClock             Icon = "ApplicationClock"
	IconApplicationCalendar          Icon = "ApplicationCalendar"
	IconApplicationChecklist         Icon = "ApplicationChecklist"

	// categories: applications
	IconApplications            Icon = "Applications"
	IconApplicationsAccessories Icon = "ApplicationsAccessories"
	IconApplicationsDevelopment Icon = "ApplicationsDevelopment"
	IconApplicationsEngineering Icon = "ApplicationsEngineering"
	IconApplicationsGames       Icon = "ApplicationsGames"
	IconApplicationsGraphics    Icon = "ApplicationsGraphics"
	IconApplicationsInternet    Icon = "ApplicationsInternet"
	IconApplicationsMultimedia  Icon = "ApplicationsMultimedia"
	IconApplicationsOffice      Icon = "ApplicationsOffice"
	IconApplicationsScience     Icon = "ApplicationsScience"
	IconApplicationsSystem      Icon = "ApplicationsSystem"
	IconApplicationsUtilities   Icon = "ApplicationsUtilities"
	// categories: preferences
	IconPreferences            Icon = "Preferences"
	IconPreferencesDesktop     Icon = "PreferencesDesktop"
	IconPreferencesPeripherals Icon = "PreferencesPeripherals"
	IconPreferencesPersonal    Icon = "PreferencesPersonal"
	IconPreferencesSystem      Icon = "PreferencesSystem"
	IconPreferencesNetwork     Icon = "PreferencesNetwork"

	// devices
	IconDevice                 Icon = "Device"
	IconDeviceCamera           Icon = "DeviceCamera"
	IconDeviceWebCamera        Icon = "DeviceWebCamera"
	IconDeviceComputer         Icon = "DeviceComputer"
	IconDevicePda              Icon = "DevicePda"
	IconDevicePhone            Icon = "DevicePhone"
	IconDevicePrinter          Icon = "DevicePrinter"
	IconDeviceScanner          Icon = "DeviceScanner"
	IconDeviceMultimediaPlayer Icon = "DeviceMultimediaPlayer"
	IconDeviceVideoDisplay     Icon = "DeviceVideoDisplay"
	IconDeviceAudioInput       Icon = "DeviceAudioInput"
	IconDeviceAudioOutput      Icon = "DeviceAudioOutput"
	// devices: hardware
	IconHardware               Icon = "Hardware"
	IconHardwareCPU            Icon = "HardwareCPU"
	IconHardwareGPU            Icon = "HardwareGPU"
	IconHardwareRAM            Icon = "HardwareRAM"
	IconHardwareSoundCard      Icon = "HardwareSoundCard"
	IconHardwareNetworkAdapter Icon = "HardwareNetworkAdapter"
	// devices: power
	IconPowerBattery Icon = "PowerBattery"
	// devices: storage
	IconStorageHardDisk     Icon = "StorageHardDisk"
	IconStorageFloppyDisk   Icon = "StorageFloppyDisk"
	IconStorageSolidState   Icon = "StorageSolidState"
	IconStorageOptical      Icon = "StorageOptical"
	IconStorageFlashStick   Icon = "StorageFlashStick"
	IconStorageFlashCard    Icon = "StorageFlashCard"
	IconStorageMagneticTape Icon = "StorageMagneticTape"
	// devices: input
	IconInputGaming   Icon = "InputGaming"
	IconInputKeyboard Icon = "InputKeyboard"
	IconInputMouse    Icon = "InputMouse"
	IconInputTablet   Icon = "InputTablet"
	// devices: network
	IconNetworkWired     Icon = "NetworkWired"
	IconNetworkWireless  Icon = "NetworkWireless"
	IconNetworkCellular  Icon = "NetworkCellular"
	IconNetworkLocal     Icon = "NetworkLocal"
	IconNetworkInternet  Icon = "NetworkInternet"
	IconNetworkVPN       Icon = "NetworkVPN"
	IconNetworkServer    Icon = "NetworkServer"
	IconNetworkWorkgroup Icon = "NetworkWorkgroup"

	// emblems
	IconEmblemDefault      Icon = "EmblemDefault"
	IconEmblemEncrypted    Icon = "EmblemEncrypted"
	IconEmblemFavorite     Icon = "EmblemFavorite"
	IconEmblemImportant    Icon = "EmblemImportant"
	IconEmblemReadOnly     Icon = "EmblemReadOnly"
	IconEmblemShared       Icon = "EmblemShared"
	IconEmblemSymbolicLink Icon = "EmblemSymbolicLink"
	IconEmblemSynchronized Icon = "EmblemSynchronized"
	IconEmblemSystem       Icon = "EmblemSystem"
	IconEmblemUnreadable   Icon = "EmblemUnreadable"

	// places
	IconPlaceDirectory    Icon = "PlaceDirectory"
	IconPlaceRemote       Icon = "PlaceRemote"
	IconPlaceHome         Icon = "PlaceHome"
	IconPlaceDownloads    Icon = "PlaceDownloads"
	IconPlaceDesktop      Icon = "PlaceDesktop"
	IconPlacePhotos       Icon = "PlacePhotos"
	IconPlaceBooks        Icon = "PlaceBooks"
	IconPlaceBookmarks    Icon = "PlaceBookmarks"
	IconPlaceTrash        Icon = "PlaceTrash"
	IconPlaceDocuments    Icon = "PlaceDocuments"
	IconPlaceRepositories Icon = "PlaceRepositories"
	IconPlaceMusic        Icon = "PlaceMusic"
	IconPlaceArchives     Icon = "PlaceArchives"
	IconPlaceFonts        Icon = "PlaceFonts"
	IconPlaceBinaries     Icon = "PlaceBinaries"
	IconPlaceVideos       Icon = "PlaceVideos"
	IconPlace3DObjects    Icon = "Place3DObjects"
	IconPlaceHistory      Icon = "PlaceHistory"
	IconPlacePreferences  Icon = "PlacePreferences"

	// status: appointments
	IconAppointmentMissed Icon = "AppointmentMissed"
	IconAppointmentSoon   Icon = "AppointmentSoon"
	// status: dialogs
	IconDialogError       Icon = "DialogError"
	IconDialogInformation Icon = "DialogInformation"
	IconDialogPassword    Icon = "DialogPassword"
	IconDialogQuestion    Icon = "DialogQuestion"
	IconDialogWarning     Icon = "DialogWarning"
	// status: directories
	IconDirectoryDragAccept Icon = "DirectoryDragAccept"
	IconDirectoryFull       Icon = "DirectoryFull"
	IconDirectoryOpen       Icon = "DirectoryOpen"
	IconDirectoryVisiting   Icon = "DirectoryVisiting"
	// status: trash
	IconTrashFull Icon = "TrashFull"
	// status: resource
	IconResourceLoading Icon = "ResourceLoading"
	IconResourceMissing Icon = "ResourceMissing"
	// status: mail
	IconMailAttachment     Icon = "MailAttachment"
	IconMailUnread         Icon = "MailUnread"
	IconMailReplied        Icon = "MailReplied"
	IconMailSigned         Icon = "MailSigned"
	IconMailSignedVerified Icon = "MailSignedVerified"
	// status: network
	IconCellularSignal0        Icon = "CellularSignal0"
	IconCellularSignal1        Icon = "CellularSignal1"
	IconCellularSignal2        Icon = "CellularSignal2"
	IconCellularSignal3        Icon = "CellularSignal3"
	IconWirelessSignal0        Icon = "WirelessSignal0"
	IconWirelessSignal1        Icon = "WirelessSignal1"
	IconWirelessSignal2        Icon = "WirelessSignal2"
	IconWirelessSignal3        Icon = "WirelessSignal3"
	IconNetworkError           Icon = "NetworkError"
	IconNetworkIdle            Icon = "NetworkIdle"
	IconNetworkOffline         Icon = "NetworkOffline"
	IconNetworkReceive         Icon = "NetworkReceive"
	IconNetworkTransmit        Icon = "NetworkTransmit"
	IconNetworkTransmitReceive Icon = "NetworkTransmitReceive"
	// status: print
	IconPrintError    Icon = "PrintError"
	IconPrintPrinting Icon = "PrintPrinting"
	// status: security
	IconSecurityHigh   Icon = "SecurityHigh"
	IconSecurityMedium Icon = "SecurityMedium"
	IconSecurityLow    Icon = "SecurityLow"
	// status: software
	IconSoftwareUpdateAvailable Icon = "SoftwareUpdateAvailable"
	IconSoftwareUpdateUrgent    Icon = "SoftwareUpdateUrgent"
	IconSoftwareInstalling      Icon = "SoftwareInstalling"
	// status: sync
	IconSyncError         Icon = "SyncError"
	IconSyncSynchronizing Icon = "SyncSynchronizing"
	// status: tasks
	IconTaskDue     Icon = "TaskDue"
	IconTaskPastDue Icon = "TaskPastDue"
	// status: users
	IconUserAvailable Icon = "UserAvailable"
	IconUserAway      Icon = "UserAway"
	IconUserIdle      Icon = "UserIdle"
	IconUserOffline   Icon = "UserOffline"
	// status: power
	IconBattery0    Icon = "Battery0"
	IconBattery1    Icon = "Battery1"
	IconBattery2    Icon = "Battery2"
	IconBattery3    Icon = "Battery3"
	IconBrightness0 Icon = "Brightness0"
	IconBrightness1 Icon = "Brightness1"
	IconBrightness2 Icon = "Brightness2"
	IconBrightness3 Icon = "Brightness3"
	// status: media
	IconVolume0         Icon = "Volume0"
	IconVolume1         Icon = "Volume1"
	IconVolume2         Icon = "Volume2"
	IconVolume3         Icon = "Volume3"
	IconPlaylistRepeat  Icon = "PlaylistRepeat"
	IconPlaylistShuffle Icon = "PlaylistShuffle"
	// status: weather
	IconWeatherClear            Icon = "WeatherClear"
	IconWeatherClearNight       Icon = "WeatherClearNight"
	IconWeatherFewClouds        Icon = "WeatherFewClouds"
	IconWeatherFewCloudsNight   Icon = "WeatherFewCloudsNight"
	IconWeatherFog              Icon = "WeatherFog"
	IconWeatherOvercast         Icon = "WeatherOvercast"
	IconWeatherSevereAlert      Icon = "WeatherSevereAlert"
	IconWeatherShowers          Icon = "WeatherShowers"
	IconWeatherShowersScattered Icon = "WeatherShowersScattered"
	IconWeatherSnow             Icon = "WeatherSnow"
	IconWeatherStorm            Icon = "WeatherStorm"
)

A list of standard icon IDs. This is roughly based off of the XDG Icon Naming Specification (https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html).

func (Icon) Texture added in v0.33.0

func (id Icon) Texture(size IconSize) canvas.Texture

Texture returns a canvas.Texture of the corresponding icon ID. It may be closed and therefore rendered invalid if the icon set changes, so it is necessary to subscribe to the IconSetChange event in order to get a new icon texture when this happens.

type IconSize added in v0.33.0

type IconSize int

IconSize represents the size of an Icon.

const (
	IconSizeSmall IconSize = iota
	IconSizeMedium
	IconSizeLarge
)

func (IconSize) String added in v0.33.0

func (size IconSize) String() string

type Inset

type Inset [4]int

Inset represents a rectangle inset that can have a different value for each side.

func I added in v0.7.0

func I(sides ...int) Inset

I allows you to create an inset in a CSS-ish way:

  • One argument: all sides are set to this value
  • Two arguments: the top and bottom sides are set to the first value, and the left and right sides are set to the second value.
  • Three arguments: the top side is set by the first value, the left and right sides are set by the second vaue, and the bottom side is set by the third value.
  • Four arguments: each value corresponds to a side.

This function will panic if an argument count that isn't one of these is given.

func (Inset) Apply added in v0.7.0

func (inset Inset) Apply(bigger image.Rectangle) (smaller image.Rectangle)

Apply returns the given image.Rectangle, shrunk on all four sides by the given Inset. If a measurment of the Inset is negative, that side will instead be expanded outward. If the rectangle's dimensions cannot be reduced any further, an empty rectangle near its center will be returned.

func (Inset) Horizontal added in v0.7.0

func (inset Inset) Horizontal() int

Horizontal returns the sum of SideRight and SideLeft.

func (Inset) Inverse added in v0.7.0

func (inset Inset) Inverse() (prime Inset)

Inverse returns a negated version of the Inset.

func (Inset) String added in v0.42.0

func (inset Inset) String() string

func (Inset) Vertical added in v0.7.0

func (inset Inset) Vertical() int

Vertical returns the sum of SideTop and SideBottom.

type Layout

type Layout interface {
	// MinimumSize returns the minimum width and height of
	// LayoutHints.Bounds needed to properly lay out all child Boxes.
	MinimumSize(LayoutHints, BoxQuerier) image.Point
	// Arrange arranges child Boxes according to the given LayoutHints.
	Arrange(LayoutHints, BoxArranger)
	// RecommendedHeight returns the recommended height for a given width,
	// if supported. Otherwise, it should just return the minimum height.
	// The result of this behavior may or may not be respected, depending on
	// the situation.
	RecommendedHeight(LayoutHints, BoxQuerier, int) int
	// RecommendedWidth returns the recommended width for a given height, if
	// supported. Otherwise, it should just return the minimum width. The
	// result of this behavior may or may not be respected, depending on the
	// situation.
	RecommendedWidth(LayoutHints, BoxQuerier, int) int
}

A Layout can be given to a ContainerBox to arrange child objects.

type LayoutHints added in v0.9.0

type LayoutHints struct {
	// Bounds is the bounding rectangle that children should be placed
	// within. Any padding values are already applied.
	Bounds image.Rectangle
	// OverflowX and OverflowY control whether child Boxes may be positioned
	// outside of Bounds.
	OverflowX bool
	OverflowY bool
	// AlignX and AlignY control how child Boxes are aligned horizontally
	// and vertically. The effect of this may vary depending on the Layout.
	AlignX Align
	AlignY Align
	// Gap controls the amount of horizontal and vertical spacing in-between
	// child Boxes.
	Gap image.Point
}

LayoutHints are passed to a layout to tell it how to arrange child Boxes.

type Object

type Object interface {
	GetBox() Box
}

Object is any onscreen object that is linked to a box (or is that box). Unlike the Box interface and associated interfaces, Object implementations may originate from anywhere.

type Role added in v0.33.0

type Role struct {
	// Package is an optional namespace field. If specified, it should be
	// the package name or module name the object is from.
	Package string

	// Object specifies what type of Object it is. For example:
	//   - TextInput
	//   - Table
	//   - Label
	//   - Dial
	// This should correspond directly to the type name of the Object.
	Object string
}

Role describes the role of an Object.

func R added in v0.33.0

func R(pack, object string) Role

R is a convenience constructor for Role.

func (Role) String added in v0.33.0

func (r Role) String() string

String satisfies the fmt.Stringer interface. It follows the format of:

Package.Object

type Side added in v0.7.0

type Side int

Side represents one side of a rectangle.

const (
	SideTop Side = iota
	SideRight
	SideBottom
	SideLeft
)

func (Side) String added in v0.42.0

func (side Side) String() string

type SurfaceBox added in v0.32.0

type SurfaceBox interface {
	Box

	// Surface returns the underlying graphics context. The result must be
	// asserted to the expected type or passed through a type switch before
	// use. The exact type returned here depends on the Backend being used,
	// and it is up to the application author to ensure that the application
	// and Backend agree on it. Applications should fail gracefully if the
	// expected type was not found. If the surface has been destroyed by the
	// Backend, it will return nil.
	Surface() any

	// Invalidate causes the data within the surface to be pushed to the
	// screen at the end of the event cycle, even if it wouldn't otherwise
	// be.
	Invalidate()

	// OnSizeChange specifies a function to be called when the size of the
	// Box is changed, the surface is re-allocated, or the surface is
	// destroyed. The application must call Surface() each time this event
	// fires in order to not draw onto a closed surface.
	OnSizeChange(func())
}

SurfaceBox is a Box that can be drawn to via a hardware accelerated (or platform-specific) graphics context.

type TextBox

type TextBox interface {
	ContentBox

	// SetText sets the text content of the Box.
	SetText(string)

	// SetSelectable sets whether or not the text content can be
	// highlighted/selected.
	SetSelectable(bool)
	// Select sets the text cursor or selection.
	Select(text.Dot)
	// Dot returns the text cursor or selection.
	Dot() text.Dot
	// OnDotChange specifies a function to be called when the text cursor or
	// selection changes.
	OnDotChange(func()) event.Cookie
}

TextBox is a box that contains text content.

func NewTextBox

func NewTextBox() TextBox

NewTextBox creates and returns a Box that can display text.

type TextureMode added in v0.40.0

type TextureMode int

TextureMode lists texture rendering modes.

const (
	TextureModeTile TextureMode = iota
	TextureModeCenter
)

func (TextureMode) String added in v0.42.0

func (mode TextureMode) String() string

type Window

type Window interface {
	// Bounds returns the bounds of the Window including its frame, if
	// possible. This means that the top-left point of the bounds will be
	// either zero or negative.
	Bounds() image.Rectangle
	// InnerBounds returns the inner bounds of the Window, not including its
	// frame. This means that the top-left point of the bounds will be zero.
	InnerBounds() image.Rectangle
	// SetRoot sets the root child of the Window. There can only be one at
	// a time, and setting it will remove the current child if there is one.
	SetRoot(Object)
	// SetTitle sets the title of the Window.
	SetTitle(string)
	// SetIcon sets the icon of the Window.
	SetIcon(Icon)
	// SetResizable sets whether the Window can be resized by the user in
	// the X and Y directions. If one or both axes are false, the ones that
	// are will be shrunk to the Window's minimum size.
	SetResizable(x, y bool)
	// SetBounds sets this Window's bounds. This may or may not have any
	// effect on the Window's position on screen depending on the platform.
	SetBounds(image.Rectangle)
	// NewChild creates a new Window that is semantically a child of this
	// Window. It does not actually reside within this Window, but it may be
	// linked to it via some other means.
	NewChild(WindowKind, image.Rectangle) (Window, error)
	// Modifiers returns which modifier keys on the keyboard are currently
	// being held down.
	Modifiers() input.Modifiers
	// MousePosition returns the position of the mouse pointer relative to
	// the Window.
	MousePosition() image.Point
	// Copy copies data to the clipboard.
	Copy(data.Data)
	// Paste reads data from the clipboard. When the data is available or an
	// error has occurred, the provided function will be called.
	Paste(callback func(data.Data, error), accept ...data.Mime)
	// SetVisible sets whether or not this window is visible. Windows are
	// invisible by default.
	SetVisible(bool)
	// Visible returns whether or not this window is visible.
	Visible() bool
	// Close closes the window. This does not trigger the TryClose event.
	Close() error
	// OnTryClose specifies a function to be called when the user attempts
	// to close the Window. If any registered handlers returns false, the
	// Window will not be closed. This can be used to display some sort of
	// "Unsaved changes" warning to the user.
	OnTryClose(func() bool) event.Cookie
	// OnClose specifies a function to be called when the Window is closed.
	OnClose(func()) event.Cookie
}

Window is an operating system Window. It can directly contain one object, which is usually a container. Windows themselves are completely transparent, and become opaque once an opaque object is added as their root.

func NewWindow

func NewWindow(kind WindowKind, bounds image.Rectangle) (Window, error)

NewWindow creates and returns a Window within the specified bounds on screen.

type WindowKind added in v0.47.0

type WindowKind string

WindowKind specifies a Window's kind, which determines how it is displayed and managed by the operating system.

const (
	// Normal is a normal Window.
	WindowKindNormal WindowKind = "Normal"
	// Plain is an undecorated Window that does not appear in window lists.
	// It is intended for things like docks, panels, etc.
	WindowKindPlain WindowKind = "Plain"
	// Utility is a small Window for toolboxes, command palletes, etc. It is
	// usually given special styling and management by the OS.
	WindowKindUtility WindowKind = "Utility"
	// Toolbar is a small Window for menus and panes which have been "torn
	// off" from their main Window or position. It is usually given special
	// styling and management by the OS.
	WindowKindToolbar WindowKind = "Toolbar"
	// Menu is an undecorated Window for drop down menus, context menus,
	// etc. It closes once the user interacts outside of it.
	WindowKindMenu WindowKind = "Menu"
	// Modal, while open, blocks all user input from reaching its parent
	// window, forcing the user's attention. It is usually given special
	// styling and management by the OS. Note that in some environments it
	// will not be given window controls, so it should contain some "Close"
	// or "Cancel" button.
	WindowKindModal WindowKind = "Modal"
)

Directories

Path Synopsis
Canvas defines a standard interface for images that support drawing primitives.
Canvas defines a standard interface for images that support drawing primitives.
Package config stores common configuration parameters.
Package config stores common configuration parameters.
Package data provides operations to deal with arbitrary data and MIME types.
Package data provides operations to deal with arbitrary data and MIME types.
Package event provides a system for broadcasting events to multiple event handlers.
Package event provides a system for broadcasting events to multiple event handlers.
Package input defines keyboard and mouse code constants.
Package input defines keyboard and mouse code constants.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL