Documentation ¶
Index ¶
- Constants
- Variables
- func AppWindowsToFront()
- func AttemptQuit()
- func HideApp()
- func HideOtherApps()
- func Invoke(taskFunction func())
- func InvokeAfter(taskFunction func(), after time.Duration)
- func MayQuitNow(quit bool)
- func SetInvokeRecoverCallback(recoveryHandler errs.RecoveryHandler)
- func ShowAllApps()
- func Start()
- func WindowContentRectForFrameRect(frame geom.Rect, style StyleMask) geom.Rect
- func WindowCount() int
- func WindowFrameRectForContentRect(content geom.Rect, style StyleMask) geom.Rect
- type DragInfo
- type DragOperation
- type OSWindow
- type Panel
- func (p *Panel) AddChild(child *Panel)
- func (p *Panel) AddChildAtIndex(child *Panel, index int)
- func (p *Panel) AsPanel() *Panel
- func (p *Panel) Border() border.Border
- func (p *Panel) Children() []*Panel
- func (p *Panel) ChildrenForLayout() []layout.Layoutable
- func (p *Panel) ClientData() map[string]interface{}
- func (p *Panel) ContentRect(includeBorder bool) geom.Rect
- func (p *Panel) Draw(gc draw.Context, dirty geom.Rect, inLiveResize bool)
- func (p *Panel) Enabled() bool
- func (p *Panel) FlushDrawing()
- func (p *Panel) Focusable() bool
- func (p *Panel) Focused() bool
- func (p *Panel) FrameRect() geom.Rect
- func (p *Panel) ID() uint64
- func (p *Panel) IndexOfChild(child *Panel) int
- func (p *Panel) InitTypeAndID(self interface{})
- func (p *Panel) Is(other *Panel) bool
- func (p *Panel) Layout() layout.Layout
- func (p *Panel) LayoutData() interface{}
- func (p *Panel) MarkForLayoutAndRedraw()
- func (p *Panel) MarkForRedraw()
- func (p *Panel) MarkRectForRedraw(rect geom.Rect)
- func (p *Panel) PanelAt(pt geom.Point) *Panel
- func (p *Panel) Parent() *Panel
- func (p *Panel) PointFromRoot(pt geom.Point) geom.Point
- func (p *Panel) PointToRoot(pt geom.Point) geom.Point
- func (p *Panel) RectFromRoot(rect geom.Rect) geom.Rect
- func (p *Panel) RectToRoot(rect geom.Rect) geom.Rect
- func (p *Panel) RemoveAllChildren()
- func (p *Panel) RemoveChild(child *Panel)
- func (p *Panel) RemoveChildAtIndex(index int)
- func (p *Panel) RemoveFromParent()
- func (p *Panel) RequestFocus()
- func (p *Panel) ScrollIntoView()
- func (p *Panel) ScrollRectIntoView(rect geom.Rect)
- func (p *Panel) Self() interface{}
- func (p *Panel) SetBorder(b border.Border) *Panel
- func (p *Panel) SetEnabled(enabled bool) *Panel
- func (p *Panel) SetFocusable(focusable bool) *Panel
- func (p *Panel) SetFrameRect(rect geom.Rect)
- func (p *Panel) SetLayout(lay layout.Layout)
- func (p *Panel) SetLayoutData(data interface{})
- func (p *Panel) SetSizer(sizer layout.Sizer)
- func (p *Panel) Sizer() layout.Sizer
- func (p *Panel) Sizes(hint geom.Size) (min, pref, max geom.Size)
- func (p *Panel) String() string
- func (p *Panel) ValidateLayout()
- func (p *Panel) Window() *Window
- type QuitResponse
- type StyleMask
- type Window
- func (w *Window) AttemptClose()
- func (w *Window) Background() draw.Ink
- func (w *Window) ClearTooltip()
- func (w *Window) ClientData() map[string]interface{}
- func (w *Window) Closable() bool
- func (w *Window) Content() *Panel
- func (w *Window) ContentRect() geom.Rect
- func (w *Window) Dispose()
- func (w *Window) Draw(gc draw.Context, dirtyRect geom.Rect, inLiveResize bool)
- func (w *Window) FlushDrawing()
- func (w *Window) Focus() *Panel
- func (w *Window) FocusNext()
- func (w *Window) FocusPrevious()
- func (w *Window) Focused() bool
- func (w *Window) FrameRect() geom.Rect
- func (w *Window) ID() uint64
- func (w *Window) IsValid() bool
- func (w *Window) MarkForRedraw()
- func (w *Window) MarkRectForRedraw(rect geom.Rect)
- func (w *Window) Minimizable() bool
- func (w *Window) Minimize()
- func (w *Window) MouseLocation() geom.Point
- func (w *Window) OSWindow() OSWindow
- func (w *Window) Pack()
- func (w *Window) RegisterDragTypes(dt ...datatypes.DataType)
- func (w *Window) Resizable() bool
- func (w *Window) RunModal() int
- func (w *Window) SetBackground(ink draw.Ink)
- func (w *Window) SetContent(panel *Panel)
- func (w *Window) SetContentRect(rect geom.Rect)
- func (w *Window) SetFocus(target *Panel)
- func (w *Window) SetFrameRect(rect geom.Rect)
- func (w *Window) SetTitle(title string)
- func (w *Window) StopModal(code int)
- func (w *Window) String() string
- func (w *Window) Title() string
- func (w *Window) ToFront()
- func (w *Window) ValidateLayout()
- func (w *Window) Zoom()
Constants ¶
const ( ButtonLeft = 0 ButtonRight = 1 )
Constants for mouse buttons.
const ( TitledWindowMask StyleMask = 1 << iota ClosableWindowMask MinimizableWindowMask ResizableWindowMask NoInternalMenuWindowMask = 1 << 30 // Has no effect on macOS BorderlessWindowMask = 0 StdWindowMask = TitledWindowMask | ClosableWindowMask | MinimizableWindowMask | ResizableWindowMask )
Possible values for the StyleMask.
Variables ¶
var ( // WillFinishStartupCallback is called right before application startup // has completed. This is a good point to create any windows your app // wants to display. WillFinishStartupCallback func() // DidFinishStartupCallback is called once application startup has // completed and it is about to start servicing the event loop. DidFinishStartupCallback func() // WillActivateCallback is called right before the application is // activated. WillActivateCallback func() // DidActivateCallback is called once the application is activated. DidActivateCallback func() // WillDeactivateCallback is called right before the application is // deactivated. WillDeactivateCallback func() // DidDeactivateCallback is called once the application is deactivated. DidDeactivateCallback func() // OpenURLsCallback is called when the application is asked to open one or // more URLs by the OS or external application. OpenURLsCallback func(urls []string) // OSThemeChangedCallback is called when the OS theme is changed. OSThemeChangedCallback func() // QuitAfterLastWindowClosedCallback is called when the last window is // closed to determine if the application should quit as a result. QuitAfterLastWindowClosedCallback func() bool // CheckQuitCallback is called when termination has been requested. CheckQuitCallback func() QuitResponse // QuittingCallback is called when the app will in fact terminate. QuittingCallback func() )
var ( // TooltipDelay holds the delay before a tooltip will be shown. TooltipDelay = 1500 * time.Millisecond // TooltipDismissal holds the delay before a tooltip will be dismissed. TooltipDismissal = 3 * time.Second )
Functions ¶
func AppWindowsToFront ¶
func AppWindowsToFront()
AppWindowsToFront attempts to bring all of the application's windows to the foreground.
func HideApp ¶
func HideApp()
HideApp will hide the application on platforms where that is supported.
func HideOtherApps ¶
func HideOtherApps()
HideOtherApps will hide all other applications on platforms where that is supported.
func Invoke ¶
func Invoke(taskFunction func())
Invoke a task on the UI thread. The task is put into the system event queue and will be run at the next opportunity.
func InvokeAfter ¶
InvokeAfter schedules a task to be run on the UI thread after waiting for the specified duration.
func MayQuitNow ¶
func MayQuitNow(quit bool)
MayQuitNow resumes the termination sequence that was delayed when Later is returned from the CheckQuitCallback. Passing in false for the quit parameter will cancel the termination sequence while true will allow it to proceed.
func SetInvokeRecoverCallback ¶
func SetInvokeRecoverCallback(recoveryHandler errs.RecoveryHandler)
SetInvokeRecoverCallback sets a callback that will be called should an invoked task panic. If no recover callback is set, the panic will be silently swallowed.
func ShowAllApps ¶
func ShowAllApps()
ShowAllApps will unhide any hidden applications on platforms where that is supported.
func Start ¶
func Start()
Start the application. This function does NOT return. No calls to anything in the ux package tree should be made before this call, although setting the various callbacks above can and should be done before this call.
func WindowContentRectForFrameRect ¶
WindowContentRectForFrameRect determines the content rect for a window based on the given frame rect and window style.
Types ¶
type DragInfo ¶
type DragInfo struct { Sequence int SourceOperationMask DragOperation DragX float64 DragY float64 DragImageX float64 DragImageY float64 ValidItemsForDrop int ItemTypes []datatypes.DataType DataForType func(dataType datatypes.DataType) [][]byte }
DragInfo holds information about the current drag.
func (*DragInfo) ApplyOffset ¶
ApplyOffset applies the delta to the drag and drag image positions.
func (*DragInfo) FirstTypePresent ¶
FirstTypePresent returns the first data type that matches the available data types, or returns datatypes.None.
type DragOperation ¶
type DragOperation = uint32
DragOperation holds the type of drag operation.
const ( DragOperationCopy DragOperation = 1 << iota DragOperationLink DragOperationGeneric DragOperationPrivate DragOperationMove DragOperationDelete DragOperationNone DragOperation = 0 DragOperationEvery DragOperation = math.MaxUint32 )
Possible DragOperation values.
type Panel ¶
type Panel struct { Tooltip *Panel DrawCallback func(gc draw.Context, dirty geom.Rect, inLiveResize bool) DrawOverCallback func(gc draw.Context, dirty geom.Rect, inLiveResize bool) GainedFocusCallback func() LostFocusCallback func() MouseDownCallback func(where geom.Point, button, clickCount int, mod keys.Modifiers) bool MouseDragCallback func(where geom.Point, button int, mod keys.Modifiers) MouseUpCallback func(where geom.Point, button int, mod keys.Modifiers) MouseEnterCallback func(where geom.Point, mod keys.Modifiers) MouseMoveCallback func(where geom.Point, mod keys.Modifiers) MouseExitCallback func() MouseWheelCallback func(where, delta geom.Point, mod keys.Modifiers) bool KeyDownCallback func(keyCode int, ch rune, mod keys.Modifiers, repeat bool) bool KeyUpCallback func(keyCode int, mod keys.Modifiers) bool UpdateCursorCallback func(where geom.Point) *draw.Cursor UpdateTooltipCallback func(where geom.Point, suggestedAvoid geom.Rect) geom.Rect DragEnteredCallback func(dragInfo *DragInfo) DragOperation DragUpdatedCallback func(dragInfo *DragInfo) DragOperation DragExitedCallback func() DragEndedCallback func() DropIsAcceptableCallback func(dragInfo *DragInfo) bool DropCallback func(dragInfo *DragInfo) bool DropFinishedCallback func(dragInfo *DragInfo) CanPerformCmdCallback func(source interface{}, id int) bool PerformCmdCallback func(source interface{}, id int) FrameChangeCallback func() FrameChangeInChildHierarchyCallback func(panel *Panel) ScrollRectIntoViewCallback func(rect geom.Rect) bool ParentChangedCallback func() NeedsLayout bool // contains filtered or unexported fields }
Panel is the basic user interface element that interacts with the user.
func (*Panel) AddChild ¶
AddChild adds child to this panel, removing it from any previous parent it may have had.
func (*Panel) AddChildAtIndex ¶
AddChildAtIndex adds child to this panel at the index, removing it from any previous parent it may have had. Passing in a negative value for the index will add it to the end.
func (*Panel) ChildrenForLayout ¶
func (p *Panel) ChildrenForLayout() []layout.Layoutable
ChildrenForLayout is the same as calling Children(), but returns them as layout.Layoutable objects instead.
func (*Panel) ClientData ¶
ClientData returns a map of client data for this panel.
func (*Panel) ContentRect ¶
ContentRect returns the location and size of the panel in local coordinates.
func (*Panel) Draw ¶
Draw is called by its owning window when a panel needs to be drawn. The gc has already had its clip set to the dirty rectangle.
func (*Panel) Enabled ¶
Enabled returns true if this panel is currently enabled and can receive events.
func (*Panel) FlushDrawing ¶
func (p *Panel) FlushDrawing()
FlushDrawing is a convenience for calling the parent window's (if any) FlushDrawing() method.
func (*Panel) FrameRect ¶
FrameRect returns the location and size of the panel in its parent's coordinate system.
func (*Panel) IndexOfChild ¶
IndexOfChild returns the index of the specified child, or -1 if the passed in panel is not a child of this panel.
func (*Panel) InitTypeAndID ¶
func (p *Panel) InitTypeAndID(self interface{})
InitTypeAndID initializes the panel with the appropriate self-identification information.
func (*Panel) LayoutData ¶
func (p *Panel) LayoutData() interface{}
LayoutData returns the layout data, if any, associated with this panel.
func (*Panel) MarkForLayoutAndRedraw ¶
func (p *Panel) MarkForLayoutAndRedraw()
MarkForLayoutAndRedraw marks this panel as needing to be laid out as well as redrawn at the next update.
func (*Panel) MarkForRedraw ¶
func (p *Panel) MarkForRedraw()
MarkForRedraw marks this panel for drawing at the next update.
func (*Panel) MarkRectForRedraw ¶
MarkRectForRedraw marks the rect in local coordinates within the panel for drawing at the next update.
func (*Panel) PanelAt ¶
PanelAt returns the leaf-most child panel containing the point, or this panel if no child is found.
func (*Panel) PointFromRoot ¶
PointFromRoot converts root coordinates (i.e. window-local, when rooted within a window) into panel-local coordinates.
func (*Panel) PointToRoot ¶
PointToRoot converts panel-local coordinates into root coordinates, which when rooted within a window, will be window-local coordinates.
func (*Panel) RectFromRoot ¶
RectFromRoot converts root coordinates (i.e. window-local, when rooted within a window) into panel-local coordinates.
func (*Panel) RectToRoot ¶
RectToRoot converts panel-local coordinates into root coordinates, which when rooted within a window, will be window-local coordinates.
func (*Panel) RemoveAllChildren ¶
func (p *Panel) RemoveAllChildren()
RemoveAllChildren removes all child panels from this panel.
func (*Panel) RemoveChild ¶
RemoveChild removes 'child' from this panel. If 'child' is not a direct descendent of this panel, nothing happens.
func (*Panel) RemoveChildAtIndex ¶
RemoveChildAtIndex removes the child panel at 'index' from this panel. If 'index' is out of range, nothing happens.
func (*Panel) RemoveFromParent ¶
func (p *Panel) RemoveFromParent()
RemoveFromParent removes this panel from its parent, if any.
func (*Panel) RequestFocus ¶
func (p *Panel) RequestFocus()
RequestFocus attempts to make this panel the keyboard focus.
func (*Panel) ScrollIntoView ¶
func (p *Panel) ScrollIntoView()
ScrollIntoView attempts to scroll this panel into the current view if it is not already there, using ScrollAreas in this panel's hierarchy.
func (*Panel) ScrollRectIntoView ¶
ScrollRectIntoView attempts to scroll the rect (in coordinates local to this panel) into the current view if it is not already there, using ScrollAreas in this panel's hierarchy.
func (*Panel) SetEnabled ¶
SetEnabled sets this panel's enabled state.
func (*Panel) SetFocusable ¶
SetFocusable sets whether this panel can have the keyboard focus.
func (*Panel) SetFrameRect ¶
SetFrameRect sets the location and size of the panel in its parent's coordinate system.
func (*Panel) SetLayoutData ¶
func (p *Panel) SetLayoutData(data interface{})
SetLayoutData sets layout data on this panel. May be nil.
func (*Panel) Sizes ¶
Sizes returns the minimum, preferred, and maximum sizes the panel wishes to be. It does this by first asking the panel's layout. If no layout is present, then the panel's sizer is asked. If no sizer is present, then it finally uses a default set of sizes that are used for all panels.
func (*Panel) ValidateLayout ¶
func (p *Panel) ValidateLayout()
ValidateLayout performs any layout that needs to be run by this panel or its children.
type QuitResponse ¶
type QuitResponse int
QuitResponse is used to respond to requests for app termination.
const ( Cancel QuitResponse = iota Now Later // Must make a call to MayQuitNow() at some point in the future. )
Possible termination responses
type Window ¶
type Window struct { // MayCloseCallback is called when the user has requested that the window // be closed. Return true to permit it, false to cancel the operation. // Defaults to always returning true. MayCloseCallback func() bool // WillCloseCallback is called just prior to the window closing. WillCloseCallback func() // GainedFocusCallback is called when the keyboard focus is gained on this // window. GainedFocusCallback func() // LostFocusCallback is called when the keyboard focus is lost from this // window. LostFocusCallback func() // MouseDownCallback is called when the mouse is pressed within this // window. MouseDownCallback func(where geom.Point, button, clickCount int, mod keys.Modifiers) // MouseDragCallback is called when the mouse is dragged after being // pressed within this window. MouseDragCallback func(where geom.Point, button int, mod keys.Modifiers) // MouseUpCallback is called when the mouse is released after being // pressed within this window. MouseUpCallback func(where geom.Point, button int, mod keys.Modifiers) // MouseEnterCallback is called when the mouse enters this window. MouseEnterCallback func(where geom.Point, mod keys.Modifiers) // MouseMoveCallback is called when the mouse moves within this window. MouseMoveCallback func(where geom.Point, mod keys.Modifiers) // MouseExitCallback is called when the mouse exits this window. MouseExitCallback func() // MouseWheelCallback is called when the mouse wheel is rotated over this // window. MouseWheelCallback func(where, delta geom.Point, mod keys.Modifiers) // KeyDownCallback is called when a key is pressed in this window. KeyDownCallback func(keyCode int, ch rune, mod keys.Modifiers, repeat bool) // KeyDownCallback is called when a key is released in this window. KeyUpCallback func(keyCode int, mod keys.Modifiers) // DragEnteredCallback is called when a drag enters this window. DragEnteredCallback func(di *DragInfo) DragOperation // DragUpdatedCallback is called when a drag moves within this window or // the drag operation changes. DragUpdatedCallback func(di *DragInfo) DragOperation // DragExitedCallback is called when a drag exits the window. DragExitedCallback func() // DragEndedCallback is called when a drag ends. DragEndedCallback func() // DropIsAcceptableCallback is called when the drag is dropped to // determine if it is still valid to drop here. DropIsAcceptableCallback func(di *DragInfo) bool // DropCallback is called to perform the actual drop. Returns true on // success. DropCallback func(di *DragInfo) bool // DropFinishedCallback is called when the drop concludes. DropFinishedCallback func(di *DragInfo) // contains filtered or unexported fields }
Window holds window information.
func WindowWithFocus ¶
func WindowWithFocus() *Window
WindowWithFocus returns the window that currently has the keyboard focus, or nil if none of your application's windows has the keyboard focus.
func Windows ¶
func Windows() []*Window
Windows returns a slice containing the current set of open windows.
func (*Window) AttemptClose ¶
func (w *Window) AttemptClose()
AttemptClose closes the window if permitted.
func (*Window) Background ¶
Background returns the background of this window.
func (*Window) ClearTooltip ¶
func (w *Window) ClearTooltip()
ClearTooltip clears any existing tooltip and resets the timer.
func (*Window) ClientData ¶
ClientData returns a map of client data for this window.
func (*Window) Closable ¶
Closable returns true if the window was created with the ClosableWindowMask.
func (*Window) ContentRect ¶
ContentRect returns the boundaries in display coordinates of the window's content area.
func (*Window) FlushDrawing ¶
func (w *Window) FlushDrawing()
FlushDrawing causes any areas marked for drawing to be drawn now.
func (*Window) FocusNext ¶
func (w *Window) FocusNext()
FocusNext moves the keyboard focus to the next focusable panel.
func (*Window) FocusPrevious ¶
func (w *Window) FocusPrevious()
FocusPrevious moves the keyboard focus to the previous focusable panel.
func (*Window) FrameRect ¶
FrameRect returns the boundaries in display coordinates of the frame of this window (i.e. the area that includes both the content and its border and window controls).
func (*Window) IsValid ¶
IsValid returns true if the window is still valid (i.e. hasn't been disposed).
func (*Window) MarkForRedraw ¶
func (w *Window) MarkForRedraw()
MarkForRedraw marks this window for drawing at the next update.
func (*Window) MarkRectForRedraw ¶
MarkRectForRedraw marks the rect in local coordinates within the window for drawing at the next update.
func (*Window) Minimizable ¶
Minimizable returns true if the window was created with the MinimizableWindowMask.
func (*Window) Minimize ¶
func (w *Window) Minimize()
Minimize performs the minimize function on the window.
func (*Window) MouseLocation ¶
MouseLocation returns the current mouse location relative to this window.
func (*Window) Pack ¶
func (w *Window) Pack()
Pack sets the window's content size to match the preferred size of the root panel.
func (*Window) RegisterDragTypes ¶
RegisterDragTypes registers the data types the window will accept in a drag & drop operation.
func (*Window) Resizable ¶
Resizable returns true if the window was created with the ResizableWindowMask.
func (*Window) RunModal ¶
RunModal displays and brings this window to the front, the runs a modal event loop until StopModal is called.
func (*Window) SetBackground ¶
SetBackground sets the background of this window.
func (*Window) SetContent ¶
SetContent sets the content panel for the window.
func (*Window) SetContentRect ¶
SetContentRect sets the boundaries of the frame of this window by converting the content rect into a suitable frame rect and then applying it to the window.
func (*Window) SetFrameRect ¶
SetFrameRect sets the boundaries of the frame of this window.
func (*Window) StopModal ¶
StopModal stops the current modal event loop, closes the window, and propagates the provided code as the result to RunModal().
func (*Window) ToFront ¶
func (w *Window) ToFront()
ToFront attempts to bring the window to the foreground and give it the keyboard focus.
func (*Window) ValidateLayout ¶
func (w *Window) ValidateLayout()
ValidateLayout performs any layout that needs to be run by this window or its children.