Documentation ¶
Overview ¶
20 april 2016
Index ¶
- Constants
- func LibuiControlDestroy(c uintptr)
- func LibuiControlDisable(c uintptr)
- func LibuiControlEnable(c uintptr)
- func LibuiControlHandle(c uintptr) uintptr
- func LibuiControlHide(c uintptr)
- func LibuiControlShow(c uintptr)
- func LibuiFreeText(c uintptr)
- func Main(f func()) error
- func MsgBox(w *Window, title string, description string)
- func MsgBoxError(w *Window, title string, description string)
- func OnShouldQuit(f func() bool)
- func OpenFile(w *Window) string
- func QueueMain(f func())
- func Quit()
- func SaveFile(w *Window) string
- type Align
- type Area
- func (a *Area) Destroy()
- func (a *Area) Disable()
- func (a *Area) Enable()
- func (a *Area) Handle() uintptr
- func (a *Area) Hide()
- func (a *Area) LibuiControl() uintptr
- func (a *Area) QueueRedrawAll()
- func (a *Area) ScrollTo(x float64, y float64, width float64, height float64)
- func (a *Area) SetSize(width int, height int)
- func (a *Area) Show()
- type AreaDrawParams
- type AreaHandler
- type AreaKeyEvent
- type AreaMouseEvent
- type At
- type Box
- func (b *Box) Append(child Control, stretchy bool)
- func (b *Box) Delete(n int)
- func (b *Box) Destroy()
- func (b *Box) Disable()
- func (b *Box) Enable()
- func (b *Box) Handle() uintptr
- func (b *Box) Hide()
- func (b *Box) LibuiControl() uintptr
- func (b *Box) Padded() bool
- func (b *Box) SetPadded(padded bool)
- func (b *Box) Show()
- type Brush
- type BrushType
- type Button
- func (b *Button) Destroy()
- func (b *Button) Disable()
- func (b *Button) Enable()
- func (b *Button) Handle() uintptr
- func (b *Button) Hide()
- func (b *Button) LibuiControl() uintptr
- func (b *Button) OnClicked(f func(*Button))
- func (b *Button) SetText(text string)
- func (b *Button) Show()
- func (b *Button) Text() string
- type Checkbox
- func (c *Checkbox) Checked() bool
- func (c *Checkbox) Destroy()
- func (c *Checkbox) Disable()
- func (c *Checkbox) Enable()
- func (c *Checkbox) Handle() uintptr
- func (c *Checkbox) Hide()
- func (c *Checkbox) LibuiControl() uintptr
- func (c *Checkbox) OnToggled(f func(*Checkbox))
- func (c *Checkbox) SetChecked(checked bool)
- func (c *Checkbox) SetText(text string)
- func (c *Checkbox) Show()
- func (c *Checkbox) Text() string
- type Combobox
- func (c *Combobox) Append(text string)
- func (c *Combobox) Destroy()
- func (c *Combobox) Disable()
- func (c *Combobox) Enable()
- func (c *Combobox) Handle() uintptr
- func (c *Combobox) Hide()
- func (c *Combobox) LibuiControl() uintptr
- func (c *Combobox) OnSelected(f func(*Combobox))
- func (c *Combobox) Selected() int
- func (c *Combobox) SetSelected(index int)
- func (c *Combobox) Show()
- type Control
- type DateTimePicker
- type DrawContext
- func (c *DrawContext) Clip(p *Path)
- func (c *DrawContext) Fill(p *Path, b *Brush)
- func (c *DrawContext) Restore()
- func (c *DrawContext) Save()
- func (c *DrawContext) Stroke(p *Path, b *Brush, sp *StrokeParams)
- func (c *DrawContext) Text(x float64, y float64, layout *TextLayout)
- func (c *DrawContext) Transform(m *Matrix)
- type Entry
- func (e *Entry) Destroy()
- func (e *Entry) Disable()
- func (e *Entry) Enable()
- func (e *Entry) Handle() uintptr
- func (e *Entry) Hide()
- func (e *Entry) LibuiControl() uintptr
- func (e *Entry) OnChanged(f func(*Entry))
- func (e *Entry) ReadOnly() bool
- func (e *Entry) SetReadOnly(ro bool)
- func (e *Entry) SetText(text string)
- func (e *Entry) Show()
- func (e *Entry) Text() string
- type ExtKey
- type FillMode
- type Font
- type FontDescriptor
- type FontFamilies
- type FontMetrics
- type Form
- func (f *Form) Append(label string, child Control, stretchy bool)
- func (f *Form) Delete(n int)
- func (f *Form) Destroy()
- func (f *Form) Disable()
- func (f *Form) Enable()
- func (f *Form) Handle() uintptr
- func (f *Form) Hide()
- func (f *Form) LibuiControl() uintptr
- func (f *Form) Padded() bool
- func (f *Form) SetPadded(padded bool)
- func (f *Form) Show()
- type GradientStop
- type Grid
- func (g *Grid) Append(child Control, left, top, xspan, yspan int, hexpand bool, uialign Align, ...)
- func (g *Grid) Delete(n int)
- func (g *Grid) Destroy()
- func (g *Grid) Disable()
- func (g *Grid) Enable()
- func (g *Grid) Handle() uintptr
- func (g *Grid) Hide()
- func (g *Grid) LibuiControl() uintptr
- func (g *Grid) Padded() bool
- func (g *Grid) SetPadded(padded bool)
- func (g *Grid) Show()
- type Group
- func (g *Group) Destroy()
- func (g *Group) Disable()
- func (g *Group) Enable()
- func (g *Group) Handle() uintptr
- func (g *Group) Hide()
- func (g *Group) LibuiControl() uintptr
- func (g *Group) Margined() bool
- func (g *Group) SetChild(child Control)
- func (g *Group) SetMargined(margined bool)
- func (g *Group) SetTitle(title string)
- func (g *Group) Show()
- func (g *Group) Title() string
- type Label
- type LineCap
- type LineJoin
- type Matrix
- func (m *Matrix) Invert() bool
- func (m *Matrix) Invertible() bool
- func (m *Matrix) Multiply(m2 *Matrix)
- func (m *Matrix) Rotate(x float64, y float64, amount float64)
- func (m *Matrix) Scale(xCenter float64, yCenter float64, x float64, y float64)
- func (m *Matrix) SetIdentity()
- func (m *Matrix) Skew(x float64, y float64, xamount float64, yamount float64)
- func (m *Matrix) TransformPoint(x float64, y float64) (xout float64, yout float64)
- func (m *Matrix) TransformSize(x float64, y float64) (xout float64, yout float64)
- func (m *Matrix) Translate(x float64, y float64)
- type Modifiers
- type MultilineEntry
- func (e *MultilineEntry) Append(text string)
- func (e *MultilineEntry) Destroy()
- func (e *MultilineEntry) Disable()
- func (e *MultilineEntry) Enable()
- func (e *MultilineEntry) Handle() uintptr
- func (e *MultilineEntry) Hide()
- func (e *MultilineEntry) LibuiControl() uintptr
- func (e *MultilineEntry) OnChanged(f func(*MultilineEntry))
- func (e *MultilineEntry) ReadOnly() bool
- func (e *MultilineEntry) SetReadOnly(ro bool)
- func (e *MultilineEntry) SetText(text string)
- func (e *MultilineEntry) Show()
- func (e *MultilineEntry) Text() string
- type Path
- func (p *Path) AddRectangle(x float64, y float64, width float64, height float64)
- func (p *Path) ArcTo(xCenter float64, yCenter float64, radius float64, startAngle float64, ...)
- func (p *Path) BezierTo(c1x float64, c1y float64, c2x float64, c2y float64, endX float64, endY float64)
- func (p *Path) CloseFigure()
- func (p *Path) End()
- func (p *Path) Free()
- func (p *Path) LineTo(x float64, y float64)
- func (p *Path) NewFigure(x float64, y float64)
- func (p *Path) NewFigureWithArc(xCenter float64, yCenter float64, radius float64, startAngle float64, ...)
- type ProgressBar
- type RadioButtons
- func (r *RadioButtons) Append(text string)
- func (r *RadioButtons) Destroy()
- func (r *RadioButtons) Disable()
- func (r *RadioButtons) Enable()
- func (r *RadioButtons) Handle() uintptr
- func (r *RadioButtons) Hide()
- func (r *RadioButtons) LibuiControl() uintptr
- func (r *RadioButtons) OnSelected(f func(*RadioButtons))
- func (r *RadioButtons) Selected() int
- func (r *RadioButtons) SetSelected(index int)
- func (r *RadioButtons) Show()
- type Separator
- type Slider
- func (s *Slider) Destroy()
- func (s *Slider) Disable()
- func (s *Slider) Enable()
- func (s *Slider) Handle() uintptr
- func (s *Slider) Hide()
- func (s *Slider) LibuiControl() uintptr
- func (s *Slider) OnChanged(f func(*Slider))
- func (s *Slider) SetValue(value int)
- func (s *Slider) Show()
- func (s *Slider) Value() int
- type Spinbox
- func (s *Spinbox) Destroy()
- func (s *Spinbox) Disable()
- func (s *Spinbox) Enable()
- func (s *Spinbox) Handle() uintptr
- func (s *Spinbox) Hide()
- func (s *Spinbox) LibuiControl() uintptr
- func (s *Spinbox) OnChanged(f func(*Spinbox))
- func (s *Spinbox) SetValue(value int)
- func (s *Spinbox) Show()
- func (s *Spinbox) Value() int
- type StrokeParams
- type Tab
- func (t *Tab) Append(name string, child Control)
- func (t *Tab) Delete(n int)
- func (t *Tab) Destroy()
- func (t *Tab) Disable()
- func (t *Tab) Enable()
- func (t *Tab) Handle() uintptr
- func (t *Tab) Hide()
- func (t *Tab) InsertAt(name string, n int, child Control)
- func (t *Tab) LibuiControl() uintptr
- func (t *Tab) Margined(n int) bool
- func (t *Tab) NumPages() int
- func (t *Tab) SetMargined(n int, margined bool)
- func (t *Tab) Show()
- type TextItalic
- type TextLayout
- type TextStretch
- type TextWeight
- type Window
- func (w *Window) Center()
- func (w *Window) Destroy()
- func (w *Window) Disable()
- func (w *Window) Enable()
- func (w *Window) GetContentSize() (width, height int)
- func (w *Window) Handle() uintptr
- func (w *Window) Hide()
- func (w *Window) LibuiControl() uintptr
- func (w *Window) Margined() bool
- func (w *Window) OnClosing(f func(*Window) bool)
- func (w *Window) SetChild(child Control)
- func (w *Window) SetContentSize(width, height int)
- func (w *Window) SetMargined(margined bool)
- func (w *Window) SetPosition(x, y int)
- func (w *Window) SetTitle(title string)
- func (w *Window) Show()
- func (w *Window) Title() string
- Bugs
Constants ¶
const DefaultMiterLimit = 10.0
TODO document
Variables ¶
This section is empty.
Functions ¶
func LibuiControlDestroy ¶
func LibuiControlDestroy(c uintptr)
LibuiControlDestroy allows implementations of Control to call the libui function uiControlDestroy.
func LibuiControlDisable ¶
func LibuiControlDisable(c uintptr)
LibuiControlDisable allows implementations of Control to call the libui function uiControlDisable.
func LibuiControlEnable ¶
func LibuiControlEnable(c uintptr)
LibuiControlEnable allows implementations of Control to call the libui function uiControlEnable.
func LibuiControlHandle ¶
LibuiControlHandle allows implementations of Control to call the libui function uiControlHandle.
func LibuiControlHide ¶
func LibuiControlHide(c uintptr)
LibuiControlHide allows implementations of Control to call the libui function uiControlHide.
func LibuiControlShow ¶
func LibuiControlShow(c uintptr)
LibuiControlShow allows implementations of Control to call the libui function uiControlShow.
func LibuiFreeText ¶
func LibuiFreeText(c uintptr)
LibuiFreeText allows implementations of Control to call the libui function uiFreeText.
func Main ¶
func Main(f func()) error
Main initializes package ui, runs f to set up the program, and executes the GUI main loop. f should set up the program's initial state: open the main window, create controls, and set up events. It should then return, at which point Main will process events until Quit is called, at which point Main will return nil. If package ui fails to initialize, Main returns an appropriate error.
func OnShouldQuit ¶
func OnShouldQuit(f func() bool)
OnShouldQuit schedules f to be exeucted when the OS wants the program to quit or when a Quit menu item has been clicked. Only one function may be registered at a time. If the function returns true, Quit will be called. If the function returns false, or if OnShouldQuit is never called. Quit will not be called and the OS will be told that the program needs to continue running.
func QueueMain ¶
func QueueMain(f func())
QueueMain queues f to be executed on the GUI thread when next possible. It returns immediately; that is, it does not wait for the function to actually be executed. QueueMain is the only function that can be called from other goroutines, and its primary purpose is to allow communication between other goroutines and the GUI thread. Calling QueueMain after Quit has been called results in undefined behavior.
Types ¶
type Area ¶
type Area struct {
// contains filtered or unexported fields
}
Area is a Control that represents a blank canvas that a program can draw on as it wishes. Areas also receive keyboard and mouse events, and programs can react to those as they see fit. Drawing and event handling are handled through an instance of a type that implements AreaHandler that every Area has; see AreaHandler for details.
There are two types of areas. Non-scrolling areas are rectangular and have no scrollbars. Programs can draw on and get mouse events from any point in the Area, and the size of the Area is decided by package ui itself, according to the layout of controls in the Window the Area is located in and the size of said Window. There is no way to query the Area's size or be notified when its size changes; instead, you are given the area size as part of the draw and mouse event handlers, for use solely within those handlers.
Scrolling areas have horziontal and vertical scrollbars. The amount that can be scrolled is determined by the area's size, which is decided by the programmer (both when creating the Area and by a call to SetSize). Only a portion of the Area is visible at any time; drawing and mouse events are automatically adjusted to match what portion is visible, so you do not have to worry about scrolling in your event handlers. AreaHandler has more information.
The internal coordinate system of an Area is points, which are floating-point and device-independent. For more details, see AreaHandler. The size of a scrolling Area must be an exact integer number of points (that is, you cannot have an Area that is 32.5 points tall) and thus the parameters to NewScrollingArea and SetSize are ints. All other instances of points in parameters and structures (including sizes of drawn objects) are float64s.
func NewScrollingArea ¶
func NewScrollingArea(handler AreaHandler, width int, height int) *Area
NewScrollingArea creates a new scrolling Area of the given size, in points.
func (*Area) Handle ¶
Handle returns the OS-level handle associated with this Area. On Windows this is an HWND of a libui-internal class. On GTK+ this is a pointer to a GtkScrolledWindow with a GtkViewport as its child. The child of the viewport is the GtkDrawingArea that provides the Area itself. On OS X this is a pointer to a NSScrollView whose document view is the NSView that provides the Area itself.
func (*Area) LibuiControl ¶
LibuiControl returns the libui uiControl pointer that backs the Area. This is only used by package ui itself and should not be called by programs.
func (*Area) QueueRedrawAll ¶
func (a *Area) QueueRedrawAll()
QueueRedrawAll queues the entire Area for redraw. The Area is not redrawn before this function returns; it is redrawn when next possible.
func (*Area) ScrollTo ¶
ScrollTo scrolls the Area to show the given rectangle; what this means is implementation-defined, but you can safely assume that as much of the given rectangle as possible will be visible after this call. (TODO verify this on OS X) ScrollTo panics if called on a non-scrolling Area.
type AreaDrawParams ¶
type AreaDrawParams struct { // Context is the drawing context to draw on. See DrawContext // for how to draw. Context *DrawContext // AreaWidth and AreaHeight provide the size of the Area for // non-scrolling Areas. For scrolling Areas both values are zero. // // To reiterate the AreaHandler documentation, do NOT save // these values for later; they can change without generating // an event. AreaWidth float64 AreaHeight float64 // These four fields define the rectangle that needs to be // redrawn. The system will not draw anything outside this // rectangle, but you can make your drawing faster if you // also stay within the lines. ClipX float64 ClipY float64 ClipWidth float64 ClipHeight float64 }
AreaDrawParams provides a drawing context that can be used to draw on an Area and tells you where to draw. See AreaHandler for introductory information.
type AreaHandler ¶
type AreaHandler interface { // Draw is sent when a part of the Area needs to be drawn. // dp will contain a drawing context to draw on, the rectangle // that needs to be drawn in, and (for a non-scrolling area) the // size of the area. The rectangle that needs to be drawn will // have been cleared by the system prior to drawing, so you are // always working on a clean slate. // // If you call Save on the drawing context, you must call Release // before returning from Draw, and the number of calls to Save // and Release must match. Failure to do so results in undefined // behavior. Draw(a *Area, dp *AreaDrawParams) // MouseEvent is called when the mouse moves over the Area // or when a mouse button is pressed or released. See // AreaMouseEvent for more details. // // If a mouse button is being held, MouseEvents will continue to // be generated, even if the mouse is not within the area. On // some systems, the system can interrupt this behavior; // see DragBroken. MouseEvent(a *Area, me *AreaMouseEvent) // MouseCrossed is called when the mouse either enters or // leaves the Area. It is called even if the mouse buttons are being // held (see MouseEvent above). If the mouse has entered the // Area, left is false; if it has left the Area, left is true. // // If, when the Area is first shown, the mouse is already inside // the Area, MouseCrossed will be called with left=false. // TODO what about future shows? MouseCrossed(a *Area, left bool) // DragBroken is called if a mouse drag is interrupted by the // system. As noted above, when a mouse button is held, // MouseEvent will continue to be called, even if the mouse is // outside the Area. On some systems, this behavior can be // stopped by the system itself for a variety of reasons. This // method is provided to allow your program to cope with the // loss of the mouse in this case. You should cope by cancelling // whatever drag-related operation you were doing. // // Note that this is only generated on some systems under // specific conditions. Do not implement behavior that only // takes effect when DragBroken is called. DragBroken(a *Area) // KeyEvent is called when a key is pressed while the Area has // keyboard focus (if the Area has been tabbed into or if the // mouse has been clicked on it). See AreaKeyEvent for specifics. // // Because some keyboard events are handled by the system // (for instance, menu accelerators and global hotkeys), you // must return whether you handled the key event; return true // if you did or false if you did not. If you wish to ignore the // keyboard outright, the correct implementation of KeyEvent is // func (h *MyHandler) KeyEvent(a *ui.Area, ke *ui.AreaKeyEvent) (handled bool) { // return false // } // DO NOT RETURN TRUE UNCONDITIONALLY FROM THIS // METHOD. BAD THINGS WILL HAPPEN IF YOU DO. KeyEvent(a *Area, ke *AreaKeyEvent) (handled bool) }
AreaHandler defines the functionality needed for handling events from an Area. Each of the methods on AreaHandler is called from the GUI thread, and every parameter (other than the Area itself) should be assumed to only be valid during the life of the method call (so for instance, do not save AreaDrawParams.AreaWidth, as that might change without generating an event).
Coordinates to Draw and MouseEvent are given in points. Points are generic, floating-point, device-independent coordinates with (0,0) at the top left corner. You never have to worry about the mapping between points and pixels; simply draw everything using points and you get nice effects like looking sharp on high-DPI monitors for free. Proper documentation on the matter is being written. In the meantime, there are several referenes to this kind of drawing, most notably on Apple's website: https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html#//apple_ref/doc/uid/TP40012302-CH4-SW1
For a scrolling Area, points are automatically offset by the scroll position. So if the mouse moves to position (5,5) while the horizontal scrollbar is at position 10 and the horizontal scrollbar is at position 20, the coordinate stored in the AreaMouseEvent structure is (15,25). The same applies to drawing.
type AreaKeyEvent ¶
TODO document all these
type AreaMouseEvent ¶
type AreaMouseEvent struct { X float64 Y float64 // AreaWidth and AreaHeight provide the size of the Area for // non-scrolling Areas. For scrolling Areas both values are zero. // // To reiterate the AreaHandler documentation, do NOT save // these values for later; they can change without generating // an event. AreaWidth float64 AreaHeight float64 Down uint Up uint Count uint Modifiers Modifiers Held []uint }
TODO document all these
TODO note that in the case of a drag, X and Y can be out of bounds, or in the event of a scrolling area, in places that are not visible
type Box ¶
type Box struct {
// contains filtered or unexported fields
}
Box is a Control that holds a group of Controls horizontally or vertically. If horizontally, then all controls have the same height. If vertically, then all controls have the same width. By default, each control has its preferred width (horizontal) or height (vertical); if a control is marked "stretchy", it will take whatever space is left over. If multiple controls are marked stretchy, they will be given equal shares of the leftover space. There can also be space between each control ("padding").
func (*Box) Destroy ¶
func (b *Box) Destroy()
Destroy destroys the Box. If the Box has children, Destroy calls Destroy on those Controls as well.
func (*Box) Handle ¶
Handle returns the OS-level handle associated with this Box. On Windows this is an HWND of a libui-internal class. On GTK+ this is a pointer to a GtkBox. On OS X this is a pointer to a NSView.
func (*Box) LibuiControl ¶
LibuiControl returns the libui uiControl pointer that backs the Box. This is only used by package ui itself and should not be called by programs.
type Brush ¶
type Brush struct { Type BrushType // If Type is Solid. // TODO R float64 G float64 B float64 A float64 // If Type is LinearGradient or RadialGradient. // TODO X0 float64 // start point for both Y0 float64 X1 float64 // linear: end point; radial: circle center Y1 float64 OuterRadius float64 // for radial gradients only Stops []GradientStop }
TODO
type Button ¶
type Button struct {
// contains filtered or unexported fields
}
Button is a Control that represents a button that the user can click to perform an action. A Button has a text label that should describe what the button does.
func (*Button) Handle ¶
Handle returns the OS-level handle associated with this Button. On Windows this is an HWND of a standard Windows API BUTTON class (as provided by Common Controls version 6). On GTK+ this is a pointer to a GtkButton. On OS X this is a pointer to a NSButton.
func (*Button) LibuiControl ¶
LibuiControl returns the libui uiControl pointer that backs the Button. This is only used by package ui itself and should not be called by programs.
func (*Button) OnClicked ¶
OnClicked registers f to be run when the user clicks the Button. Only one function can be registered at a time.
type Checkbox ¶
type Checkbox struct {
// contains filtered or unexported fields
}
Checkbox is a Control that represents a box with a text label at its side. When the user clicks the checkbox, a check mark will appear in the box; clicking it again removes the check.
func NewCheckbox ¶
NewCheckbox creates a new Checkbox with the given text as its label.
func (*Checkbox) Handle ¶
Handle returns the OS-level handle associated with this Checkbox. On Windows this is an HWND of a standard Windows API BUTTON class (as provided by Common Controls version 6). On GTK+ this is a pointer to a GtkCheckButton. On OS X this is a pointer to a NSButton.
func (*Checkbox) LibuiControl ¶
LibuiControl returns the libui uiControl pointer that backs the Window. This is only used by package ui itself and should not be called by programs.
func (*Checkbox) OnToggled ¶
OnToggled registers f to be run when the user clicks the Checkbox. Only one function can be registered at a time.
func (*Checkbox) SetChecked ¶
SetChecked sets whether the Checkbox is checked.
type Combobox ¶
type Combobox struct {
// contains filtered or unexported fields
}
Combobox is a Control that represents a drop-down list of strings that the user can choose one of at any time. An editable Combobox also has an entry field that the user can type an alternate choice into.
func NewCombobox ¶
func NewCombobox() *Combobox
NewCombobox creates a new Combobox. This Combobox is not editable.
func (*Combobox) Destroy ¶
func (c *Combobox) Destroy()
TODO // NewEditableCombobox creates a new editable Combobox.
func NewEditableCombobox() *Combobox { c := new(Combobox) c.c = C.uiNewEditableCombobox() c.co = (*C.uiControl)(unsafe.Pointer(c.c)) C.realuiComboboxOnSelected(c.c) comboboxes[c.c] = c return c }
Destroy destroys the Combobox.
func (*Combobox) Handle ¶
Handle returns the OS-level handle associated with this Combobox. On Windows this is an HWND of a standard Windows API COMBOBOX class (as provided by Common Controls version 6). On GTK+ this is a pointer to a GtkComboBoxText. On OS X this is a pointer to a NSComboBox for editable Comboboxes and to a NSPopUpButton for noneditable Comboboxes.
func (*Combobox) LibuiControl ¶
LibuiControl returns the libui uiControl pointer that backs the Window. This is only used by package ui itself and should not be called by programs.
func (*Combobox) OnSelected ¶
OnSelected registers f to be run when the user selects an item in the Combobox. Only one function can be registered at a time.
func (*Combobox) Selected ¶
Selected returns the index of the currently selected item in the Combobox, or -1 if nothing is selected.
func (*Combobox) SetSelected ¶
SetChecked sets the currently select item in the Combobox to index. If index is -1 no item will be selected.
type Control ¶
type Control interface { // Destroy destroys the Control. // // Implementations should do any necessary cleanup, // then call LibuiControlDestroy. Destroy() // LibuiControl returns the libui uiControl pointer that backs // the Control. This is only used by package ui itself and should // not be called by programs. LibuiControl() uintptr // Handle returns the OS-level handle that backs the // Control. On OSs that use reference counting for // controls, Handle does not increment the reference // count; you are sharing package ui's reference. // // Implementations should call LibuiControlHandle and // document exactly what kind of handle is returned. Handle() uintptr // Show shows the Control. // // Implementations should call LibuiControlShow. Show() // Hide shows the Control. Hidden controls do not participate // in layout (that is, Box, Grid, etc. does not reserve space for // hidden controls). // // Implementations should call LibuiControlHide. Hide() // Enable enables the Control. // // Implementations should call LibuiControlEnable. Enable() // Disable disables the Control. // // Implementations should call LibuiControlDisable. Disable() }
Control represents a GUI control. It provdes methods common to all Controls.
To create a new Control, implement the control on the libui side, then provide access to that control on the Go side via an implementation of Control as described.
type DateTimePicker ¶
type DateTimePicker struct {
// contains filtered or unexported fields
}
DateTimePicker is a Control that represents a field where the user can enter a date and/or a time.
func NewDatePicker ¶
func NewDatePicker() *DateTimePicker
NewDatePicker creates a new DateTimePicker that shows only a date.
func NewDateTimePicker ¶
func NewDateTimePicker() *DateTimePicker
NewDateTimePicker creates a new DateTimePicker that shows both a date and a time.
func NewTimePicker ¶
func NewTimePicker() *DateTimePicker
NewTimePicker creates a new DateTimePicker that shows only a time.
func (*DateTimePicker) Destroy ¶
func (d *DateTimePicker) Destroy()
Destroy destroys the DateTimePicker.
func (*DateTimePicker) Disable ¶
func (d *DateTimePicker) Disable()
Disable disables the DateTimePicker.
func (*DateTimePicker) Enable ¶
func (d *DateTimePicker) Enable()
Enable enables the DateTimePicker.
func (*DateTimePicker) Handle ¶
func (d *DateTimePicker) Handle() uintptr
Handle returns the OS-level handle associated with this DateTimePicker. On Windows this is an HWND of a standard Windows API DATETIMEPICK_CLASS class (as provided by Common Controls version 6). On GTK+ this is a pointer to a libui-internal class. On OS X this is a pointer to a NSDatePicker.
func (*DateTimePicker) LibuiControl ¶
func (d *DateTimePicker) LibuiControl() uintptr
LibuiControl returns the libui uiControl pointer that backs the Window. This is only used by package ui itself and should not be called by programs.
type DrawContext ¶
type DrawContext struct {
// contains filtered or unexported fields
}
DrawContext represents a drawing surface that you can draw to. At present the only DrawContexts are surfaces associated with Areas and are provided by package ui; see AreaDrawParams.
func (*DrawContext) Text ¶
func (c *DrawContext) Text(x float64, y float64, layout *TextLayout)
Text draws the given TextLayout onto c at the given point. The point refers to the top-left corner of the text. (TODO bounding box or typographical extent?)
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry is a Control that represents a space that the user can type a single line of text into.
func NewPasswordEntry ¶
func NewPasswordEntry() *Entry
NewPasswordEntry creates a new Entry suitable for entering passwords.
func NewSearchEntry ¶
func NewSearchEntry() *Entry
NewSearchEntry creates a new Entry suitable for searching.
func (*Entry) Handle ¶
Handle returns the OS-level handle associated with this Entry. On Windows this is an HWND of a standard Windows API EDIT class (as provided by Common Controls version 6). On GTK+ this is a pointer to a GtkEntry. On OS X this is a pointer to a NSTextField.
func (*Entry) LibuiControl ¶
LibuiControl returns the libui uiControl pointer that backs the Window. This is only used by package ui itself and should not be called by programs.
func (*Entry) OnChanged ¶
OnChanged registers f to be run when the user makes a change to the Entry. Only one function can be registered at a time.
func (*Entry) SetReadOnly ¶
SetReadOnly sets whether the Entry can be changed.
type ExtKey ¶
type ExtKey int
TODO document
Note: these must be numerically identical to their libui equivalents.
const ( Escape ExtKey = iota + 1 Insert // equivalent to "Help" on Apple keyboards Delete Home End PageUp PageDown Up Down Left Right F1 // F1..F12 are guaranteed to be consecutive F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 N0 // numpad keys; independent of Num Lock state N1 // N0..N9 are guaranteed to be consecutive N2 N3 N4 N5 N6 N7 N8 N9 NDot NEnter NAdd NSubtract NMultiply NDivide )
type Font ¶
type Font struct {
// contains filtered or unexported fields
}
Font represents an actual font that can be drawn with.
func LoadClosestFont ¶
func LoadClosestFont(desc *FontDescriptor) *Font
LoadClosestFont loads a Font.
You pass the properties of the ideal font you want to load in the FontDescriptor you pass to this function. If the requested font is not available on the system, the closest matching font is used. This means that, for instance, if you specify a Weight of TextWeightUltraHeavy and the heaviest weight available for the chosen font family is actually TextWeightBold, that will be used instead. The specific details of font matching beyond this description are implementation defined. This also means that getting a descriptor back out of a Font may return a different desriptor.
TODO guarantee that passing *that* back into LoadClosestFont() returns the same font
func (*Font) Describe ¶
func (f *Font) Describe() *FontDescriptor
Describe returns the FontDescriptor that most closely matches this Font. TODO guarantees about idempotency TODO rewrite that first sentence
func (*Font) Free ¶
func (f *Font) Free()
Free destroys a Font. After calling Free the Font cannot be used.
func (*Font) Handle ¶
Handle returns the OS font object that backs this Font. On OSs that use reference counting for font objects, Handle does not increment the reference count; you are sharing package ui's reference.
On Windows this is a pointer to an IDWriteFont.
On Unix systems this is a pointer to a PangoFont.
On OS X this is a CTFontRef.
func (*Font) Metrics ¶
func (f *Font) Metrics() *FontMetrics
Metrics returns metrics about the given Font.
type FontDescriptor ¶
type FontDescriptor struct { Family string Size float64 // as a text size, for instance 12 for a 12-point font Weight TextWeight Italic TextItalic Stretch TextStretch }
FontDescriptor describes a Font.
type FontFamilies ¶
type FontFamilies struct {
// contains filtered or unexported fields
}
FontFamilies represents an enumerator over the font families available for use by package ui. A FontFamilies object behaves similarly to a []string, except that since family names are loaded on demand (depending on the operating system), it is not an actual []string. You call ListFontFamilies to obtain a FontFamilies object, which should reflect the available fonts at the time of the call (TODO verify). Use NumFamilies to get the number of families, and Family to get the name of a given family by index. When finished, call Free.
There is no guarantee that the list of families is sorted. You will need to do sorting yourself if you need it.
TODO thread affinity
func ListFontFamilies ¶
func ListFontFamilies() *FontFamilies
ListFontFamilies creates a new FontFamilies object ready for use.
func (*FontFamilies) Family ¶
func (f *FontFamilies) Family(n int) string
Family returns the name of the nth family in the list.
func (*FontFamilies) Free ¶
func (f *FontFamilies) Free()
Free destroys a FontFamilies. After calling Free, the FontFamilies cannot be used.
func (*FontFamilies) NumFamilies ¶
func (f *FontFamilies) NumFamilies() int
NumFamilies returns the number of font families available.
type FontMetrics ¶
type FontMetrics struct { // Ascent is the ascent of the font; that is, the distance from // the top of the character cell to the baseline. Ascent float64 // Descent is the descent of the font; that is, the distance from // the baseline to the bottom of the character cell. The sum of // Ascent and Descent is the height of the character cell (and // thus, the maximum height of a line of text). Descent float64 // Leading is the amount of space the font designer suggests // to have between lines (between the bottom of the first line's // character cell and the top of the second line's character cell). // This is a suggestion; it is chosen by the font designer to // improve legibility. Leading float64 // TODO figure out what these are UnderlinePos float64 UnderlineThickness float64 }
FontMetrics holds various measurements about a Font. All metrics are in the same point units used for drawing.
type Form ¶
type Form struct {
// contains filtered or unexported fields
}
func (*Form) Destroy ¶
func (f *Form) Destroy()
Destroy destroys the Form. If the Form has children, Destroy calls Destroy on those Controls as well.
func (*Form) LibuiControl ¶
LibuiControl returns the libui uiControl pointer that backs the Form. This is only used by package ui itself and should not be called by programs.
type GradientStop ¶
type GradientStop struct { Pos float64 // between 0 and 1 inclusive R float64 G float64 B float64 A float64 }
TODO
type Grid ¶
type Grid struct {
// contains filtered or unexported fields
}
Grid is a container Control that arranges controls in rows and columns, with stretchy ("expanding") rows, stretchy ("expanding") columns, cells that span rows and columns, and cells whose content is aligned in either direction rather than just filling.
func (*Grid) Append ¶
func (g *Grid) Append(child Control, left, top, xspan, yspan int, hexpand bool, uialign Align, vexpand bool, valign Align)
Append adds the given control to the end of the Grid.
func (*Grid) Destroy ¶
func (g *Grid) Destroy()
Destroy destroys the Grid. If the Grid has children, Destroy calls Destroy on those Controls as well.
func (*Grid) LibuiControl ¶
LibuiControl returns the libui uiControl pointer that backs the Grid. This is only used by package ui itself and should not be called by programs.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is a Control that holds another Control and wraps it around a labelled box (though some systems make this box invisible). You can use this to group related controls together.
func (*Group) Destroy ¶
func (g *Group) Destroy()
Destroy destroys the Group. If the Group has a child, Destroy calls Destroy on that as well.
func (*Group) Handle ¶
Handle returns the OS-level handle associated with this Group. On Windows this is an HWND of a standard Windows API BUTTON class (as provided by Common Controls version 6). On GTK+ this is a pointer to a GtkFrame. On OS X this is a pointer to a NSBox.
func (*Group) LibuiControl ¶
LibuiControl returns the libui uiControl pointer that backs the Group. This is only used by package ui itself and should not be called by programs.
func (*Group) SetChild ¶
SetChild sets the Group's child to child. If child is nil, the Group will not have a child.
func (*Group) SetMargined ¶
SetMargined controls whether the Group has margins around its child. The size of the margins are determined by the OS and its best practices.
type Label ¶
type Label struct {
// contains filtered or unexported fields
}
Label is a Control that represents a line of text that cannot be interacted with. TODO rest of documentation.
func (*Label) Handle ¶
Handle returns the OS-level handle associated with this Label. On Windows this is an HWND of a standard Windows API STATIC class (as provided by Common Controls version 6). On GTK+ this is a pointer to a GtkLabel. On OS X this is a pointer to a NSTextField.
func (*Label) LibuiControl ¶
LibuiControl returns the libui uiControl pointer that backs the Window. This is only used by package ui itself and should not be called by programs.
type LineCap ¶
type LineCap int
TODO
TODO disclaimer TODO rename these to put LineCap at the beginning? or just Cap?
type Matrix ¶
TODO TODO should the methods of these return self for chaining?
func (*Matrix) TransformPoint ¶
TODO unimplemented
func (*Matrix) TransformSize ¶
TODO unimplemented
type Modifiers ¶
type Modifiers uint
TODO document
Note: these must be numerically identical to their libui equivalents.
type MultilineEntry ¶
type MultilineEntry struct {
// contains filtered or unexported fields
}
MultilineEntry is a Control that represents a space that the user can type multiple lines of text into.
func NewMultilineEntry ¶
func NewMultilineEntry() *MultilineEntry
NewMultilineEntry creates a new MultilineEntry.
func NewMultilineNonWrappingEntry ¶
func NewMultilineNonWrappingEntry() *MultilineEntry
NewMultilineNonWrappingEntry creates a new MultilineEntry.
func (*MultilineEntry) Append ¶
func (e *MultilineEntry) Append(text string)
Append text to the MultilineEntry's text.
func (*MultilineEntry) Destroy ¶
func (e *MultilineEntry) Destroy()
Destroy destroys the MultilineEntry.
func (*MultilineEntry) Disable ¶
func (e *MultilineEntry) Disable()
Disable disables the MultilineEntry.
func (*MultilineEntry) Enable ¶
func (e *MultilineEntry) Enable()
Enable enables the MultilineEntry.
func (*MultilineEntry) Handle ¶
func (e *MultilineEntry) Handle() uintptr
Handle returns the OS-level handle associated with this MultilineEntry.
func (*MultilineEntry) LibuiControl ¶
func (e *MultilineEntry) LibuiControl() uintptr
LibuiControl returns the libui uiControl pointer that backs the Window. This is only used by package ui itself and should not be called by programs.
func (*MultilineEntry) OnChanged ¶
func (e *MultilineEntry) OnChanged(f func(*MultilineEntry))
OnChanged registers f to be run when the user makes a change to the MultilineEntry. Only one function can be registered at a time.
func (*MultilineEntry) ReadOnly ¶
func (e *MultilineEntry) ReadOnly() bool
ReadOnly returns whether the MultilineEntry can be changed.
func (*MultilineEntry) SetReadOnly ¶
func (e *MultilineEntry) SetReadOnly(ro bool)
SetReadOnly sets whether the MultilineEntry can be changed.
func (*MultilineEntry) SetText ¶
func (e *MultilineEntry) SetText(text string)
SetText sets the MultilineEntry's text to text.
func (*MultilineEntry) Text ¶
func (e *MultilineEntry) Text() string
Text returns the MultilineEntry's text.
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path represents a geometric path in a drawing context. This is the basic unit of drawing: all drawing operations consist of forming a path, then stroking, filling, or clipping to that path. A path is an OS resource; you must explicitly free it when finished. Paths consist of multiple figures. Once you have added all the figures to a path, you must "end" the path to make it ready to draw with. TODO rewrite all that
Or more visually, the lifecycle of a Path is
p := NewPath() for every figure { p.NewFigure(...) // or NewFigureWithArc p.LineTo(...) // any number of these in any order p.ArcTo(...) p.BezierTo(...) if figure should be closed { p.CloseFigure() } } p.End() // ... dp.Context.Stroke(p, ...) // any number of these in any order dp.Context.Fill(p, ...) dp.Context.Clip(p) // ... p.Free() // when done with the path
A Path also defines its fill mode. (This should ideally be a fill parameter, but some implementations prevent it.) TODO talk about fill modes
func (*Path) AddRectangle ¶
AddRectangle creates a new figure in the Path that consists entirely of a rectangle whose top-left corner is at the given point and whose size is the given size. The rectangle is a closed figure; you must either start a new figure or end the Path after calling this method.
func (*Path) ArcTo ¶
func (p *Path) ArcTo(xCenter float64, yCenter float64, radius float64, startAngle float64, sweep float64, isNegative bool)
ArcTo adds a circular arc to the current figure of the Path. You pass it the center of the arc, its radius in radians, the starting angle (couterclockwise) in radians, and the number of radians the arc should sweep (counterclockwise). A line segment is drawn from the current point to the start of the arc. The current point is set to the end of the arc.
func (*Path) BezierTo ¶
func (p *Path) BezierTo(c1x float64, c1y float64, c2x float64, c2y float64, endX float64, endY float64)
BezierTo adds a cubic Bezier curve to the current figure of the Path. Its start point is the current point. c1x and c1y are the first control point. c2x and c2y are the second control point. endX and endY are the end point. The current point is set to the end point.
func (*Path) CloseFigure ¶
func (p *Path) CloseFigure()
CloseFigure draws a line segment from the current point of the current figure of the Path back to its initial point. After calling this, the current figure is over and you must either start a new figure or end the Path. If this is not called and you start a new figure or end the Path, then the current figure will not have this closing line segment added to it (but the figure will still be over).
func (*Path) End ¶
func (p *Path) End()
End ends the current Path. You cannot add figures to a Path that has been ended. You cannot draw with a Path that has not been ended.
func (*Path) Free ¶
func (p *Path) Free()
Free destroys a Path. After calling Free the Path cannot be used.
func (*Path) LineTo ¶
LineTo adds a line to the current figure of the Path starting from the current point and ending at the given point. The current point is set to the ending point.
func (*Path) NewFigure ¶
NewFigure starts a new figure in the Path. The current point is set to the given point.
func (*Path) NewFigureWithArc ¶
func (p *Path) NewFigureWithArc(xCenter float64, yCenter float64, radius float64, startAngle float64, sweep float64, isNegative bool)
NewFigureWithArc starts a new figure in the Path and adds an arc as the first element of the figure. Unlike ArcTo, NewFigureWithArc does not draw an initial line segment. Otherwise, see ArcTo.
type ProgressBar ¶
type ProgressBar struct {
// contains filtered or unexported fields
}
ProgressBar is a Control that represents a horizontal bar that is filled in progressively over time as a process completes.
func (*ProgressBar) Handle ¶
func (p *ProgressBar) Handle() uintptr
Handle returns the OS-level handle associated with this ProgressBar. On Windows this is an HWND of a standard Windows API PROGRESS_CLASS class (as provided by Common Controls version 6). On GTK+ this is a pointer to a GtkProgressBar. On OS X this is a pointer to a NSProgressIndicator.
func (*ProgressBar) LibuiControl ¶
func (p *ProgressBar) LibuiControl() uintptr
LibuiControl returns the libui uiControl pointer that backs the Window. This is only used by package ui itself and should not be called by programs.
func (*ProgressBar) SetValue ¶
func (p *ProgressBar) SetValue(value int)
SetValue sets the ProgressBar's currently displayed percentage to value. value must be between 0 and 100 inclusive.
type RadioButtons ¶
type RadioButtons struct {
// contains filtered or unexported fields
}
RadioButtons is a Control that represents a set of checkable buttons from which exactly one may be chosen by the user.
func NewRadioButtons ¶
func NewRadioButtons() *RadioButtons
NewRadioButtons creates a new RadioButtons.
func (*RadioButtons) Append ¶
func (r *RadioButtons) Append(text string)
Append adds the named button to the end of the RadioButtons. If this button is the first button, it is automatically selected.
func (*RadioButtons) Handle ¶
func (r *RadioButtons) Handle() uintptr
Handle returns the OS-level handle associated with this RadioButtons. On Windows this is an HWND of a libui-internal class; its child windows are instances of the standard Windows API BUTTON class (as provided by Common Controls version 6). On GTK+ this is a pointer to a GtkBox containing GtkRadioButtons. On OS X this is a pointer to a NSView with each radio button as a NSButton subview.
func (*RadioButtons) LibuiControl ¶
func (r *RadioButtons) LibuiControl() uintptr
LibuiControl returns the libui uiControl pointer that backs the Window. This is only used by package ui itself and should not be called by programs.
func (*RadioButtons) OnSelected ¶
func (r *RadioButtons) OnSelected(f func(*RadioButtons))
OnSelected registers f to be run when the user selects an item in the RadioButtons. Only one function can be registered at a time.
func (*RadioButtons) Selected ¶
func (r *RadioButtons) Selected() int
Selected returns the index of the currently selected item in the RadioButtons.
func (*RadioButtons) SetSelected ¶
func (r *RadioButtons) SetSelected(index int)
SetSelected sets the currently select item in the RadioButtons to index.
type Separator ¶
type Separator struct {
// contains filtered or unexported fields
}
Separator is a Control that represents a horizontal line that visually separates controls.
func NewHorizontalSeparator ¶
func NewHorizontalSeparator() *Separator
NewSeparator creates a new horizontal Separator.
func (*Separator) Handle ¶
Handle returns the OS-level handle associated with this Separator. On Windows this is an HWND of a standard Windows API STATIC class (as provided by Common Controls version 6). On GTK+ this is a pointer to a GtkSeparator. On OS X this is a pointer to a NSBox.
func (*Separator) LibuiControl ¶
LibuiControl returns the libui uiControl pointer that backs the Window. This is only used by package ui itself and should not be called by programs.
type Slider ¶
type Slider struct {
// contains filtered or unexported fields
}
Slider is a Control that represents a horizontal bar that represents a range of integers. The user can drag a pointer on the bar to select an integer.
func (*Slider) Handle ¶
Handle returns the OS-level handle associated with this Slider. On Windows this is an HWND of a standard Windows API TRACKBAR_CLASS class (as provided by Common Controls version 6). On GTK+ this is a pointer to a GtkScale. On OS X this is a pointer to a NSSlider.
func (*Slider) LibuiControl ¶
LibuiControl returns the libui uiControl pointer that backs the Window. This is only used by package ui itself and should not be called by programs.
func (*Slider) OnChanged ¶
OnChanged registers f to be run when the user changes the value of the Slider. Only one function can be registered at a time.
type Spinbox ¶
type Spinbox struct {
// contains filtered or unexported fields
}
Spinbox is a Control that represents a space where the user can enter integers. The space also comes with buttons to add or subtract 1 from the integer.
func NewSpinbox ¶
NewSpinbox creates a new Spinbox. If min >= max, they are swapped.
func (*Spinbox) Handle ¶
Handle returns the OS-level handle associated with this Spinbox. On Windows this is an HWND of a standard Windows API EDIT class (as provided by Common Controls version 6). Due to various limitations which affect the lifetime of the associated Common Controls version 6 UPDOWN_CLASS window that provides the buttons, there is no way to access it. On GTK+ this is a pointer to a GtkSpinButton. On OS X this is a pointer to a NSView that contains a NSTextField and a NSStepper as subviews.
func (*Spinbox) LibuiControl ¶
LibuiControl returns the libui uiControl pointer that backs the Window. This is only used by package ui itself and should not be called by programs.
func (*Spinbox) OnChanged ¶
OnChanged registers f to be run when the user changes the value of the Spinbox. Only one function can be registered at a time.
type StrokeParams ¶
type StrokeParams struct { Cap LineCap Join LineJoin Thickness float64 MiterLimit float64 Dashes []float64 DashPhase float64 }
TODO
type Tab ¶
type Tab struct {
// contains filtered or unexported fields
}
Tab is a Control that holds tabbed pages of Controls. Each tab has a label. The user can click on the tabs themselves to switch pages. Individual pages can also have margins.
func (*Tab) Destroy ¶
func (t *Tab) Destroy()
Destroy destroys the Tab. If the Tab has pages, Destroy calls Destroy on the pages's Controls as well.
func (*Tab) Handle ¶
Handle returns the OS-level handle associated with this Tab. On Windows this is an HWND of a standard Windows API WC_TABCONTROL class (as provided by Common Controls version 6). The pages are not children of this window and there currently is no way to directly access them. On GTK+ this is a pointer to a GtkNotebook. On OS X this is a pointer to a NSTabView.
func (*Tab) InsertAt ¶
InsertAt adds the given page to the Tab such that it is the nth page of the Tab (starting at 0).
func (*Tab) LibuiControl ¶
LibuiControl returns the libui uiControl pointer that backs the Tab. This is only used by package ui itself and should not be called by programs.
func (*Tab) Margined ¶
Margined returns whether page n (starting at 0) of the Tab has margins around its child.
func (*Tab) SetMargined ¶
SetMargined controls whether page n (starting at 0) of the Tab has margins around its child. The size of the margins are determined by the OS and its best practices.
type TextItalic ¶
type TextItalic int
TextItalic defines the various text italic modes.
TODO disclaimer
const ( TextItalicNormal TextItalic = iota TextItalicOblique // merely slanted text TextItalicItalic // true italics )
type TextLayout ¶
type TextLayout struct {
// contains filtered or unexported fields
}
TextLayout is the entry point for formatting a block of text to be drawn onto a DrawContext.
The block of text to lay out and the default font that is used if no font attributes are applied to a given character are provided at TextLayout creation time and cannot be changed later. However, you may add attributes to various points of the text at any time, even after drawing the text once (unlike a DrawPath). Some of these attributes also have initial values; refer to each method to see what they are.
The block of text can either be a single line or multiple word-wrapped lines, each with a given maximum width.
func NewTextLayout ¶
func NewTextLayout(text string, defaultFont *Font, width float64) *TextLayout
NewTextLayout creates a new TextLayout. For details on the width parameter, see SetWidth.
func (*TextLayout) Extents ¶
func (l *TextLayout) Extents() (width float64, height float64)
Extents returns the width and height that the TextLayout will actually take up when drawn. This measures full line allocations, even if no glyph reaches to the top of its ascent or bottom of its descent; it does not return a "best fit" rectnagle for the points that are actually drawn.
For a single-line TextLayout (where the width is negative), if there are no font changes throughout the TextLayout, then the height returned by TextLayout is equivalent to the sum of the ascent and descent of its default font's metrics. Or in other words, after
f := ui.LoadClosestFont(...) l := ui.NewTextLayout("text", f, -1) metrics := f.Metrics() _, height := l.Extents()
metrics.Ascent+metrics.Descent and height are equivalent.
func (*TextLayout) Free ¶
func (l *TextLayout) Free()
Free destroys a TextLayout. After calling Free the TextLayout cannot be used.
func (*TextLayout) SetWidth ¶
func (l *TextLayout) SetWidth(width float64)
SetWidth sets the maximum width of the lines of text in a TextLayout. If the given width is negative, then the TextLayout will draw as a single line of text instead.
type TextStretch ¶
type TextStretch int
TextStretch defines the various text stretches, in order of increasing wideness.
Note that if you leave this field unset, it will default to TextStretchUltraCondensed. If you want the normal font stretch, explicitly use the constant TextStretchNormal instead. TODO realign these?
TODO disclaimer
const ( TextStretchUltraCondensed TextStretch = iota TextStretchExtraCondensed TextStretchCondensed TextStretchSemiCondensed TextStretchNormal TextStretchSemiExpanded TextStretchExpanded TextStretchExtraExpanded TextStretchUltraExpanded )
type TextWeight ¶
type TextWeight int
TextWeight defines the various text weights, in order of increasing weight.
Note that if you leave this field unset, it will default to TextWeightThin. If you want the normal font weight, explicitly use the constant TextWeightNormal instead. TODO realign these?
TODO disclaimer
const ( TextWeightThin TextWeight = iota TextWeightUltraLight TextWeightLight TextWeightBook TextWeightNormal TextWeightMedium TextWeightSemiBold TextWeightBold TextWeightUtraBold TextWeightHeavy TextWeightUltraHeavy )
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window is a Control that represents a top-level window. A Window contains one child Control that occupies the entirety of the window. Though a Window is a Control, a Window cannot be the child of another Control.
func (*Window) Destroy ¶
func (w *Window) Destroy()
Destroy destroys the Window. If the Window has a child, Destroy calls Destroy on that as well.
func (*Window) GetContentSize ¶
GetContentSize change the window content size.
func (*Window) Handle ¶
Handle returns the OS-level handle associated with this Window. On Windows this is an HWND of a libui-internal class. On GTK+ this is a pointer to a GtkWindow. On OS X this is a pointer to a NSWindow.
func (*Window) LibuiControl ¶
LibuiControl returns the libui uiControl pointer that backs the Window. This is only used by package ui itself and should not be called by programs.
func (*Window) OnClosing ¶
OnClosing registers f to be run when the user clicks the Window's close button. Only one function can be registered at a time. If f returns true, the window is destroyed with the Destroy method. If f returns false, or if OnClosing is never called, the window is not destroyed and is kept visible.
func (*Window) SetChild ¶
SetChild sets the Window's child to child. If child is nil, the Window will not have a child.
func (*Window) SetContentSize ¶
SetContentSize change the window content size.
func (*Window) SetMargined ¶
SetMargined controls whether the Window has margins around its child. The size of the margins are determined by the OS and its best practices.
func (*Window) SetPosition ¶
SetPosition changes the position of the Window.
Notes ¶
Bugs ¶
Ideally, all the drawing APIs should be in another package ui/draw (they all have the "uiDraw" prefix in C to achieve a similar goal of avoiding confusing programmers via namespace pollution); managing the linkage of the libui shared library itself across multiple packages is likely going to be a pain, though. (Custom controls implemented using libui won't have this issue, as they *should* only need libui present when linking the shared object, not when linking the Go wrapper. I'm not sure; I'd have to find out first.)
Source Files ¶
- area.go
- areahandler.go
- box.go
- button.go
- checkbox.go
- combobox.go
- control.go
- datetimepicker.go
- draw.go
- entry.go
- fontbutton.go
- form.go
- grid.go
- group.go
- label.go
- link_linux_amd64.go
- main.go
- multilineentry.go
- progressbar.go
- radiobuttons.go
- separator.go
- slider.go
- spinbox.go
- stddialogs.go
- tab.go
- util.go
- window.go