High level wrapper for libui-ng.
Documentation mainly from ui.h
Author: | Jasmine |
---|
See also
- genui macro
Types
Attribute = ref object
-
Attribute stores information about an attribute in a AttributedString.
You do not create Attributes directly; instead, you create a Attribute of a given type using the specialized constructor functions. For every Unicode codepoint in the AttributedString, at most one value of each attribute type can be applied.
Attributes are immutable.
Source Edit AttributedString = ref object
-
AttributedString represents a string of UTF-8 text that can optionally be embellished with formatting attributes. libui-ng 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.
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.
The empty string can also be represented by AttributedString, but because of the no-zero-length-attribute rule, it will not have attributes.
A AttributedString takes ownership of all attributes given to it, as it may need to duplicate or delete Attribute objects at any time. By extension, when you free a AttributedString, all Attributes within will also be freed. Each method will describe its own rules in more details.
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".
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 a AttributedString and a set of layout-specific properties.
Source Edit Box = ref object of Widget children*: seq[Widget] ## The widgets contained within the box.
-
A boxlike container that holds a group of widgets.
The contained widgets are arranged to be displayed either horizontally or vertically next to each other.
Source Edit Button = ref object of Widget onclick*: proc (sender: Button) ## callback for when the button is clicked.
- A widget that visually represents a button to be clicked by the user to trigger an action. Source Edit
Checkbox = ref object of Widget ontoggled*: proc (sender: Checkbox) ## callback for when the checkbox is toggled by the user.
- A widget with a user checkable box accompanied by a text label. Source Edit
ColorButton = ref object of Widget onchanged*: proc (sender: ColorButton) ## Callback for when the color is changed.
-
A widget with a color indicator that opens a color chooser when clicked.
The widget visually represents a button with a color field representing the selected color.
Clicking on the button opens up a color chooser in form of a color palette.
Source Edit Combobox = ref object of Widget items*: seq[string] ## List of items in the combobox onselected*: proc (sender: Combobox) ## Callback for when a combo box item is selected.
- A widget to select one item from a predefined list of items via a drop down menu. Source Edit
DateTimePicker = ref object of Widget onchanged*: proc (sender: DateTimePicker) ## Callback for when the date time picker value is changed by the user.
-
A widget to enter a date and/or time.
All functions assume local time and do NOT perform any time zone conversions.
Source Edit DrawTextLayout = ref object
-
DrawTextLayout is a concrete representation of a 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.
Note: There are OS-specific differences with text drawing that libui-ng can't account forSource Edit EditableCombobox = ref object of Widget items*: seq[string] ## Predefined text items in the combo box onchanged*: proc (sender: EditableCombobox) ## Callback for when an editable combo box item is selected or user text changed.
-
A widget to select one item from a predefined list of items or enter ones own.
Predefined items can be selected from a drop down menu.
A customary item can be entered by the user via an editable text field.
Source Edit Entry = ref object of Widget onchanged*: proc (sender: Entry) ## Callback for when the user changes the entry's text.
- A widget with a single line text entry field. Source Edit
FontButton = ref object of Widget onchanged*: proc (sender: FontButton) ## Callback for when the font is changed.
- A button-like widget that opens a font chooser when clicked. Source Edit
Form = ref object of Widget chlidren*: seq[tuple[label: string, widget: Widget]]
-
A container widget to organize contained widgets as labeled fields.
As the name suggests this container is perfect to create ascetically pleasing input forms.
Each widget is preceded by it's corresponding label.
Labels and containers are organized into two panes, making both labels and containers align with each other.
Source Edit Grid = ref object of Widget children*: seq[Widget]
-
A widget container to arrange containing widgets in a grid.
Contained widgets are arranged on an imaginary grid of rows and columns. Widgets can be placed anywhere on this grid, spanning multiple rows and/or columns.
Additionally placed widgets can be programmed to expand horizontally and/or vertically, sharing the remaining space among other expanded widgets.
Alignment options are available via Align attributes to determine the widgets placement within the reserved area, should the area be bigger than the widget itself.
Widgets can also be placed in relation to other widget using At attributes.
Source Edit Group = ref object of Widget
-
A widget container that adds a label to the contained child widget.
This widget is a great way of grouping related widgets in combination with Box.
A visual box will or will not be drawn around the child widget dependent on the underlying OS implementation.
Source Edit Image = ref object of Widget
-
A container for an image to be displayed on screen.
The container can hold multiple representations of the same image with the same aspect ratio but in different resolutions to support high-density displays.
Common image dimension scale factors are 1x and 2x. Providing higher density representations is entirely optional.
The system will automatically determine the correct image to render depending on the screen's pixel density.
Image only supports premultiplied 32-bit RGBA images.
No image file loading or image format conversion utilities are provided.
Important: Image is only a container format for using with tables See libui-ng issue #229: https://github.com/libui-ng/libui-ng/issues/229Source Edit Menu = ref object of Widget children*: seq[MenuItem]
-
An application level menu bar.
The various operating systems impose different requirements on the creation and placement of menu bar items, hence the abstraction of the items Quit, Preferences and About.
An exemplary, cross platform menu bar:
- File
- New
- Open
- Save
- Quit, use addQuitItem()
- Edit
- Undo
- Redo
- Cut
- Copy
- Paste
- Select All
- Preferences, use addPreferencesItem()
- Help
- About, use addAboutItem()
- File
MenuItem = ref object of Widget onclicked*: proc (sender: MenuItem; window: Window) ## Callback for when the menu item is clicked.
- A menu item used in conjunction with Menu. Source Edit
MultilineEntry = ref object of Widget onchanged*: proc (sender: MultilineEntry) ## Callback for when the user changes the multi line entry's text.
- A widget with a multi line text entry field. Source Edit
OpenTypeFeatures = ref object
-
OpenTypeFeatures 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 OpenTypeFeatures 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.
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.
Source Edit ProgressBar = ref object of Widget
-
A widget that visualizes the progress of a task via the fill level of a horizontal bar.
Indeterminate values are supported via an animated bar.
Source Edit RadioButtons = ref object of Widget items*: seq[string] ## Seq of text of the radio buttons onselected*: proc (sender: RadioButtons) ## Callback for when radio button is selected.
- A multiple choice widget of check buttons from which only one can be selected at a time. Source Edit
Separator = ref object of Widget
- A widget to visually separate widget, horizontally or vertically. Source Edit
Slider = ref object of Widget onchanged*: proc (sender: Slider) ## Callback for when the slider value is changed by the user. onreleased*: proc (sender: Slider) ## Callback for when the slider is released from dragging.
-
A widget to display and modify integer values via a user draggable slider.
Values are guaranteed to be within the specified range.
Sliders by default display a tool tip showing the current value when being dragged.
Sliders are horizontal only.
Source Edit Spinbox = ref object of Widget onchanged*: proc (sender: Spinbox) ## Callback for when the spinbox value is changed by the user.
-
A widget to display and modify integer values via a text field or +/- buttons.
This is a convenient widget for having the user enter integer values. Values are guaranteed to be within the specified range.
The + button increases the held value by 1.
The - button decreased the held value by 1.
Entering a value out of range will clamp to the nearest value in range.
Source Edit Tab = ref object of Widget tabs*: seq[tuple[name: string, widget: Widget]]
-
A multi page widget interface that displays one page at a time.
Each page/tab has an associated label that can be selected to switch between pages/tabs.
Source Edit Table = ref object of Widget onRowClicked*: proc (sender: Table; row: int) ## Callback for when the user single clicks a table row. onRowDoubleClicked*: proc (sender: Table; row: int) ## Callback for when the user double clicks a table row. onHeaderClicked*: proc (sender: Table; column: int) ## Callback for when a table column header is clicked. onSelectionChanged*: proc (sender: Table) ## Callback for when the table selection changed.
-
A widget to display data in a tabular fashion.
The view of the architecture.
Data is retrieved from a TableModel via methods that you need to define in a TableModelHandler.
Make sure the TableModel columns return the right type, as specified in the addColumn() parameters.
The EditableModelColumn parameters typically point to a TableModel column index, that specifies the property on a per row basis.
They can however also be passed two special values defining the property for all rows: TableModelColumnNeverEditable and TableModelColumnAlwaysEditable.
Source Edit TableModel = ref object
-
Table model delegate to retrieve data and inform about model changes.
This is a wrapper around TableModelHandler where the actual data is held.
The main purpose it to provide methods to the developer to signal that underlying data has changed.
Row indexes match both the row indexes in Table and TableModelHandler.
A TableModel can be used as the backing store for multiple Table views.
Once created, the number of columns and their data types are not allowed to change.
Error: Not informing the TableModel about out-of-band data changes is an error. User edits via Table do not fall in this category.Source Edit TableValue = ref object
-
Container to store values used in container related methods.
TableValue objects are immutable.
Source Edit Window = ref object of Widget onclosing*: proc (sender: Window): bool ## Callback for when the window is to be closed. onfocuschanged*: proc (sender: Window) ## Callback for when the window focus changes. onContentSizeChanged*: proc (sender: Window) ## Callback for when the window content size is changed. onPositionChanged*: proc (sender: Window) ## Callback for when the window moved.
-
A Widget that represents a top-level window.
A window contains exactly one child widget that occupies the entire window.
Note: Many of the Window methods should be regarded as mere hints. The underlying system may override these or even choose to ignore them completely. This is especially true for many Unix systems.Warning: A Window can NOT be a child of another Widget.Source Edit
Procs
proc `$`(s: AttributedString): string {....raises: [], tags: [], forbids: [].}
- Returns the textual content of s as a string. Source Edit
proc `$`(v: TableValue): string {....raises: [ValueError], tags: [], forbids: [].}
-
Returns the string value held internally.
To be used only on TableValue objects of type TableValueTypeString.
Source Editv: Table value. proc add(b: Box; child: Widget; stretchy = false) {....raises: [], tags: [], forbids: [].}
-
Appends a widget to the box.
Stretchy items expand to use the remaining space within the box. In the case of multiple stretchy items the space is shared equally.
Source Editb: Box instance. child: widget instance to append. stretchy: true to stretch widget,false otherwise. Default is false. proc add(c: Box; items: openArray[Widget]; stretchy = false) {....raises: [], tags: [], forbids: [].}
- Adds multiple widgets to the box Source Edit
proc add(c: Combobox; items: varargs[string, `$`]) {....raises: [], tags: [], forbids: [].}
-
Appends an item to the combo box.
Source Editc: Combobox instance. items: Item text(s). proc add(c: EditableCombobox; items: varargs[string, `$`]) {....raises: [], tags: [], forbids: [].}
-
Appends an item to the editable combo box.
Source Editc: Combobox instance. items: Item text(s). proc add(e: MultilineEntry; text: string) {....raises: [], tags: [], forbids: [].}
-
Appends text to the multi line entry's text.
Source Edite: MultilineEntry instance text: Text to append. proc add(f: Form; label: string; w: Widget; stretchy: bool = false) {. ...raises: [], tags: [], forbids: [].}
-
Appends a widget with a label to the form.
Stretchy items expand to use the remaining space within the container. In the case of multiple stretchy items the space is shared equally.
Source Editf: Form instance. label: Label text. w: Widget to append. stretchy: true to stretch widget, false otherwise. proc add(g: Grid; w: Widget; left, top, xspan, yspan: int; hexpand: bool; halign: Align; vexpand: bool; valign: Align) {....raises: [], tags: [], forbids: [].}
-
Appends a widget to the grid.
Source Editg: Grid instance. w: The widget to insert. left: Placement as number of columns from the left. Integer in range of [INT_MIN, INT_MAX]. top: Placement as number of rows from the top. Integer in range of [INT_MIN, INT_MAX]. xspan: Number of columns to span. Integer in range of [0, INT_MAX]. yspan: Number of rows to span. Integer in range of [0, INT_MAX]. hexpand: true to expand reserved area horizontally, false otherwise. halign: Horizontal alignment of the widget within the reserved space. vexpand: true to expand reserved area vertically, false otherwise. valign: Vertical alignment of the widget within the reserved space. proc add(i: Image; pixels: pointer; pixelWidth: int; pixelHeight: int; byteStride: int) {....raises: [], tags: [], forbids: [].}
-
Appends a new image representation.
Source Editi: Image instance. pixels: Pointer to byte array of premultiplied pixels in R G B A order. pixels[0] equals the R of the first pixel, [3] the A of the first pixel. pixels must be at least byteStride * pixelHeight bytes long. pixelWidth: Width in pixels. pixelHeight: Height in pixels. byteStride: Number of bytes per row of the pixel array. proc add(otf: OpenTypeFeatures; a, b, c, d: char; value: uint32) {....raises: [], tags: [], forbids: [].}
- Adds the given feature tag and value to otf. The feature tag is specified by a, b, c, and d. If there is already a value associated with the specified tag in otf, the old value is removed. Source Edit
proc add(otf: OpenTypeFeatures; abcd: string; value: uint32 | bool)
- Alias of add. a, b, c, and d are instead a string of 4 characters, each character representing a, b, c, and d respectively. Source Edit
proc add(r: RadioButtons; items: varargs[string, `$`]) {....raises: [], tags: [], forbids: [].}
-
Appends a radio button.
Source Editr: RadioButtons instance. items: Radio button text(s). proc addAboutItem(m: Menu; onclicked: proc (sender: MenuItem; window: Window) = nil): MenuItem {. discardable, ...raises: [], tags: [], forbids: [].}
-
Appends a new About menu item.Warning: Only one such menu item may exist per application.
Source Editm: Menu instance. onclicked: Callback for when the menu item is clicked. proc addButtonColumn(table: Table; title: string; index, clickableMode: int) {. ...raises: [], tags: [], forbids: [].}
-
Appends a column to the table containing a button.
Button clicks are signaled to the TableModelHandler via a call to SetCellValue() with a value of NULL for the buttonModelColumn.
CellValue() must return the button text to display.
Source Edittable: Table instance. title: Column title text. index: Column that holds the button text to be displayed. clickableMode: Column that defines whether or not the button is clickable. TableModelColumnNeverEditable to make all rows never clickable. TableModelColumnAlwaysEditable to make all rows always clickable. proc addCheckboxColumn(table: Table; title: string; index, editableMode: int) {. ...raises: [], tags: [], forbids: [].}
-
Appends a column to the table containing a checkbox.
Source Editt: Table instance. title: Column title text. index: Column that holds the data to be displayed. editableMode: Column that defines whether or not the checkbox is editable. TableModelColumnNeverEditable to make all rows never editable. TableModelColumnAlwaysEditable to make all rows always editable. proc addCheckboxTextColumn(t: Table; name: string; checkboxModelColumn, checkboxEditableModelColumn, textModelColumn, textEditableModelColumn: int; textParams: ptr TableTextColumnOptionalParams = nil) {. ...raises: [], tags: [], forbids: [].}
-
Appends a column to the table containing a checkbox and text.
Source Editt: Table instance. name: Column title text. checkboxModelColumn: Column that holds the data to be displayed. true for a checked checkbox, false otherwise. checkboxEditableModelColumn: Column that defines whether or not the checkbox is editable. TableModelColumnNeverEditable to make all rows never editable. TableModelColumnAlwaysEditable to make all rows always editable. textModelColumn: Column that holds the text to be displayed. textEditableModelColumn: Column that defines whether or not the text is editable. TableModelColumnNeverEditable to make all rows never editable. TableModelColumnAlwaysEditable to make all rows always editable. textParams: Text display settings, nil to use defaults. proc addCheckItem(m: Menu; name: string; onclicked: proc (sender: MenuItem; window: Window) = nil): MenuItem {. discardable, ...raises: [], tags: [], forbids: [].}
-
Appends a generic menu item with a checkbox.
Source Editm: Menu instance. name: Menu item text. onclicked: Callback for when the menu item is clicked. proc addImageColumn(table: Table; title: string; index: int) {....raises: [], tags: [], forbids: [].}
-
Appends an image column to the table.
Images are drawn at icon size, using the representation that best fits the pixel density of the screen.
Source Edittable: Table instance. title: Column title text. index: Column that holds the images to be displayed. proc addImageTextColumn(t: Table; name: string; imageIndex, textIndex, editableMode: int; textParams: ptr TableTextColumnOptionalParams) {. ...raises: [], tags: [], forbids: [].}
-
Appends a column to the table that displays both an image and text.
Images are drawn at icon size, using the representation that best fits the pixel density of the screen.
Source Editt: Table instance. name: Column title text. imageIndex: Column that holds the images to be displayed. textIndex: Column that holds the text to be displayed. editableMode: Column that defines whether or not the text is editable. TableModelColumnNeverEditable to make all rows never editable. TableModelColumnAlwaysEditable to make all rows always editable. textParams: Text display settings, NULL to use defaults. proc addPreferencesItem(m: Menu; onclicked: proc (sender: MenuItem; window: Window) = nil): MenuItem {.discardable, ...raises: [], tags: [], forbids: [].}
-
Appends a new Preferences menu item.Warning: Only one such menu item may exist per application.
Source Editm: Menu instance. onclicked: Callback for when the menu item is clicked. proc addProgressBarColumn(table: Table; title: string; index: int) {....raises: [], tags: [], forbids: [].}
-
Appends a column to the table containing a progress bar.
The workings and valid range are exactly the same as that of uiProgressBar.
Source Edittable: Table instance. title: Column title text. index: Column that holds the data to be displayed. Integer in range of [-1, 100], see ProgressBar for details. proc addQuitItem(m: Menu; shouldQuit: proc (): bool): MenuItem {.discardable, ...raises: [], tags: [], forbids: [].}
-
Appends a new Quit menu item.Warning: Only one such menu item may exist per application.Error: the window MUST be destroyed in shouldQuit if the proc returns true
Source Editm: Menu instance shouldQuit: Proc that returns if the application should quit or not proc addRectangle(p: DrawPath; x, y, width, height: float) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc addSeparator(m: Menu) {....raises: [], tags: [], forbids: [].}
-
Appends a new separator.
Source Editm: Menu instance. proc addTextColumn(t: Table; name: string; textModelColumn, textEditableModelColumn: int; textParams: ptr TableTextColumnOptionalParams = nil) {. ...raises: [], tags: [], forbids: [].}
-
Appends a text column to the table.
Source Editt: Table instance. name: Column title text. textModelColumn: Column that holds the text to be displayed. textEditableModelColumn: Column that defines whether or not the text is editable. TableModelColumnNeverEditable to make all rows never editable. TableModelColumnAlwaysEditable to make all rows always editable. textParams: Text display settings, nil to use defaults. proc addUnattributed(s: AttributedString; str: string) {....raises: [], tags: [], forbids: [].}
- Adds string str to the end of s. The new substring will be unattributed. Source Edit
proc addWithAttributes(s: AttributedString; str: string; attrs: openArray[Attribute]) {....raises: [], tags: [], forbids: [].}
- Adds string str to the end of s. The new substring will have the attributes attrs applied to it. Source Edit
proc addWithAttributes(s: AttributedString; str: string; attrs: varargs[Attribute]) {....raises: [], tags: [], forbids: [].}
- Adds string str to the end of s. The new substring will have the attributes attrs applied to it. Source Edit
proc beginUserWindowMove(a: Area) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc beginUserWindowResize(a: Area; edge: WindowResizeEdge) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc borderless(w: Window): bool {....raises: [], tags: [], forbids: [].}
-
Returns whether or not the window is borderless.
Source Editw: Window instance. proc borderless=(w: Window; borderless: bool) {....raises: [], tags: [], forbids: [].}
-
Returns whether or not the window is full screen.Note: This method is merely a hint and may be ignored by the system.
Source Editw: Window instance. borderless: true to make window borderless, false otherwise. proc byteIndexToGrapheme(s: AttributedString; pos: int): int {....raises: [], tags: [], forbids: [].}
- Source Edit
proc checked(c: Checkbox): bool {....raises: [], tags: [], forbids: [].}
-
Returns whether or the checkbox is checked.
Source Editc: Checkbox instance. proc checked(m: MenuItem): bool {....raises: [], tags: [], forbids: [].}
-
Returns whether or not the menu item's checkbox is checked.
To be used only with items created via addCheckItem().
Source Editm: MenuItem instance. proc checked=(c: Checkbox; checked: bool) {....raises: [], tags: [], forbids: [].}
-
Sets whether or not the checkbox is checked.
Source Editc: Checkbox instance. checked: true to check box, false otherwise. proc checked=(m: MenuItem; checked: bool) {....raises: [], tags: [], forbids: [].}
-
Sets whether or not the menu item's checkbox is checked.
To be used only with items created via addCheckItem().
Source Editm: MenuItem instance. checked: true to check menu item checkbox, false otherwise. proc clear(c: Combobox) {....raises: [], tags: [], forbids: [].}
-
Deletes all items from the combo box.
Source Editc: Combobox instance. proc clear(e: EditableCombobox) {....raises: [], tags: [], forbids: [].}
-
Clears the editable combobox's text
Source Edite: Combobox instance. proc clear(e: Entry) {....raises: [], tags: [], forbids: [].}
-
Clears the entry's text
Source Edite: Entry instance. proc clear(e: MultilineEntry) {....raises: [], tags: [], forbids: [].}
-
Clears the multi line entry's text
Source Edite: MultilineEntry instance. proc clip(c: ptr DrawContext; path: DrawPath) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc clone(otf: OpenTypeFeatures): OpenTypeFeatures {....raises: [], tags: [], forbids: [].}
- Makes a copy of otf and returns it. Changing one will not affect the other. Source Edit
proc closeFigure(p: DrawPath) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc color(a: Attribute): tuple[r, g, b, alpha: float] {....raises: [], tags: [], forbids: [].}
-
Returns the text color stored in a.Error: It is an error to call this on a Attribute that does not hold a text color.Source Edit
proc color(c: ColorButton): tuple[r, g, b, a: float] {....raises: [], tags: [], forbids: [].}
-
Returns the color button color.
Source Editc: ColorButton instance proc color(v: TableValue): tuple[r, g, b, a: float] {....raises: [ValueError], tags: [], forbids: [].}
-
Returns the color value held internally.
To be used only on TableValue objects of type TableValueTypeColor.
Source Editv: Table value. proc color=(c: ColorButton; color: Color) {....raises: [], tags: [], forbids: [].}
-
Sets the color button color.
If you need to set color alpha use setColor()
Source Editc: ColorButton instance. color: Color. proc columnWidth(table: Table; column: int): int {....raises: [], tags: [], forbids: [].}
-
Returns the table column width in pixels.
Source Edittable: Table instance. column: Column index. proc contentSize(window: Window): tuple[width, height: int] {....raises: [], tags: [], forbids: [].}
-
Gets the window content size.Note: The content size does NOT include window decorations like menus or title bars.
Source Editwindow: Window instance. proc contentSize=(window: Window; size: tuple[width, height: int]) {....raises: [], tags: [], forbids: [].}
-
Gets the window content size.Note: The content size does NOT include window decorations like menus or title bars.Note: This method is merely a hint and may be ignored by the system.
Source Editwindow: Window instance. size.width: Window content width to set. size.height: Window content height to set. proc delete(b: Box; index: int) {....raises: [], tags: [], forbids: [].}
-
Removes the widget at index from the box.Note: The widget is neither destroyed nor freed.
Source Editb: Box instance. index: Index of widget to be removed. proc delete(c: Combobox; index: int) {....raises: [], tags: [], forbids: [].}
-
Deletes an item at index from the combo box.Note: Deleting the index of the item currently selected will move the selection to the next item in the combo box or -1 if no such item exists.
Source Editc: Combobox instance. index: Index of the item to be deleted. proc delete(f: Form; index: int) {....raises: [], tags: [], forbids: [].}
-
Removes the widget at index from the form.Note: The widget is neither destroyed nor freed.
Source Editf: Form instance. index: Index of the widget to be removed. proc delete(s: AttributedString; start, end: int) {....raises: [], tags: [], forbids: [].}
- Deletes the characters and attributes of s in the byte range [start, end). Source Edit
proc drawText(c: ptr DrawContext; tl: DrawTextLayout; point: tuple[x, y: float]) {. ...raises: [], tags: [], forbids: [].}
- Draws tl in c with the top-left point of tl at (point.x, point.y). Source Edit
proc enabledToUser[SomeWidget: Widget](w: SomeWidget): bool
-
Returns whether or not the widget can be interacted with by the user.
Checks if the widget and all it's parents are enabled to make sure it can be interacted with by the user.
Source Edit proc error(parent: Window; title, desc: string) {....raises: [], tags: [], forbids: [].}
- Alias for msgBoxError Source Edit
proc extents(tl: DrawTextLayout): tuple[width, height: float] {....raises: [], tags: [], forbids: [].}
- Returns the width and height of tl. The returned width may be smaller than the width passed into newDrawTextLayout() depending on how the text in tl is wrapped. Therefore, you can use this function to get the actual size of the text layout. Source Edit
proc features(a: Attribute): OpenTypeFeatures {....raises: [], tags: [], forbids: [].}
-
Returns the OpenType features stored in a.Error: It is an error to call this on a Attribute that does not hold OpenType features.Source Edit
proc font(f: FontButton): FontDescriptor {....raises: [], tags: [], forbids: [].}
-
Returns the selected font.
Source Editf: FontButton instance proc forEach(otf: OpenTypeFeatures; f: proc (otf: OpenTypeFeatures; abcd: string; value: int): ForEach) {. ...raises: [], tags: [], forbids: [].}
-
Executes f for every tag-value pair in otf. The enumeration order is unspecified.Error: You cannot modify otf while this function is running.Source Edit
proc forEachAttribute(str: AttributedString; fun: proc (s: AttributedString; a: Attribute; start, end: int): ForEach) {....raises: [], tags: [], forbids: [].}
-
enumerates all the Attributes in str. Within fun, str still owns the attribute; you can neither free it nor save it for later use.Error: You cannot modify str in fun.Source Edit
proc free(a: Attribute) {....raises: [], tags: [], forbids: [].}
-
Frees a Attribute. You generally do not need to call this yourself, as AttributedString does this for you.Error: It is an error to call this function on a Attribute that has been given to a AttributedString.
You can call this, however, if you created a Attribute that you aren't going to use later.
Source Edit proc free(a: AttributedString) {....raises: [], tags: [], forbids: [].}
- Destroys the AttributedString a. It will also free all Attributes within. Source Edit
proc free(f: ptr FontDescriptor) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc free(i: Image) {....raises: [], tags: [], forbids: [].}
-
Frees the image container and all associated resources.
Source Editi: Image instance. proc free(otf: OpenTypeFeatures) {....raises: [], tags: [], forbids: [].}
- Frees otf Source Edit
proc free(str: cstring) {....raises: [], tags: [], forbids: [].}
-
Free the memory of a returned string.
Every time a string is returned from libui, this method should be called.
Source Edit proc free(t: ptr TableSelection) {....raises: [], tags: [], forbids: [].}
-
Frees the given TableSelection and all its resources.
Source Edits: TableSelection instance. proc free(t: TableModel) {....raises: [], tags: [], forbids: [].}
-
Frees the table model.Error: It is an error to free table models currently associated with a Table.
Source Editm: Table model to free. proc free(t: TableValue) {....raises: [], tags: [], forbids: [].}
-
Frees the TableValue.Warning:
This function is to be used only on TableValue objects that have NOT been passed to Table or TableModel - as these take ownership of the object.
Use this for freeing erroneously created values or when directly calling TableModelHandler without transferring ownership to Table or TableModel.
Source Editt: TableValue to free. proc free(tl: DrawTextLayout) {....raises: [], tags: [], forbids: [].}
- Frees tl. The underlying AttributedString is not freed. Source Edit
proc freeFont(desc: ptr FontDescriptor) {....raises: [], tags: [], forbids: [].}
-
Frees a FontDescriptor previously filled by font().
After calling this function the contents of desc should be assumed undefined, however you can safely reuse desc.
Calling this function on a FontDescriptor not previously filled by font() results in undefined behavior.
Source Editdesc: Font descriptor to free. proc fullscreen(w: Window): bool {....raises: [], tags: [], forbids: [].}
-
Returns whether or not the window is full screen.
Source Editw: Window instance. proc fullscreen=(w: Window; fullscreen: bool) {....raises: [], tags: [], forbids: [].}
-
Returns whether or not the window is full screen.Note: This method is merely a hint and may be ignored by the system.
Source Editw: Window instance. fullscreen: true to make window full screen, false otherwise. proc get(otf: OpenTypeFeatures; a, b, c, d: char; value: var int): bool {. ...raises: [], tags: [], forbids: [].}
-
Determines whether the given feature tag is present in otf. If it is, value is set to the tag's value and true is returned. Otherwise, false is returned.
Note that if this function returns false, value isn't changed. This is important: if a feature is not present in a OpenTypeFeatures, the feature is NOT treated as if its value was zero anyway. 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.
Source Edit proc get(otf: OpenTypeFeatures; abcd: string; value: var int): bool {. ...raises: [ValueError], tags: [], forbids: [].}
- Alias of get. a, b, c, and d are instead a string of 4 characters, each character representing a, b, c, and d respectively. Source Edit
proc getInt(v: TableValue): int {....raises: [ValueError], tags: [], forbids: [].}
-
Returns the integer value held internally.
To be used only on TableValue objects of type TableValueTypeInt.
Source Editv: Table value. proc getType(a: Attribute): AttributeType {....raises: [], tags: [], forbids: [].}
- Returns the AttributeType of a. Source Edit
proc graphemeToByteIndex(s: AttributedString; pos: int): int {....raises: [], tags: [], forbids: [].}
- Source Edit
proc handler(a: Area): ptr AreaHandler {....raises: [], tags: [], forbids: [].}
- Source Edit
proc hasToolTip(s: Slider): bool {....raises: [], tags: [], forbids: [].}
-
Returns whether or not the slider has a tool tip.
Source Edits: Slider instance. proc hasToolTip=(s: Slider; hasToolTip: bool) {....raises: [], tags: [], forbids: [].}
-
Sets whether or not the slider has a tool tip.
Source Edits: Slider instance. hasToolTip: true to display a tool tip, false to display no tool tip. proc headerVisible(t: Table): bool {....raises: [], tags: [], forbids: [].}
-
Returns whether or not the table header is visible.
Source Edittable: Table instance. proc headerVisible=(t: Table; visible: bool) {....raises: [], tags: [], forbids: [].}
-
Sets whether or not the table header is visible.
Source Edittable: Table instance. visible: true to show header, false to hide header. proc image(v: TableValue): Image {....raises: [ValueError], tags: [], forbids: [].}
-
Returns the image contained.
To be used only on TableValue objects of kind TableValueTypeImage.
Warning: The image returned is not owned by the object v, hence no lifetime guarantees can be made.
Source Editv: Table value. func impl(b: Area): RawArea {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Attribute): RawAttribute {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: AttributedString): RawAttributedString {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Box): RawBox {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Button): RawButton {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Checkbox): RawCheckbox {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: ColorButton): RawColorButton {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Combobox): RawCombobox {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: DateTimePicker): RawDateTimePicker {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: DrawPath): RawDrawPath {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: DrawTextLayout): RawDrawTextLayout {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: EditableCombobox): RawEditableCombobox {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Entry): RawEntry {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: FontButton): RawFontButton {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Form): RawForm {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Grid): RawGrid {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Group): RawGroup {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Image): RawImage {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Label): RawLabel {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Menu): RawMenu {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: MenuItem): RawMenuItem {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: MultilineEntry): RawMultilineEntry {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: OpenTypeFeatures): RawOpenTypeFeatures {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: ProgressBar): RawProgressBar {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: RadioButtons): RawRadioButtons {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Separator): RawSeparator {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Slider): RawSlider {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Spinbox): RawSpinbox {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Tab): RawTab {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: Table): RawTable {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: TableModel): RawTableModel {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl(b: TableValue): RawTableValue {....raises: [], tags: [], forbids: [].}
- Gets internal implementation of b Source Edit
func impl=(b: Area; r: RawArea) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Attribute; r: RawAttribute) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: AttributedString; r: RawAttributedString) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Box; r: RawBox) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Button; r: RawButton) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Checkbox; r: RawCheckbox) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: ColorButton; r: RawColorButton) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Combobox; r: RawCombobox) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: DateTimePicker; r: RawDateTimePicker) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: DrawPath; r: RawDrawPath) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: DrawTextLayout; r: RawDrawTextLayout) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: EditableCombobox; r: RawEditableCombobox) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Entry; r: RawEntry) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: FontButton; r: RawFontButton) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Form; r: RawForm) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Grid; r: RawGrid) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Group; r: RawGroup) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Image; r: RawImage) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Label; r: RawLabel) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Menu; r: RawMenu) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: MenuItem; r: RawMenuItem) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: MultilineEntry; r: RawMultilineEntry) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: OpenTypeFeatures; r: RawOpenTypeFeatures) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: ProgressBar; r: RawProgressBar) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: RadioButtons; r: RawRadioButtons) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Separator; r: RawSeparator) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Slider; r: RawSlider) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Spinbox; r: RawSpinbox) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Tab; r: RawTab) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: Table; r: RawTable) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: TableModel; r: RawTableModel) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
func impl=(b: TableValue; r: RawTableValue) {....raises: [], tags: [], forbids: [].}
- Sets internal implementation of b Source Edit
proc insertAt(c: Combobox; index: int; text: string) {....raises: [], tags: [], forbids: [].}
-
Inserts an item at index to the combo box.
Source Editc: Combobox instance. index: Index at which to insert the item. text: Item text. proc insertAt(g: Grid; w, existing: Widget; at: At; left, top, xspan, yspan: int; hexpand: bool; halign: Align; vexpand: bool; valign: Align) {....raises: [], tags: [], forbids: [].}
-
Inserts a widget positioned in relation to another widget within the grid.
Source Editg: Grid instance. w: The widget to insert. existing: The existing widget to position relatively to. at: Placement specifier in relation to existing widget. xspan: Number of columns to span. Integer in range of [0, INT_MAX]. yspan: Number of rows to span. Integer in range of [0, INT_MAX]. hexpand: true to expand reserved area horizontally, false otherwise. halign: Horizontal alignment of the widget within the reserved space. vexpand: true to expand reserved area vertically, false otherwise. valign: Vertical alignment of the widget within the reserved space. proc insertAtUnattributed(s: AttributedString; str: string; at: int) {. ...raises: [], tags: [], forbids: [].}
- Adds the string 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. Source Edit
proc invert(m: ptr DrawMatrix): int {....raises: [], tags: [], forbids: [].}
- Source Edit
proc invertible(m: ptr DrawMatrix): bool {....raises: [], tags: [], forbids: [].}
- Source Edit
proc italic(a: Attribute): TextItalic {....raises: [], tags: [], forbids: [].}
-
Returns the font italic mode stored in a.Error: It is an error to call this on a Attribute that does not hold a font italic mode.Source Edit
proc len(s: AttributedString): int {....raises: [], tags: [], forbids: [].}
- Returns the number of UTF-8 bytes in the textual content of s Source Edit
proc loadControlFont(f: ptr FontDescriptor) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc margined(g: Group): bool {....raises: [], tags: [], forbids: [].}
-
Returns whether or not the group has a margin.
Source Editg: Group instance. proc msgBoxError(parent: Window; title, desc: string) {....raises: [], tags: [], forbids: [].}
-
Error message box dialog window.
A message box displayed in a new window indicating an error. On some systems this may invoke an accompanying sound.
Source Editparent: Parent window. title: Dialog window title text. description: Dialog message text. proc multiply(dest, src: ptr DrawMatrix) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc newArea(ah: ptr AreaHandler): Area {....raises: [], tags: [], forbids: [].}
- Source Edit
proc newAttributedString(initialString: string): AttributedString {....raises: [], tags: [], forbids: [].}
- Creates a new AttributedString from initialString. The returned string will be entirely unattributed. Source Edit
proc newBackgroundColorAttribute(color: Color; a: float = 1.0): Attribute {. ...raises: [], tags: [], forbids: [].}
-
Creates a new Attribute that changes the background color of the text it is applied to.Error: It is an error to specify an invalid color.Source Edit
proc newBackgroundColorAttribute(r, g, b: float; a: float = 1.0): Attribute {. ...raises: [], tags: [], forbids: [].}
-
Creates a new Attribute that changes the background color of the text it is applied to.Error: It is an error to specify an invalid color.Source Edit
proc newCheckbox(text: string; ontoggled: proc (sender: Checkbox) = nil): Checkbox {. ...raises: [], tags: [], forbids: [].}
-
Creates and returns a new checkbox.
Source Edittext: Checkbox label text ontoggled: Callback for when the checkbox is toggled by the user. proc newColorAttribute(color: Color; a: float = 1.0): Attribute {....raises: [], tags: [], forbids: [].}
-
Creates a new Attribute that changes the color of the text it is applied to.Error: It is an error to specify an invalid color.Source Edit
proc newColorAttribute(r, g, b: float; a: float = 1.0): Attribute {....raises: [], tags: [], forbids: [].}
-
Creates a new Attribute that changes the color of the text it is applied to.Error: It is an error to specify an invalid color.Source Edit
proc newColorButton(color: Color; onchanged: proc (sender: ColorButton) = nil): ColorButton {. ...raises: [], tags: [], forbids: [].}
-
Creates a new color button.
Source Editcolor: ColorButton Color. onchanged: Callback for when the color is changed. proc newColorButton(onchanged: proc (sender: ColorButton) = nil): ColorButton {. ...raises: [], tags: [], forbids: [].}
-
Creates a new color button.
Source Editonchanged: Callback for when the color is changed. proc newColorButton(r, g, b: float; alpha: float = 1.0; onchanged: proc (sender: ColorButton) = nil): ColorButton {. ...raises: [], tags: [], forbids: [].}
-
Creates a new color button.
Source Editr: Red. Float in range of 0.0, 1.0. g: Green. Float in range of 0.0, 1.0. b: Blue. Float in range of 0.0, 1.0. alpha: Alpha. Float in range of 0.0, 1.0. onchanged: Callback for when the color is changed. proc newCombobox(items: openArray[string] = []; onselected: proc (sender: Combobox) = nil): Combobox {. ...raises: [], tags: [], forbids: [].}
-
Creates a new combo box.
Source Edititems: List of strings to add to the combobox onselected: Callback for when a combo box item is selected. proc newDatePicker(date: DateTime; onchanged: proc (sender: DateTimePicker) = nil): DateTimePicker {. ...raises: [], tags: [], forbids: [].}
-
Creates a new date picker
Source Editdate: Date and/or time as local time. onchanged: Callback for when the date time picker value is changed by the user. proc newDatePicker(onchanged: proc (sender: DateTimePicker) = nil): DateTimePicker {. ...raises: [], tags: [], forbids: [].}
-
Creates a new date picker
Source Editonchanged: Callback for when the date time picker value is changed by the user. proc newDateTimePicker(dateTime: DateTime; onchanged: proc (sender: DateTimePicker) = nil): DateTimePicker {. ...raises: [], tags: [], forbids: [].}
-
Creates a new date and time picker.
Source EditdateTime: Date and/or time as local time. onchanged: Callback for when the date time picker value is changed by the user. proc newDateTimePicker(onchanged: proc (sender: DateTimePicker) = nil): DateTimePicker {. ...raises: [], tags: [], forbids: [].}
-
Creates a new date and time picker.
Source Editonchanged: Callback for when the date time picker value is changed by the user. proc newDrawPath(fillMode: DrawFillMode): DrawPath {....raises: [], tags: [], forbids: [].}
- Source Edit
proc newDrawTextLayout(params: ptr DrawTextLayoutParams): DrawTextLayout {. ...raises: [], tags: [], forbids: [].}
- Creates a new DrawTextLayout from the given parameters params. Source Edit
proc newEditableCombobox(items: openArray[string] = []; onchanged: proc (sender: EditableCombobox) = nil): EditableCombobox {. ...raises: [], tags: [], forbids: [].}
-
Creates a new editable combo box.
Source Editonchanged: Callback for when an editable combo box item is selected or user text changed. proc newFamilyAttribute(family: string): Attribute {....raises: [], tags: [], forbids: [].}
- Creates a new Attribute that changes the font family of the text it is applied to. Font family names are case-insensitive. Source Edit
proc newFeaturesAttribute(otf: OpenTypeFeatures): Attribute {....raises: [], tags: [], forbids: [].}
- Creates a and returns new Attribute that changes the font family of the text it is applied to. otf is copied; you may free it after this function returns. Source Edit
proc newFigureWithArc(p: DrawPath; xCenter, yCenter, radius, startAngle, sweep: float; negative: int) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc newFontButton(onchanged: proc (sender: FontButton) = nil): FontButton {. ...raises: [], tags: [], forbids: [].}
-
Creates and returns a new font button.
The default font is determined by the OS defaults.
Source Editonchanged: Callback for when the font is changed. proc newHorizontalBox(padded = false): Box {....raises: [], tags: [], forbids: [].}
-
Creates and returns a new horizontal box.
Widgets within the box are placed next to each other horizontally.
Source Editpadded: true to make widgets padded, false otherwise. proc newHorizontalSeparator(): Separator {....raises: [], tags: [], forbids: [].}
- Creates a new horizontal separator to separate controls being stacked vertically. Source Edit
proc newImage(width, height: float): Image {....raises: [], tags: [], forbids: [].}
-
Creates a new image container.
Dimensions are measured in points. This is most commonly the pixel size of the 1x scaled image.
width: Width in points. height: Height in points. Important: To reduce confusion, please read the notice in the documentation for ImageSource Edit proc newItalicAttribute(italic: TextItalic): Attribute {....raises: [], tags: [], forbids: [].}
- Creates a new Attribute that changes the italic mode of the text it is applied to. Source Edit
proc newMultilineEntry(onchanged: proc (sender: MultilineEntry) = nil): MultilineEntry {. ...raises: [], tags: [], forbids: [].}
- Creates a new multi line entry that visually wraps text when lines overflow. Source Edit
proc newNonWrappingMultilineEntry(onchanged: proc (sender: MultilineEntry) = nil): MultilineEntry {. ...raises: [], tags: [], forbids: [].}
-
Creates a new multi line entry that scrolls horizontally when lines overflow.Note: Windows does not allow for this style to be changed after creation, hence the two constructors.Source Edit
proc newOpenTypeFeatures(): OpenTypeFeatures {....raises: [], tags: [], forbids: [].}
- Returns a new OpenTypeFeatures instance, with no tags yet added. Source Edit
proc newPasswordEntry(text: string = ""; onchanged: proc (sender: Entry) = nil): Entry {. ...raises: [], tags: [], forbids: [].}
-
Creates a new entry suitable for sensitive inputs like passwords.
The entered text is NOT readable by the user but masked as *******.
Source Edittext: Entry text onchanged: Callback for when the user changes the entry's text. proc newProgressBar(indeterminate: bool = false): ProgressBar {....raises: [], tags: [], forbids: [].}
-
Creates a new progress bar.
Source Editindeterminate: Whether or not the progress bar will display an indeterminate value. proc newRadioButtons(items: openArray[string] = []; onselected: proc (sender: RadioButtons) = nil): RadioButtons {. ...raises: [], tags: [], forbids: [].}
-
Creates a new radio buttons instance.
Source Editonselected: Callback for when radio button is selected. proc newScrollingArea(ah: ptr AreaHandler; width, height: int): Area {. ...raises: [], tags: [], forbids: [].}
- Source Edit
proc newSearchEntry(text: string = ""; onchanged: proc (sender: Entry) = nil): Entry {. ...raises: [], tags: [], forbids: [].}
-
Creates a new entry suitable for search.
Some systems will deliberately delay the onchanged() callback for a more natural feel.
Source Edittext: Entry text onchanged: Callback for when the user changes the entry's text. proc newSizeAttribute(size: float): Attribute {....raises: [], tags: [], forbids: [].}
- Creates a new Attribute that changes the size of the text it is applied to, in typographical points. Source Edit
proc newSlider(min, max: int; onchanged: proc (sender: Slider) = nil): Slider {. ...deprecated: "Use `newSlider(min..max, ...)` instead.", raises: [], tags: [], forbids: [].}
-
Creates a new slider.
The initial slider value equals the minimum value.
In the current implementation min and max are swapped if min > max. This may change in the future though.
Source Editmin: Minimum value max: Maximum value onchanged: Callback for when the slider value is changed by the user. proc newSlider(range: Slice[SomeInteger]; onchanged: proc (sender: Slider) = nil): Slider
-
Creates a new slider.
The initial slider value equals the minimum value.
In the current implementation min and max are swapped if min > max. This may change in the future though.
Source Editrange: Slider range, as min .. max onchanged: Callback for when the slider value is changed by the user. proc newSpinbox(min, max: int; onchanged: proc (sender: Spinbox) = nil): Spinbox {. ...deprecated: "Use `newSpinbox(min..max, ...)` instead", raises: [], tags: [], forbids: [].}
-
Creates a new spinbox.
The initial spinbox value equals the minimum value.
In the current implementation min and max are swapped if min>max. This may change in the future though.
Source Editmin: Minimum value. max: Maximum value. onchanged: Callback for when the spinbox value is changed by the user. proc newSpinbox(range: Slice[SomeInteger]; onchanged: proc (sender: Spinbox) = nil): Spinbox
-
Creates a new spinbox.
The initial spinbox value equals the minimum value.
In the current implementation min and max are swapped if min>max. This may change in the future though.
Source Editrange: Range of allowed values as min..max. onchanged: Callback for when the spinbox value is changed by the user. proc newStretchAttribute(stretch: TextStretch): Attribute {....raises: [], tags: [], forbids: [].}
- Creates a new Attribute that changes the stretch of the text it is applied to. Source Edit
proc newTable(params: ptr TableParams): Table {....raises: [], tags: [], forbids: [].}
-
Creates a new table.
Source Editparams: Table parameters. proc newTableModel(mh: ptr TableModelHandler): TableModel {....raises: [], tags: [], forbids: [].}
-
Creates a new table model.
Source Editmh: Table model handler. proc newTableValue(color: Color; a: float = 1.0): TableValue {....raises: [], tags: [], forbids: [].}
-
Creates a new table value to store a color in.
Source Editcolor: Table value color. a: Alpha. Float in range of 0, 1.0. proc newTableValue(i: int | bool): TableValue
-
Creates a new table value to store an integer.
This value type can be used in conjunction with properties like column editable `true`, `false` or widget like progress bars and checkboxes. For these, consult ProgressBar and Checkbox for the allowed integer ranges.
Source Editi: Integer or boolean value. proc newTableValue(img: Image): TableValue {....raises: [], tags: [], forbids: [].}
-
Creates a new table value to store an image.Warning: Unlike other TableValue constructors, this function does NOT copy the image to save time and space. Make sure the image data stays valid while in use by the library. As a general rule: if the constructor is called via the TableModelHandler, the image is safe to free once execution returns to ANY of your code.
Source Editimg: Image. Data is NOT copied and needs to kept alive. proc newTableValue(r, g, b: float; a: float = 1.0): TableValue {....raises: [], tags: [], forbids: [].}
-
Creates a new table value to store a color in.
Source Editr: Red. Float in range of 0, 1.0. g: Green. Float in range of 0, 1.0. b: Blue. Float in range of 0, 1.0. a: Alpha. Float in range of 0, 1.0. proc newTableValue(str: string): TableValue {....raises: [], tags: [], forbids: [].}
-
Creates a new TableValue to store a text string.
Source Editstr: String value. proc newTimePicker(onchanged: proc (sender: DateTimePicker) = nil): DateTimePicker {. ...raises: [], tags: [], forbids: [].}
-
Creates a new time picker.
Source Editonchanged: Callback for when the date time picker value is changed by the user. proc newTimePicker(time: DateTime; onchanged: proc (sender: DateTimePicker) = nil): DateTimePicker {. ...raises: [], tags: [], forbids: [].}
-
Creates a new time picker.
Source Edittime: Date and/or time as local time. onchanged: Callback for when the date time picker value is changed by the user. proc newUnderlineAttribute(u: Underline): Attribute {....raises: [], tags: [], forbids: [].}
- Creates a new Attribute that changes the type of underline on the text it is applied to. Source Edit
proc newUnderlineColorAttribute(u: UnderlineColor; color: Color; a: float = 0.0): Attribute {. ...raises: [], tags: [], forbids: [].}
-
Creates a new Attribute that changes the color of the underline on the text it is applied to.Error: If the specified color type is UnderlineColorCustom, it is an error to specify an invalid color value. Otherwise, the color values are ignored and should be specified as zero.Source Edit
proc newUnderlineColorAttribute(u: UnderlineColor; r = 0.0; g = 0.0; b = 0.0; a: float = 0.0): Attribute {....raises: [], tags: [], forbids: [].}
-
Creates a new Attribute that changes the color of the underline on the text it is applied to.Error: If the specified color type is UnderlineColorCustom, it is an error to specify an invalid color value. Otherwise, the color values are ignored and should be specified as zero.Source Edit
proc newVerticalBox(padded = false): Box {....raises: [], tags: [], forbids: [].}
-
Creates a new vertical box.
Widgets within the box are placed next to each other vertically.
Source Editpadded: true to make widgets padded, false otherwise. proc newVerticalSeparator(): Separator {....raises: [], tags: [], forbids: [].}
- Creates a new vertical separator to separate controls being stacked horizontally. Source Edit
proc newWeightAttribute(weight: TextWeight): Attribute {....raises: [], tags: [], forbids: [].}
- Creates a new Attribute that changes the weight of the text it is applied to. Source Edit
proc newWindow(title: string; width, height: int; hasMenubar: bool = false; onfocuschanged: proc (sender: Window) = nil): Window {. ...raises: [], tags: [], forbids: [].}
-
Creates and returns a new Window.
Source Edittitle: Window title text. width: Window width. height: Window height. hasMenubar: Whether or not the window should display a menu bar. onfocuschanged: Callback for when the window focus changes. proc numGraphemes(s: AttributedString): int {....raises: [], tags: [], forbids: [].}
- Source Edit
proc openFolder(parent: Window): string {....raises: [], tags: [], forbids: [].}
-
Folder chooser dialog window to select a single file. Returns the selected folder pathNote: File paths are separated by the underlying OS file path separator.
Source Editparent: Parent window. func osSignature[SomeWidget: Widget](w: SomeWidget): int
- Get widget OS signature Source Edit
proc padded(b: Box): bool {....raises: [], tags: [], forbids: [].}
-
Returns whether or not widgets within the box are padded.
Padding is defined as space between individual widgets.
Source Editb: Box instance. proc padded=(b: Box; padded: bool) {....raises: [], tags: [], forbids: [].}
-
Sets whether or not widgets within the box are padded.
Padding is defined as space between individual widgets. The padding size is determined by the OS defaults.
Source Editb: Box instance. padded: true to make widgets padded, false otherwise. proc padded=(f: Form; padded: bool) {....raises: [], tags: [], forbids: [].}
-
Sets whether or not widgets within the box are padded.
Padding is defined as space between individual widgets. The padding size is determined by the OS defaults.
Source Editf: Form instance. padded: true to make widgets padded, false otherwise. proc padded=(g: Grid; padded: bool) {....raises: [], tags: [], forbids: [].}
-
Sets whether or not widgets within the grid are padded.
Padding is defined as space between individual widgets. The padding size is determined by the OS defaults.
Source Editg: Grid instance. padded: true to make widgets padded, false otherwise. proc pollingMainLoop(poll: proc (timeout: int); timeout: int) {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
-
Can be used to merge an async event loop with libui-ng's event loop.
Implemented using timeouts and polling because that's the only thing that truely composes.
Source Edit proc position=(w: Window; pos: tuple[x, y: int]) {....raises: [], tags: [], forbids: [].}
-
Moves the window to the specified position.
Coordinates are measured from the top left corner of the screen.
Note: This method may return inaccurate or dummy values on Unix platforms.
Source Editw: Window instance. pos.x: New x position of the window. pos.y: New y position of the window. proc queueRedrawAll(a: Area) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc readOnly(e: Entry): bool {....raises: [], tags: [], forbids: [].}
-
Returns whether or not the entry's text can be changed.
Source Edite: Entry instance. proc readOnly(e: MultilineEntry): bool {....raises: [], tags: [], forbids: [].}
-
Returns whether or not the multi line entry's text can be changed.
Source Edite: MultilineEntry instance proc readOnly=(e: Entry; readOnly: bool) {....raises: [], tags: [], forbids: [].}
-
Sets whether or not the entry's text is read only.
Source Edite: Entry instance. readonly: true to make read only, false otherwise. proc readOnly=(e: MultilineEntry; readOnly: bool) {....raises: [], tags: [], forbids: [].}
-
Sets whether or not the multi line entry's text is read only.
Source Edite: MultilineEntry instance readonly: true to make read only, false otherwise. proc remove(otf: OpenTypeFeatures; a, b, c, d: char) {....raises: [], tags: [], forbids: [].}
- Removes the given feature tag and value from otf. If the tag is not present in otf, this function does nothing. Source Edit
proc remove(otf: OpenTypeFeatures; abcd: string) {....raises: [ValueError], tags: [], forbids: [].}
- Alias of remove. a, b, c, and d are instead a string of 4 characters, each character representing a, b, c, and d respectively. Source Edit
proc resizeable(w: Window): bool {....raises: [], tags: [], forbids: [].}
-
Returns whether or not the window is user resizeable.
Source Editw: Window instance. proc resizeable=(w: Window; resizeable: bool) {....raises: [], tags: [], forbids: [].}
-
Sets whether or not the window is user resizeable.Note: This method is merely a hint and may be ignored by the system.
Source Editw: Window instance. resizeable: true to make window resizable, false otherwise. proc restore(c: ptr DrawContext) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc rotate(m: ptr DrawMatrix; x, y, amount: float) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc rowChanged(m: TableModel; index: int) {....raises: [], tags: [], forbids: [].}
-
Informs all associated Table views that a row has been changed.
You do NOT need to call this in your setCellValue() handlers, but NEED to call this if your data changes at any other point.
Source Editm: Table model that has changed. index: Index of the row that has changed. proc rowDeleted(m: TableModel; oldIndex: int) {....raises: [], tags: [], forbids: [].}
-
Informs all associated Table views that a row has been deleted.
You must delete the row from your model before you call this function.
numRows() must represent the new row count before you call this function.
Source Editm: Table model that has changed. oldIndex: Index of the row that has been deleted. proc rowInserted(m: TableModel; newIndex: int) {....raises: [], tags: [], forbids: [].}
-
Informs all associated Table views that a new row has been added.
You must insert the row data in your model before calling this function.
numRows() must represent the new row count before you call this function.
Source Editm: Table model that has changed. newIndex: Index of the row that has been added. proc save(c: ptr DrawContext) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc saveFile(parent: Window): string {....raises: [], tags: [], forbids: [].}
-
Save file dialog window. Returns the selected file path.
The user is asked to confirm overwriting existing files, should the chosen file path already exist on the system.
Note: File paths are separated by the underlying OS file path separator.
Source Editparent: Parent window. proc scale(m: ptr DrawMatrix; xCenter, yCenter, x, y: float) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc selected(r: RadioButtons): int {....raises: [], tags: [], forbids: [].}
- Source Edit
proc selected=(c: Combobox; index: int) {....raises: [], tags: [], forbids: [].}
-
Sets the item selected.
Source Editc: Combobox instance. index: Index of the item to be selected, -1 to clear selection. proc selected=(r: RadioButtons; index: int) {....raises: [], tags: [], forbids: [].}
-
Sets the item selected.
Source Editr: RadioButtons instance. index: Index of the item to be selected, -1 to clear selection. proc selection=(table: Table; sel: openArray[int]) {....raises: [], tags: [], forbids: [].}
-
Sets the current table selection, clearing any previous selection.Note: Selecting more rows than the selection mode allows for results in nothing happening.
Source Edittable: Table instance. sel: List of rows to select. proc selectionMode(table: Table): TableSelectionMode {....raises: [], tags: [], forbids: [].}
-
Returns the table selection mode. Defaults to TableSelectionModeZeroOrOne
Source Edittable: Table instance. proc selectionMode=(table: Table; mode: TableSelectionMode) {....raises: [], tags: [], forbids: [].}
-
Sets the table selection mode.Warning: All rows will be deselected if the existing selection is illegal in the new selection mode.
Source Edittable: Table instance. mode: Table selection mode to set. proc setAllTabsMargined(t: Tab; margined: bool = true) {....raises: [], tags: [], forbids: [].}
-
Set all tabs in t as margined
Source Editt: Tab instance. margined: true to set a margin for all tabs, false otherwise. proc setAttribute(s: AttributedString; a: Attribute; start, end: int) {. ...raises: [], tags: [], forbids: [].}
- Sets a in the byte range [start, end) of s. Any existing attributes in that byte range of the same type are removed. You should not use a after this function returns. Source Edit
proc setColor(c: ColorButton; r, g, b: float; alpha: float = 1.0) {....raises: [], tags: [], forbids: [].}
-
Sets the color button color.
Source Editc: ColorButton instance. r: Red. Float in range of 0.0, 1.0. g: Green. Float in range of 0.0, 1.0. b: Blue. Float in range of 0.0, 1.0. alpha: Alpha. Float in range of 0.0, 1.0. proc setColumnWidth(table: Table; column, width: int) {....raises: [], tags: [], forbids: [].}
-
Sets the table column width.
Setting the width to -1 will restore automatic column sizing matching either the width of the content or column header (which ever one is bigger).
Note: Darwin currently only resizes to the column header width on -1.
Source Edittable: Table instance. column: Column index. width: Column width to set in pixels, -1 to restore automatic column sizing. proc setIdentity(m: ptr DrawMatrix) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc setMargined(t: Tab; index: int; margined: bool) {....raises: [], tags: [], forbids: [].}
-
Sets whether or not the page/tab at index has a margin.
The margin size is determined by the OS defaults.
Source Editt: Tab instance. index: Index of the tab/page to un/set margin for. margined: true to set a margin for tab at index, false otherwise. proc setSortIndicator(table: Table; column: int; indicator: SortIndicator) {. ...raises: [], tags: [], forbids: [].}
-
Sets the column's sort indicator displayed in the table header.
Use this to display appropriate arrows in the table header to indicate a sort direction.
Note: Setting the indicator is purely visual and does not perform any sorting.
Source Edittable: Table instance. column: Column index. indicator: Sort indicator. proc skew(m: ptr DrawMatrix; x, y, xamount, yamount: float) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc sortIndicator(table: Table; column: int): SortIndicator {....raises: [], tags: [], forbids: [].}
-
Returns the column's sort indicator displayed in the table header.
Source Edittable: Table instance. column: Column index. proc stretch(a: Attribute): TextStretch {....raises: [], tags: [], forbids: [].}
-
Returns the font stretch stored in a.Error: It is an error to call this on a Attribute that does not hold a font stretch.Source Edit
proc stroke(c: ptr DrawContext; path: DrawPath; b: ptr DrawBrush; p: ptr DrawStrokeParams) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc text(b: Button): string {....raises: [], tags: [], forbids: [].}
- Returns the button label text. Source Edit
proc text(c: Checkbox): string {....raises: [], tags: [], forbids: [].}
-
Returns the checkbox label text.
Source Editc: Checkbox instance. proc text(c: EditableCombobox): string {....raises: [], tags: [], forbids: [].}
-
Returns the text of the editable combo box.
This text is either the text of one of the predefined list items or the text manually entered by the user.
Source Editc: Combobox instance. proc text(e: Entry): string {....raises: [], tags: [], forbids: [].}
-
Returns the entry's text.
Source Edite: Entry instance. proc text(e: MultilineEntry): string {....raises: [], tags: [], forbids: [].}
-
Returns the multi line entry's text.
Source Edite: MultilineEntry instance proc text=(b: Button; text: string) {....raises: [], tags: [], forbids: [].}
-
Sets the button label text.
Source Editb: Button instance text: Label text proc text=(c: Checkbox; text: string) {....raises: [], tags: [], forbids: [].}
-
Sets the checkbox label text.
Source Editc: Checkbox instance. text: Label text. proc text=(c: EditableCombobox; text: string) {....raises: [], tags: [], forbids: [].}
-
Sets the text of the editable combo box.
This text is either the text of one of the predefined list items or the text manually entered by the user.
Source Editc: Combobox instance. text: Text field text. proc text=(e: Entry; text: string) {....raises: [], tags: [], forbids: [].}
-
Sets the entry's text.
Source Edite: Entry instance. text: Entry text proc text=(e: MultilineEntry; text: string) {....raises: [], tags: [], forbids: [].}
-
Sets the multi line entry's text.
Source Edite: MultilineEntry instance text: Single/multi line text proc time(d: DateTimePicker): DateTime {....raises: [], tags: [], forbids: [].}
-
Returns date and time stored in the data time picker.
Source Editd: DateTimePicker instance proc time=(d: DateTimePicker; dateTime: DateTime) {....raises: [], tags: [], forbids: [].}
-
Sets date and time of the data time picker.
Source Editd: DateTimePicker instance. time: Date and/or time as local time. proc timer(milliseconds: int; fun: proc (): bool) {....raises: [], tags: [], forbids: [].}
-
Call fun after milliseconds milliseconds. This is repeated until fun returns false.Note: This cannot be called from any thread, unlike queueMain()Note: The minimum exact timing, either accuracy (timer burst, etc.) or granularity (15ms on Windows, etc.), is OS-definedSource Edit
proc transform(c: ptr DrawContext; m: ptr DrawMatrix) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc transformPoint(m: ptr DrawMatrix): tuple[x, y: float] {....raises: [], tags: [], forbids: [].}
- Source Edit
proc transformSize(m: ptr DrawMatrix): tuple[x, y: float] {....raises: [], tags: [], forbids: [].}
- Source Edit
proc translate(m: ptr DrawMatrix; x, y: float) {....raises: [], tags: [], forbids: [].}
- Source Edit
proc `type`(v: TableValue): TableValueType {....raises: [], tags: [], forbids: [].}
-
Gets the TableValue type.
Source Editv: Table value. func typeSignature[SomeWidget: Widget](w: SomeWidget): int
- Get widget type signature Source Edit
proc underlineColor(a: Attribute): tuple[u: UnderlineColor, r, g, b, alpha: float] {....raises: [], tags: [], forbids: [].}
-
Returns the underline color stored in a.Error: It is an error to call this on a Attribute that does not hold an underline color.Source Edit
proc uninit() {....raises: [], tags: [], forbids: [].}
-
Un-Initialize the application
Usually not needed as mainLoop() calls this for you.
Source Edit proc value(p: ProgressBar): int {....raises: [], tags: [], forbids: [].}
-
Returns the progress bar value.
Source Editp: ProgressBar instance. proc value=(p: ProgressBar; n: -1 .. 100) {....raises: [], tags: [], forbids: [].}
-
Sets the progress bar value.
Valid values are [0, 100] for displaying a solid bar imitating a percent value.
Use a value of -1 to render an animated bar to convey an indeterminate value.
Source Editp: ProgressBar instance. n: Value to set. Integer in the range of [-1, 100]. proc verifySetParent[SomeWidget: Widget](w: SomeWidget; parent: Widget)
-
Makes sure the widget's parent can be set to parent.Warning: This will crash the application if false.
Source Editw: Widget instance. parent: Widget instance. proc weight(a: Attribute): TextWeight {....raises: [], tags: [], forbids: [].}
-
Returns the font weight stored in a.Error: It is an error to call this on a Attribute that does not hold a font weight.Source Edit
Exports
-
ForEach, TextWeight, TextItalic, TextStretch, FontDescriptor, WindowResizeEdge, Modifiers, ExtKey, AreaDrawParams, AreaMouseEvent, AreaKeyEvent, AreaHandler, DrawMatrix, DrawFillMode, DrawBrushType, DrawLineCap, DrawLineJoin, DrawStrokeParams, DrawDefaultMiterLimit, DrawBrushGradientStop, AttributeType, TextWeight, TextItalic, TextStretch, Underline, UnderlineColor, DrawTextAlign, DrawTextLayoutParams, DrawContext, DrawBrush, DrawBrushType, Align, At, TableSelectionMode, TableModelHandler, TableParams, TableTextColumnOptionalParams, TableColumnType, TableValueType, TableModelColumnNeverEditable, TableModelColumnAlwaysEditable, SortIndicator