import "github.com/andlabs/ui"
area.go areahandler.go box.go button.go checkbox.go colorbutton.go combobox.go control.go datetimepicker.go draw.go drawtext.go editablecombobox.go entry.go fontbutton.go form.go grid.go group.go image.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 table.go tablemodel.go util.go window.go
const ( TableModelColumnNeverEditable = -1 TableModelColumnAlwaysEditable = -2 )
TableModelColumnNeverEditable and TableModelColumnAlwaysEditable are the value of an editable model column parameter to one of the Table create column functions; if used, that jparticular Table colum is not editable by the user and always editable by the user, respectively.
TableModelColumnEventable和 TableModelColumnAlwaysEditable是可编辑的 一个表创建列的模型列参数 函数;如果使用该函数,则jp关节表列不可编辑 分别由用户和始终由用户编辑。
const DrawDefaultMiterLimit = 10.0
TODO document
LibuiFreeText allows implementations of Control to call the libui function uiFreeText.
LibuiFreeText允许实现控件 调用libui函数uiFreeText。
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.
Main初始化包ui,运行f来设置程序,并执行GUI主循环。f应该设置程序的初始状态:打开主窗口、创建控件和设置事件。然后它应该返回,此时Main将处理事件,直到调用Quit,此时Main将返回nil。如果包ui未能初始化,Main将返回相应的错误。
TODO
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.
OnShouldQuit计划在操作系统希望程序退出或单击退出菜单项时执行f。一次只能注册一个函数。如果函数返回true,将调用Quit。如果函数返回false,或者从不调用OnShouldQuit。不会调用Quit,系统将被告知程序需要继续运行。
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.
当 下一个可能。它立即返回;也就是说,它不会等待 以便实际执行该函数。QueueMain是唯一 可以从其他goroutine调用的函数,以及 主要目的是允许其他人之间的交流 goroutines和GUI线程。退出后调用QueueMain 已被称为未定义行为的结果。
If you start a goroutine in f, it also cannot call package ui functions. So for instance, the following will result in undefined behavior:
如果在f中启动goroutine,它也不能调用包ui 功能。例如,下面将导致 未定义的行为:
ui.QueueMain(func() { go ui.MsgBox(...) })
func Quit()
Quit queues a return from Main. It does not exit the program. It also does not immediately cause Main to return; Main will return when it next can. Quit must be called from the GUI thread.
退出将排队从Main返回。它不会退出程序。 它也不会立即导致Main返回;Main will 下次可以回来。必须从GUI线程调用Quit。
Align represents the alignment of a Control in its cell of a Grid.
type Area struct { ControlBase // 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.
区域是一个控件,它表示程序 可以随心所欲地利用。区域还接收键盘和鼠标 事件和程序可以在它们认为合适的时候对它们做出反应。绘图 事件处理通过 实现每个区域都有的AreaHandler;请参阅AreaHandler 详细情况。
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.
有两种类型的区域。非滚动区域为矩形 没有滚动条。程序可以绘制并获取鼠标 区域内任意点的事件,区域大小为 根据控件的布局,由包ui本身决定 在窗口中,该区域位于和所述窗口的大小。 无法查询该区域的大小或在其 大小更改;相反,您将获得区域大小作为 绘图和鼠标事件处理程序,仅用于 处理程序。
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.
滚动区域有水平和垂直滚动条。金额 可以滚动的是由区域大小决定的,即 由程序员决定(创建区域时和 调用SetSize)。任何时候只有一部分区域是可见的; 绘图和鼠标事件将自动调整为匹配 什么部分是可见的,所以不必担心滚动 在事件处理程序中。AreaHandler有更多信息。
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.
区域的内部坐标系是点,它们是 与浮点和设备无关。有关详细信息,请参见 区域处理程序。滚动区域的大小必须是一个精确的整数 点数(即不能有32.5的区域 点高),因此参数为NewScrollingArea和 设置大小为整数。参数中点的所有其他实例和 结构(包括绘制对象的大小)是float64。
func NewArea(handler AreaHandler) *Area
NewArea creates a new non-scrolling Area.
new Area创建一个新的非滚动区域。
func NewScrollingArea(handler AreaHandler, width int, height int) *Area
NewScrollingArea creates a new scrolling Area of the given size, in points.
newscorlinngarea创建一个给定大小的新滚动区域, 在点上。
Destroy destroys the Area.
摧毁摧毁这个地区。
QueueRedrawAll queues the entire Area for redraw. The Area is not redrawn before this function returns; it is redrawn when next possible.
QueueRedrawAll将整个区域排队进行重绘。 在该函数返回之前,不会重新绘制该区域;它是 下次可能时重新绘制。
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.
scroll滚动区域以显示给定的矩形;这是什么 方法是实现定义的,但您可以安全地假设 尽可能多的给定矩形将是可见的 在这个电话之后。(要在OS X上验证这一点)调用时滚动到panics 在非滚动区域。
SetSize sets the size of a scrolling Area to the given size, in points. SetSize panics if called on a non-scrolling Area.
SetSize将滚动区域的大小设置为给定大小(以磅为单位)。 如果在非滚动区域调用SetSize panics。
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.
AreaDrawParams提供可用于在区域上绘制的绘图上下文,并告诉您在何处绘制。有关介绍信息,请参阅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).
AreaHandler定义处理事件所需的功能 从一个地区。AreaHandler上的每个方法都是从 GUI线程和每个参数(除了区域本身) 应假定仅在方法有效期内有效 调用(例如,不要将AreaDrawParams.AreaWidth另存为 这可能会在不生成事件的情况下发生变化)。
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
要绘制的坐标和鼠标事件以点表示。点数 是通用的、浮点的、与设备无关的坐标 (0,0)在左上角。你不必担心 点和像素之间的映射;只需使用 点,你会得到很好的效果,比如在高DPI下看起来很锐利 免费的监视器。关于这件事的适当文件正在 写的。同时,也有一些关于这种 最引人注目的是苹果网站上的绘画: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.
对于滚动区域,点会被滚动自动偏移 位置。所以如果鼠标移动到位置(5,5),而 水平滚动条位于位置10,水平滚动条位于 在位置20,存储在区域鼠标事件中的坐标 结构为(15,25)。这同样适用于绘图。
TODO document all these
要记录所有这些
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
注意,在拖动的情况下,X和Y可能超出界限,或者在滚动区域的情况下,在不可见的地方
At represents a side of a Control to add other Controls to a Grid to.
At表示要将其他控件添加到网格的控件的一侧。
type Attribute interface {
// contains filtered or unexported methods
}
Attribute stores information about an attribute in an AttributedString.
属性将有关属性的信息存储在 属性字符串。
The following types can be used as Attributes:
以下类型可以用作属性:
- TextFamily - TextSize - TextWeight - TextItalic - TextStretch - TextColor - TextBackground - Underline - UnderlineColor - UnderlineColorCustom - OpenTypeFeatures
For every Unicode codepoint in the AttributedString, at most one value of each attribute type can be applied.
对于AttributedString中的每个Unicode码位,最多一个 可以应用每个属性类型的值。
type AttributedString struct {
// contains filtered or unexported fields
}
AttributedString represents a string of UTF-8 text that can optionally be embellished with formatting attributes. Package ui provides the list of formatting attributes, which cover common formatting traits like boldface and color as well as advanced typographical features provided by OpenType like superscripts and small caps. These attributes can be combined in a variety of ways.
AttributedString表示可以 可以选择使用格式化属性进行修饰。包用户界面 提供格式属性列表,其中包含 设置粗体、颜色和高级等特征的格式 OpenType提供的印刷特征,如上标 还有小帽子。这些属性可以组合为 方式。
Attributes are applied to runs of Unicode codepoints in the string. Zero-length runs are elided. Consecutive runs that have the same attribute type and value are merged. Each attribute is independent of each other attribute; overlapping attributes of different types do not split each other apart, but different values of the same attribute type do.
属性应用于字符串中Unicode代码点的运行。 零长度运行被省略。具有相同的连续运行 属性类型和值合并。每个属性都是独立的 相互重叠的属性;不同类型的重叠属性 不要把彼此分开,但是相同的值是不同的 属性类型do。
The empty string can also be represented by AttributedString, but because of the no-zero-length-attribute rule, it will not have attributes.
空字符串也可以用AttributedString表示, 但是由于没有零长度属性规则,它将没有 属性。
Unlike Go strings, AttributedStrings are mutable.
与Go字符串不同,AttributedStrings是可变的。
AttributedString allocates resources within libui, which package ui sits on top of. As such, when you are finished with an AttributedString, you must free it with Free. Like other things in package ui, AttributedString must only be used from the main goroutine.
AttributedString在libui中分配资源,哪个包 用户界面位于顶部。因此,当你完成一个 AttributedString,必须用free释放它。就像里面的其他东西 包ui,AttributedString只能从main中使用 戈鲁廷。
In addition, AttributedString provides facilities for moving between grapheme clusters, which represent a character from the point of view of the end user. The cursor of a text editor is always placed on a grapheme boundary, so you can use these features to move the cursor left or right by one "character". TODO does uiAttributedString itself need this
此外,AttributedString还提供了移动 在表示字符的字形簇之间 从最终用户的角度来看。文本编辑器的光标 总是放在一个字形边界上,所以您可以使用 将光标向左或向右移动一个“字符”的功能。 TODO uiAttributedString本身需要这个
AttributedString does not provide enough information to be able to draw itself onto a DrawContext or respond to user actions. In order to do that, you'll need to use a DrawTextLayout, which is built from the combination of an AttributedString and a set of layout-specific properties.
AttributedString提供的信息不足,无法 将自身绘制到DrawContext或响应用户操作。 为此,您需要使用DrawTextLayout,它 是由AttributedString和一组 布局特定属性。
func NewAttributedString(initialString string) *AttributedString
NewAttributedString creates a new AttributedString from initialString. The string will be entirely unattributed.
func (s *AttributedString) AppendUnattributed(str string)
AppendUnattributed adds str to the end of s. The new substring will be unattributed.
func (s *AttributedString) Delete(start, end int)
Delete deletes the characters and attributes of s in the byte range [start, end).
func (s *AttributedString) Free()
Free destroys s.
func (s *AttributedString) InsertAtUnattributed(str string, at int)
InsertAtUnattributed adds str to s at the byte position specified by at. The new substring will be unattributed; existing attributes will be moved along with their text.
func (s *AttributedString) SetAttribute(a Attribute, start, end int)
SetAttribute sets a in the byte range [start, end) of s. Any existing attributes in that byte range of the same type are removed.
func (s *AttributedString) String() string
String returns the textual content of s.
type Box struct { ControlBase // 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").
NewHorizontalBox creates a new horizontal Box.
NewVerticalBox creates a new vertical Box.
Append adds the given control to the end of the Box.
Delete deletes the nth control of the Box.
Destroy destroys the Box. If the Box has children, Destroy calls Destroy on those Controls as well.
Padded returns whether there is space between each control of the Box.
SetPadded controls whether there is space between each control of the Box. The size of the padding is determined by the OS and its best practices.
type Button struct { ControlBase // 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.
NewButton creates a new Button with the given text as its label.
OnClicked registers f to be run when the user clicks the Button. Only one function can be registered at a time.
SetText sets the Button's text to text.
Text returns the Button's text.
type Checkbox struct { ControlBase // 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.
NewCheckbox creates a new Checkbox with the given text as its label.
Checked returns whether the Checkbox is checked.
OnToggled registers f to be run when the user clicks the Checkbox. Only one function can be registered at a time.
SetChecked sets whether the Checkbox is checked.
SetText sets the Checkbox's text to text.
Text returns the Checkbox's text.
type ColorButton struct { ControlBase // contains filtered or unexported fields }
ColorButton is a Control that represents a button that the user can click to select a color.
func NewColorButton() *ColorButton
NewColorButton creates a new ColorButton.
func (b *ColorButton) Color() (r, g, bl, a float64)
Color returns the color currently selected in the ColorButton. Colors are not alpha-premultiplied. TODO rename b or bl
func (b *ColorButton) OnChanged(f func(*ColorButton))
OnChanged registers f to be run when the user changes the currently selected color in the ColorButton. Only one function can be registered at a time.
func (b *ColorButton) SetColor(r, g, bl, a float64)
SetColor sets the currently selected color in the ColorButton. Colors are not alpha-premultiplied. TODO rename b or bl
type Combobox struct { ControlBase // 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. For a Combobox that users can type values into, see EditableCombobox.
NewCombobox creates a new Combobox.
Append adds the named item to the end of the Combobox.
OnSelected registers f to be run when the user selects an item in the Combobox. Only one function can be registered at a time.
Selected returns the index of the currently selected item in the Combobox, or -1 if nothing is selected.
SetSelected sets the currently selected item in the Combobox to index. If index is -1 no item will be selected.
type Control interface { // LibuiControl returns the uiControl pointer for the Control. // This is intended for use when adding a control to a // container. LibuiControl() uintptr // Destroy destroys the Control. Destroy() // 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. Handle() uintptr // Visible returns whether the Control is visible. Visible() bool // Show shows the Control. Show() // Hide shows the Control. Hidden controls do not participate // in layout (that is, Box, Grid, etc. does not reserve space for // hidden controls). Hide() // Enabled returns whether the Control is enabled. Enabled() bool // Enable enables the Control. Enable() // Disable disables the Control. Disable() }
Control represents a GUI control. It provdes methods common to all Controls.
The preferred way to create new Controls is to use ControlBase; see ControlBase below.
ControlFromLibui returns the Control associated with a libui uiControl. This is intended for implementing event handlers on the Go side, to prevent sharing Go pointers with C. This function only works on Controls that use ControlBase.
type ControlBase struct {
// contains filtered or unexported fields
}
ControlBase is an implementation of Control that provides all the methods that Control requires. To use it, embed a ControlBase (not a *ControlBase) into your structure, then assign the result of NewControlBase to that field:
type MyControl struct { ui.ControlBase c *C.MyControl } func NewMyControl() *MyControl { m := &NewMyControl{ c: C.newMyControl(), } m.ControlBase = ui.NewControlBase(m, uintptr(unsafe.Pointer(c))) return m }
func NewControlBase(iface Control, c uintptr) ControlBase
NewControlBase creates a new ControlBase. See the documentation of ControlBase for an example. NewControl should only be called once per instance of Control.
func (c *ControlBase) Destroy()
func (c *ControlBase) Disable()
func (c *ControlBase) Enable()
func (c *ControlBase) Enabled() bool
func (c *ControlBase) Handle() uintptr
func (c *ControlBase) Hide()
func (c *ControlBase) LibuiControl() uintptr
func (c *ControlBase) Show()
func (c *ControlBase) Visible() bool
type DateTimePicker struct { ControlBase // 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() *DateTimePicker
NewDatePicker creates a new DateTimePicker that shows only a date.
func NewDateTimePicker() *DateTimePicker
NewDateTimePicker creates a new DateTimePicker that shows both a date and a time.
func NewTimePicker() *DateTimePicker
NewTimePicker creates a new DateTimePicker that shows only a time.
func (d *DateTimePicker) OnChanged(f func(*DateTimePicker))
OnChanged registers f to be run when the user changes the time in the DateTimePicker. Only one function can be registered at a time.
func (d *DateTimePicker) SetTime(t time.Time)
SetTime sets the time in the DateTimePicker to t. t's components are read as-is via t.Date() and t.Clock(); no time zone manipulations are done.
func (d *DateTimePicker) Time() time.Time
Time returns the time stored in the uiDateTimePicker. The time is assumed to be local time.
type DrawBrush struct { Type DrawBrushType // 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 []DrawGradientStop }
TODO
DrawBrushType defines the various types of brushes.
TODO disclaimer
const ( DrawBrushTypeSolid DrawBrushType = iota DrawBrushTypeLinearGradient DrawBrushTypeRadialGradient DrawBrushTypeImage // presently unimplemented )
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 (c *DrawContext) Clip(p *DrawPath)
TODO
func (c *DrawContext) Fill(p *DrawPath, b *DrawBrush)
TODO
func (c *DrawContext) Restore()
TODO
func (c *DrawContext) Save()
TODO
func (c *DrawContext) Stroke(p *DrawPath, b *DrawBrush, sp *DrawStrokeParams)
TODO
func (c *DrawContext) Text(tl *DrawTextLayout, x, y float64)
Text draws tl in c with the top-left point of tl at (x, y).
func (c *DrawContext) Transform(m *DrawMatrix)
TODO
TODO
TODO disclaimer
const ( DrawFillModeWinding DrawFillMode = iota DrawFillModeAlternate )
type DrawGradientStop struct { Pos float64 // between 0 and 1 inclusive R float64 G float64 B float64 A float64 }
TODO
TODO
TODO disclaimer TODO rename these to put LineCap at the beginning? or just Cap?
const ( DrawLineCapFlat DrawLineCap = iota DrawLineCapRound DrawLineCapSquare )
TODO
TODO disclaimer
const ( DrawLineJoinMiter DrawLineJoin = iota DrawLineJoinRound DrawLineJoinBevel )
TODO TODO should the methods of these return self for chaining?
func DrawNewMatrix() *DrawMatrix
TODO identity matrix
func (m *DrawMatrix) Invert() bool
TODO
If m is not invertible, false is returned and m is left unchanged.
func (m *DrawMatrix) Invertible() bool
TODO
func (m *DrawMatrix) Multiply(m2 *DrawMatrix)
TODO
func (m *DrawMatrix) Rotate(x float64, y float64, amount float64)
TODO
TODO
func (m *DrawMatrix) SetIdentity()
TODO
TODO
TODO unimplemented
TODO unimplemented
func (m *DrawMatrix) Translate(x float64, y float64)
TODO
type DrawPath struct {
// contains filtered or unexported fields
}
DrawPath 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 := DrawNewPath() 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 DrawPath also defines its fill mode. (This should ideally be a fill parameter, but some implementations prevent it.) TODO talk about fill modes
func DrawNewPath(fillMode DrawFillMode) *DrawPath
DrawNewPath creates a new DrawPath with the given fill mode.
AddRectangle creates a new figure in the DrawPath 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 (p *DrawPath) ArcTo(xCenter float64, yCenter float64, radius float64, startAngle float64, sweep float64, isNegative bool)
ArcTo adds a circular arc to the current figure of the DrawPath. 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 (p *DrawPath) 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 DrawPath. 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.
CloseFigure draws a line segment from the current point of the current figure of the DrawPath back to its initial point. After calling this, the current figure is over and you must either start a new figure or end the DrawPath. If this is not called and you start a new figure or end the DrawPath, then the current figure will not have this closing line segment added to it (but the figure will still be over).
End ends the current DrawPath. You cannot add figures to a DrawPath that has been ended. You cannot draw with a DrawPath that has not been ended.
Free destroys a DrawPath. After calling Free the DrawPath cannot be used.
LineTo adds a line to the current figure of the DrawPath starting from the current point and ending at the given point. The current point is set to the ending point.
NewFigure starts a new figure in the DrawPath. The current point is set to the given point.
func (p *DrawPath) NewFigureWithArc(xCenter float64, yCenter float64, radius float64, startAngle float64, sweep float64, isNegative bool)
NewFigureWithArc starts a new figure in the DrawPath 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 DrawStrokeParams struct { Cap DrawLineCap Join DrawLineJoin Thickness float64 MiterLimit float64 Dashes []float64 DashPhase float64 }
TODO
DrawTextAlign specifies the alignment of lines of text in a DrawTextLayout. TODO should this really have Draw in the name?
const ( DrawTextAlignLeft DrawTextAlign = iota DrawTextAlignCenter DrawTextAlignRight )
type DrawTextLayout struct {
// contains filtered or unexported fields
}
DrawTextLayout is a concrete representation of an AttributedString that can be displayed in a DrawContext. It includes information important for the drawing of a block of text, including the bounding box to wrap the text within, the alignment of lines of text within that box, areas to mark as being selected, and other things.
Unlike AttributedString, the content of a DrawTextLayout is immutable once it has been created.
TODO talk about OS-specific differences with text drawing that libui can't account for...
func DrawNewTextLayout(p *DrawTextLayoutParams) *DrawTextLayout
DrawNewTextLayout() creates a new DrawTextLayout from the given parameters.
func (tl *DrawTextLayout) Free()
Free frees tl. The underlying AttributedString is not freed.
type DrawTextLayoutParams struct { String *AttributedString DefaultFont *FontDescriptor Width float64 Align DrawTextAlign }
DrawTextLayoutParams describes a DrawTextLayout. DefaultFont is used to render any text that is not attributed sufficiently in String. Width determines the width of the bounding box of the text; the height is determined automatically.
type EditableCombobox struct { ControlBase // contains filtered or unexported fields }
EditableCombobox is a Control that represents a drop-down list of strings that the user can choose one of at any time. It also has an entry field that the user can type an alternate choice into.
func NewEditableCombobox() *EditableCombobox
NewEditableCombobox creates a new EditableCombobox.
func (e *EditableCombobox) Append(text string)
Append adds the named item to the end of the EditableCombobox.
func (e *EditableCombobox) OnChanged(f func(*EditableCombobox))
OnChanged registers f to be run when the user either selects an item or changes the text in the EditableCombobox. Only one function can be registered at a time.
func (e *EditableCombobox) SetText(text string)
SetText sets the text in the entry of the EditableCombobox.
func (e *EditableCombobox) Text() string
Text returns the text in the entry of the EditableCombobox, which could be one of the choices in the list if the user has selected one.
type Entry struct { ControlBase // contains filtered or unexported fields }
Entry is a Control that represents a space that the user can type a single line of text into.
NewEntry creates a new Entry.
NewPasswordEntry creates a new Entry whose contents are visibly obfuscated, suitable for passwords.
NewSearchEntry creates a new Entry suitable for searching with. Changed events may, depending on the system, be delayed with a search Entry, to produce a smoother user experience.
OnChanged registers f to be run when the user makes a change to the Entry. Only one function can be registered at a time.
ReadOnly returns whether the Entry can be changed.
SetReadOnly sets whether the Entry can be changed.
SetText sets the Entry's text to text.
Text returns the Entry's text.
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 FontButton struct { ControlBase // contains filtered or unexported fields }
FontButton is a Control that represents a button that the user can click to select a font.
func NewFontButton() *FontButton
NewFontButton creates a new FontButton.
func (b *FontButton) Font() *FontDescriptor
Font returns the font currently selected in the FontButton.
func (b *FontButton) OnChanged(f func(*FontButton))
OnChanged registers f to be run when the user changes the currently selected font in the FontButton. Only one function can be registered at a time.
type FontDescriptor struct { Family TextFamily Size TextSize Weight TextWeight Italic TextItalic Stretch TextStretch }
FontDescriptor provides a complete description of a font where one is needed. Currently, this means as the default font of a DrawTextLayout and as the data returned by FontButton.
type Form struct { ControlBase // contains filtered or unexported fields }
Form is a Control that holds a group of Controls vertically with labels next to each. By default, each control has its preferred height; 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").
NewForm creates a new horizontal Form.
Append adds the given control to the end of the Form.
Delete deletes the nth control of the Form.
Destroy destroys the Form. If the Form has children, Destroy calls Destroy on those Controls as well.
Padded returns whether there is space between each control of the Form.
SetPadded controls whether there is space between each control of the Form. The size of the padding is determined by the OS and its best practices.
type Grid struct { ControlBase // contains filtered or unexported fields }
Grid is a Control that arranges other Controls in a grid. Grid is a very powerful container: it can position and size each Control in several ways and can (and must) have Controls added to it in any direction. It can also have Controls spanning multiple rows and columns.
Each Control in a Grid has associated "expansion" and "alignment" values in both the X and Y direction. Expansion determines whether all cells in the same row/column are given whatever space is left over after figuring out how big the rest of the Grid should be. Alignment determines the position of a Control relative to its cell after computing the above. The special alignment Fill can be used to grow a Control to fit its cell. Note that expansion and alignment are independent variables. For more information on expansion and alignment, read https://developer.gnome.org/gtk3/unstable/ch28s02.html.
NewGrid creates a new Grid.
func (g *Grid) Append(child Control, left, top int, xspan, yspan int, hexpand bool, halign Align, vexpand bool, valign Align)
Append adds the given control to the Grid, at the given coordinate.
func (g *Grid) InsertAt(child Control, existing Control, at At, xspan, yspan int, hexpand bool, halign Align, vexpand bool, valign Align)
InsertAt adds the given control to the Grid relative to an existing control.
Padded returns whether there is space between each control of the Grid.
SetPadded controls whether there is space between each control of the Grid. The size of the padding is determined by the OS and its best practices.
type Group struct { ControlBase // 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.
NewGroup creates a new Group.
Destroy destroys the Group. If the Group has a child, Destroy calls Destroy on that as well.
Margined returns whether the Group has margins around its child.
SetChild sets the Group's child to child. If child is nil, the Group will not have a child.
SetMargined controls whether the Group has margins around its child. The size of the margins are determined by the OS and its best practices.
SetTitle sets the Group's title to title.
Title returns the Group's title.
type Image struct {
// contains filtered or unexported fields
}
Image stores an image for display on screen.
Images are built from one or more representations, each with the same aspect ratio but a different pixel size. Package ui automatically selects the most appropriate representation for drawing the image when it comes time to draw the image; what this means depends on the pixel density of the target context. Therefore, one can use Image to draw higher-detailed images on higher-density displays. The typical use cases are either:
- have just a single representation, at which point all screens use the same image, and thus uiImage acts like a simple bitmap image, or - have two images, one at normal resolution and one at 2x resolution; this matches the current expectations of some desktop systems at the time of writing (mid-2018)
Image allocates OS resources; you must explicitly free an Image when you are finished with it.
NewImage creates a new Image with the given width and height. This width and height should be the size in points of the image in the device-independent case; typically this is the 1x size.
Append adds the given image as a representation of the Image.
Free frees the Image.
type Label struct { ControlBase // contains filtered or unexported fields }
Label is a Control that represents a line of text that cannot be interacted with.
NewLabel creates a new Label with the given text.
SetText sets the Label's text to text.
Text returns the Label's text.
TODO document
Note: these must be numerically identical to their libui equivalents.
type MultilineEntry struct { ControlBase // 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() *MultilineEntry
NewMultilineEntry creates a new MultilineEntry. The MultilineEntry soft-word-wraps and has no horizontal scrollbar.
func NewNonWrappingMultilineEntry() *MultilineEntry
NewNonWrappingMultilineEntry creates a new MultilineEntry. The MultilineEntry does not word-wrap and thus has horizontal scrollbar.
func (m *MultilineEntry) Append(text string)
Append adds text to the end of the MultilineEntry's text. TODO selection and scroll behavior
func (m *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 (m *MultilineEntry) ReadOnly() bool
ReadOnly returns whether the MultilineEntry can be changed.
func (m *MultilineEntry) SetReadOnly(ro bool)
SetReadOnly sets whether the MultilineEntry can be changed.
func (m *MultilineEntry) SetText(text string)
SetText sets the MultilineEntry's text to text.
func (m *MultilineEntry) Text() string
Text returns the MultilineEntry's text.
type OpenTypeFeatures map[OpenTypeTag]uint32
OpenTypeFeatures is an Attribute that represents a set of OpenType feature tag-value pairs, for applying OpenType features to text. OpenType feature tags are four-character codes defined by OpenType that cover things from design features like small caps and swashes to language-specific glyph shapes and beyond. Each tag may only appear once in any given uiOpenTypeFeatures instance. Each value is a 32-bit integer, often used as a Boolean flag, but sometimes as an index to choose a glyph shape to use.
If a font does not support a certain feature, that feature will be ignored. (TODO verify this on all OSs)
See the OpenType specification at https://www.microsoft.com/typography/otspec/featuretags.htm for the complete list of available features, information on specific features, and how to use them. TODO invalid features
Note that if a feature is not present in a OpenTypeFeatures, the feature is NOT treated as if its value was zero, unlike in Go. Script-specific font shaping rules and font-specific feature settings may use a different default value for a feature. You should likewise NOT treat a missing feature as having a value of zero either. Instead, a missing feature should be treated as having some unspecified default value.
Note that despite OpenTypeFeatures being a map, its contents are copied by AttributedString. Modifying an OpenTypeFeatures after giving it to an AttributedString, or modifying one that comes out of an AttributedString, will have no effect.
OpenTypeTag represents a four-byte OpenType feature tag.
func ToOpenTypeTag(a, b, c, d byte) OpenTypeTag
ToOpenTypeTag converts the four characters a, b, c, and d into an OpenTypeTag.
type ProgressBar struct { ControlBase // 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 NewProgressBar() *ProgressBar
NewProgressBar creates a new ProgressBar.
func (p *ProgressBar) SetValue(value int)
SetValue sets the ProgressBar's currently displayed percentage to value. value must be between 0 and 100 inclusive, or -1 for an indeterminate progressbar.
func (p *ProgressBar) Value() int
Value returns the value currently shown in the ProgressBar.
type RadioButtons struct { ControlBase // 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() *RadioButtons
NewRadioButtons creates a new RadioButtons.
func (r *RadioButtons) Append(text string)
Append adds the named button to the end of the RadioButtons.
func (r *RadioButtons) OnSelected(f func(*RadioButtons))
OnSelected registers f to be run when the user selects an option in the RadioButtons. Only one function can be registered at a time.
func (r *RadioButtons) Selected() int
Selected returns the index of the currently selected option in the RadioButtons, or -1 if no item is selected.
func (r *RadioButtons) SetSelected(index int)
SetSelected sets the currently selected option in the RadioButtons to index.
type Separator struct { ControlBase // contains filtered or unexported fields }
Separator is a Control that represents a horizontal line that visually separates controls.
NewHorizontalSeparator creates a new horizontal Separator.
NewVerticalSeparator creates a new vertical Separator.
type Slider struct { ControlBase // 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.
NewSlider creates a new Slider. If min >= max, they are swapped.
OnChanged registers f to be run when the user changes the value of the Slider. Only one function can be registered at a time.
SetValue sets the Slider's current value to value.
Value returns the Slider's current value.
type Spinbox struct { ControlBase // 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.
NewSpinbox creates a new Spinbox. If min >= max, they are swapped.
OnChanged registers f to be run when the user changes the value of the Spinbox. Only one function can be registered at a time.
SetValue sets the Spinbox's current value to value.
Value returns the Spinbox's current value.
type Tab struct { ControlBase // 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.
NewTab creates a new Tab.
Append adds the given page to the end of the Tab.
Delete deletes the nth page of the Tab.
Destroy destroys the Tab. If the Tab has pages, Destroy calls Destroy on the pages's Controls as well.
InsertAt adds the given page to the Tab such that it is the nth page of the Tab (starting at 0).
Margined returns whether page n (starting at 0) of the Tab has margins around its child.
NumPages returns the number of pages in the Tab.
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 Table struct { ControlBase // contains filtered or unexported fields }
Table is a Control that shows tabular data, allowing users to manipulate rows of such data at a time.
func NewTable(p *TableParams) *Table
NewTable creates a new Table with the specified parameters.
func (t *Table) AppendButtonColumn(name string, buttonModelColumn int, buttonClickableModelColumn int)
AppendButtonColumn appends a column to t that shows a button that the user can click on. When the user does click on the button, SetCellValue is called with a nil value and buttonModelColumn as the column. CellValue on buttonModelColumn should return the text to show in the button.
func (t *Table) AppendCheckboxColumn(name string, checkboxModelColumn int, checkboxEditableModelColumn int)
AppendCheckboxColumn appends a column to t that contains a checkbox that the user can interact with (assuming the checkbox is editable). SetCellValue will be called with checkboxModelColumn as the column in this case.
func (t *Table) AppendCheckboxTextColumn(name string, checkboxModelColumn int, checkboxEditableModelColumn int, textModelColumn int, textEditableModelColumn int, textParams *TableTextColumnOptionalParams)
AppendCheckboxTextColumn appends a column to t that contains both a checkbox and text.
AppendImageColumn appends an image column to t. Images are drawn at icon size, appropriate to the pixel density of the screen showing the Table.
func (t *Table) AppendImageTextColumn(name string, imageModelColumn int, textModelColumn int, textEditableModelColumn int, textParams *TableTextColumnOptionalParams)
AppendImageTextColumn appends a column to t that shows both an image and text.
AppendProgressBarColumn appends a column to t that displays a progress bar. These columns work like ProgressBar: a cell value of 0..100 displays that percentage, and a cell value of -1 displays an indeterminate progress bar.
func (t *Table) AppendTextColumn(name string, textModelColumn int, textEditableModelColumn int, textParams *TableTextColumnOptionalParams)
AppendTextColumn appends a text column to t. name is displayed in the table header. textModelColumn is where the text comes from. If a row is editable according to textEditableModelColumn, SetCellValue is called with textModelColumn as the column.
TableColor is a TableValue that represents a color.
TableImage is a TableValue that represents an Image. Ownership of the Image is not copied; you must keep it alive alongside the TableImage.
TableInt is a TableValue that stores integers. These are used for progressbars. Due to current limitations of libui, they also represent checkbox states, via TableFalse and TableTrue.
TableFalse and TableTrue are the Boolean constants for TableInt.
type TableModel struct {
// contains filtered or unexported fields
}
TableModel is an object that provides the data for a Table. This data is returned via methods you provide in the TableModelHandler interface.
TableModel represents data using a table, but this table does not map directly to Table itself. Instead, you can have data columns which provide instructions for how to render a given Table's column — for instance, one model column can be used to give certain rows of a Table a different background color. Row numbers DO match with uiTable row numbers.
Once created, the number and data types of columns of a TableModel cannot change.
Row and column numbers start at 0. A TableModel can be associated with more than one Table at a time.
func NewTableModel(handler TableModelHandler) *TableModel
NewTableModel creates a new TableModel.
func (m *TableModel) Free()
Free frees m. It is an error to Free any models associated with a Table.
func (m *TableModel) RowChanged(index int)
RowChanged tells any Tables associated with m that the data in the row at index has changed. You do not need to call this in your SetCellValue handlers, but you do need to call this if your data changes at some other point.
func (m *TableModel) RowDeleted(index int)
RowDeleted tells any Tables associated with m that the row at index index has been deleted. You call this function when the number of rows in your model has changed; after calling it, NumRows should returm the new row count.
func (m *TableModel) RowInserted(index int)
RowInserted tells any Tables associated with m that a new row has been added to m at index index. You call this method when the number of rows in your model has changed; after calling it, NumRows should returm the new row count.
type TableModelHandler interface { // ColumnTypes returns a slice of value types of the data // stored in the model columns of the TableModel. // Each entry in the slice should ideally be a zero value for // the TableValue type of the column in question; the number // of elements in the slice determines the number of model // columns in the TableModel. The returned slice must remain // constant through the lifetime of the TableModel. This // method is not guaranteed to be called depending on the // system. ColumnTypes(m *TableModel) []TableValue // NumRows returns the number or rows in the TableModel. // This value must be non-negative. NumRows(m *TableModel) int // CellValue returns a TableValue corresponding to the model // cell at (row, column). The type of the returned TableValue // must match column's value type. Under some circumstances, // nil may be returned; refer to the various methods that add // columns to Table for details. CellValue(m *TableModel, row, column int) TableValue // SetCellValue changes the model cell value at (row, column) // in the TableModel. Within this function, either do nothing // to keep the current cell value or save the new cell value as // appropriate. After SetCellValue is called, the Table will // itself reload the table cell. Under certain conditions, the // TableValue passed in can be nil; refer to the various // methods that add columns to Table for details. SetCellValue(m *TableModel, row, column int, value TableValue) }
TableModelHandler defines the methods that TableModel calls when it needs data.
type TableParams struct { // Model is the TableModel to use for this uiTable. // This parameter cannot be nil. Model *TableModel // RowBackgroundColorModelColumn is a model column // number that defines the background color used for the // entire row in the Table, or -1 to use the default color for // all rows. // // If CellValue for this column for any row returns NULL, that // row will also use the default background color. RowBackgroundColorModelColumn int }
TableParams defines the parameters passed to NewTable.
TableString is a TableValue that stores a string. TableString is used for displaying text in a Table.
type TableTextColumnOptionalParams struct { // ColorModelColumn is the model column containing the // text color of this Table column's text, or -1 to use the // default color. // // If CellValue for this column for any cell returns nil, that // cell will also use the default text color. ColorModelColumn int }
TableTextColumnOptionalParams are the optional parameters that control the appearance of the text column of a Table.
type TableValue interface {
// contains filtered or unexported methods
}
TableValue is a type that represents a piece of data that can come out of a TableModel.
TextBackground is an Attribute that changes the background color of the text it is applied to.
TextColor is an Attribute that changes the color of the text it is applied to.
TextFamily is an Attribute that changes the font family of the text it is applied to. Font family names are case-insensitive.
TextItalic is an Attribute that changes the italic mode of the text it is applied to. Italic represents "true" italics where the slanted glyphs have custom shapes, whereas oblique represents italics that are merely slanted versions of the normal glyphs. Most fonts usually have one or the other.
const ( TextItalicNormal TextItalic = iota TextItalicOblique TextItalicItalic )
TextSize is an Attribute that changes the size of the text it is applied to, in typographical points.
TextStretch is an Attribute that changes the stretch (also called "width") of the text it is applied to.
Note that due to restrictions in early versions of Windows, some fonts have "special" stretches be exposed in many programs as separate font families. This is perhaps most notable with Arial Condensed. Package ui does not do this, even on Windows (because the DirectWrite API package ui uses on Windows does not do this); to specify Arial Condensed, use family Arial and stretch TextStretchCondensed.
const ( TextStretchUltraCondensed TextStretch = iota TextStretchExtraCondensed TextStretchCondensed TextStretchSemiCondensed TextStretchNormal TextStretchSemiExpanded TextStretchExpanded TextStretchExtraExpanded TextStretchUltraExpanded )
TextWeight is an Attribute that changes the weight of the text it is applied to. These roughly map to the OS/2 text weight field of TrueType and OpenType fonts, or to CSS weight numbers. The named constants are nominal values; the actual values may vary by font and by OS, though this isn't particularly likely. Any value between TextWeightMinimum and TextWeightMaximum, inclusive, is allowed.
Note that due to restrictions in early versions of Windows, some fonts have "special" weights be exposed in many programs as separate font families. This is perhaps most notable with Arial Black. Package ui does not do this, even on Windows (because the DirectWrite API libui uses on Windows does not do this); to specify Arial Black, use family Arial and weight TextWeightBlack.
const ( TextWeightMinimum TextWeight = 0 TextWeightThin TextWeight = 100 TextWeightUltraLight TextWeight = 200 TextWeightLight TextWeight = 300 TextWeightBook TextWeight = 350 TextWeightNormal TextWeight = 400 TextWeightMedium TextWeight = 500 TextWeightSemiBold TextWeight = 600 TextWeightBold TextWeight = 700 TextWeightUltraBold TextWeight = 800 TextWeightHeavy TextWeight = 900 TextWeightUltraHeavy TextWeight = 950 TextWeightMaximum TextWeight = 1000 )
Underline is an Attribute that specifies a type of underline to use on text.
const ( UnderlineNone Underline = iota UnderlineSingle UnderlineDouble UnderlineSuggestion // wavy or dotted underlines used for spelling/grammar checkers )
UnderlineColor is an Attribute that changes the color of any underline on the text it is applied to, regardless of the type of underline. In addition to being able to specify the platform-specific colors for suggestion underlines here, you can also use a custom color with UnderlineColorCustom.
To use the constants here correctly, pair them with UnderlineSuggestion (though they can be used on other types of underline as well).
If an underline type is applied but no underline color is specified, the text color is used instead. If an underline color is specified without an underline type, the underline color attribute is ignored, but not removed from the uiAttributedString.
const ( UnderlineColorSpelling UnderlineColor = iota + 1 UnderlineColorGrammar UnderlineColorAuxiliary // for instance, the color used by smart replacements on macOS or in Microsoft Office )
UnderlineColorCustom is an Attribute like UnderlineColor, except it allows specifying a custom color.
type Window struct { ControlBase // 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.
NewWindow creates a new Window.
Borderless returns whether the Window is borderless.
Destroy destroys the Window. If the Window has a child, Destroy calls Destroy on that as well.
Margined returns whether the Window has margins around its child.
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.
SetBorderless sets the Window to be borderless or not.
SetChild sets the Window's child to child. If child is nil, the Window will not have a child.
SetMargined controls whether the Window has margins around its child. The size of the margins are determined by the OS and its best practices.
SetTitle sets the Window's title to title.
Title returns the Window's title.
Path | Synopsis |
---|---|
winmanifest | Package winmanifest provides a basic manifest for use with package ui. |
Package ui imports 7 packages (graph) and is imported by 44 packages. Updated 2 months ago. Refresh now. Tools for package owners.