core

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: BSD-3-Clause Imports: 66 Imported by: 114

Documentation

Overview

Package core provides the core GUI functionality of Cogent Core.

Index

Examples

Constants

View Source
const (
	ListRowProperty = "sv-row"
	ListColProperty = "sv-col"
)
View Source
const (
	// Sprites are stored as arrays of same-sized textures,
	// allocated by size in Set 2, starting at 32
	SpriteStart = system.MaxTexturesPerSet * 2

	// Full set of sprite textures in set = 2
	MaxSpriteTextures = system.MaxTexturesPerSet

	// Allocate 128 layers within each sprite size
	MaxSpritesPerTexture = 128
)
View Source
const DragSpriteName = "__DragSprite__"

DragSpriteName is the name of the sprite added when dragging an object.

View Source
const TreeTempMovedTag = `_\&MOVED\&`

TreeTempMovedTag is a kind of hack to prevent moved items from being deleted, using DND

Variables

View Source
var (
	// TheApp is the current [App]; only one is ever in effect.
	TheApp = &App{App: system.TheApp}

	// AppAbout is the about information for the current app.
	// It is set by a linker flag in the core command line tool.
	AppAbout string

	// AppIcon is the svg icon for the current app.
	// It is set by a linker flag in the core command line tool.
	// It defaults to [icons.DefaultAppIcon] otherwise.
	AppIcon string = icons.DefaultAppIcon
)
View Source
var (
	// TextFieldBlinker manages cursor blinking
	TextFieldBlinker = Blinker{}

	// TextFieldSpriteName is the name of the window sprite used for the cursor
	TextFieldSpriteName = "TextField.Cursor"
)

AllSettings is a global slice containing all of the user Settings that the user will see in the settings window. It contains the base Cogent Core settings by default and should be modified by other apps to add their app settings.

View Source
var AppColor = color.RGBA{66, 133, 244, 255}

AppColor is the default primary color used to generate the color scheme. The user can still change the primary color used to generate the color scheme through [AppearanceSettingsData.Color] unless ForceAppColor is set to true, but this value will always take effect if the settings color is the default value. It defaults to Google Blue (#4285f4).

View Source
var AppearanceSettings = &AppearanceSettingsData{
	SettingsBase: SettingsBase{
		Name: "Appearance",
		File: filepath.Join(TheApp.CogentCoreDataDir(), "appearance-settings.toml"),
	},
}

AppearanceSettings are the currently active global Cogent Core appearance settings.

View Source
var AutoScrollRate = float32(1)

AutoScrollRate determines the rate of auto-scrolling of layouts

View Source
var BasicBarType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.BasicBar", IDName: "basic-bar", Doc: "BasicBar is a [Frame] that automatically has [ToolbarStyles] applied but does\nnot have the more advanced features of a [Toolbar].", Embeds: []types.Field{{Name: "Frame"}}, Instance: &BasicBar{}})

BasicBarType is the types.Type for BasicBar

View Source
var BodyType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Body", IDName: "body", Doc: "Body holds the primary content of a [Scene].\nIt is the main container for app content.", Directives: []types.Directive{{Tool: "core", Directive: "no-new"}}, Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Title", Doc: "Title is the title of the body, which is also\nused for the window title where relevant."}}, Instance: &Body{}})

BodyType is the types.Type for Body

View Source
var ButtonType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Button", IDName: "button", Doc: "Button is an interactive button with text, an icon, an indicator, a shortcut,\nand/or a menu. The standard behavior is to register a click event handler with\nOnClick.", Directives: []types.Directive{{Tool: "core", Directive: "embedder"}}, Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the type of button."}, {Name: "Text", Doc: "Text is the text for the button.\nIf it is blank, no text is shown."}, {Name: "Icon", Doc: "Icon is the icon for the button.\nIf it is \"\" or [icons.None], no icon is shown."}, {Name: "Indicator", Doc: "Indicator is the menu indicator icon to present.\nIf it is \"\" or [icons.None],, no indicator is shown.\nIt is automatically set to [icons.KeyboardArrowDown]\nwhen there is a Menu elements present unless it is\nset to [icons.None]."}, {Name: "Shortcut", Doc: "Shortcut is an optional shortcut keyboard chord to trigger this button,\nactive in window-wide scope. Avoid conflicts with other shortcuts\n(a log message will be emitted if so). Shortcuts are processed after\nall other processing of keyboard input. Command is automatically translated\ninto Meta on macOS and Control on all other platforms."}, {Name: "Menu", Doc: "Menu is a menu constructor function used to build and display\na menu whenever the button is clicked. There will be no menu\nif it is nil. The constructor function should add buttons\nto the Scene that it is passed."}}, Instance: &Button{}})

ButtonType is the types.Type for Button

View Source
var CanvasType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Canvas", IDName: "canvas", Doc: "Canvas is a widget that can be arbitrarily drawn to by setting\nits Draw function using [Canvas.SetDraw].", Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "Draw", Doc: "Draw is the function used to draw the content of the\ncanvas every time that it is rendered. The paint context\nis automatically normalized to the size of the canvas,\nso you should specify points on a 0-1 scale."}, {Name: "Context", Doc: "Context is the paint context used for drawing."}}, Instance: &Canvas{}})

CanvasType is the types.Type for Canvas

View Source
var ChooserType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Chooser", IDName: "chooser", Doc: "Chooser is a drop down selection widget that allows users to choose\none option among a list of items.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the styling type of the chooser."}, {Name: "Items", Doc: "Items are the chooser items available for selection."}, {Name: "Icon", Doc: "Icon is an optional icon displayed on the left side of the chooser."}, {Name: "Indicator", Doc: "Indicator is the icon to use for the indicator displayed on the\nright side of the chooser."}, {Name: "Editable", Doc: "Editable is whether provide a text field for editing the value,\nor just a button for selecting items."}, {Name: "AllowNew", Doc: "AllowNew is whether to allow the user to add new items to the\nchooser through the editable textfield (if Editable is set to\ntrue) and a button at the end of the chooser menu. See also [DefaultNew]."}, {Name: "DefaultNew", Doc: "DefaultNew configures the chooser to accept new items, as in\n[AllowNew], and also turns off completion popups and always\nadds new items to the list of items, without prompting.\nUse this for cases where the typical use-case is to enter new values,\nbut the history of prior values can also be useful."}, {Name: "Placeholder", Doc: "Placeholder, if Editable is set to true, is the text that is\ndisplayed in the text field when it is empty. It must be set\nusing [Chooser.SetPlaceholder]."}, {Name: "ItemsFuncs", Doc: "ItemsFuncs is a slice of functions to call before showing the items\nof the chooser, which is typically used to configure them\n(eg: if they are based on dynamic data). The functions are called\nin ascending order such that the items added in the first function\nwill appear before those added in the last function. Use\n[Chooser.AddItemsFunc] to add a new items function. If at least\none ItemsFunc is specified, the items of the chooser will be\ncleared before calling the functions."}, {Name: "CurrentItem", Doc: "CurrentItem is the currently selected item."}, {Name: "CurrentIndex", Doc: "CurrentIndex is the index of the currently selected item\nin [Chooser.Items]."}}, Instance: &Chooser{}})

ChooserType is the types.Type for Chooser

View Source
var ColorButtonType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.ColorButton", IDName: "color-button", Doc: "ColorButton represents a color value with a button.", Embeds: []types.Field{{Name: "Button"}}, Fields: []types.Field{{Name: "Color"}}, Instance: &ColorButton{}})

ColorButtonType is the types.Type for ColorButton

View Source
var ColorMapButtonType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.ColorMapButton", IDName: "color-map-button", Doc: "ColorMapButton displays a color map spectrum and can be clicked on\nto display a dialog for selecting different color map options.\nIt represents a [ColorMapName] value.", Embeds: []types.Field{{Name: "Button"}}, Fields: []types.Field{{Name: "MapName"}}, Instance: &ColorMapButton{}})

ColorMapButtonType is the types.Type for ColorMapButton

View Source
var ColorPickerType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.ColorPicker", IDName: "color-picker", Doc: "ColorPicker represents a color value with an interactive color picker\ncomposed of three HCT sliders.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Color", Doc: "the color that we view"}}, Instance: &ColorPicker{}})

ColorPickerType is the types.Type for ColorPicker

View Source
var DatePickerType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.DatePicker", IDName: "date-picker", Doc: "DatePicker is a widget for picking a date.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Time", Doc: "Time is the time that we are viewing"}}, Instance: &DatePicker{}})

DatePickerType is the types.Type for DatePicker

View Source
var DebugSettings = &DebugSettingsData{
	SettingsBase: SettingsBase{
		Name: "Debug",
		File: filepath.Join(TheApp.CogentCoreDataDir(), "debug-settings.toml"),
	},
}

DebugSettings are the currently active debugging settings

View Source
var DefaultPaths = FavPaths{
	{icons.Home, "home", "~"},
	{icons.DesktopMac, "Desktop", "~/Desktop"},
	{icons.Document, "Documents", "~/Documents"},
	{icons.Download, "Downloads", "~/Downloads"},
	{icons.Computer, "root", "/"},
}

DefaultPaths are default favorite paths

View Source
var DeviceSettings = &DeviceSettingsData{
	SettingsBase: SettingsBase{
		Name: "Device",
		File: filepath.Join(TheApp.CogentCoreDataDir(), "device-settings.toml"),
	},
}

DeviceSettings are the global device settings.

View Source
var DurationInputType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.DurationInput", IDName: "duration-input", Doc: "DurationInput represents a [time.Duration] value with a spinner and unit chooser.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Duration"}, {Name: "Unit", Doc: "Unit is the unit of time."}}, Instance: &DurationInput{}})

DurationInputType is the types.Type for DurationInput

View Source
var FileButtonType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.FileButton", IDName: "file-button", Doc: "FileButton represents a [Filename] value with a button\nthat opens a [FilePicker].", Embeds: []types.Field{{Name: "Button"}}, Fields: []types.Field{{Name: "Filename"}}, Instance: &FileButton{}})

FileButtonType is the types.Type for FileButton

View Source
var FilePickerKindColorMap = map[string]string{
	"folder": "pref(link)",
}

STYTODO: get rid of this or make it use actual color values FilePickerKindColorMap translates file Kinds into different colors for the file picker

View Source
var FilePickerType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.FilePicker", IDName: "file-picker", Doc: "FilePicker is a widget for selecting files.", Methods: []types.Method{{Name: "UpdateFilesAction", Doc: "UpdateFilesAction updates the list of files and other views for the current path.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "AddPathToFavorites", Doc: "AddPathToFavorites adds the current path to favorites", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "DirectoryUp", Doc: "DirectoryUp moves up one directory in the path", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "NewFolder", Doc: "NewFolder creates a new folder with the given name in the current directory.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"name"}, Returns: []string{"error"}}}, Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Directory", Doc: "Directory is the absolute path to the directory of files to display."}, {Name: "SelectedFilename", Doc: "SelectedFilename is the name of the currently selected file, not including the directory.\nSee [FilePicker.SelectedFile] for the full path."}, {Name: "Extensions", Doc: "Extensions is a list of the target file extensions.\nIf there are multiple, they must be comma separated.\nThe extensions must include the dot (\".\") at the start.\nThey must be set using [FilePicker.SetExtensions]."}, {Name: "FilterFunc", Doc: "FilterFunc is an optional filtering function for which files to display."}, {Name: "extensionMap", Doc: "extensionMap is a map of lower-cased extensions from Extensions.\nIt used for highlighting files with one of these extensions;\nmaps onto original Extensions value."}, {Name: "files", Doc: "files for current directory"}, {Name: "selectedIndex", Doc: "index of currently selected file in Files list (-1 if none)"}, {Name: "watcher", Doc: "change notify for current dir"}, {Name: "doneWatcher", Doc: "channel to close watcher watcher"}, {Name: "prevPath", Doc: "Previous path that was processed via UpdateFiles"}}, Instance: &FilePicker{}})

FilePickerType is the types.Type for FilePicker

View Source
var FontButtonType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.FontButton", IDName: "font-button", Doc: "FontButton represents a [FontName] with a [Button] that opens\na dialog for selecting the font family.", Embeds: []types.Field{{Name: "Button"}}, Instance: &FontButton{}})

FontButtonType is the types.Type for FontButton

View Source
var ForceAppColor bool

ForceAppColor is whether to prevent the user from changing the color scheme and make it always based on AppColor.

View Source
var FormButtonType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.FormButton", IDName: "form-button", Doc: "FormButton represents a struct value with a button that opens a [Form].", Embeds: []types.Field{{Name: "Button"}}, Fields: []types.Field{{Name: "Struct"}}, Instance: &FormButton{}})

FormButtonType is the types.Type for FormButton

View Source
var FormType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Form", IDName: "form", Doc: "Form represents a struct with rows of field names and editable values.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Struct", Doc: "Struct is the pointer to the struct that we are viewing."}, {Name: "Inline", Doc: "Inline is whether to display the form in one line."}, {Name: "structFields", Doc: "structFields are the fields of the current struct."}, {Name: "isShouldShower", Doc: "isShouldShower is whether the struct implements [ShouldShower], which results\nin additional updating being done at certain points."}}, Instance: &Form{}})

FormType is the types.Type for Form

View Source
var FrameType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Frame", IDName: "frame", Doc: "Frame is the primary node type responsible for organizing the sizes\nand positions of child widgets. It also renders the standard box model.\nAll collections of widgets should generally be contained within a [Frame];\notherwise, the parent widget must take over responsibility for positioning.\nFrames automatically can add scrollbars depending on the [styles.Style.Overflow].\n\nFor a [styles.Grid] frame, the [styles.Style.Columns] property should\ngenerally be set to the desired number of columns, from which the number of rows\nis computed; otherwise, it uses the square root of number of\nelements.", Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "StackTop", Doc: "StackTop, for a [styles.Stacked] frame, is the index of the node to use as the top of the stack.\nOnly the node at this index is rendered; if not a valid index, nothing is rendered."}, {Name: "LayoutStackTopOnly", Doc: "LayoutStackTopOnly is whether to only layout the top widget (specified by [Frame.StackTop])\nfor a [styles.Stacked] frame. This is appropriate for e.g., [Tabs], which do a full\nredraw on stack changes, but not for e.g., [Switch]es which don't."}, {Name: "Layout", Doc: "Layout contains implementation state info for doing layout"}, {Name: "HasScroll", Doc: "HasScroll is whether scrollbar is used for given dim."}, {Name: "Scrolls", Doc: "Scrolls are the scroll bars, which are fully managed as needed."}, {Name: "focusName", Doc: "accumulated name to search for when keys are typed"}, {Name: "focusNameTime", Doc: "time of last focus name event; for timeout"}, {Name: "focusNameLast", Doc: "last element focused on; used as a starting point if name is the same"}}, Instance: &Frame{}})

FrameType is the types.Type for Frame

View Source
var FuncButtonType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.FuncButton", IDName: "func-button", Doc: "FuncButton is a button that is set up to call a function when it\nis pressed, using a dialog to prompt the user for any arguments.\nAlso, it automatically sets various properties of the button like\nthe name, text, tooltip, and icon based on the properties of the\nfunction, using [reflect] and [types]. The function must be registered\nwith [types] to get documentation information, but that is not\nrequired; add a `//types:add` comment directive and run `core generate`\nif you want tooltips. If the function is a method, both the method and\nits receiver type must be added to [types] to get documentation.", Embeds: []types.Field{{Name: "Button"}}, Fields: []types.Field{{Name: "Func", Doc: "Func is the [types.Func] associated with this button.\nThis function can also be a method, but it must be\nconverted to a [types.Func] first. It should typically\nbe set using [FuncButton.SetFunc]."}, {Name: "ReflectFunc", Doc: "ReflectFunc is the [reflect.Value] of the function or\nmethod associated with this button. It should typically\nbet set using [FuncButton.SetFunc]."}, {Name: "Args", Doc: "Args are the [FuncArg] objects associated with the\narguments of the function. They are automatically set in\n[SetFunc], but they can be customized to configure\ndefault values and other options."}, {Name: "Returns", Doc: "Returns are the [FuncArg] objects associated with the\nreturn values of the function. They are automatically\nset in [SetFunc], but they can be customized to configure\noptions. The [FuncArg.Value]s are not set until the\nfunction is called, and are thus not typically applicable\nto access."}, {Name: "Confirm", Doc: "Confirm is whether to prompt the user for confirmation\nbefore calling the function."}, {Name: "ShowReturn", Doc: "ShowReturn is whether to display the return values of\nthe function (and a success message if there are none).\nThe way that the return values are shown is determined\nby ShowReturnAsDialog. Non-nil error return values will\nalways be shown, even if ShowReturn is set to false."}, {Name: "ShowReturnAsDialog", Doc: "ShowReturnAsDialog, if and only if ShowReturn is true,\nindicates to show the return values of the function in\na dialog, instead of in a snackbar, as they are by default.\nIf there are multiple return values from the function, or if\none of them is a complex type (pointer, struct, slice,\narray, map), then ShowReturnAsDialog will\nautomatically be set to true."}, {Name: "NewWindow", Doc: "NewWindow makes the ReturnDialog a NewWindow dialog\n(if supported by platform)."}, {Name: "WarnUnadded", Doc: "WarnUnadded is whether to log warnings when a function that\nhas not been added to [types] is used. It is on by default and\nmust be set before [FuncButton.SetFunc] is called for it to\nhave any effect. Warnings are never logged for anonymous functions."}, {Name: "Context", Doc: "Context is used for opening Dialogs if non-nil."}, {Name: "AfterFunc", Doc: "AfterFunc is an optional function called after the func button\nfunction is executed"}}, Instance: &FuncButton{}})

FuncButtonType is the types.Type for FuncButton

View Source
var HandleType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Handle", IDName: "handle", Doc: "Handle represents a draggable handle that can be used to\ncontrol the size of an element. The [Handle.Styles.Direction]\ncontrols the direction in which the handle moves.", Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "Min", Doc: "Min is the minimum value that the handle can go to\n(typically the lower bound of the dialog/splits)"}, {Name: "Max", Doc: "Max is the maximum value that the handle can go to\n(typically the upper bound of the dialog/splits)"}, {Name: "Pos", Doc: "Pos is the current position of the handle on the\nscale of [Handle.Min] to [Handle.Max]"}}, Instance: &Handle{}})

HandleType is the types.Type for Handle

View Source
var IconButtonType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.IconButton", IDName: "icon-button", Doc: "IconButton represents an [icons.Icon] with a [Button] that opens\na dialog for selecting the icon.", Embeds: []types.Field{{Name: "Button"}}, Instance: &IconButton{}})

IconButtonType is the types.Type for IconButton

View Source
var IconType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Icon", IDName: "icon", Doc: "Icon renders an [svg.SVG] icon.\nThe rendered version is cached for a given size.\nIcons do not render a background or border independent of their SVG object.\nThe size of on Icon is determined by the [styles.Font.Size] property.", Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "Icon", Doc: "icon name that has been set."}, {Name: "Filename", Doc: "file name for the loaded icon, if loaded"}, {Name: "SVG", Doc: "SVG drawing of the icon"}}, Instance: &Icon{}})

IconType is the types.Type for Icon

View Source
var ImageType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Image", IDName: "image", Doc: "Image is a widget that renders a static bitmap image.\nSee [styles.ObjectFits] for how to control the image rendering within\nthe allocated size. The default minimum requested size is the pixel\nsize in [units.Dp] units (1/160th of an inch).", Methods: []types.Method{{Name: "Open", Doc: "Open sets the image to the image located at the given filename.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"filename"}, Returns: []string{"error"}}}, Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "Image", Doc: "Image is the bitmap image."}, {Name: "prevPixels", Doc: "prevPixels is the cached last rendered image."}, {Name: "prevObjectFit", Doc: "prevObjectFit is the cached [styles.Style.ObjectFit] of the last rendered image."}, {Name: "prevSize", Doc: "prevSize is the cached allocated size for the last rendered image."}}, Instance: &Image{}})

ImageType is the types.Type for Image

View Source
var InlineListType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.InlineList", IDName: "inline-list", Doc: "InlineList represents a slice within a single line of value widgets.\nThis is typically used for smaller slices.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Slice", Doc: "Slice is the slice that we are viewing."}, {Name: "isArray", Doc: "isArray is whether the slice is actually an array."}}, Instance: &InlineList{}})

InlineListType is the types.Type for InlineList

View Source
var InspectorType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Inspector", IDName: "inspector", Doc: "Inspector represents a struct, creating a property editor of the fields --\nconstructs Children widgets to show the field names and editor fields for\neach field, within an overall frame with an optional title, and a button\nbox at the bottom where methods can be invoked", Methods: []types.Method{{Name: "Save", Doc: "Save saves tree to current filename, in a standard JSON-formatted file", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Returns: []string{"error"}}, {Name: "SaveAs", Doc: "SaveAs saves tree to given filename, in a standard JSON-formatted file", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"filename"}, Returns: []string{"error"}}, {Name: "Open", Doc: "Open opens tree from given filename, in a standard JSON-formatted file", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"filename"}, Returns: []string{"error"}}, {Name: "ToggleSelectionMode", Doc: "ToggleSelectionMode toggles the editor between selection mode or not.\nIn selection mode, bounding boxes are rendered around each Widget,\nand clicking on a Widget pulls it up in the inspector.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "InspectApp", Doc: "InspectApp displays the underlying operating system app", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}}, Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Root", Doc: "Root is the root of the tree being edited."}, {Name: "CurrentNode", Doc: "CurrentNode is the currently selected node in the tree."}, {Name: "Filename", Doc: "Filename is the current filename for saving / loading"}}, Instance: &Inspector{}})

InspectorType is the types.Type for Inspector

View Source
var KeyChordButtonType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.KeyChordButton", IDName: "key-chord-button", Doc: "KeyChordButton represents a [key.Chord] value with a button.", Embeds: []types.Field{{Name: "Button"}}, Fields: []types.Field{{Name: "Chord"}}, Instance: &KeyChordButton{}})

KeyChordButtonType is the types.Type for KeyChordButton

View Source
var KeyMapButtonType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.KeyMapButton", IDName: "key-map-button", Doc: "KeyMapButton represents a [keymap.MapName] value with a button.", Embeds: []types.Field{{Name: "Button"}}, Fields: []types.Field{{Name: "MapName"}}, Instance: &KeyMapButton{}})

KeyMapButtonType is the types.Type for KeyMapButton

View Source
var KeyedListButtonType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.KeyedListButton", IDName: "keyed-list-button", Doc: "KeyedListButton represents a map value with a button that opens a [KeyedList].", Embeds: []types.Field{{Name: "Button"}}, Fields: []types.Field{{Name: "Map"}}, Instance: &KeyedListButton{}})

KeyedListButtonType is the types.Type for KeyedListButton

View Source
var KeyedListType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.KeyedList", IDName: "keyed-list", Doc: "KeyedList represents a map value using two columns of editable key and value widgets.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Map", Doc: "Map is the pointer to the map that we are viewing."}, {Name: "Inline", Doc: "Inline is whether to display the map in one line."}, {Name: "SortValues", Doc: "SortValue is whether to sort by values instead of keys."}, {Name: "ncols", Doc: "ncols is the number of columns to display if the keyed list is not inline."}}, Instance: &KeyedList{}})

KeyedListType is the types.Type for KeyedList

View Source
var LayoutLastAutoScroll time.Time
View Source
var ListBaseType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.ListBase", IDName: "list-base", Doc: "ListBase is the base for [List] and [Table] and any other displays\nof array-like data. It automatically computes the number of rows that fit\nwithin its allocated space, and manages the offset view window into the full\nlist of items, and supports row selection, copy / paste, Drag-n-Drop, etc.\nUse [ListBase.BindSelect] to make the list designed for item selection.", Methods: []types.Method{{Name: "CopyIndexes", Doc: "CopyIndexes copies selected idxs to system.Clipboard, optionally resetting the selection", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"reset"}}, {Name: "DeleteIndexes", Doc: "DeleteIndexes deletes all selected indexes", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "CutIndexes", Doc: "CutIndexes copies selected indexes to system.Clipboard and deletes selected indexes", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "PasteIndex", Doc: "PasteIndex pastes clipboard at given idx", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"idx"}}, {Name: "Duplicate", Doc: "Duplicate copies selected items and inserts them after current selection --\nreturn idx of start of duplicates if successful, else -1", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Returns: []string{"int"}}}, Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Slice", Doc: "Slice is the pointer to the slice that we are viewing."}, {Name: "ShowIndexes", Doc: "ShowIndexes is whether to show the indexes of rows or not (default false)."}, {Name: "MinRows", Doc: "MinRows specifies the minimum number of rows to display, to ensure\nat least this amount is displayed."}, {Name: "SelectedValue", Doc: "SelectedValue is the current selection value; initially select this value if set."}, {Name: "SelectedIndex", Doc: "index of currently selected item"}, {Name: "InitSelectedIndex", Doc: "index of row to select at start"}, {Name: "SelectedIndexes", Doc: "list of currently selected slice indexes"}, {Name: "lastClick", Doc: "lastClick is the last row that has been clicked on.\nThis is used to prevent erroneous double click events\nfrom being sent when the user clicks on multiple different\nrows in quick succession."}, {Name: "NormalCursor", Doc: "NormalCursor is the cached cursor to display when there\nis no row being hovered."}, {Name: "CurrentCursor", Doc: "CurrentCursor is the cached cursor that should currently be\ndisplayed."}, {Name: "SliceUnderlying", Doc: "SliceUnderlying is the underlying slice value."}, {Name: "hoverRow", Doc: "currently hovered row"}, {Name: "DraggedIndexes", Doc: "list of currently dragged indexes"}, {Name: "VisRows", Doc: "total number of rows visible in allocated display size"}, {Name: "StartIndex", Doc: "starting slice index of visible rows"}, {Name: "SliceSize", Doc: "size of slice"}, {Name: "MakeIter", Doc: "iteration through the configuration process, reset when a new slice type is set"}, {Name: "tmpIndex", Doc: "temp idx state for e.g., dnd"}, {Name: "ElementValue", Doc: "ElementValue is a [reflect.Value] representation of the underlying element type\nwhich is used whenever there are no slice elements available"}, {Name: "maxWidth", Doc: "maximum width of value column in chars, if string"}, {Name: "ReadOnlyKeyNav", Doc: "ReadOnlyKeyNav is whether support key navigation when ReadOnly (default true).\nIt uses a capture of up / down events to manipulate selection, not focus."}, {Name: "SelectMode", Doc: "SelectMode is whether to be in select rows mode or editing mode."}, {Name: "ReadOnlyMultiSelect", Doc: "ReadOnlyMultiSelect: if view is ReadOnly, default selection mode is to choose one row only.\nIf this is true, standard multiple selection logic with modifier keys is instead supported."}, {Name: "InFocusGrab", Doc: "InFocusGrab is a guard for recursive focus grabbing."}, {Name: "isArray", Doc: "isArray is whether the slice is actually an array."}}, Instance: &ListBase{}})

ListBaseType is the types.Type for ListBase

View Source
var ListButtonType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.ListButton", IDName: "list-button", Doc: "ListButton represents a slice or array value with a button that opens a [List].", Embeds: []types.Field{{Name: "Button"}}, Fields: []types.Field{{Name: "Slice"}}, Instance: &ListButton{}})

ListButtonType is the types.Type for ListButton

View Source
var ListGridType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.ListGrid", IDName: "list-grid", Doc: "ListGrid handles the resizing logic for [List], [Table].", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "MinRows", Doc: "MinRows is set from parent SV"}, {Name: "RowHeight", Doc: "height of a single row, computed during layout"}, {Name: "VisRows", Doc: "total number of rows visible in allocated display size"}, {Name: "BgStripe", Doc: "Various computed backgrounds"}, {Name: "BgSelect", Doc: "Various computed backgrounds"}, {Name: "BgSelectStripe", Doc: "Various computed backgrounds"}, {Name: "BgHover", Doc: "Various computed backgrounds"}, {Name: "BgHoverStripe", Doc: "Various computed backgrounds"}, {Name: "BgHoverSelect", Doc: "Various computed backgrounds"}, {Name: "BgHoverSelectStripe", Doc: "Various computed backgrounds"}, {Name: "LastBackground", Doc: "LastBackground is the background for which modified\nbackgrounds were computed -- don't update if same"}}, Instance: &ListGrid{}})

ListGridType is the types.Type for ListGrid

View Source
var ListType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.List", IDName: "list", Doc: "List represents a slice value with a list of value widgets and optional index widgets.\nUse [ListBase.BindSelect] to make the list designed for item selection.", Embeds: []types.Field{{Name: "ListBase"}}, Fields: []types.Field{{Name: "StyleFunc", Doc: "StyleFunc is an optional styling function."}}, Instance: &List{}})

ListType is the types.Type for List

View Source
var MeterType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Meter", IDName: "meter", Doc: "Meter is a widget that renders a current value on as a filled\nbar/semicircle relative to a minimum and maximum potential value.", Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the styling type of the meter."}, {Name: "Value", Doc: "Value is the current value of the meter.\nIt defaults to 0.5."}, {Name: "Min", Doc: "Min is the minimum possible value of the meter.\nIt defaults to 0."}, {Name: "Max", Doc: "Max is the maximum possible value of the meter.\nIt defaults to 1."}, {Name: "Text", Doc: "Text, for [MeterCircle] and [MeterSemicircle], is the\ntext to render inside of the circle/semicircle."}, {Name: "ValueColor", Doc: "ValueColor is the image color that will be used to\nrender the filled value bar. It should be set in Style."}, {Name: "Width", Doc: "Width, for [MeterCircle] and [MeterSemicircle], is the\nwidth of the circle/semicircle. It should be set in Style."}}, Instance: &Meter{}})

MeterType is the types.Type for Meter

View Source
var NoSentenceCaseFor []string

NoSentenceCaseFor indicates to not transform field names in [Form]s into "Sentence case" for types whose full, package-path-qualified name contains any of these strings. For example, this can be used to disable sentence casing for types with scientific abbreviations in field names, which are more readable when not sentence cased. However, this should not be needed in most circumstances.

View Source
var RenderWindowGlobalMu sync.Mutex

RenderWindowGlobalMu is a mutex for any global state associated with windows

View Source
var SVGType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.SVG", IDName: "svg", Doc: "SVG is a Widget that renders an [svg.SVG] object.\nIf it is not [states.ReadOnly], the user can pan and zoom the display.\nBy default, it is [states.ReadOnly].", Methods: []types.Method{{Name: "Open", Doc: "Open opens an XML-formatted SVG file", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"filename"}, Returns: []string{"error"}}, {Name: "SaveSVG", Doc: "SaveSVG saves the current SVG to an XML-encoded standard SVG file.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"filename"}, Returns: []string{"error"}}, {Name: "SavePNG", Doc: "SavePNG saves the current rendered SVG image to an PNG image file.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"filename"}, Returns: []string{"error"}}}, Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "SVG", Doc: "SVG is the SVG drawing to display in this widget"}}, Instance: &SVG{}})

SVGType is the types.Type for SVG

View Source
var SavedPathsFilename = "saved-paths.json"

SavedPathsFilename is the name of the saved file paths file in the Cogent Core data directory.

View Source
var SceneShowIters = 2
View Source
var SceneType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Scene", IDName: "scene", Doc: "Scene contains a [Widget] tree, rooted in an embedded [Frame] layout,\nwhich renders into its [Scene.Pixels] image. The [Scene] is set in a\n[Stage], which the [Scene] has a pointer to.\n\nEach [Scene] contains state specific to its particular usage\nwithin a given [Stage] and overall rendering context, representing the unit\nof rendering in the Cogent Core framework.", Directives: []types.Directive{{Tool: "core", Directive: "no-new"}}, Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Bars", Doc: "Bars contains functions for constructing the control bars for this Scene,\nattached to different sides of a Scene (e.g., TopAppBar at Top,\nNavBar at Bottom, etc).  Functions are called in forward order\nso first added are called first."}, {Name: "BarsInherit", Doc: "BarsInherit determines which of the Bars side functions are inherited\nfrom the context widget, for FullWindow Dialogs"}, {Name: "AppBars", Doc: "AppBars contains functions for making the plan for the top app bar."}, {Name: "Body", Doc: "Body provides the main contents of scenes that use control Bars\nto allow the main window contents to be specified separately\nfrom that dynamic control content.  When constructing scenes using\na Body, you can operate directly on the [Body], which has wrappers\nfor most major Scene functions."}, {Name: "Data", Doc: "Data is the optional data value being represented by this scene.\nUsed e.g., for recycling views of a given item instead of creating new one."}, {Name: "SceneGeom", Doc: "Size and position relative to overall rendering context."}, {Name: "PaintContext", Doc: "paint context for rendering"}, {Name: "Pixels", Doc: "live pixels that we render into"}, {Name: "Events", Doc: "event manager for this scene"}, {Name: "Stage", Doc: "current stage in which this Scene is set"}, {Name: "renderBBoxes", Doc: "renderBBoxes indicates to render colored bounding boxes for all of the widgets\nin the scene. This is enabled by the [Inspector] in select element mode."}, {Name: "renderBBoxHue", Doc: "renderBBoxHue is current hue for rendering bounding box in [Scene.RenderBBoxes] mode."}, {Name: "selectedWidget", Doc: "selectedWidget is the currently selected/hovered widget through the [Inspector] selection mode\nthat should be highlighted with a background color."}, {Name: "selectedWidgetChan", Doc: "selectedWidgetChan is the channel on which the selected widget through the inspect editor\nselection mode is transmitted to the inspect editor after the user is done selecting."}, {Name: "lastRender", Doc: "lastRender captures key params from last render.\nIf different then a new ApplyStyleScene is needed."}, {Name: "showIter", Doc: "showIter counts up at start of showing a Scene\nto trigger Show event and other steps at start of first show"}, {Name: "directRenders", Doc: "directRenders are widgets that render directly to the RenderWin\ninstead of rendering into the Scene Pixels image."}, {Name: "HasShown", Doc: "HasShown is whether this scene has been shown.\nThis is used to ensure that [events.Show] is only sent once."}, {Name: "updating", Doc: "updating means the Scene is in the process of updating.\nIt is set for any kind of tree-level update.\nSkip any further update passes until it goes off."}, {Name: "sceneNeedsRender", Doc: "sceneNeedsRender is whether anything in the Scene needs to be re-rendered\n(but not necessarily the whole scene itself)."}, {Name: "needsLayout", Doc: "needsLayout is whether the Scene needs a new layout pass."}, {Name: "imageUpdated", Doc: "imageUpdated indicates that the Scene's image has been updated\ne.g., due to a render or a resize. This is reset by the\nglobal [RenderWindow] rendering pass, so it knows whether it needs to\ncopy the image up to the GPU or not."}, {Name: "prefSizing", Doc: "prefSizing means that this scene is currently doing a\nPrefSize computation to compute the size of the scene\n(for sizing window for example); affects layout size computation\nonly for Over"}}, Instance: &Scene{}})

SceneType is the types.Type for Scene

View Source
var ScrimType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Scrim", IDName: "scrim", Doc: "A Scrim is just a dummy Widget used for rendering a Scrim.\nOnly used for its type. Everything else managed by RenderWindow.", Directives: []types.Directive{{Tool: "core", Directive: "no-new"}}, Embeds: []types.Field{{Name: "WidgetBase"}}, Instance: &Scrim{}})

ScrimType is the types.Type for Scrim

View Source
var SeparatorType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Separator", IDName: "separator", Doc: "Separator draws a separator line. It goes in the direction\nspecified by [style.Style.Direction].", Embeds: []types.Field{{Name: "WidgetBase"}}, Instance: &Separator{}})

SeparatorType is the types.Type for Separator

View Source
var SliderType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Slider", IDName: "slider", Doc: "Slider is a slideable widget that provides slider functionality for two Types:\nSlider type provides a movable thumb that represents Value as the center of thumb\nPos position, with room reserved at ends for 1/2 of the thumb size.\nScrollbar has a VisiblePct factor that specifies the percent of the content\ncurrently visible, which determines the size of the thumb, and thus the range of motion\nremaining for the thumb Value (VisiblePct = 1 means thumb is full size, and no remaining\nrange of motion).\nThe Content size (inside the margin and padding) determines the outer bounds of\nthe rendered area.\nThe [styles.Style.Direction] determines the direction in which the slider slides.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the type of the slider, which determines its visual\nand functional properties. The default type, [SliderSlider],\nshould work for most end-user use cases."}, {Name: "Value", Doc: "Value is the current value, represented by the position of the thumb.\nIt defaults to 0.5."}, {Name: "Min", Doc: "Min is the minimum possible value.\nIt defaults to 0."}, {Name: "Max", Doc: "Max is the maximum value supported.\nIt defaults to 1."}, {Name: "Step", Doc: "Step is the amount that the arrow keys increment/decrement the value by.\nIt defaults to 0.1."}, {Name: "EnforceStep", Doc: "EnforceStep is whether to ensure that the value is always\na multiple of [Slider.Step]."}, {Name: "PageStep", Doc: "PageStep is the amount that the PageUp and PageDown keys\nincrement/decrement the value by.\nIt defaults to 0.2, and will be at least as big as [Slider.Step]."}, {Name: "Icon", Doc: "Icon is an optional icon to use for the dragging knob."}, {Name: "VisiblePct", Doc: "For Scrollbar type only: proportion (1 max) of the full range of scrolled data\nthat is currently visible.  This determines the thumb size and range of motion:\nif 1, full slider is the thumb and no motion is possible."}, {Name: "ThumbSize", Doc: "Size of the thumb as a proportion of the slider thickness, which is\nContent size (inside the padding).  This is for actual X,Y dimensions,\nso must be sensitive to Dim dimension alignment."}, {Name: "TrackSize", Doc: "TrackSize is the proportion of slider thickness for the visible track\nfor the Slider type.  It is often thinner than the thumb, achieved by\nvalues < 1 (.5 default)"}, {Name: "InputThreshold", Doc: "threshold for amount of change in scroll value before emitting an input event"}, {Name: "Prec", Doc: "specifies the precision of decimal places (total, not after the decimal point)\nto use in representing the number. This helps to truncate small weird floating\npoint values in the nether regions."}, {Name: "ValueColor", Doc: "The background color that is used for styling the selected value section of the slider.\nIt should be set in the StyleFuncs, just like the main style object is.\nIf it is set to transparent, no value is rendered, so the value section of the slider\njust looks like the rest of the slider."}, {Name: "ThumbColor", Doc: "The background color that is used for styling the thumb (handle) of the slider.\nIt should be set in the StyleFuncs, just like the main style object is.\nIf it is set to transparent, no thumb is rendered, so the thumb section of the slider\njust looks like the rest of the slider."}, {Name: "StayInView", Doc: "If true, keep the slider (typically a Scrollbar) within the parent Scene\nbounding box, if the parent is in view.  This is the default behavior\nfor Layout scrollbars, and setting this flag replicates that behavior\nin other scrollbars."}, {Name: "Pos", Doc: "logical position of the slider relative to Size"}, {Name: "LastValue", Doc: "previous Change event emitted value - don't re-emit Change if it is the same"}, {Name: "PrevSlide", Doc: "previous sliding value - for computing the Input change"}, {Name: "Size", Doc: "Computed size of the slide box in the relevant dimension\nrange of motion, exclusive of spacing, based on layout allocation."}, {Name: "SlideStartPos", Doc: "underlying drag position of slider -- not subject to snapping"}}, Instance: &Slider{}})

SliderType is the types.Type for Slider

View Source
var SpaceType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Space", IDName: "space", Doc: "Space is a fixed size blank space, with\na default width of 1ch and a height of 1em.\nYou can set [styles.Style.Min] to change its size.\nIt does not render anything.", Embeds: []types.Field{{Name: "WidgetBase"}}, Instance: &Space{}})

SpaceType is the types.Type for Space

View Source
var SpinnerType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Spinner", IDName: "spinner", Doc: "Spinner is a [TextField] for editing numerical values. It comes with\nfields, methods, buttons, and shortcuts to enhance numerical value editing.", Embeds: []types.Field{{Name: "TextField"}}, Fields: []types.Field{{Name: "Value", Doc: "Value is the current value."}, {Name: "HasMin", Doc: "HasMin is whether there is a minimum value to enforce."}, {Name: "Min", Doc: "Min, if HasMin is true, is the the minimum value in range."}, {Name: "HasMax", Doc: "HaxMax is whether there is a maximum value to enforce."}, {Name: "Max", Doc: "Max, if HasMax is true, is the maximum value in range."}, {Name: "Step", Doc: "Step is the amount that the up and down buttons and arrow keys\nincrement/decrement the value by. It defaults to 0.1."}, {Name: "EnforceStep", Doc: "EnforceStep is whether to ensure that the value of the spinner\nis always a multiple of [Spinner.Step]."}, {Name: "PageStep", Doc: "PageStep is the amount that the PageUp and PageDown keys\nincrement/decrement the value by.\nIt defaults to 0.2, and will be at least as big as [Spinner.Step]."}, {Name: "Prec", Doc: "Prec specifies the precision of decimal places\n(total, not after the decimal point) to use in\nrepresenting the number. This helps to truncate\nsmall weird floating point values."}, {Name: "Format", Doc: "Format is the format string to use for printing the value.\nIf it unset, %g is used. If it is decimal based\n(ends in d, b, c, o, O, q, x, X, or U) then the value is\nconverted to decimal prior to printing."}}, Instance: &Spinner{}})

SpinnerType is the types.Type for Spinner

View Source
var SplitsType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Splits", IDName: "splits", Doc: "Splits allocates a certain proportion of its space to each of its children\nalong [styles.Style.Direction]. It adds [Handle] widgets to its parts that\nallow the user to customize the amount of space allocated to each child.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Splits", Doc: "Splits is the proportion (0-1 normalized, enforced) of space\nallocated to each element. 0 indicates that an element should\nbe completely collapsed. By default, each element gets the\nsame amount of space."}, {Name: "SavedSplits", Doc: "SavedSplits is a saved version of the splits that can be restored\nfor dynamic collapse/expand operations."}}, Instance: &Splits{}})

SplitsType is the types.Type for Splits

View Source
var StretchType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Stretch", IDName: "stretch", Doc: "Stretch adds a stretchy element that grows to fill all\navailable space. You can set [styles.Style.Grow] to change\nhow much it grows relative to other growing elements.\nIt does not render anything.", Embeds: []types.Field{{Name: "WidgetBase"}}, Instance: &Stretch{}})

StretchType is the types.Type for Stretch

View Source
var SwitchType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Switch", IDName: "switch", Doc: "Switch is a widget that can toggle between an on and off state.\nIt can be displayed as a switch, checkbox, or radio button.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the styling type of switch."}, {Name: "Text", Doc: "Text is the text for the switch."}, {Name: "IconOn", Doc: "IconOn is the icon to use for the on, checked state of the switch."}, {Name: "IconOff", Doc: "Iconoff is the icon to use for the off, unchecked state of the switch."}, {Name: "IconIndeterminate", Doc: "IconIndeterminate is the icon to use for the indeterminate (unknown) state."}}, Instance: &Switch{}})

SwitchType is the types.Type for Switch

View Source
var SwitchesType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Switches", IDName: "switches", Doc: "Switches is a widget for containing a set of [Switch]es.\nIt can optionally enforce mutual exclusivity (ie: radio buttons)\nthrough the [Switches.Mutex] field. It supports binding to\n[enums.Enum] and [enums.BitFlag] values with appropriate properties\nautomatically set.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the type of switches that will be made."}, {Name: "Items", Doc: "Items are the items displayed to the user."}, {Name: "Mutex", Doc: "Mutex is whether to make the items mutually exclusive\n(checking one turns off all the others)."}, {Name: "AllowNone", Doc: "AllowNone is whether to allow the user to deselect all items.\nIt is on by default."}, {Name: "SelectedIndexes", Doc: "SelectedIndexes are the indexes in [Switches.Items] of the currently\nselected switch items."}, {Name: "bitFlagValue", Doc: "bitFlagValue is the associated bit flag value if non-nil (for [Value])."}}, Instance: &Switches{}})

SwitchesType is the types.Type for Switches

View Source
var SystemSettings = &SystemSettingsData{
	SettingsBase: SettingsBase{
		Name: "System",
		File: filepath.Join(TheApp.CogentCoreDataDir(), "system-settings.toml"),
	},
}

SystemSettings are the currently active Cogent Core system settings.

View Source
var TabType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Tab", IDName: "tab", Doc: "Tab is a tab button that contains any, all, or none of a label, an icon,\nand a close icon. Tabs should be made using the [Tabs.NewTab] function.", Directives: []types.Directive{{Tool: "core", Directive: "no-new"}}, Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the styling type of the tab. This property\nmust be set on the parent [Tabs] for it to work correctly."}, {Name: "Text", Doc: "Text is the text for the tab.\nIf it is nil, no text is shown.\nText is never shown for [NavigationRail] tabs."}, {Name: "Icon", Doc: "Icon is the icon for the tab.\nIf it is \"\" or [icons.None], no icon is shown."}, {Name: "CloseIcon", Doc: "CloseIcon is the icon used as a close button for the tab.\nIf it is \"\" or [icons.None], the tab is not closeable.\nThe default value is [icons.Close].\nOnly [FunctionalTabs] can be closed; all other types of\ntabs will not render a close button and can not be closed."}, {Name: "MaxChars", Doc: "MaxChars is the maximum number of characters to include in tab text.\nIt elides text that is longer than that."}}, Instance: &Tab{}})

TabType is the types.Type for Tab

View Source
var TableType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Table", IDName: "table", Doc: "Table represents a slice of structs as a table, where the fields are\nthe columns and the elements are the rows. It is a full-featured editor with\nmultiple-selection, cut-and-paste, and drag-and-drop.\nUse [ListBase.BindSelect] to make the table designed for item selection.", Embeds: []types.Field{{Name: "ListBase"}}, Fields: []types.Field{{Name: "StyleFunc", Doc: "StyleFunc is an optional styling function."}, {Name: "SelectedField", Doc: "SelectedField is the current selection field; initially select value in this field."}, {Name: "SortIndex", Doc: "SortIndex is the current sort index."}, {Name: "SortDescending", Doc: "SortDescending is whether the current sort order is descending."}, {Name: "visibleFields", Doc: "visibleFields are the visible fields."}, {Name: "numVisibleFields", Doc: "numVisibleFields is the number of visible fields."}, {Name: "headerWidths", Doc: "headerWidths has the number of characters in each header, per visibleFields."}, {Name: "colMaxWidths", Doc: "colMaxWidths records maximum width in chars of string type fields."}}, Instance: &Table{}})

TableType is the types.Type for Table

View Source
var TabsType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Tabs", IDName: "tabs", Doc: "Tabs divide widgets into logical groups and give users the ability\nto freely navigate between them using tab buttons.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the styling type of the tabs. If it is changed after\nthe tabs are first configured, Update needs to be called on\nthe tabs."}, {Name: "NewTabButton", Doc: "NewTabButton is whether to show a new tab button at the end of the list of tabs."}, {Name: "MaxChars", Doc: "MaxChars is the maximum number of characters to include in the tab text.\nIt elides text that are longer than that."}, {Name: "CloseIcon", Doc: "CloseIcon is the icon used for tab close buttons.\nIf it is \"\" or [icons.None], the tab is not closeable.\nThe default value is [icons.Close].\nOnly [FunctionalTabs] can be closed; all other types of\ntabs will not render a close button and can not be closed."}, {Name: "PrevEffectiveType", Doc: "PrevEffectiveType is the previous effective type of the tabs\nas computed by [TabTypes.Effective]."}, {Name: "Mu", Doc: "Mu is a mutex protecting updates to tabs. Tabs can be driven\nprogrammatically and via user input so need extra protection."}}, Instance: &Tabs{}})

TabsType is the types.Type for Tabs

View Source
var TextFieldType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.TextField", IDName: "text-field", Doc: "TextField is a widget for editing a line of text.\nWith the default WhiteSpaceNormal style setting,\ntext will wrap onto multiple lines as needed.\nSet to WhiteSpaceNowrap (e.g., styles.Style.SetTextWrap(false)) to\nforce everything to be on a single line.\nWith multi-line wrapped text, the text is still treated as a single\ncontiguous line of wrapped text.", Directives: []types.Directive{{Tool: "core", Directive: "embedder"}}, Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the styling type of the text field."}, {Name: "Placeholder", Doc: "Placeholder is the text that is displayed\nwhen the text field is empty."}, {Name: "Validator", Doc: "Validator is a function used to validate the input\nof the text field. If it returns a non-nil error,\nthen an error color, icon, and tooltip will be displayed."}, {Name: "LeadingIcon", Doc: "LeadingIcon, if specified, indicates to add a button\nat the start of the text field with this icon."}, {Name: "LeadingIconOnClick", Doc: "LeadingIconOnClick, if specified, is the function to call when\nthe LeadingIcon is clicked. If this is nil, the leading icon\nwill not be interactive."}, {Name: "TrailingIcon", Doc: "TrailingIcon, if specified, indicates to add a button\nat the end of the text field with this icon."}, {Name: "TrailingIconOnClick", Doc: "TrailingIconOnClick, if specified, is the function to call when\nthe TrailingIcon is clicked. If this is nil, the trailing icon\nwill not be interactive."}, {Name: "NoEcho", Doc: "NoEcho is whether replace displayed characters with bullets to conceal text\n(for example, for a password input)."}, {Name: "CursorWidth", Doc: "CursorWidth is the width of the text field cursor.\nIt should be set in Style like all other style properties.\nBy default, it is 1dp."}, {Name: "CursorColor", Doc: "CursorColor is the color used for the text field cursor (caret).\nIt should be set in Style like all other style properties.\nBy default, it is [colors.Scheme.Primary.Base]."}, {Name: "PlaceholderColor", Doc: "PlaceholderColor is the color used for the Placeholder text.\nIt should be set in Style like all other style properties.\nBy default, it is [colors.Scheme.OnSurfaceVariant]."}, {Name: "SelectColor", Doc: "SelectColor is the color used for the text selection background color.\nIt should be set in Style like all other style properties.\nBy default, it is [colors.Scheme.Select.Container]"}, {Name: "Complete", Doc: "Complete contains functions and data for text field completion.\nIt must be set using [TextField.SetCompleter]."}, {Name: "Txt", Doc: "Txt is the last saved value of the text string being edited."}, {Name: "Edited", Doc: "Edited is whether the text has been edited relative to the original."}, {Name: "EditTxt", Doc: "EditTxt is the live text string being edited, with the latest modifications."}, {Name: "Error", Doc: "Error is the current validation error of the text field."}, {Name: "EffPos", Doc: "EffPos is the effective position with any leading icon space added."}, {Name: "EffSize", Doc: "EffSize is the effective size, subtracting any leading and trailing icon space."}, {Name: "StartPos", Doc: "StartPos is the starting display position in the string."}, {Name: "EndPos", Doc: "EndPos is the ending display position in the string."}, {Name: "CursorPos", Doc: "CursorPos is the current cursor position."}, {Name: "CursorLine", Doc: "CursorLine is the current cursor line position."}, {Name: "CharWidth", Doc: "CharWidth is the approximate number of chars that can be\ndisplayed at any time, which is computed from the font size."}, {Name: "SelectStart", Doc: "SelectStart is the starting position of selection in the string."}, {Name: "SelectEnd", Doc: "SelectEnd is the ending position of selection in the string."}, {Name: "SelectInit", Doc: "SelectInit is the initial selection position (where it started)."}, {Name: "SelectMode", Doc: "SelectMode is whether to select text as the cursor moves."}, {Name: "RenderAll", Doc: "RenderAll is the render version of entire text, for sizing."}, {Name: "RenderVis", Doc: "RenderVis is the render version of just the visible text."}, {Name: "NLines", Doc: "number of lines from last render update, for word-wrap version"}, {Name: "FontHeight", Doc: "FontHeight is the font height cached during styling."}, {Name: "BlinkOn", Doc: "BlinkOn oscillates between on and off for blinking."}, {Name: "CursorMu", Doc: "CursorMu is the mutex for updating the cursor between blinker and field."}, {Name: "Undos", Doc: "Undos is the undo manager for the text field."}}, Instance: &TextField{}})

TextFieldType is the types.Type for TextField

View Source
var TextType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Text", IDName: "text", Doc: "Text is a widget for rendering text. It supports full HTML styling,\nincluding links. By default, text wraps and collapses whitespace, although\nyou can change this by changing [styles.Text.WhiteSpace].", Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "Text", Doc: "Text is the text to display."}, {Name: "Type", Doc: "Type is the styling type of text to use."}, {Name: "paintText", Doc: "paintText is the [paint.Text] for the text."}, {Name: "normalCursor", Doc: "normalCursor is the cached cursor to display when there\nis no link being hovered."}}, Instance: &Text{}})

TextType is the types.Type for Text

View Source
var TheWindowGeometrySaver = WindowGeometrySaver{}

TheWindowGeometrySaver is the manager of window geometry settings

View Source
var TimeInputType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.TimeInput", IDName: "time-input", Doc: "TimeInput presents two text fields for editing a date and time,\nboth of which can pull up corresponding picker dialogs.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Time"}}, Instance: &TimeInput{}})

TimeInputType is the types.Type for TimeInput

View Source
var TimePickerType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.TimePicker", IDName: "time-picker", Doc: "TimePicker is a widget for picking a time.", Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Time", Doc: "Time is the time that we are viewing"}, {Name: "Hour", Doc: "the raw input hour"}, {Name: "PM", Doc: "whether we are in PM mode (so we have to add 12h to everything)"}}, Instance: &TimePicker{}})

TimePickerType is the types.Type for TimePicker

View Source
var ToolbarType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Toolbar", IDName: "toolbar", Doc: "Toolbar is a [Frame] that is useful for holding [Button]s that do things.\nIt automatically moves items that do not fit into an overflow menu, and\nmanages additional items that are always placed onto this overflow menu.\nUse [Body.AddAppBar] to add to the default toolbar at the top of an app.", Methods: []types.Method{{Name: "StandardOverflowMenu", Doc: "StandardOverflowMenu adds standard overflow menu items.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"m"}}}, Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "OverflowMenus", Doc: "OverflowMenus are functions for configuring the overflow menu of the\ntoolbar. You can use [Toolbar.AddOverflowMenu] to add them.\nThese are processed in reverse order (last in, first called)\nso that the default items are added last."}, {Name: "overflowItems", Doc: "overflowItems are items moved from the main toolbar that will be\nshown in the overflow menu."}, {Name: "overflowButton", Doc: "overflowButton is the widget to pull up the overflow menu."}}, Instance: &Toolbar{}})

ToolbarType is the types.Type for Toolbar

View Source
var TreeButtonType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.TreeButton", IDName: "tree-button", Doc: "TreeButton represents a [tree.Node] value with a button.", Embeds: []types.Field{{Name: "Button"}}, Fields: []types.Field{{Name: "Tree"}}, Instance: &TreeButton{}})

TreeButtonType is the types.Type for TreeButton

View Source
var TreePageSteps = 10

TreePageSteps is the number of steps to take in PageUp / Down events

View Source
var TreeType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Tree", IDName: "tree", Doc: "Tree provides a graphical representation of a tree structure,\nproviding full navigation and manipulation abilities.\n\nIt does not handle layout by itself, so if you want it to scroll\nseparately from the rest of the surrounding context, use [NewTreeFrame].\n\nIf the SyncNode field is non-nil, typically via\nSyncRootNode method, then the Tree mirrors another\ntree structure, and tree editing functions apply to\nthe source tree first, and then to the Tree by sync.\n\nOtherwise, data can be directly encoded in a Tree\nderived type, to represent any kind of tree structure\nand associated data.\n\nStandard [events.Event]s are sent to any listeners, including\nSelect, Change, and DoubleClick. The selected nodes\nare in the root SelectedNodes list.", Methods: []types.Method{{Name: "OpenAll", Doc: "OpenAll opens the given node and all of its sub-nodes", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "CloseAll", Doc: "CloseAll closes the given node and all of its sub-nodes.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "Copy", Doc: "Copy copies to system.Clipboard, optionally resetting the selection.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"reset"}}, {Name: "Cut", Doc: "Cut copies to system.Clipboard and deletes selected items.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "Paste", Doc: "Paste pastes clipboard at given node.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "InsertAfter", Doc: "InsertAfter inserts a new node in the tree\nafter this node, at the same (sibling) level,\nprompting for the type of node to insert.\nIf SyncNode is set, operates on Sync Tree.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "InsertBefore", Doc: "InsertBefore inserts a new node in the tree\nbefore this node, at the same (sibling) level,\nprompting for the type of node to insert\nIf SyncNode is set, operates on Sync Tree.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "AddChildNode", Doc: "AddChildNode adds a new child node to this one in the tree,\nprompting the user for the type of node to add\nIf SyncNode is set, operates on Sync Tree.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "DeleteNode", Doc: "DeleteNode deletes the tree node or sync node corresponding\nto this view node in the sync tree.\nIf SyncNode is set, operates on Sync Tree.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "Duplicate", Doc: "Duplicate duplicates the sync node corresponding to this view node in\nthe tree, and inserts the duplicate after this node (as a new sibling).\nIf SyncNode is set, operates on Sync Tree.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "EditNode", Doc: "EditNode pulls up a [Form] dialog for the node.\nIf SyncNode is set, operates on Sync Tree.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}, {Name: "InspectNode", Doc: "InspectNode pulls up a new Inspector window on the node.\nIf SyncNode is set, operates on Sync Tree.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}}, Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "SyncNode", Doc: "If non-nil, the [tree.Node] that this widget is viewing in the tree (the source)"}, {Name: "Text", Doc: "The text to display for the tree item label, which automatically\ndefaults to the [tree.Node.Name] of the tree node. It has no effect\nif [Tree.SyncNode] is non-nil."}, {Name: "Icon", Doc: "optional icon, displayed to the the left of the text label"}, {Name: "IconOpen", Doc: "icon to use for an open (expanded) branch; defaults to [icons.KeyboardArrowDown]"}, {Name: "IconClosed", Doc: "icon to use for a closed (collapsed) branch; defaults to [icons.KeyboardArrowRight]"}, {Name: "IconLeaf", Doc: "icon to use for a terminal node branch that has no children; defaults to [icons.Blank]"}, {Name: "Indent", Doc: "amount to indent children relative to this node"}, {Name: "OpenDepth", Doc: "OpenDepth is the depth for nodes be initialized as open (default 4).\nNodes beyond this depth will be initialized as closed."}, {Name: "Closed", Doc: "Closed is whether this tree node is currently toggled closed (children not visible)."}, {Name: "SelectMode", Doc: "SelectMode, when set on the root node, determines whether keyboard movements should update selection."}, {Name: "viewIndex", Doc: "linear index of this node within the entire tree.\nupdated on full rebuilds and may sometimes be off,\nbut close enough for expected uses"}, {Name: "widgetSize", Doc: "size of just this node widget.\nour alloc includes all of our children, but we only draw us."}, {Name: "Root", Doc: "Root is the cached root of the tree. It is automatically set and does not need to be\nset by the end user."}, {Name: "SelectedNodes", Doc: "SelectedNodes holds the currently selected nodes, on the\nRootView node only."}, {Name: "actStateLayer", Doc: "actStateLayer is the actual state layer of the tree, which\nshould be used when rendering it and its parts (but not its children).\nthe reason that it exists is so that the children of the tree\n(other trees) do not inherit its stateful background color, as\nthat does not look good."}, {Name: "inOpen", Doc: "inOpen is set in the Open method to prevent recursive opening for lazy-open nodes."}}, Instance: &Tree{}})

TreeType is the types.Type for Tree

View Source
var TypeChooserType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.TypeChooser", IDName: "type-chooser", Doc: "TypeChooser represents a [types.Type] value with a chooser.", Embeds: []types.Field{{Name: "Chooser"}}, Instance: &TypeChooser{}})

TypeChooserType is the types.Type for TypeChooser

View Source
var ValueConverters []func(value any, tags reflect.StructTag) Value

ValueConverters is a slice of functions that return a Value for a value, using optional tags context to inform the selection. It is used by ToValue. If a function returns nil, it falls back on the next function in the slice, and if all functions return nil, it falls back on the default bindings. These functions must NOT call Bind. These functions are called in sequential order, so you can insert a function at the start to take precedence over others. You can add to this using the AddValueConverter helper function.

View Source
var ValueTypes = map[string]func(value any) Value{}

ValueTypes is a map of functions that return a Value for a value of a certain fully package path qualified type name. It is used by ToValue. If a function returns nil, it falls back onto the next step. You can add to this using the AddValueType helper function. These functions must NOT call Bind.

View Source
var WidgetBaseType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.WidgetBase", IDName: "widget-base", Doc: "WidgetBase implements the [Widget] interface and provides the core functionality\nof a widget. You must use WidgetBase as an embedded struct in all higher-level\nwidget types. It renders the standard box model, but does not layout or render\nany children; see [Frame] for that.", Methods: []types.Method{{Name: "Update", Doc: "Update updates the widget and all of its children by running [WidgetBase.UpdateWidget]\nand [WidgetBase.Style] on each one, and triggering a new layout pass with\n[WidgetBase.NeedsLayout]. It is the main way that end users should trigger widget\nupdates, and it is guaranteed to fully update a widget to the current state.\nFor example, it should be called after making any changes to the core properties\nof a widget, such as the text of [Text], the icon of a [Button], or the slice\nof a [Table].\n\nUpdate differs from [WidgetBase.UpdateWidget] in that it updates the widget and all\nof its children down the tree, whereas [WidgetBase.UpdateWidget] only updates the widget\nitself. Also, Update also calls [WidgetBase.Style] and [WidgetBase.NeedsLayout],\nwhereas [WidgetBase.UpdateWidget] does not. End-user code should typically call Update,\nnot [WidgetBase.UpdateWidget].\n\nIf you are calling this in a separate goroutine outside of the main\nconfiguration, rendering, and event handling structure, you need to\ncall [WidgetBase.AsyncLock] and [WidgetBase.AsyncUnlock] before and\nafter this, respectively.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}}, Embeds: []types.Field{{Name: "NodeBase"}}, Fields: []types.Field{{Name: "Tooltip", Doc: "Tooltip is the text for the tooltip for this widget,\nwhich can use HTML formatting."}, {Name: "Parts", Doc: "Parts are a separate tree of sub-widgets that can be used to store\northogonal parts of a widget when necessary to separate them from children.\nFor example, trees use parts to separate their internal parts from\nthe other child tree nodes. Composite widgets like buttons should\nNOT use parts to store their components; parts should only be used when\nabsolutely necessary."}, {Name: "Geom", Doc: "Geom has the full layout geometry for size and position of this Widget"}, {Name: "Updaters", Doc: "Updaters are a slice of functions called in sequential descending (reverse) order\nin [WidgetBase.UpdateWidget] to update the widget. You can use\n[WidgetBase.Updater] to add one. By default, this slice contains a function\nthat updates the widget's children using [WidgetBase.Make]."}, {Name: "Makers", Doc: "Makers are a slice of functions called in sequential ascending order\nin [WidgetBase.Make] to make the plan for how the widget's children should\nbe configured. You can use [WidgetBase.Maker] to add one."}, {Name: "OverrideStyle", Doc: "If true, override the computed styles and allow directly editing Styles."}, {Name: "Styles", Doc: "Styles are styling settings for this widget.\nThese are set in SetApplyStyle which should be called after any Config\nchange (e.g., as done by the Update method).  See Stylers for functions\nthat set all of the styles, ordered from initial base defaults to later\nadded overrides."}, {Name: "Stylers", Doc: "Stylers are a slice of functions that are called in sequential\nascending order (so the last added styler is called last and\nthus overrides all other functions) to style the element.\nThese should be set using Styler function. FirstStylers and\nFinalStylers are called before and after these stylers, respectively."}, {Name: "FirstStylers", Doc: "FirstStylers are a slice of functions that are called in sequential\nascending order (so the last added styler is called last and\nthus overrides all other functions) to style the element.\nThese should be set using FirstStyler function. These stylers\nare called before Stylers and FinalStylers."}, {Name: "FinalStylers", Doc: "FinalStylers are a slice of functions that are called in sequential\nascending order (so the last added styler is called last and\nthus overrides all other functions) to style the element.\nThese should be set using FinalStyler function. These stylers\nare called after FirstStylers and Stylers."}, {Name: "Listeners", Doc: "Listeners are event listener functions for processing events on this widget.\nThey are called in sequential descending order (so the last added listener\nis called first). They should be added using the On function. FirstListeners\nand FinalListeners are called before and after these listeners, respectively."}, {Name: "FirstListeners", Doc: "FirstListeners are event listener functions for processing events on this widget.\nThey are called in sequential descending order (so the last added listener\nis called first). They should be added using the OnFirst function. These listeners\nare called before Listeners and FinalListeners."}, {Name: "FinalListeners", Doc: "FinalListeners are event listener functions for processing events on this widget.\nThey are called in sequential descending order (so the last added listener\nis called first). They should be added using the OnFinal function. These listeners\nare called after FirstListeners and Listeners."}, {Name: "OnWidgetAdders", Doc: "A slice of functions to call on all widgets that are added as children\nto this widget or its children. These functions are called in sequential\nascending order, so the last added one is called last and thus can\noverride anything set by the other ones. These should be set using\nOnWidgetAdded, which can be called by both end-user and internal code."}, {Name: "ContextMenus", Doc: "ContextMenus is a slice of menu functions to call to construct\nthe widget's context menu on an [events.ContextMenu]. The\nfunctions are called in reverse order such that the elements\nadded in the last function are the first in the menu.\nContext menus should be added through [WidgetBase.AddContextMenu].\nSeparators will be added between each context menu function."}, {Name: "Scene", Doc: "Scene is the overall Scene to which we belong. It is automatically\nby widgets whenever they are added to another widget parent."}, {Name: "ValueUpdate", Doc: "ValueUpdate is a function set by [Bind] that is called in\n[WidgetBase.UpdateWidget] to update the widget's value from the bound value."}, {Name: "ValueOnChange", Doc: "ValueOnChange is a function set by [Bind] that is called when\nthe widget receives an [events.Change] event to update the bound value\nfrom the widget's value."}, {Name: "ValueTitle", Doc: "ValueTitle is the title to display for a dialog for this [Value]."}, {Name: "ValueNewWindow", Doc: "ValueNewWindow indicates that the dialog of a [Value] should be opened\nas a new window, instead of a typical full window in the same current window.\nThis is set by [InitValueButton] and handled by [OpenValueDialog].\nThis is triggered by holding down the Shift key while clicking on a\n[Value] button. Certain values such as [FileButton] may set this to true\nin their [InitValueButton] function."}, {Name: "needsRender", Doc: "needsRender is whether the widget needs to be rendered on the next render iteration."}}, Instance: &WidgetBase{}})

WidgetBaseType is the types.Type for WidgetBase

View Source
var WindowWait sync.WaitGroup

WindowWait is a wait group for waiting for all the open window event loops to finish. It is incremented by RenderWindow.GoStartEventLoop and decremented when the event loop terminates.

Functions

func AddValueConverter added in v0.2.0

func AddValueConverter(f func(value any, tags reflect.StructTag) Value)

AddValueConverter adds a converter function to ValueConverters.

func AddValueType added in v0.2.0

func AddValueType[T any, W Value]()

AddValueType binds the given value type to the given Value type, meaning that ToValue will return a new Value of the given type when it receives values of the given value type. It uses ValueTypes. This function is called with various standard types automatically.

func AppIconImages added in v0.1.3

func AppIconImages() []image.Image

AppIconImages returns a slice of images of sizes 16x16, 32x32, and 48x48 rendered from AppIcon. It returns nil if AppIcon is "" or if there is an error. It automatically logs any errors. It caches the result for future calls.

func AsWidget

func AsWidget(n tree.Node) (Widget, *WidgetBase)

AsWidget returns the given tree.Node as a Widget interface and a WidgetBase.

func Bind added in v0.2.0

func Bind[T Value](value any, vw T) T

Bind binds the given value to the given Value such that the values of the two will be linked and updated appropriately after events.Change events and during [Widget.UpdateWidget]. It returns the widget to enable method chaining.

func BindMapKey added in v0.2.0

func BindMapKey[T Value](mapv reflect.Value, key reflect.Value, vw T) T

BindMapKey is a version of Bind that works for keys in a map.

func BindMapValue added in v0.2.0

func BindMapValue[T Value](mapv reflect.Value, key reflect.Value, vw T) T

BindMapValue is a version of Bind that works for values in a map.

func CallFunc added in v0.2.0

func CallFunc(ctx Widget, fun any)

CallFunc calls the given function in the context of the given widget, popping up a dialog to prompt for any arguments and show the return values of the function. It is a helper function that uses NewSoloFuncButton under the hood.

func ChildByLabelCanFocus

func ChildByLabelCanFocus(fr *Frame, name string, after tree.Node) tree.Node

ChildByLabelCanFocus uses breadth-first search to find the first focusable element within the layout whose Label (using [ToLabel]) matches the given name using complete.IsSeedMatching. If after is non-nil, it only finds after that element.

func CompleteEditText

func CompleteEditText(text string, cp int, completion string, seed string) (ed complete.Edit)

CompleteEditText is a chance to modify the completion selection before it is inserted

func ConcealDots

func ConcealDots(n int) []rune

ConcealDots creates an n-length []rune of bullet characters.

func EndCPUMemoryProfile added in v0.1.1

func EndCPUMemoryProfile()

EndCPUMemoryProfile ends the standard Go cpu and memory profiling.

func EndTargetedProfile added in v0.1.1

func EndTargetedProfile()

EndTargetedProfile ends targeted profiling and prints report.

func ErrorDialog

func ErrorDialog(ctx Widget, err error, title ...string)

ErrorDialog opens a new Dialog displaying the given error in the context of the given widget. An optional title can be provided; if it is not, the title will default to "There was an error". If the given error is nil, no dialog is created.

func ErrorSnackbar

func ErrorSnackbar(ctx Widget, err error, label ...string)

ErrorSnackbar opens a [Snackbar] displaying the given error in the context of the given widget. Optional label text can be provided; if it is not, the label text will default to "Error". If the given error is nil, no snackbar is created.

func FilePickerDialog added in v0.2.0

func FilePickerDialog(ctx Widget, filename, exts, title string, fun func(selfile string))

FilePickerDialog opens a dialog for selecting a file.

func FilePickerDirOnlyFilter added in v0.2.0

func FilePickerDirOnlyFilter(fp *FilePicker, fi *fileinfo.FileInfo) bool

FilePickerDirOnlyFilter is a FilePickerFilterFunc that only shows directories (folders).

func FilePickerExtOnlyFilter added in v0.2.0

func FilePickerExtOnlyFilter(fp *FilePicker, fi *fileinfo.FileInfo) bool

FilePickerExtOnlyFilter is a FilePickerFilterFunc that only shows files that match the target extensions, and directories.

func FormDialog added in v0.2.0

func FormDialog(ctx Widget, stru any, title string, newWindow bool)

FormDialog opens a dialog (optionally in a new, separate window) for viewing / editing the given struct object, in the context of given ctx widget

func FuncArgsToStruct added in v0.2.0

func FuncArgsToStruct(args []FuncArg) reflect.Value

FuncArgsToStruct converts a slice of FuncArg objects to a new non-pointer struct reflect.Value.

func GrabRenderFrom

func GrabRenderFrom(w Widget) *image.RGBA

GrabRenderFrom grabs the rendered image from the given widget. If it returns nil, then the image could not be fetched.

func HandleRecover

func HandleRecover(r any)

HandleRecover is the core value of system.HandleRecover. If r is not nil, it makes a window displaying information about the panic. system.HandleRecover is initialized to this in init.

func InitValueButton added in v0.2.0

func InitValueButton(v Value, allowReadOnly bool, make func(d *Body), after ...func())

InitValueButton configures the given Value to open a dialog representing its value in accordance with the given dialog construction function when clicked. It also sets the tooltip of the widget appropriately. If allowReadOnly is false, the dialog will not be opened if the widget is read only. It also takes an optional function to call after the dialog is accepted.

func InspectorView added in v0.2.0

func InspectorView(b *Body, n tree.Node)

InspectorView configures the given body to have an interactive inspector of the given tree.

func InspectorWindow

func InspectorWindow(n tree.Node)

InspectorWindow opens an interactive editor of the given tree in a new window.

func IsWordBreak

func IsWordBreak(r1, r2 rune) bool

IsWordBreak defines what counts as a word break for the purposes of selecting words. r1 is the rune in question, r2 is the rune past r1 in the direction you are moving. Pass -1 for r2 if there is no rune past r1.

func JoinValueTitle added in v0.2.0

func JoinValueTitle(a, b string) string

JoinValueTitle returns a [WidgetBase.ValueTitle] string composed of two elements, with a • separator, handling the cases where either or both can be empty.

func LoadAllSettings

func LoadAllSettings() error

LoadAllSettings sets the defaults of, opens, and applies AllSettings.

func LoadSettings

func LoadSettings(se Settings) error

LoadSettings sets the defaults of, opens, and applies the given settings. If they are not already saved, it saves them. It process their `default:` struct tags in addition to calling their [Settings.Default] method.

func MenuSceneConfigStyles(msc *Scene)

MenuSceneConfigStyles configures the default styles for the given pop-up menu frame with the given parent. It should be called on menu frames when they are created.

func MessageDialog

func MessageDialog(ctx Widget, message string, title ...string)

MessageDialog opens a new Dialog displaying the given message in the context of the given widget. An optional title can be provided.

func MessageSnackbar

func MessageSnackbar(ctx Widget, message string)

MessageSnackbar opens a [Snackbar] displaying the given message in the context of the given widget.

func NoSentenceCaseForType added in v0.2.0

func NoSentenceCaseForType(tnm string) bool

NoSentenceCaseForType returns whether the given fully package-path-qualified name contains anything in the NoSentenceCaseFor list.

func OpenRecentPaths

func OpenRecentPaths()

OpenRecentPaths loads the active RecentPaths from data dir

func OpenSettings

func OpenSettings(se Settings) error

OpenSettings opens the given settings from their [Settings.Filename]. The settings are assumed to be in TOML unless they have a .json file extension. If they satisfy the SettingsOpener interface, [SettingsOpener.Open] will be used instead.

func OpenValueDialog added in v0.2.0

func OpenValueDialog(v Value, make func(d *Body), after ...func())

OpenValueDialog opens a new value dialog for the given Value using the given function for constructing the dialog and the optional given function to call after the dialog is accepted.

func ProfileToggle

func ProfileToggle()

ProfileToggle turns profiling on or off, which does both targeted and global CPU and Memory profiling.

func RecycleDialog

func RecycleDialog(data any) bool

RecycleDialog looks for a dialog with the given data. If it finds it, it shows it and returns true. Otherwise, it returns false. See RecycleMainWindow for a non-dialog window version.

func RecycleMainWindow added in v0.1.1

func RecycleMainWindow(data any) bool

RecycleMainWindow looks for an existing non-dialog window with the given Data. If it finds it, it shows it and returns true. Otherwise, it returns false. See RecycleDialog for a dialog version.

func ResetAllSettings

func ResetAllSettings() error

ResetAllSettings resets all of the settings to their default values.

func ResetSettings

func ResetSettings(se Settings) error

ResetSettings resets the given settings to their default values.

func SaveAllSettings

func SaveAllSettings() error

SaveAllSettings saves AllSettings.

func SaveRecentPaths

func SaveRecentPaths()

SaveRecentPaths saves the active RecentPaths to data dir

func SaveSettings

func SaveSettings(se Settings) error

SaveSettings saves the given settings to their [Settings.Filename]. The settings will be encoded in TOML unless they have a .json file extension. If they satisfy the SettingsSaver interface, [SettingsSaver.Save] will be used instead. Any non default fields are not saved, following reflectx.NonDefaultFields.

func SettingsEditor added in v0.2.0

func SettingsEditor(b *Body)

SettingsEditor adds to the given body an editor of user settings.

func SettingsEditorToolbarBase added in v0.2.0

func SettingsEditorToolbarBase(p *tree.Plan)

SettingsEditorToolbarBase is the base toolbar configuration function used in SettingsEditor.

func SettingsWindow

func SettingsWindow()

SettingsWindow opens a window for editing user settings.

func SliceIndexByValue added in v0.2.0

func SliceIndexByValue(slc any, fldVal any) (int, bool)

SliceIndexByValue searches for first index that contains given value in slice -- returns false if not found

func StartCPUMemoryProfile added in v0.1.1

func StartCPUMemoryProfile()

StartCPUMemoryProfile starts the standard Go cpu and memory profiling.

func StartTargetedProfile added in v0.1.1

func StartTargetedProfile()

StartTargetedProfile starts targeted profiling using the prof package.

func StringsInsertFirstUnique

func StringsInsertFirstUnique(strs *[]string, str string, max int)

StringsInsertFirstUnique inserts the given string at the start of the given string slice while keeping the overall length to the given max value. If the item is already on the list, then it is moved to the top and not re-added (unique items only). This is useful for a list of recent items.

func StructSliceIndexByValue added in v0.2.0

func StructSliceIndexByValue(structSlice any, fieldName string, fieldValue any) (int, error)

StructSliceIndexByValue searches for first index that contains given value in field of given name.

func StyleFromTags added in v0.2.0

func StyleFromTags(w Widget, tags reflect.StructTag)

StyleFromTags adds a WidgetBase.Styler to the given widget to set its style properties based on the given reflect.StructTag. Width, height, and grow properties are supported.

func ToolbarStyles

func ToolbarStyles(w Widget)

ToolbarStyles styles the given widget to have standard toolbar styling.

func UpdateAll

func UpdateAll()

UpdateAll updates all windows and triggers a full render rebuild. It is typically called when user settings are changed.

func UpdateSettings added in v0.1.1

func UpdateSettings(ctx Widget, se Settings)

UpdateSettings applies and saves the given settings in the context of the given widget and then updates all windows and triggers a full render rebuild.

func Wait

func Wait()

Wait waits for all windows to close and runs the main app loop. This should be put at the end of the main function, and is typically called through Stage.Wait.

Types

type App

type App struct {
	system.App `set:"-"`

	// AppBarConfig is the function that configures the AppBar,
	// typically put in the [Scene.Bars.Top] (i.e., a TopAppBar).
	// It is set to StdAppBarConfig by default, which makes the
	// standard AppBar behavior. If this is nil, then no AppBar
	// will be created by default.
	AppBarConfig func(parent Widget)

	// SceneConfig is the function called on every newly created [Scene]
	// to configure it, if it is non-nil. This can be used to set global
	// configuration and styling for all widgets using the OnWidgetAdded
	// method.
	SceneConfig func(sc *Scene)
}

App represents a Cogent Core app. It extends system.App to provide both system-level and high-level data and functions to do with the currently running application. The single instance of it is TheApp, which embeds system.TheApp.

func (*App) SetAppBarConfig

func (t *App) SetAppBarConfig(v func(parent Widget)) *App

SetAppBarConfig sets the [App.AppBarConfig]: AppBarConfig is the function that configures the AppBar, typically put in the [Scene.Bars.Top] (i.e., a TopAppBar). It is set to StdAppBarConfig by default, which makes the standard AppBar behavior. If this is nil, then no AppBar will be created by default.

func (*App) SetSceneConfig

func (t *App) SetSceneConfig(v func(sc *Scene)) *App

SetSceneConfig sets the [App.SceneConfig]: SceneConfig is the function called on every newly created Scene to configure it, if it is non-nil. This can be used to set global configuration and styling for all widgets using the OnWidgetAdded method.

type AppearanceSettingsData

type AppearanceSettingsData struct {
	SettingsBase

	// the color theme
	Theme Themes `default:"Auto"`

	// the primary color used to generate the color scheme
	Color color.RGBA `default:"#4285f4"`

	// overall zoom factor as a percentage of the default zoom
	Zoom float32 `default:"100" min:"10" max:"500" step:"10" format:"%g%%"`

	// the overall spacing factor as a percentage of the default amount of spacing
	// (higher numbers lead to more space and lower numbers lead to higher density)
	Spacing float32 `default:"100" min:"10" max:"500" step:"10" format:"%g%%"`

	// the overall font size factor applied to all text as a percentage
	// of the default font size (higher numbers lead to larger text)
	FontSize float32 `default:"100" min:"10" max:"500" step:"10" format:"%g%%"`

	// the amount that alternating rows are highlighted when showing tabular data (set to 0 to disable zebra striping)
	ZebraStripes float32 `default:"0" min:"0" max:"100" step:"10" format:"%g%%"`

	// screen-specific settings, which will override overall defaults if set
	Screens map[string]ScreenSettings

	// text highlighting style / theme
	HiStyle HiStyleName `default:"emacs"`

	// Font is the default font family to use.
	Font FontName `default:"Roboto"`

	// MonoFont is the default mono-spaced font family to use.
	MonoFont FontName `default:"Roboto Mono"`
}

AppearanceSettingsData is the data type for the global Cogent Core appearance settings.

func (*AppearanceSettingsData) Apply

func (as *AppearanceSettingsData) Apply()

func (*AppearanceSettingsData) ApplyDPI

func (as *AppearanceSettingsData) ApplyDPI()

ApplyDPI updates the screen LogicalDPI values according to current settings and zoom factor, and then updates all open windows as well.

func (*AppearanceSettingsData) DeleteSavedWindowGeoms

func (as *AppearanceSettingsData) DeleteSavedWindowGeoms()

DeleteSavedWindowGeoms deletes the file that saves the position and size of each window, by screen, and clear current in-memory cache. You shouldn't generally need to do this, but sometimes it is useful for testing or windows that are showing up in bad places that you can't recover from.

func (*AppearanceSettingsData) SaveScreenZoom

func (as *AppearanceSettingsData) SaveScreenZoom()

SaveScreenZoom saves the current zoom factor for the current screen.

func (*AppearanceSettingsData) ShouldShow

func (as *AppearanceSettingsData) ShouldShow(field string) bool

func (*AppearanceSettingsData) ZebraStripesWeight

func (as *AppearanceSettingsData) ZebraStripesWeight() float32

ZebraStripesWeight returns a 0 to 0.2 alpha opacity factor to use in computing a zebra stripe color.

type BarFuncs

type BarFuncs []func(parent Widget)

BarFuncs are functions for creating control bars, attached to different sides of a Scene (e.g., TopAppBar at Top, NavBar at Bottom, etc). Functions are called in forward order so first added are called first.

func (*BarFuncs) Add

func (bf *BarFuncs) Add(fun func(parent Widget)) *BarFuncs

Add adds the given function for configuring a control bar

func (*BarFuncs) Call

func (bf *BarFuncs) Call(parent Widget)

Call calls all the functions for configuring given widget

func (*BarFuncs) Inherit

func (bf *BarFuncs) Inherit(obf BarFuncs)

Inherit adds other bar funcs in front of any existing

func (*BarFuncs) IsEmpty

func (bf *BarFuncs) IsEmpty() bool

IsEmpty returns true if there are no functions added

type BasicBar

type BasicBar struct {
	Frame
}

BasicBar is a Frame that automatically has ToolbarStyles applied but does not have the more advanced features of a Toolbar.

func NewBasicBar

func NewBasicBar(parent ...tree.Node) *BasicBar

NewBasicBar returns a new BasicBar with the given optional parent: BasicBar is a Frame that automatically has ToolbarStyles applied but does not have the more advanced features of a Toolbar.

func (*BasicBar) Init added in v0.2.0

func (tb *BasicBar) Init()

func (*BasicBar) New

func (t *BasicBar) New() tree.Node

New returns a new *BasicBar value

func (*BasicBar) NodeType

func (t *BasicBar) NodeType() *types.Type

NodeType returns the *types.Type of BasicBar

type Blinker

type Blinker struct {
	// Ticker is the time.Ticker
	Ticker *time.Ticker

	// Widget is the current widget subject to blinking
	Widget Widget

	// Func is the function called every tick under Mu mutex protection
	Func func()

	Quit chan struct{}

	Mu sync.Mutex
}

Blinker manages the logistics of blinking things, such as cursors

func (bl *Blinker) Blink(dur time.Duration)

Blink sets up the blinking; does nothing if already setup

func (*Blinker) BlinkLoop

func (bl *Blinker) BlinkLoop()

BlinkLoop is the blinker's main control loop

func (*Blinker) QuitClean

func (bl *Blinker) QuitClean()

QuitClean is a cleanup function to call during Quit that breaks out of the ticker loop

func (*Blinker) ResetWidget

func (bl *Blinker) ResetWidget(w Widget)

ResetWidget sets Widget = nil if it is currently set to given one

func (*Blinker) SetWidget

func (bl *Blinker) SetWidget(w Widget)

SetWidget sets Widget to given one, under mutex lock

type Body

type Body struct {
	Frame

	// Title is the title of the body, which is also
	// used for the window title where relevant.
	Title string `set:"-"`
}

Body holds the primary content of a Scene. It is the main container for app content.

func NewBody

func NewBody(name ...string) *Body

NewBody creates a new Body that will serve as the content of a Scene (e.g., a Window, Dialog, etc). Body forms the central region of a Scene, and has OverflowAuto scrollbars by default. It will create its own parent Scene at this point, and has wrapper functions to transparently manage everything that the Scene typically manages during configuration, so you can usually avoid having to access the Scene directly. If a name is given and the name of TheApp is unset, it sets it to the given name.

func (*Body) AddAppBar

func (bd *Body) AddAppBar(m ...func(p *tree.Plan))

AddAppBar adds plan maker function(s) for the top app bar, which can be used to add items to it.

func (*Body) AddBottomBar

func (bd *Body) AddBottomBar(fun func(parent Widget))

AddBottomBar adds the given function for configuring a control bar at the bottom of the window

func (*Body) AddCancel

func (bd *Body) AddCancel(parent Widget) *Button

AddCancel adds Cancel button to given parent Widget (typically in Bottom Bar function), connecting to Close method and the Esc keychord event. Close sends a Change event to the Scene for listeners there. Should add an OnClick listener to this button to perform additional specific actions needed beyond Close.

func (*Body) AddLeftBar

func (bd *Body) AddLeftBar(fun func(parent Widget))

AddLeftBar adds the given function for configuring a control bar on the left of the window

func (*Body) AddOK

func (bd *Body) AddOK(parent Widget) *Button

AddOK adds an OK button to given parent Widget (typically in Bottom Bar function), connecting to Close method the Ctrl+Enter keychord event. Close sends a Change event to the Scene for listeners there. Should add an OnClick listener to this button to perform additional specific actions needed beyond Close.

func (*Body) AddOKOnly

func (bd *Body) AddOKOnly() *Body

AddOKOnly just adds an OK button in the BottomBar for simple popup dialogs that just need that one button

func (*Body) AddRightBar

func (bd *Body) AddRightBar(fun func(parent Widget))

AddRightBar adds the given function for configuring a control bar on the right of the window

func (*Body) AddSnackbarButton

func (bd *Body) AddSnackbarButton(text string, onClick ...func(e events.Event)) *Body

AddSnackbarButton adds a snackbar button with the given text and optional OnClick event handler. Only the first of the given event handlers is used, and the snackbar is automatically closed when the button is clicked regardless of whether there is an event handler passed.

func (*Body) AddSnackbarIcon

func (bd *Body) AddSnackbarIcon(icon icons.Icon, onClick ...func(e events.Event)) *Body

AddSnackbarIcon adds a snackbar icon button with the given icon and optional OnClick event handler. Only the first of the given event handlers is used, and the snackbar is automatically closed when the button is clicked regardless of whether there is an event handler passed.

func (*Body) AddSnackbarText

func (bd *Body) AddSnackbarText(text string) *Body

AddSnackbarText adds a snackbar Text with the given text.

func (*Body) AddText

func (bd *Body) AddText(text string) *Body

AddText adds the given supporting Text, typically added after a title.

func (*Body) AddTitle

func (bd *Body) AddTitle(title string) *Body

AddTitle adds Text with the given title, and sets the Title text which will be used by the Scene etc.

func (*Body) AddTopBar

func (bd *Body) AddTopBar(fun func(parent Widget))

AddTopBar adds the given function for configuring a control bar at the top of the window

func (*Body) AssertRender

func (b *Body) AssertRender(t imagex.TestingT, filename string, fun ...func())

AssertRender makes a new window from the body, waits until it is shown and all events have been handled, does any necessary re-rendering, asserts that its rendered image is the same as that stored at the given filename, saving the image to that filename if it does not already exist, and then closes the window. It does not return until all of those steps are completed. Each (optional) function passed is called after the window is shown, and all system events are handled before proessing continues. A testdata directory and png file extension are automatically added to the the filename, and forward slashes are automatically replaced with backslashes on Windows. See Body.AssertRenderScreen for a version that asserts the rendered image of the entire screen, not just this body.

func (*Body) AssertRenderScreen added in v0.1.1

func (b *Body) AssertRenderScreen(t imagex.TestingT, filename string, fun ...func())

AssertRenderScreen is the same as Body.AssertRender except that it asserts the rendered image of the entire screen, not just this body. It should be used for multi-scene tests like those of snackbars and dialogs.

func (*Body) Close

func (bd *Body) Close()

Close closes the stage associated with this Body (typically for dialogs)

func (*Body) DialogStyles

func (bd *Body) DialogStyles()

DialogStyles sets default stylers for dialog bodies. It is automatically called in Body.NewDialog.

func (*Body) GetTopAppBar

func (bd *Body) GetTopAppBar() *Toolbar

GetTopAppBar returns the TopAppBar Toolbar if it exists, nil otherwise.

func (*Body) Init added in v0.2.0

func (bd *Body) Init()

func (*Body) New

func (t *Body) New() tree.Node

New returns a new *Body value

func (*Body) NewDialog

func (bd *Body) NewDialog(ctx Widget) *Stage

NewDialog returns a new DialogStage that does not take up the full window it is created in, in the context of the given widget. You must call Stage.Run to run the dialog; see Body.RunDialog for a version that automatically runs it.

func (*Body) NewFullDialog

func (bd *Body) NewFullDialog(ctx Widget) *Stage

NewFullDialog returns a new DialogStage that takes up the full window it is created in, in the context of the given widget. You must call Stage.Run to run the dialog; see Body.RunFullDialog for a version that automatically runs it.

func (*Body) NewSnackbar

func (bd *Body) NewSnackbar(ctx Widget) *Stage

NewSnackbar returns a new SnackbarStage in the context of the given widget. You must call Stage.Run to run the snackbar; see Body.RunSnackbar for a version that automatically runs it.

func (*Body) NewWindow

func (bd *Body) NewWindow() *Stage

NewWindow returns a new WindowStage that is placed in a new system window on multi-window platforms. You must call Stage.Run to run the window; see Body.RunWindow for a version that automatically runs it.

func (*Body) NewWindowDialog added in v0.1.1

func (bd *Body) NewWindowDialog(ctx Widget) *Stage

NewWindowDialog returns a new DialogStage that is placed in a new system window on multi-window platforms, in the context of the given widget. You must call Stage.Run to run the dialog; see Body.RunWindowDialog for a version that automatically runs it.

func (*Body) NodeType

func (t *Body) NodeType() *types.Type

NodeType returns the *types.Type of Body

func (*Body) RunDialog added in v0.1.1

func (bd *Body) RunDialog(ctx Widget) *Stage

RunDialog returns and runs a new DialogStage that does not take up the full window it is created in, in the context of the given widget. See Body.NewDialog to make a new dialog without running it.

func (*Body) RunFullDialog added in v0.1.1

func (bd *Body) RunFullDialog(ctx Widget) *Stage

RunFullDialog returns and runs a new DialogStage that takes up the full window it is created in, in the context of the given widget. See Body.NewFullDialog to make a full dialog without running it.

func (*Body) RunMainWindow

func (bd *Body) RunMainWindow()

RunMainWindow creates a new main window from the body, runs it, starts the app's main loop, and waits for all windows to close. It should typically be called once by every app at the end of their main function. It can not be called more than once for one app. For secondary windows, see Body.RunWindow.

func (*Body) RunSnackbar added in v0.1.1

func (bd *Body) RunSnackbar(ctx Widget) *Stage

RunSnackbar returns and runs a new SnackbarStage in the context of the given widget. See Body.NewSnackbar to make a snackbar without running it.

func (*Body) RunWindow added in v0.1.1

func (bd *Body) RunWindow() *Stage

RunWindow returns and runs a new WindowStage that is placed in a new system window on multi-window platforms. See Body.NewWindow to make a window without running it. For the first window of your app, you should typically call Body.RunMainWindow instead.

func (*Body) RunWindowDialog added in v0.1.1

func (bd *Body) RunWindowDialog(ctx Widget) *Stage

RunWindowDialog returns and runs a new DialogStage that is placed in a new system window on multi-window platforms, in the context of the given widget. See Body.NewWindowDialog to make a dialog window without running it.

func (*Body) SetData

func (bd *Body) SetData(data any) *Body

SetData sets the Body's [Scene.Data].

func (*Body) SetTitle

func (bd *Body) SetTitle(title string) *Body

SetTitle sets the title in the Body, Scene, Stage, RenderWindow, and title widget. This is the one place to change the title for everything.

func (*Body) SnackbarStyles

func (bd *Body) SnackbarStyles()

SnackbarStyles sets default stylers for snackbar bodies. It is automatically called in Body.NewSnackbar.

type Button

type Button struct {
	Frame

	// Type is the type of button.
	Type ButtonTypes

	// Text is the text for the button.
	// If it is blank, no text is shown.
	Text string

	// Icon is the icon for the button.
	// If it is "" or [icons.None], no icon is shown.
	Icon icons.Icon `xml:"icon" display:"show-name"`

	// Indicator is the menu indicator icon to present.
	// If it is "" or [icons.None],, no indicator is shown.
	// It is automatically set to [icons.KeyboardArrowDown]
	// when there is a Menu elements present unless it is
	// set to [icons.None].
	Indicator icons.Icon `xml:"indicator" display:"show-name"`

	// Shortcut is an optional shortcut keyboard chord to trigger this button,
	// active in window-wide scope. Avoid conflicts with other shortcuts
	// (a log message will be emitted if so). Shortcuts are processed after
	// all other processing of keyboard input. Command is automatically translated
	// into Meta on macOS and Control on all other platforms.
	Shortcut key.Chord `xml:"shortcut"`

	// Menu is a menu constructor function used to build and display
	// a menu whenever the button is clicked. There will be no menu
	// if it is nil. The constructor function should add buttons
	// to the Scene that it is passed.
	Menu func(m *Scene) `json:"-" xml:"-"`
}

Button is an interactive button with text, an icon, an indicator, a shortcut, and/or a menu. The standard behavior is to register a click event handler with OnClick.

func AsButton

func AsButton(n tree.Node) *Button

AsButton returns the given value as a value of type Button if the type of the given value embeds Button, or nil otherwise

func NewButton

func NewButton(parent ...tree.Node) *Button

NewButton returns a new Button with the given optional parent: Button is an interactive button with text, an icon, an indicator, a shortcut, and/or a menu. The standard behavior is to register a click event handler with OnClick.

func (*Button) AsButton

func (t *Button) AsButton() *Button

AsButton satisfies the ButtonEmbedder interface

func (*Button) HasMenu

func (bt *Button) HasMenu() bool

HasMenu returns true if the button has a menu that pops up when it is clicked (not that it is in a menu itself; see ButtonMenu)

func (*Button) Init added in v0.2.0

func (bt *Button) Init()

func (*Button) Label

func (bt *Button) Label() string

func (*Button) New

func (t *Button) New() tree.Node

New returns a new *Button value

func (*Button) NodeType

func (t *Button) NodeType() *types.Type

NodeType returns the *types.Type of Button

func (*Button) OpenMenu

func (bt *Button) OpenMenu(e events.Event) bool

OpenMenu will open any menu associated with this element. Returns true if menu opened, false if not.

func (*Button) SetIcon

func (t *Button) SetIcon(v icons.Icon) *Button

SetIcon sets the [Button.Icon]: Icon is the icon for the button. If it is "" or icons.None, no icon is shown.

func (*Button) SetIndicator

func (t *Button) SetIndicator(v icons.Icon) *Button

SetIndicator sets the [Button.Indicator]: Indicator is the menu indicator icon to present. If it is "" or icons.None,, no indicator is shown. It is automatically set to icons.KeyboardArrowDown when there is a Menu elements present unless it is set to icons.None.

func (*Button) SetKey

func (bt *Button) SetKey(kf keymap.Functions) *Button

SetKey sets the shortcut of the button from the given keymap.Functions

func (*Button) SetMenu

func (t *Button) SetMenu(v func(m *Scene)) *Button

SetMenu sets the [Button.Menu]: Menu is a menu constructor function used to build and display a menu whenever the button is clicked. There will be no menu if it is nil. The constructor function should add buttons to the Scene that it is passed.

func (*Button) SetShortcut

func (t *Button) SetShortcut(v key.Chord) *Button

SetShortcut sets the [Button.Shortcut]: Shortcut is an optional shortcut keyboard chord to trigger this button, active in window-wide scope. Avoid conflicts with other shortcuts (a log message will be emitted if so). Shortcuts are processed after all other processing of keyboard input. Command is automatically translated into Meta on macOS and Control on all other platforms.

func (*Button) SetText

func (t *Button) SetText(v string) *Button

SetText sets the [Button.Text]: Text is the text for the button. If it is blank, no text is shown.

func (*Button) SetType

func (t *Button) SetType(v ButtonTypes) *Button

SetType sets the [Button.Type]: Type is the type of button.

func (*Button) WidgetTooltip

func (bt *Button) WidgetTooltip(pos image.Point) (string, image.Point)

type ButtonEmbedder

type ButtonEmbedder interface {
	AsButton() *Button
}

ButtonEmbedder is an interface that all types that embed Button satisfy

type ButtonTypes

type ButtonTypes int32 //enums:enum -trim-prefix Button

ButtonTypes is an enum containing the different possible types of buttons.

const (
	// ButtonFilled is a filled button with a
	// contrasting background color. It should be
	// used for prominent actions, typically those
	// that are the final in a sequence. It is equivalent
	// to Material Design's filled button.
	ButtonFilled ButtonTypes = iota

	// ButtonTonal is a filled button, similar
	// to [ButtonFilled]. It is used for the same purposes,
	// but it has a lighter background color and less emphasis.
	// It is equivalent to Material Design's filled tonal button.
	ButtonTonal

	// ButtonElevated is an elevated button with
	// a light background color and a shadow.
	// It is equivalent to Material Design's elevated button.
	ButtonElevated

	// ButtonOutlined is an outlined button that is
	// used for secondary actions that are still important.
	// It is equivalent to Material Design's outlined button.
	ButtonOutlined

	// ButtonText is a low-importance button with no border,
	// background color, or shadow when not being interacted with.
	// It renders primary-colored text, and it renders a background
	// color and shadow when hovered/focused/active.
	// It should only be used for low emphasis
	// actions, and you must ensure it stands out from the
	// surrounding context sufficiently. It is equivalent
	// to Material Design's text button, but it can also
	// contain icons and other things.
	ButtonText

	// ButtonAction is a simple button that typically serves
	// as a simple action among a series of other buttons
	// (eg: in a toolbar), or as a part of another widget,
	// like a spinner or snackbar. It has no border, background color,
	// or shadow when not being interacted with. It inherits the text
	// color of its parent, and it renders a background when
	// hovered/focused/active. You must ensure it stands out from the
	// surrounding context sufficiently. It is equivalent to Material Design's
	// icon button, but it can also contain text and other things (and frequently does).
	ButtonAction

	// ButtonMenu is similar to [ButtonAction], but it is designed
	// for buttons located in popup menus.
	ButtonMenu
)
const ButtonTypesN ButtonTypes = 7

ButtonTypesN is the highest valid value for type ButtonTypes, plus one.

func ButtonTypesValues

func ButtonTypesValues() []ButtonTypes

ButtonTypesValues returns all possible values for the type ButtonTypes.

func (ButtonTypes) Desc

func (i ButtonTypes) Desc() string

Desc returns the description of the ButtonTypes value.

func (ButtonTypes) Int64

func (i ButtonTypes) Int64() int64

Int64 returns the ButtonTypes value as an int64.

func (ButtonTypes) MarshalText

func (i ButtonTypes) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*ButtonTypes) SetInt64

func (i *ButtonTypes) SetInt64(in int64)

SetInt64 sets the ButtonTypes value from an int64.

func (*ButtonTypes) SetString

func (i *ButtonTypes) SetString(s string) error

SetString sets the ButtonTypes value from its string representation, and returns an error if the string is invalid.

func (ButtonTypes) String

func (i ButtonTypes) String() string

String returns the string representation of this ButtonTypes value.

func (*ButtonTypes) UnmarshalText

func (i *ButtonTypes) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (ButtonTypes) Values

func (i ButtonTypes) Values() []enums.Enum

Values returns all possible values for the type ButtonTypes.

type Canvas

type Canvas struct {
	WidgetBase

	// Draw is the function used to draw the content of the
	// canvas every time that it is rendered. The paint context
	// is automatically normalized to the size of the canvas,
	// so you should specify points on a 0-1 scale.
	Draw func(pc *paint.Context)

	// Context is the paint context used for drawing.
	Context *paint.Context `set:"-"`
}

Canvas is a widget that can be arbitrarily drawn to by setting its Draw function using Canvas.SetDraw.

func NewCanvas

func NewCanvas(parent ...tree.Node) *Canvas

NewCanvas returns a new Canvas with the given optional parent: Canvas is a widget that can be arbitrarily drawn to by setting its Draw function using Canvas.SetDraw.

func (*Canvas) Init added in v0.2.0

func (c *Canvas) Init()

func (*Canvas) New

func (t *Canvas) New() tree.Node

New returns a new *Canvas value

func (*Canvas) NodeType

func (t *Canvas) NodeType() *types.Type

NodeType returns the *types.Type of Canvas

func (*Canvas) Render

func (c *Canvas) Render()

func (*Canvas) SetDraw

func (t *Canvas) SetDraw(v func(pc *paint.Context)) *Canvas

SetDraw sets the [Canvas.Draw]: Draw is the function used to draw the content of the canvas every time that it is rendered. The paint context is automatically normalized to the size of the canvas, so you should specify points on a 0-1 scale.

type Chooser

type Chooser struct {
	Frame

	// Type is the styling type of the chooser.
	Type ChooserTypes

	// Items are the chooser items available for selection.
	Items []ChooserItem

	// Icon is an optional icon displayed on the left side of the chooser.
	Icon icons.Icon `display:"show-name"`

	// Indicator is the icon to use for the indicator displayed on the
	// right side of the chooser.
	Indicator icons.Icon `display:"show-name"`

	// Editable is whether provide a text field for editing the value,
	// or just a button for selecting items.
	Editable bool

	// AllowNew is whether to allow the user to add new items to the
	// chooser through the editable textfield (if Editable is set to
	// true) and a button at the end of the chooser menu. See also [DefaultNew].
	AllowNew bool

	// DefaultNew configures the chooser to accept new items, as in
	// [AllowNew], and also turns off completion popups and always
	// adds new items to the list of items, without prompting.
	// Use this for cases where the typical use-case is to enter new values,
	// but the history of prior values can also be useful.
	DefaultNew bool

	// Placeholder, if Editable is set to true, is the text that is
	// displayed in the text field when it is empty. It must be set
	// using [Chooser.SetPlaceholder].
	Placeholder string `set:"-"`

	// ItemsFuncs is a slice of functions to call before showing the items
	// of the chooser, which is typically used to configure them
	// (eg: if they are based on dynamic data). The functions are called
	// in ascending order such that the items added in the first function
	// will appear before those added in the last function. Use
	// [Chooser.AddItemsFunc] to add a new items function. If at least
	// one ItemsFunc is specified, the items of the chooser will be
	// cleared before calling the functions.
	ItemsFuncs []func() `copier:"-" json:"-" xml:"-" set:"-"`

	// CurrentItem is the currently selected item.
	CurrentItem ChooserItem `json:"-" xml:"-" set:"-"`

	// CurrentIndex is the index of the currently selected item
	// in [Chooser.Items].
	CurrentIndex int `json:"-" xml:"-" set:"-"`
}

Chooser is a drop down selection widget that allows users to choose one option among a list of items.

func NewChooser

func NewChooser(parent ...tree.Node) *Chooser

NewChooser returns a new Chooser with the given optional parent: Chooser is a drop down selection widget that allows users to choose one option among a list of items.

func (*Chooser) AddItemsFunc

func (ch *Chooser) AddItemsFunc(f func()) *Chooser

AddItemsFunc adds the given function to [Chooser.ItemsFuncs]. These functions are called before showing the items of the chooser, and they are typically used to configure them (eg: if they are based on dynamic data). The functions are called in ascending order such that the items added in the first function will appear before those added in the last function. If at least one ItemsFunc is specified, the items, labels, icons, and tooltips of the chooser will be cleared before calling the functions.

func (*Chooser) CallItemsFuncs

func (ch *Chooser) CallItemsFuncs()

CallItemsFuncs calls [Chooser.ItemsFuncs].

func (*Chooser) ClearError added in v0.1.4

func (ch *Chooser) ClearError()

ClearError clears any existing validation error, for editable choosers.

func (*Chooser) ClearText added in v0.1.4

func (ch *Chooser) ClearText()

ClearText clears the text field, for editable choosers. Also clears any errors.

func (*Chooser) CompleteEdit

func (ch *Chooser) CompleteEdit(data any, text string, cursorPos int, completion complete.Completion, seed string) (ed complete.Edit)

CompleteEdit is the complete.EditFunc used for the editable textfield part of the Chooser (if it exists).

func (*Chooser) CompleteMatch

func (ch *Chooser) CompleteMatch(data any, text string, posLine, posChar int) (md complete.Matches)

CompleteMatch is the complete.MatchFunc used for the editable text field part of the Chooser (if it exists).

func (*Chooser) FindItem

func (ch *Chooser) FindItem(it any) int

FindItem finds the given item value on the list of items and returns its index

func (*Chooser) Init added in v0.2.0

func (ch *Chooser) Init()

func (*Chooser) MakeItemsMenu

func (ch *Chooser) MakeItemsMenu(m *Scene)

MakeItemsMenu constructs a menu of all the items. It is used when the chooser is clicked.

func (*Chooser) New

func (t *Chooser) New() tree.Node

New returns a new *Chooser value

func (*Chooser) NodeType

func (t *Chooser) NodeType() *types.Type

NodeType returns the *types.Type of Chooser

func (*Chooser) OnBind added in v0.2.0

func (ch *Chooser) OnBind(value any)

func (*Chooser) OpenMenu

func (ch *Chooser) OpenMenu(e events.Event) bool

OpenMenu opens the chooser menu that displays all of the items. It returns false if there are no items.

func (*Chooser) SelectItem

func (ch *Chooser) SelectItem(index int) *Chooser

SelectItem selects the item at the given index and updates the chooser to display it.

func (*Chooser) SelectItemAction

func (ch *Chooser) SelectItemAction(index int) *Chooser

SelectItemAction selects the item at the given index and updates the chooser to display it. It also sends an events.Change event to indicate that the value has changed.

func (*Chooser) SetAllowNew

func (t *Chooser) SetAllowNew(v bool) *Chooser

SetAllowNew sets the [Chooser.AllowNew]: AllowNew is whether to allow the user to add new items to the chooser through the editable textfield (if Editable is set to true) and a button at the end of the chooser menu. See also [DefaultNew].

func (*Chooser) SetCurrentIndex

func (ch *Chooser) SetCurrentIndex(index int) *Chooser

SetCurrentIndex sets the current index and the item associated with it.

func (*Chooser) SetCurrentText

func (ch *Chooser) SetCurrentText(text string) error

SetCurrentText sets the current index and item based on the given text string. It can only be used for editable choosers.

func (*Chooser) SetCurrentValue

func (ch *Chooser) SetCurrentValue(value any) *Chooser

SetCurrentValue sets the current item and index to those associated with the given value. If the given item is not found, it adds it to the items list if it is not "". It also sets the text of the chooser to the label of the item.

func (*Chooser) SetDefaultNew

func (t *Chooser) SetDefaultNew(v bool) *Chooser

SetDefaultNew sets the [Chooser.DefaultNew]: DefaultNew configures the chooser to accept new items, as in [AllowNew], and also turns off completion popups and always adds new items to the list of items, without prompting. Use this for cases where the typical use-case is to enter new values, but the history of prior values can also be useful.

func (*Chooser) SetEditable

func (t *Chooser) SetEditable(v bool) *Chooser

SetEditable sets the [Chooser.Editable]: Editable is whether provide a text field for editing the value, or just a button for selecting items.

func (*Chooser) SetEnum

func (ch *Chooser) SetEnum(enum enums.Enum) *Chooser

SetEnum sets the [Chooser.Items] from the enums.Enum.Values of the given enum.

func (*Chooser) SetEnums

func (ch *Chooser) SetEnums(es ...enums.Enum) *Chooser

SetEnums sets the [Chooser.Items] from the given enums.

func (*Chooser) SetIcon

func (t *Chooser) SetIcon(v icons.Icon) *Chooser

SetIcon sets the [Chooser.Icon]: Icon is an optional icon displayed on the left side of the chooser.

func (*Chooser) SetIndicator

func (t *Chooser) SetIndicator(v icons.Icon) *Chooser

SetIndicator sets the [Chooser.Indicator]: Indicator is the icon to use for the indicator displayed on the right side of the chooser.

func (*Chooser) SetItems

func (t *Chooser) SetItems(v ...ChooserItem) *Chooser

SetItems sets the [Chooser.Items]: Items are the chooser items available for selection.

func (*Chooser) SetPlaceholder

func (ch *Chooser) SetPlaceholder(text string) *Chooser

SetPlaceholder sets the given placeholder text and indicates that nothing has been selected.

func (*Chooser) SetStrings

func (ch *Chooser) SetStrings(ss ...string) *Chooser

SetStrings sets the [Chooser.Items] from the given strings.

func (*Chooser) SetType

func (t *Chooser) SetType(v ChooserTypes) *Chooser

SetType sets the [Chooser.Type]: Type is the styling type of the chooser.

func (*Chooser) SetTypes

func (ch *Chooser) SetTypes(ts ...*types.Type) *Chooser

SetTypes sets the [Chooser.Items] from the given types.

func (*Chooser) SetWidgetValue added in v0.2.0

func (ch *Chooser) SetWidgetValue(value any) error

func (*Chooser) ShowCurrentItem

func (ch *Chooser) ShowCurrentItem() *Chooser

ShowCurrentItem updates the display to present the current item.

func (*Chooser) TextField

func (ch *Chooser) TextField() *TextField

TextField returns the text field widget of an editable Chooser if present.

func (*Chooser) TextWidget added in v0.1.1

func (ch *Chooser) TextWidget() *Text

TextWidget returns the text widget if present.

func (*Chooser) WidgetTooltip added in v0.1.1

func (ch *Chooser) WidgetTooltip(pos image.Point) (string, image.Point)

func (*Chooser) WidgetValue added in v0.2.0

func (ch *Chooser) WidgetValue() any

type ChooserItem

type ChooserItem struct {

	// Value is the underlying value the chooser item represents.
	Value any

	// Text is the text displayed to the user for this item.
	// If it is empty, then [labels.ToLabel] of [ChooserItem.Value]
	// is used instead.
	Text string

	// Icon is the icon displayed to the user for this item.
	Icon icons.Icon

	// Tooltip is the tooltip displayed to the user for this item.
	Tooltip string

	// Func, if non-nil, is a function to call whenever this
	// item is selected as the current value of the chooser.
	Func func() `json:"-" xml:"-"`

	// SeparatorBefore is whether to add a separator before
	// this item in the chooser menu.
	SeparatorBefore bool
}

ChooserItem is an item that can be used in a Chooser.

func (*ChooserItem) GetText added in v0.2.0

func (ci *ChooserItem) GetText() string

GetText returns the effective text for this chooser item. If [ChooserItem.Text] is set, it returns that. Otherwise, it returns labels.ToLabel of [ChooserItem.Value].

type ChooserTypes

type ChooserTypes int32 //enums:enum -trim-prefix Chooser

ChooserTypes is an enum containing the different possible types of combo boxes

const (
	// ChooserFilled represents a filled
	// Chooser with a background color
	// and a bottom border
	ChooserFilled ChooserTypes = iota

	// ChooserOutlined represents an outlined
	// Chooser with a border on all sides
	// and no background color
	ChooserOutlined
)
const ChooserTypesN ChooserTypes = 2

ChooserTypesN is the highest valid value for type ChooserTypes, plus one.

func ChooserTypesValues

func ChooserTypesValues() []ChooserTypes

ChooserTypesValues returns all possible values for the type ChooserTypes.

func (ChooserTypes) Desc

func (i ChooserTypes) Desc() string

Desc returns the description of the ChooserTypes value.

func (ChooserTypes) Int64

func (i ChooserTypes) Int64() int64

Int64 returns the ChooserTypes value as an int64.

func (ChooserTypes) MarshalText

func (i ChooserTypes) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*ChooserTypes) SetInt64

func (i *ChooserTypes) SetInt64(in int64)

SetInt64 sets the ChooserTypes value from an int64.

func (*ChooserTypes) SetString

func (i *ChooserTypes) SetString(s string) error

SetString sets the ChooserTypes value from its string representation, and returns an error if the string is invalid.

func (ChooserTypes) String

func (i ChooserTypes) String() string

String returns the string representation of this ChooserTypes value.

func (*ChooserTypes) UnmarshalText

func (i *ChooserTypes) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (ChooserTypes) Values

func (i ChooserTypes) Values() []enums.Enum

Values returns all possible values for the type ChooserTypes.

type ColorButton added in v0.2.0

type ColorButton struct {
	Button
	Color color.RGBA
}

ColorButton represents a color value with a button.

func NewColorButton added in v0.2.0

func NewColorButton(parent ...tree.Node) *ColorButton

NewColorButton returns a new ColorButton with the given optional parent: ColorButton represents a color value with a button.

func (*ColorButton) Init added in v0.2.0

func (cb *ColorButton) Init()

func (*ColorButton) New added in v0.2.0

func (t *ColorButton) New() tree.Node

New returns a new *ColorButton value

func (*ColorButton) NodeType added in v0.2.0

func (t *ColorButton) NodeType() *types.Type

NodeType returns the *types.Type of ColorButton

func (*ColorButton) SetColor added in v0.2.0

func (t *ColorButton) SetColor(v color.RGBA) *ColorButton

SetColor sets the [ColorButton.Color]

func (*ColorButton) WidgetValue added in v0.2.0

func (cb *ColorButton) WidgetValue() any

type ColorMapButton added in v0.2.0

type ColorMapButton struct {
	Button
	MapName string
}

ColorMapButton displays a color map spectrum and can be clicked on to display a dialog for selecting different color map options. It represents a ColorMapName value.

func NewColorMapButton added in v0.2.0

func NewColorMapButton(parent ...tree.Node) *ColorMapButton

NewColorMapButton returns a new ColorMapButton with the given optional parent: ColorMapButton displays a color map spectrum and can be clicked on to display a dialog for selecting different color map options. It represents a ColorMapName value.

func (*ColorMapButton) Init added in v0.2.0

func (cm *ColorMapButton) Init()

func (*ColorMapButton) New added in v0.2.0

func (t *ColorMapButton) New() tree.Node

New returns a new *ColorMapButton value

func (*ColorMapButton) NodeType added in v0.2.0

func (t *ColorMapButton) NodeType() *types.Type

NodeType returns the *types.Type of ColorMapButton

func (*ColorMapButton) SetMapName added in v0.2.0

func (t *ColorMapButton) SetMapName(v string) *ColorMapButton

SetMapName sets the [ColorMapButton.MapName]

func (*ColorMapButton) WidgetValue added in v0.2.0

func (cm *ColorMapButton) WidgetValue() any

type ColorMapName added in v0.2.0

type ColorMapName string

ColorMapName represents the name of a color map, which can be edited using a ColorMapButton.

func (ColorMapName) Value added in v0.2.0

func (cm ColorMapName) Value() Value

type ColorPicker added in v0.2.0

type ColorPicker struct {
	Frame

	// the color that we view
	Color hct.HCT `set:"-"`
}

ColorPicker represents a color value with an interactive color picker composed of three HCT sliders.

func NewColorPicker added in v0.2.0

func NewColorPicker(parent ...tree.Node) *ColorPicker

NewColorPicker returns a new ColorPicker with the given optional parent: ColorPicker represents a color value with an interactive color picker composed of three HCT sliders.

func (*ColorPicker) Init added in v0.2.0

func (cp *ColorPicker) Init()

func (*ColorPicker) New added in v0.2.0

func (t *ColorPicker) New() tree.Node

New returns a new *ColorPicker value

func (*ColorPicker) NodeType added in v0.2.0

func (t *ColorPicker) NodeType() *types.Type

NodeType returns the *types.Type of ColorPicker

func (*ColorPicker) SetColor added in v0.2.0

func (cp *ColorPicker) SetColor(clr color.Color) *ColorPicker

SetColor sets the source color.

func (*ColorPicker) SetHCT added in v0.2.0

func (cp *ColorPicker) SetHCT(hct hct.HCT) *ColorPicker

SetHCT sets the source color in terms of HCT

func (*ColorPicker) WidgetValue added in v0.2.0

func (cp *ColorPicker) WidgetValue() any

type Complete

type Complete struct {
	// function to get the list of possible completions
	MatchFunc complete.MatchFunc

	// function to get the text to show for lookup
	LookupFunc complete.LookupFunc

	// function to edit text using the selected completion
	EditFunc complete.EditFunc

	// the object that implements complete.Func
	Context any

	// line number in source that completion is operating on, if relevant
	SrcLn int

	// character position in source that completion is operating on
	SrcCh int

	// the list of potential completions
	Completions complete.Completions

	// current completion seed
	Seed string

	// the user's completion selection
	Completion string

	// the event listeners for the completer (it sends Select events)
	Listeners events.Listeners `set:"-" display:"-"`

	// Stage is the [PopupStage] associated with the [Complete]
	Stage *Stage

	DelayTimer *time.Timer `set:"-"`
	DelayMu    sync.Mutex  `set:"-"`
	ShowMu     sync.Mutex  `set:"-"`
}

Complete holds the current completion data and functions to call for building the list of possible completions and for editing text after a completion is selected. It also holds the [PopupStage] associated with it.

func NewComplete

func NewComplete() *Complete

NewComplete returns a new Complete object. It does not show it; see Complete.Show.

func (*Complete) Abort

func (c *Complete) Abort() bool

Abort aborts *only* pending completions, but does not close existing window. Returns true if aborted.

func (*Complete) Cancel

func (c *Complete) Cancel() bool

Cancel cancels any existing *or* pending completion. Call when new events nullify prior completions. Returns true if canceled.

func (*Complete) CancelAsync

func (c *Complete) CancelAsync() bool

CancelAsync cancels any existing *or* pending completion, inside a delayed callback function (Async) Call when new events nullify prior completions. Returns true if canceled.

func (*Complete) Complete

func (c *Complete) Complete(s string)

Complete sends Select event to listeners, indicating that the user has made a selection from the list of possible completions. This is called inside the main event loop.

func (*Complete) GetCompletion

func (c *Complete) GetCompletion(s string) complete.Completion

func (*Complete) IsAboutToShow

func (c *Complete) IsAboutToShow() bool

IsAboutToShow returns true if the DelayTimer is started for preparing to show a completion. note: don't really need to lock

func (*Complete) Lookup

func (c *Complete) Lookup(text string, posLine, posChar int, sc *Scene, pt image.Point)

Lookup is the main call for doing lookups

func (*Complete) On

func (c *Complete) On(etype events.Types, fun func(e events.Event))

On adds an event listener function for the given event type

func (*Complete) OnSelect

func (c *Complete) OnSelect(fun func(e events.Event))

OnSelect registers given listener function for Select events on Value. This is the primary notification event for all Complete elements.

func (*Complete) SetCompletion

func (t *Complete) SetCompletion(v string) *Complete

SetCompletion sets the [Complete.Completion]: the user's completion selection

func (*Complete) SetCompletions

func (t *Complete) SetCompletions(v complete.Completions) *Complete

SetCompletions sets the [Complete.Completions]: the list of potential completions

func (*Complete) SetContext

func (t *Complete) SetContext(v any) *Complete

SetContext sets the [Complete.Context]: the object that implements complete.Func

func (*Complete) SetEditFunc

func (t *Complete) SetEditFunc(v complete.EditFunc) *Complete

SetEditFunc sets the [Complete.EditFunc]: function to edit text using the selected completion

func (*Complete) SetLookupFunc

func (t *Complete) SetLookupFunc(v complete.LookupFunc) *Complete

SetLookupFunc sets the [Complete.LookupFunc]: function to get the text to show for lookup

func (*Complete) SetMatchFunc

func (t *Complete) SetMatchFunc(v complete.MatchFunc) *Complete

SetMatchFunc sets the [Complete.MatchFunc]: function to get the list of possible completions

func (*Complete) SetSeed

func (t *Complete) SetSeed(v string) *Complete

SetSeed sets the [Complete.Seed]: current completion seed

func (*Complete) SetSrcCh

func (t *Complete) SetSrcCh(v int) *Complete

SetSrcCh sets the [Complete.SrcCh]: character position in source that completion is operating on

func (*Complete) SetSrcLn

func (t *Complete) SetSrcLn(v int) *Complete

SetSrcLn sets the [Complete.SrcLn]: line number in source that completion is operating on, if relevant

func (*Complete) SetStage

func (t *Complete) SetStage(v *Stage) *Complete

SetStage sets the [Complete.Stage]: Stage is the [PopupStage] associated with the Complete

func (*Complete) Show

func (c *Complete) Show(ctx Widget, pos image.Point, text string)

Show is the main call for listing completions. Has a builtin delay timer so completions are only shown after a delay, which resets every time it is called. After delay, Calls ShowNow, which calls MatchFunc to get a list of completions and builds the completion popup menu

func (*Complete) ShowNow

func (c *Complete) ShowNow(ctx Widget, pos image.Point, text string)

ShowNow actually calls MatchFunc to get a list of completions and builds the completion popup menu. This is the sync version called from

func (*Complete) ShowNowAsync

func (c *Complete) ShowNowAsync(ctx Widget, pos image.Point, text string)

ShowNowAsync actually calls MatchFunc to get a list of completions and builds the completion popup menu. This is the Async version for delayed AfterFunc call.

func (*Complete) ShowNowImpl

func (c *Complete) ShowNowImpl(ctx Widget, pos image.Point, text string) bool

ShowNowImpl is the implementation of ShowNow, presenting completions. Returns false if nothing to show.

type CompleteSignals

type CompleteSignals int32 //enums:enum -trim-prefix Complete

CompleteSignals are signals that are sent by Complete

const (
	// CompleteSelect means the user chose one of the possible completions
	CompleteSelect CompleteSignals = iota

	// CompleteExtend means user has requested that the seed extend if all
	// completions have a common prefix longer than current seed
	CompleteExtend
)
const CompleteSignalsN CompleteSignals = 2

CompleteSignalsN is the highest valid value for type CompleteSignals, plus one.

func CompleteSignalsValues

func CompleteSignalsValues() []CompleteSignals

CompleteSignalsValues returns all possible values for the type CompleteSignals.

func (CompleteSignals) Desc

func (i CompleteSignals) Desc() string

Desc returns the description of the CompleteSignals value.

func (CompleteSignals) Int64

func (i CompleteSignals) Int64() int64

Int64 returns the CompleteSignals value as an int64.

func (CompleteSignals) MarshalText

func (i CompleteSignals) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*CompleteSignals) SetInt64

func (i *CompleteSignals) SetInt64(in int64)

SetInt64 sets the CompleteSignals value from an int64.

func (*CompleteSignals) SetString

func (i *CompleteSignals) SetString(s string) error

SetString sets the CompleteSignals value from its string representation, and returns an error if the string is invalid.

func (CompleteSignals) String

func (i CompleteSignals) String() string

String returns the string representation of this CompleteSignals value.

func (*CompleteSignals) UnmarshalText

func (i *CompleteSignals) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (CompleteSignals) Values

func (i CompleteSignals) Values() []enums.Enum

Values returns all possible values for the type CompleteSignals.

type DatePicker added in v0.2.0

type DatePicker struct {
	Frame

	// Time is the time that we are viewing
	Time time.Time `set:"-"`
}

DatePicker is a widget for picking a date.

func NewDatePicker added in v0.2.0

func NewDatePicker(parent ...tree.Node) *DatePicker

NewDatePicker returns a new DatePicker with the given optional parent: DatePicker is a widget for picking a date.

func (*DatePicker) Init added in v0.2.0

func (dp *DatePicker) Init()

func (*DatePicker) New added in v0.2.0

func (t *DatePicker) New() tree.Node

New returns a new *DatePicker value

func (*DatePicker) NodeType added in v0.2.0

func (t *DatePicker) NodeType() *types.Type

NodeType returns the *types.Type of DatePicker

func (*DatePicker) SetTime added in v0.2.0

func (dp *DatePicker) SetTime(tim time.Time) *DatePicker

SetTime sets the source time and updates the view

type DebugSettingsData

type DebugSettingsData struct {
	SettingsBase

	// Print a trace of updates that trigger re-rendering
	UpdateTrace bool

	// Print a trace of the nodes rendering
	RenderTrace bool

	// Print a trace of all layouts
	LayoutTrace bool

	// Print more detailed info about the underlying layout computations
	LayoutTraceDetail bool

	// Print a trace of window events
	WinEventTrace bool

	// Print the stack trace leading up to win publish events
	// which are expensive
	WinRenderTrace bool

	// Print a trace of window geometry saving / loading functions
	WinGeomTrace bool

	// Print a trace of keyboard events
	KeyEventTrace bool

	// Print a trace of event handling
	EventTrace bool

	// Print a trace of focus changes
	FocusTrace bool

	// Print a trace of DND event handling
	DNDTrace bool

	// Print a trace of Go language completion and lookup process
	GoCompleteTrace bool

	// Print a trace of Go language type parsing and inference process
	GoTypeTrace bool
}

DebugSettingsData is the data type for debugging settings.

func (*DebugSettingsData) Apply

func (db *DebugSettingsData) Apply()

func (*DebugSettingsData) Defaults

func (db *DebugSettingsData) Defaults()

type DeviceSettingsData

type DeviceSettingsData struct {
	SettingsBase

	// The keyboard shortcut map to use
	KeyMap keymap.MapName

	// The keyboard shortcut maps available as options for Key map.
	// If you do not want to have custom key maps, you should leave
	// this unset so that you always have the latest standard key maps.
	KeyMaps option.Option[keymap.Maps]

	// The maximum time interval between button press events to count as a double-click
	DoubleClickInterval time.Duration `default:"500ms" min:"100ms" step:"50ms"`

	// How fast the scroll wheel moves, which is typically pixels per wheel step
	// but units can be arbitrary. It is generally impossible to standardize speed
	// and variable across devices, and we don't have access to the system settings,
	// so unfortunately you have to set it here.
	ScrollWheelSpeed float32 `default:"1" min:"0.01" step:"1"`

	// The amount of time to wait before initiating a slide event
	// (as opposed to a basic press event)
	SlideStartTime time.Duration `default:"50ms" min:"5ms" max:"1s" step:"5ms"`

	// The amount of time to wait before initiating a drag (drag and drop) event
	// (as opposed to a basic press or slide event)
	DragStartTime time.Duration `default:"250ms" min:"5ms" max:"1s" step:"5ms"`

	// The amount of time to wait between each repeat click event,
	// when the mouse is pressed down.  The first click is 8x this.
	RepeatClickTime time.Duration `default:"100ms" min:"5ms" max:"1s" step:"5ms"`

	// The number of pixels that must be moved before initiating a slide/drag
	// event (as opposed to a basic press event)
	DragStartDistance int `default:"4" min:"0" max:"100" step:"1"`

	// The amount of time to wait before initiating a long hover event (e.g., for opening a tooltip)
	LongHoverTime time.Duration `default:"500ms" min:"10ms" max:"10s" step:"10ms"`

	// The maximum number of pixels that mouse can move and still register a long hover event
	LongHoverStopDistance int `default:"5" min:"0" max:"1000" step:"1"`

	// The amount of time to wait before initiating a long press event (e.g., for opening a tooltip)
	LongPressTime time.Duration `default:"500ms" min:"10ms" max:"10s" step:"10ms"`

	// The maximum number of pixels that mouse/finger can move and still register a long press event
	LongPressStopDistance int `default:"50" min:"0" max:"1000" step:"1"`
}

DeviceSettingsData is the data type for the device settings.

func (*DeviceSettingsData) Apply

func (ds *DeviceSettingsData) Apply()

func (*DeviceSettingsData) Defaults

func (ds *DeviceSettingsData) Defaults()

type DurationInput added in v0.2.0

type DurationInput struct {
	Frame

	Duration time.Duration

	// Unit is the unit of time.
	Unit string
}

DurationInput represents a time.Duration value with a spinner and unit chooser.

func NewDurationInput added in v0.2.0

func NewDurationInput(parent ...tree.Node) *DurationInput

NewDurationInput returns a new DurationInput with the given optional parent: DurationInput represents a time.Duration value with a spinner and unit chooser.

func (*DurationInput) Init added in v0.2.0

func (di *DurationInput) Init()

func (*DurationInput) New added in v0.2.0

func (t *DurationInput) New() tree.Node

New returns a new *DurationInput value

func (*DurationInput) NodeType added in v0.2.0

func (t *DurationInput) NodeType() *types.Type

NodeType returns the *types.Type of DurationInput

func (*DurationInput) SetAutoUnit added in v0.2.0

func (di *DurationInput) SetAutoUnit()

SetAutoUnit sets the [DurationInput.Unit] automatically based on the current duration.

func (*DurationInput) SetDuration added in v0.2.0

func (t *DurationInput) SetDuration(v time.Duration) *DurationInput

SetDuration sets the [DurationInput.Duration]

func (*DurationInput) SetUnit added in v0.2.0

func (t *DurationInput) SetUnit(v string) *DurationInput

SetUnit sets the [DurationInput.Unit]: Unit is the unit of time.

func (*DurationInput) WidgetValue added in v0.2.0

func (di *DurationInput) WidgetValue() any

type EditorSettings

type EditorSettings struct {

	// size of a tab, in chars; also determines indent level for space indent
	TabSize int `default:"4"`

	// use spaces for indentation, otherwise tabs
	SpaceIndent bool

	// wrap lines at word boundaries; otherwise long lines scroll off the end
	WordWrap bool `default:"true"`

	// whether to show line numbers
	LineNumbers bool `default:"true"`

	// use the completion system to suggest options while typing
	Completion bool `default:"true"`

	// suggest corrections for unknown words while typing
	SpellCorrect bool `default:"true"`

	// automatically indent lines when enter, tab, }, etc pressed
	AutoIndent bool `default:"true"`

	// use emacs-style undo, where after a non-undo command, all the current undo actions are added to the undo stack, such that a subsequent undo is actually a redo
	EmacsUndo bool

	// colorize the background according to nesting depth
	DepthColor bool `default:"true"`
}

EditorSettings contains text editor settings.

type Events added in v0.1.1

type Events struct {

	// Scene is the scene that we manage events for
	Scene *Scene

	// mutex that protects timer variable updates (e.g., hover AfterFunc's)
	TimerMu sync.Mutex

	// stack of sprites with mouse pointer in BBox, with any listeners present
	SpriteInBBox []*Sprite

	// currently pressing sprite
	SpritePress *Sprite

	// currently sliding (dragging) sprite
	SpriteSlide *Sprite

	// stack of widgets with mouse pointer in BBox, and are not Disabled.
	// Last item in the stack is the deepest nested widget (smallest BBox).
	MouseInBBox []Widget

	// stack of hovered widgets: have mouse pointer in BBox and have Hoverable flag
	Hovers []Widget

	// LastClickWidget is the last widget that has been clicked on
	LastClickWidget Widget

	// LastDoubleClickWidget is the last widget that has been clicked on
	LastDoubleClickWidget Widget

	// LastClickTime is the time the last widget was clicked on
	LastClickTime time.Time

	// the current candidate for a long hover event
	LongHoverWidget Widget

	// the position of the mouse at the start of LongHoverTimer
	LongHoverPos image.Point

	// the timer for the LongHover event, started with time.AfterFunc
	LongHoverTimer *time.Timer

	// the current candidate for a long press event
	LongPressWidget Widget

	// the position of the mouse at the start of LongPressTimer
	LongPressPos image.Point

	// the timer for the LongPress event, started with time.AfterFunc
	LongPressTimer *time.Timer

	// stack of drag-hovered widgets: have mouse pointer in BBox and have Droppable flag
	DragHovers []Widget

	// the deepest widget that was just pressed
	Press Widget

	// widget receiving mouse dragging events -- for drag-n-drop
	Drag Widget

	// the deepest draggable widget that was just pressed
	DragPress Widget

	// widget receiving mouse sliding events
	Slide Widget

	// the deepest slideable widget that was just pressed
	SlidePress Widget

	// widget receiving mouse scrolling events
	Scroll Widget

	// widget being held down with RepeatClickable ability
	RepeatClick Widget

	// the timer for RepeatClickable items
	RepeatClickTimer *time.Timer

	// widget receiving keyboard events -- use SetFocus, CurFocus
	Focus Widget

	// widget to focus on at start when no other focus has been set yet -- use SetStartFocus
	StartFocus Widget

	// if StartFocus not set, activate starting focus on first element
	StartFocusFirst bool

	// previously focused widget -- what was in Focus when FocusClear is called
	PrevFocus Widget

	// Last Select Mode from most recent Mouse, Keyboard events
	LastSelMode events.SelectModes

	// Currently active shortcuts for this window (shortcuts are always window-wide.
	// Use widget key event processing for more local key functions)
	Shortcuts Shortcuts

	// source data from DragStart event
	DragData any
}

Events is an event manager that handles incoming events for a Scene. It creates all the derived event types (Hover, Sliding, Dragging) and Focus management for keyboard events.

func (*Events) ActivateStartFocus added in v0.1.1

func (em *Events) ActivateStartFocus() bool

ActivateStartFocus activates start focus if there is no current focus and StartFocus is set -- returns true if activated

func (*Events) AddShortcut added in v0.1.1

func (em *Events) AddShortcut(chord key.Chord, bt *Button)

AddShortcut adds given shortcut to given button.

func (*Events) CancelLongPress added in v0.1.1

func (em *Events) CancelLongPress()

func (*Events) CancelRepeatClick added in v0.1.1

func (em *Events) CancelRepeatClick()

func (*Events) ClearNonFocus added in v0.1.1

func (em *Events) ClearNonFocus(foc Widget)

ClearNonFocus clears the focus of any non-w.Focus item.

func (*Events) Clipboard added in v0.1.1

func (em *Events) Clipboard() system.Clipboard

Clipboard returns the system system.Clipboard, supplying the window context if available.

func (*Events) DeleteShortcut added in v0.1.1

func (em *Events) DeleteShortcut(chord key.Chord, bt *Button)

DeleteShortcut deletes given shortcut

func (*Events) DragClearSprite added in v0.1.1

func (em *Events) DragClearSprite()

func (*Events) DragDrop added in v0.1.1

func (em *Events) DragDrop(drag Widget, e events.Event)

DragDrop sends the events.Drop event to the top of the DragHovers stack. clearing the current dragging sprite before doing anything. It is up to the target to call

func (*Events) DragMenuAddModText added in v0.1.1

func (em *Events) DragMenuAddModText(m *Scene, mod events.DropMods)

func (*Events) DragMove added in v0.1.1

func (em *Events) DragMove(e events.Event)

DragMove is generally handled entirely by the event manager

func (*Events) DragStart added in v0.1.1

func (em *Events) DragStart(w Widget, data any, e events.Event)

DragStart starts a drag event, capturing a sprite image of the given widget and storing the data for later use during Drop. A drag does not officially start until this is called.

func (*Events) DragStartCheck added in v0.1.1

func (em *Events) DragStartCheck(e events.Event, dur time.Duration, dist int) bool

func (*Events) DropFinalize added in v0.1.1

func (em *Events) DropFinalize(de *events.DragDrop)

DropFinalize should be called as the last step in the Drop event processing, to send the DropDeleteSource event to the source in case of DropMod == DropMove. Otherwise, nothing actually happens.

func (*Events) FocusClear added in v0.1.1

func (em *Events) FocusClear() bool

FocusClear saves current focus to FocusPrev

func (*Events) FocusFirst added in v0.1.1

func (em *Events) FocusFirst() bool

FocusFirst sets the focus on the first focusable item in the tree. returns true if a focusable item was found.

func (*Events) FocusLast added in v0.1.1

func (em *Events) FocusLast() bool

FocusLast sets the focus on the last focusable item in the tree. returns true if a focusable item was found.

func (*Events) FocusLastFrom added in v0.1.1

func (em *Events) FocusLastFrom(from Widget) bool

FocusLastFrom sets the focus on the last focusable item in the given tree. returns true if a focusable item was found.

func (*Events) FocusNext added in v0.1.1

func (em *Events) FocusNext() bool

FocusNext sets the focus on the next item that can accept focus after the current Focus item. returns true if a focus item found.

func (*Events) FocusNextFrom added in v0.1.1

func (em *Events) FocusNextFrom(from Widget) bool

FocusNextFrom sets the focus on the next item that can accept focus after the given item. returns true if a focus item found.

func (*Events) FocusOnOrNext added in v0.1.1

func (em *Events) FocusOnOrNext(foc Widget) bool

FocusOnOrNext sets the focus on the given item, or the next one that can accept focus -- returns true if a new focus item found.

func (*Events) FocusOnOrPrev added in v0.1.1

func (em *Events) FocusOnOrPrev(foc Widget) bool

FocusOnOrPrev sets the focus on the given item, or the previous one that can accept focus -- returns true if a new focus item found.

func (*Events) FocusPrev added in v0.1.1

func (em *Events) FocusPrev() bool

FocusPrev sets the focus on the previous item before the current focus item.

func (*Events) FocusPrevFrom added in v0.1.1

func (em *Events) FocusPrevFrom(from Widget) bool

FocusPrevFrom sets the focus on the previous item before the given item (can be nil).

func (*Events) GetMouseInBBox added in v0.1.1

func (em *Events) GetMouseInBBox(w Widget, pos image.Point)

func (*Events) GetShortcuts added in v0.1.1

func (em *Events) GetShortcuts()

GetShortcuts gathers all [Button]s in the Scene with a shortcut specified. It recursively navigates [Button.Menu]s.

func (*Events) GetShortcutsIn added in v0.1.1

func (em *Events) GetShortcutsIn(parent Widget)

GetShortcutsIn gathers all [Button]s in the given parent widget with a shortcut specified. It recursively navigates [Button.Menu]s.

func (*Events) GetSpriteInBBox added in v0.1.4

func (em *Events) GetSpriteInBBox(sc *Scene, pos image.Point)

func (*Events) HandleEvent added in v0.1.1

func (em *Events) HandleEvent(e events.Event)

func (*Events) HandleFocusEvent added in v0.1.1

func (em *Events) HandleFocusEvent(e events.Event)

func (*Events) HandleLong added in v0.1.1

func (em *Events) HandleLong(e events.Event, deep Widget, w *Widget, pos *image.Point, t **time.Timer, styp, etyp events.Types, stime time.Duration, sdist int)

HandleLong is the implementation of Events.HandleLongHover and [EventManger.HandleLongPress]. It handles the logic to do with tracking long events using the given pointers to event manager fields and constant type, time, and distance properties. It should not need to be called by anything except for the aforementioned functions.

func (*Events) HandleLongHover added in v0.1.1

func (em *Events) HandleLongHover(e events.Event)

HandleLongHover handles long hover events

func (*Events) HandleLongPress added in v0.1.1

func (em *Events) HandleLongPress(e events.Event)

HandleLongPress handles long press events

func (*Events) HandleOtherEvent added in v0.1.1

func (em *Events) HandleOtherEvent(e events.Event)

func (*Events) HandlePosEvent added in v0.1.1

func (em *Events) HandlePosEvent(e events.Event)

func (*Events) HandleSpriteEvent added in v0.1.4

func (em *Events) HandleSpriteEvent(e events.Event) bool

HandleSpriteEvent handles the given event with sprites returns true if event was handled

func (*Events) Mains added in v0.1.1

func (em *Events) Mains() *Stages

Mains returns the stack of main stages for our scene.

func (*Events) ManagerKeyChordEvents added in v0.1.1

func (em *Events) ManagerKeyChordEvents(e events.Event)

MangerKeyChordEvents handles lower-priority manager-level key events. Mainly tab, shift-tab, and Inspector and Settings. event will be marked as processed if handled here.

func (*Events) RenderWindow added in v0.1.1

func (em *Events) RenderWindow() *RenderWindow

RenderWindow returns the overall render window in which we reside, which could be nil.

func (*Events) ResetOnMouseDown added in v0.1.1

func (em *Events) ResetOnMouseDown()

func (*Events) SetCursor added in v0.1.1

func (em *Events) SetCursor(cur cursors.Cursor)

SetCursor sets window cursor to given Cursor

func (*Events) SetFocus added in v0.1.1

func (em *Events) SetFocus(w Widget) bool

SetFocus sets focus to given item, and returns true if focus changed. If item is nil, then nothing has focus. This does NOT send the events.Focus event to the widget. See [SetFocusEvent] for version that does send event.

func (*Events) SetFocusEvent added in v0.1.1

func (em *Events) SetFocusEvent(w Widget) bool

SetFocusEvent sets focus to given item, and returns true if focus changed. If item is nil, then nothing has focus. This sends the events.Focus event to the widget. See [SetFocus] for a version that does not.

func (*Events) SetFocusImpl added in v0.1.1

func (em *Events) SetFocusImpl(w Widget, sendEvent bool) bool

SetFocusImpl sets focus to given item -- returns true if focus changed. If item is nil, then nothing has focus. sendEvent determines whether the events.Focus event is sent to the focused item.

func (*Events) SetStartFocus added in v0.1.1

func (em *Events) SetStartFocus(k Widget)

SetStartFocus sets the given item to be first focus when window opens.

func (*Events) StartRepeatClickTimer added in v0.1.1

func (em *Events) StartRepeatClickTimer()

func (*Events) TopLongHover added in v0.1.1

func (em *Events) TopLongHover() Widget

TopLongHover returns the top-most LongHoverable widget among the Hovers

func (*Events) TriggerShortcut added in v0.1.1

func (em *Events) TriggerShortcut(chord key.Chord) bool

TriggerShortcut attempts to trigger a shortcut, returning true if one was triggered, and false otherwise. Also eliminates any shortcuts with deleted buttons, and does not trigger for Disabled buttons.

func (*Events) UpdateHovers added in v0.1.1

func (em *Events) UpdateHovers(hov, prev []Widget, e events.Event, enter, leave events.Types) []Widget

UpdateHovers updates the hovered widgets based on current widgets in bounding box.

type FavPathItem

type FavPathItem struct {

	// icon for item
	Ic icons.Icon

	// name of the favorite item
	Name string `width:"20"`

	// the path of the favorite item
	Path string `table:"-select"`
}

FavPathItem represents one item in a favorite path list, for display of favorites. Is an ordered list instead of a map because user can organize in order

func (FavPathItem) Label

func (fi FavPathItem) Label() string

Label satisfies the Labeler interface

type FavPaths

type FavPaths []FavPathItem

FavPaths is a list (slice) of favorite path items

func (*FavPaths) FindPath

func (pf *FavPaths) FindPath(path string) (int, bool)

FindPath returns index of path on list, or -1, false if not found

func (*FavPaths) SetToDefaults

func (pf *FavPaths) SetToDefaults()

SetToDefaults sets the paths to default values

type FieldValidator

type FieldValidator interface {
	// ValidateField returns an error if the value of the given named field is invalid.
	ValidateField(field string) error
}

FieldValidator is an interface for types to provide a ValidateField method that is used to validate string field [Value]s using [TextField.Validator].

type FileButton added in v0.2.0

type FileButton struct {
	Button
	Filename string
}

FileButton represents a Filename value with a button that opens a FilePicker.

func NewFileButton added in v0.2.0

func NewFileButton(parent ...tree.Node) *FileButton

NewFileButton returns a new FileButton with the given optional parent: FileButton represents a Filename value with a button that opens a FilePicker.

func (*FileButton) Init added in v0.2.0

func (fb *FileButton) Init()

func (*FileButton) New added in v0.2.0

func (t *FileButton) New() tree.Node

New returns a new *FileButton value

func (*FileButton) NodeType added in v0.2.0

func (t *FileButton) NodeType() *types.Type

NodeType returns the *types.Type of FileButton

func (*FileButton) SetFilename added in v0.2.0

func (t *FileButton) SetFilename(v string) *FileButton

SetFilename sets the [FileButton.Filename]

func (*FileButton) WidgetValue added in v0.2.0

func (fb *FileButton) WidgetValue() any

type FilePaths

type FilePaths []string

FilePaths represents a set of file paths.

var RecentPaths FilePaths

RecentPaths are the recently opened paths in the file picker.

func (*FilePaths) AddPath

func (fp *FilePaths) AddPath(path string, max int)

AddPath inserts a path to the file paths (at the start), subject to max length -- if path is already on the list then it is moved to the start.

func (*FilePaths) Open

func (fp *FilePaths) Open(filename string) error

Open file paths from a json-formatted file.

func (*FilePaths) Save

func (fp *FilePaths) Save(filename string) error

Save file paths to a json-formatted file.

type FilePicker added in v0.2.0

type FilePicker struct {
	Frame

	// Directory is the absolute path to the directory of files to display.
	Directory string `set:"-"`

	// SelectedFilename is the name of the currently selected file, not including the directory.
	// See [FilePicker.SelectedFile] for the full path.
	SelectedFilename string `set:"-"`

	// Extensions is a list of the target file extensions.
	// If there are multiple, they must be comma separated.
	// The extensions must include the dot (".") at the start.
	// They must be set using [FilePicker.SetExtensions].
	Extensions string `set:"-"`

	// FilterFunc is an optional filtering function for which files to display.
	FilterFunc FilePickerFilterFunc `display:"-" json:"-" xml:"-"`
	// contains filtered or unexported fields
}

FilePicker is a widget for selecting files.

func NewFilePicker added in v0.2.0

func NewFilePicker(parent ...tree.Node) *FilePicker

NewFilePicker returns a new FilePicker with the given optional parent: FilePicker is a widget for selecting files.

func (*FilePicker) AddChooserPaths added in v0.2.0

func (fp *FilePicker) AddChooserPaths(ch *Chooser)

AddChooserPaths adds paths to the app chooser

func (*FilePicker) AddPathToFavorites added in v0.2.0

func (fp *FilePicker) AddPathToFavorites()

AddPathToFavorites adds the current path to favorites

func (*FilePicker) ConfigWatcher added in v0.2.0

func (fp *FilePicker) ConfigWatcher() error

func (*FilePicker) DirectoryUp added in v0.2.0

func (fp *FilePicker) DirectoryUp()

DirectoryUp moves up one directory in the path

func (*FilePicker) Disconnect added in v0.2.0

func (fp *FilePicker) Disconnect()

func (*FilePicker) EditRecentPaths added in v0.2.0

func (fp *FilePicker) EditRecentPaths()

EditRecentPaths displays a dialog allowing the user to edit the recent paths list.

func (*FilePicker) ExtField added in v0.2.0

func (fp *FilePicker) ExtField() *TextField

ExtField returns the TextField of the extension

func (*FilePicker) FavoritesSelect added in v0.2.0

func (fp *FilePicker) FavoritesSelect(idx int)

FavoritesSelect selects a favorite path and goes there

func (*FilePicker) FavoritesView added in v0.2.0

func (fp *FilePicker) FavoritesView() *Table

FavoritesView returns the Table of the favorites

func (*FilePicker) FileComplete added in v0.2.0

func (fp *FilePicker) FileComplete(data any, text string, posLine, posChar int) (md complete.Matches)

FileComplete finds the possible completions for the file field

func (*FilePicker) FileCompleteEdit added in v0.2.0

func (fp *FilePicker) FileCompleteEdit(data any, text string, cursorPos int, c complete.Completion, seed string) (ed complete.Edit)

FileCompleteEdit is the editing function called when inserting the completion selection in the file field

func (*FilePicker) FileSelect added in v0.2.0

func (fp *FilePicker) FileSelect(idx int)

FileSelect updates the selection with the given selected file index and sends a select event.

func (*FilePicker) FilesView added in v0.2.0

func (fp *FilePicker) FilesView() *Table

FilesView returns the Table of the files

func (*FilePicker) Init added in v0.2.0

func (fp *FilePicker) Init()

func (*FilePicker) MakeToolbar added in v0.2.0

func (fp *FilePicker) MakeToolbar(p *tree.Plan)

func (*FilePicker) New added in v0.2.0

func (t *FilePicker) New() tree.Node

New returns a new *FilePicker value

func (*FilePicker) NewFolder added in v0.2.0

func (fp *FilePicker) NewFolder(name string) error

NewFolder creates a new folder with the given name in the current directory.

func (*FilePicker) NodeType added in v0.2.0

func (t *FilePicker) NodeType() *types.Type

NodeType returns the *types.Type of FilePicker

func (*FilePicker) PathComplete added in v0.2.0

func (fp *FilePicker) PathComplete(data any, path string, posLine, posChar int) (md complete.Matches)

PathComplete finds the possible completions for the path field

func (*FilePicker) PathCompleteEdit added in v0.2.0

func (fp *FilePicker) PathCompleteEdit(data any, text string, cursorPos int, c complete.Completion, seed string) (ed complete.Edit)

PathCompleteEdit is the editing function called when inserting the completion selection in the path field

func (*FilePicker) ReadFiles added in v0.2.0

func (fp *FilePicker) ReadFiles()

func (*FilePicker) SaveSortSettings added in v0.2.0

func (fp *FilePicker) SaveSortSettings()

SaveSortSettings saves current sorting preferences

func (*FilePicker) SelectField added in v0.2.0

func (fp *FilePicker) SelectField() *TextField

SelectField returns the TextField of the select file

func (*FilePicker) SelectFile added in v0.2.0

func (fp *FilePicker) SelectFile() bool

SelectFile selects the current file as the selection. if a directory it opens the directory and returns false. if a file it selects the file and returns true. if no selection, returns false.

func (*FilePicker) SelectedFile added in v0.2.0

func (fp *FilePicker) SelectedFile() string

SelectedFile returns the full path to the currently selected file.

func (*FilePicker) SelectedFileInfo added in v0.2.0

func (fp *FilePicker) SelectedFileInfo() (*fileinfo.FileInfo, bool)

SelectedFileInfo returns the currently selected fileinfo, returns false if none

func (*FilePicker) SetExtensions added in v0.2.0

func (fp *FilePicker) SetExtensions(ext string) *FilePicker

SetExtensions sets the [FilePicker.Extensions] to the given comma separated list of file extensions, which each must start with a dot (".").

func (*FilePicker) SetFilename added in v0.2.0

func (fp *FilePicker) SetFilename(filename string) *FilePicker

SetFilename sets the directory and filename of the file picker from the given filepath.

func (*FilePicker) SetFilterFunc added in v0.2.0

func (t *FilePicker) SetFilterFunc(v FilePickerFilterFunc) *FilePicker

SetFilterFunc sets the [FilePicker.FilterFunc]: FilterFunc is an optional filtering function for which files to display.

func (*FilePicker) SetSelectedFile added in v0.2.0

func (fp *FilePicker) SetSelectedFile(file string)

SetSelectedFile sets the currently selected file to the given name, sends a selection event, and updates the selection in the table.

func (*FilePicker) UpdateFavorites added in v0.2.0

func (fp *FilePicker) UpdateFavorites()

UpdateFavorites updates list of files and other views for current path

func (*FilePicker) UpdateFilesAction added in v0.2.0

func (fp *FilePicker) UpdateFilesAction()

UpdateFilesAction updates the list of files and other views for the current path.

func (*FilePicker) UpdatePath added in v0.2.0

func (fp *FilePicker) UpdatePath()

UpdatePath ensures that path is in abs form and ready to be used..

func (*FilePicker) WatchWatcher added in v0.2.0

func (fp *FilePicker) WatchWatcher()

type FilePickerFilterFunc added in v0.2.0

type FilePickerFilterFunc func(fp *FilePicker, fi *fileinfo.FileInfo) bool

FilePickerFilterFunc is a filtering function for files; returns true if the file should be visible in the picker, and false if not

type Filename

type Filename string

Filename is used to specify an file path. It results in a FileButton Value.

type FontButton added in v0.2.0

type FontButton struct {
	Button
}

FontButton represents a FontName with a Button that opens a dialog for selecting the font family.

func NewFontButton added in v0.2.0

func NewFontButton(parent ...tree.Node) *FontButton

NewFontButton returns a new FontButton with the given optional parent: FontButton represents a FontName with a Button that opens a dialog for selecting the font family.

func (*FontButton) Init added in v0.2.0

func (fb *FontButton) Init()

func (*FontButton) New added in v0.2.0

func (t *FontButton) New() tree.Node

New returns a new *FontButton value

func (*FontButton) NodeType added in v0.2.0

func (t *FontButton) NodeType() *types.Type

NodeType returns the *types.Type of FontButton

func (*FontButton) WidgetValue added in v0.2.0

func (fb *FontButton) WidgetValue() any

type FontName

type FontName string

FontName is used to specify a font family name. It results in a FontButton Value.

type Form added in v0.2.0

type Form struct {
	Frame

	// Struct is the pointer to the struct that we are viewing.
	Struct any

	// Inline is whether to display the form in one line.
	Inline bool
	// contains filtered or unexported fields
}

Form represents a struct with rows of field names and editable values.

func NewForm added in v0.2.0

func NewForm(parent ...tree.Node) *Form

NewForm returns a new Form with the given optional parent: Form represents a struct with rows of field names and editable values.

func (*Form) Init added in v0.2.0

func (fm *Form) Init()

func (*Form) New added in v0.2.0

func (t *Form) New() tree.Node

New returns a new *Form value

func (*Form) NodeType added in v0.2.0

func (t *Form) NodeType() *types.Type

NodeType returns the *types.Type of Form

func (*Form) SetInline added in v0.2.0

func (t *Form) SetInline(v bool) *Form

SetInline sets the [Form.Inline]: Inline is whether to display the form in one line.

func (*Form) SetStruct added in v0.2.0

func (t *Form) SetStruct(v any) *Form

SetStruct sets the [Form.Struct]: Struct is the pointer to the struct that we are viewing.

func (*Form) WidgetValue added in v0.2.0

func (fm *Form) WidgetValue() any

type FormButton added in v0.2.0

type FormButton struct {
	Button
	Struct any
}

FormButton represents a struct value with a button that opens a Form.

func NewFormButton added in v0.2.0

func NewFormButton(parent ...tree.Node) *FormButton

NewFormButton returns a new FormButton with the given optional parent: FormButton represents a struct value with a button that opens a Form.

func (*FormButton) Init added in v0.2.0

func (fb *FormButton) Init()

func (*FormButton) New added in v0.2.0

func (t *FormButton) New() tree.Node

New returns a new *FormButton value

func (*FormButton) NodeType added in v0.2.0

func (t *FormButton) NodeType() *types.Type

NodeType returns the *types.Type of FormButton

func (*FormButton) SetStruct added in v0.2.0

func (t *FormButton) SetStruct(v any) *FormButton

SetStruct sets the [FormButton.Struct]

func (*FormButton) WidgetValue added in v0.2.0

func (fb *FormButton) WidgetValue() any

type Frame

type Frame struct {
	WidgetBase

	// StackTop, for a [styles.Stacked] frame, is the index of the node to use as the top of the stack.
	// Only the node at this index is rendered; if not a valid index, nothing is rendered.
	StackTop int

	// LayoutStackTopOnly is whether to only layout the top widget (specified by [Frame.StackTop])
	// for a [styles.Stacked] frame. This is appropriate for e.g., [Tabs], which do a full
	// redraw on stack changes, but not for e.g., [Switch]es which don't.
	LayoutStackTopOnly bool

	// Layout contains implementation state info for doing layout
	Layout LayoutState `edit:"-" copier:"-" json:"-" xml:"-" set:"-"`

	// HasScroll is whether scrollbar is used for given dim.
	HasScroll [2]bool `edit:"-" copier:"-" json:"-" xml:"-" set:"-"`

	// Scrolls are the scroll bars, which are fully managed as needed.
	Scrolls [2]*Slider `edit:"-" copier:"-" json:"-" xml:"-" set:"-"`
	// contains filtered or unexported fields
}

Frame is the primary node type responsible for organizing the sizes and positions of child widgets. It also renders the standard box model. All collections of widgets should generally be contained within a Frame; otherwise, the parent widget must take over responsibility for positioning. Frames automatically can add scrollbars depending on the styles.Style.Overflow.

For a styles.Grid frame, the styles.Style.Columns property should generally be set to the desired number of columns, from which the number of rows is computed; otherwise, it uses the square root of number of elements.

func AsFrame added in v0.2.0

func AsFrame(k tree.Node) *Frame

AsFrame returns the given value as a value of type Frame if the type of the given value embeds Frame, or nil otherwise.

func NewFrame

func NewFrame(parent ...tree.Node) *Frame

NewFrame returns a new Frame with the given optional parent: Frame is the primary node type responsible for organizing the sizes and positions of child widgets. It also renders the standard box model. All collections of widgets should generally be contained within a Frame; otherwise, the parent widget must take over responsibility for positioning. Frames automatically can add scrollbars depending on the styles.Style.Overflow.

For a styles.Grid frame, the styles.Style.Columns property should generally be set to the desired number of columns, from which the number of rows is computed; otherwise, it uses the square root of number of elements.

func (*Frame) AsFrame added in v0.2.0

func (t *Frame) AsFrame() *Frame

AsFrame satisfies the Layouter interface.

func (*Frame) AutoScroll added in v0.2.0

func (ly *Frame) AutoScroll(pos math32.Vector2) bool

AutoScroll scrolls the layout based on given position in scroll coordinates (i.e., already subtracing the BBox Min for a mouse event).

func (*Frame) AutoScrollDim added in v0.2.0

func (ly *Frame) AutoScrollDim(d math32.Dims, pos float32) bool

AutoScrollDim auto-scrolls along one dimension, based on the current position value, which is in the current scroll value range.

func (*Frame) ChildWithFocus added in v0.2.0

func (fr *Frame) ChildWithFocus() (Widget, int)

ChildWithFocus returns a direct child of this layout that either is the current window focus item, or contains that focus item (along with its index) -- nil, -1 if none.

func (*Frame) ConfigScroll added in v0.2.0

func (ly *Frame) ConfigScroll(d math32.Dims)

ConfigScroll configures scroll for given dimension

func (*Frame) ConfigScrolls added in v0.2.0

func (ly *Frame) ConfigScrolls()

ConfigScrolls configures any scrollbars that have been enabled during the Layout process. This is called during Position, once the sizing and need for scrollbars has been established. The final position of the scrollbars is set during ScenePos in PositionScrolls. Scrolls are kept around in general.

func (*Frame) DeleteScroll added in v0.2.0

func (fr *Frame) DeleteScroll(d math32.Dims)

DeleteScroll deletes scrollbar along given dimesion.

func (*Frame) Destroy added in v0.2.0

func (fr *Frame) Destroy()

func (*Frame) FocusNextChild added in v0.2.0

func (fr *Frame) FocusNextChild(updn bool) bool

FocusNextChild attempts to move the focus into the next layout child (with wraparound to start); returns true if successful. if updn is true, then for Grid layouts, it moves down to next row instead of just the sequentially next item.

func (*Frame) FocusOnName added in v0.2.0

func (fr *Frame) FocusOnName(e events.Event) bool

FocusOnName processes key events to look for an element starting with given name

func (*Frame) FocusPreviousChild added in v0.2.0

func (fr *Frame) FocusPreviousChild(updn bool) bool

FocusPreviousChild attempts to move the focus into the previous layout child (with wraparound to end); returns true if successful. If updn is true, then for Grid layouts, it moves up to next row instead of just the sequentially next item.

func (*Frame) HasAnyScroll added in v0.2.0

func (ly *Frame) HasAnyScroll() bool

HasAnyScroll returns true if the frame has any scrollbars.

func (*Frame) Init added in v0.2.0

func (fr *Frame) Init()

func (*Frame) LaySetContentFitOverflow added in v0.2.0

func (ly *Frame) LaySetContentFitOverflow(nsz math32.Vector2, pass LayoutPasses)

LaySetContentFitOverflow sets Internal and Actual.Content size to fit given new content size, depending on the Styles Overflow: Auto and Scroll types do NOT expand Actual and remain at their current styled actual values, absorbing the extra content size within their own scrolling zone (full size recorded in Internal).

func (*Frame) LaySetGapSizeFromCells added in v0.2.0

func (ly *Frame) LaySetGapSizeFromCells()

func (*Frame) LaySetInitCells added in v0.2.0

func (ly *Frame) LaySetInitCells()

SetInitCells sets the initial default assignment of cell indexes to each widget, based on layout type.

func (*Frame) LaySetInitCellsFlex added in v0.2.0

func (ly *Frame) LaySetInitCellsFlex()

func (*Frame) LaySetInitCellsGrid added in v0.2.0

func (ly *Frame) LaySetInitCellsGrid()

func (*Frame) LaySetInitCellsStacked added in v0.2.0

func (ly *Frame) LaySetInitCellsStacked()

func (*Frame) LaySetInitCellsWrap added in v0.2.0

func (ly *Frame) LaySetInitCellsWrap()

func (*Frame) LaySetWrapIndexes added in v0.2.0

func (ly *Frame) LaySetWrapIndexes()

LaySetWrapIndexes sets indexes for Wrap case

func (*Frame) LayoutSpace added in v0.2.0

func (ly *Frame) LayoutSpace()

LayoutSpace sets our Space based on Styles and Scroll. Other layout types can change this if they want to.

func (*Frame) ManageOverflow added in v0.2.0

func (ly *Frame) ManageOverflow(iter int, updateSize bool) bool

ManageOverflow uses overflow settings to determine if scrollbars are needed (Internal > Alloc). Returns true if size changes as a result. If updateSize is false, then the Actual and Alloc sizes are NOT updated as a result of change from adding scrollbars (generally should be true, but some cases not)

func (*Frame) New

func (t *Frame) New() tree.Node

New returns a new *Frame value

func (*Frame) NodeType

func (t *Frame) NodeType() *types.Type

NodeType returns the *types.Type of Frame

func (*Frame) Position added in v0.2.0

func (ly *Frame) Position()

Position: uses the final sizes to position everything within layouts according to alignment settings.

func (*Frame) PositionCells added in v0.2.0

func (ly *Frame) PositionCells()

func (*Frame) PositionCellsMainX added in v0.2.0

func (ly *Frame) PositionCellsMainX()

Main axis = X

func (*Frame) PositionCellsMainY added in v0.2.0

func (ly *Frame) PositionCellsMainY()

Main axis = Y

func (*Frame) PositionLay added in v0.2.0

func (ly *Frame) PositionLay()

func (*Frame) PositionScroll added in v0.2.0

func (ly *Frame) PositionScroll(d math32.Dims)

func (*Frame) PositionScrolls added in v0.2.0

func (ly *Frame) PositionScrolls()

PositionScrolls arranges scrollbars

func (*Frame) PositionStacked added in v0.2.0

func (ly *Frame) PositionStacked()

func (*Frame) PositionWrap added in v0.2.0

func (ly *Frame) PositionWrap()

func (*Frame) RenderChildren added in v0.2.0

func (fr *Frame) RenderChildren()

func (*Frame) RenderScrolls added in v0.2.0

func (ly *Frame) RenderScrolls()

RenderScrolls draws the scrollbars

func (*Frame) RenderWidget

func (fr *Frame) RenderWidget()

func (*Frame) ScenePos added in v0.2.0

func (ly *Frame) ScenePos()

ScenePos: scene-based position and final BBox is computed based on parents accumulated position and scrollbar position. This step can be performed when scrolling after updating Scroll.

func (*Frame) ScenePosChildren added in v0.2.0

func (ly *Frame) ScenePosChildren()

ScenePosChildren runs ScenePos on the children

func (*Frame) ScenePosLay added in v0.2.0

func (ly *Frame) ScenePosLay()

func (*Frame) ScrollActionDelta added in v0.2.0

func (ly *Frame) ScrollActionDelta(d math32.Dims, delta float32)

ScrollActionDelta moves the scrollbar in given dimension by given delta and emits a ScrollSig signal.

func (*Frame) ScrollActionPos added in v0.2.0

func (ly *Frame) ScrollActionPos(d math32.Dims, pos float32)

ScrollActionPos moves the scrollbar in given dimension to given position and emits a ScrollSig signal.

func (*Frame) ScrollChanged added in v0.2.0

func (ly *Frame) ScrollChanged(d math32.Dims, sb *Slider)

ScrollChanged is called in the OnInput event handler for updating, when the scrollbar value has changed, for given dimension. This is part of the Layouter interface.

func (*Frame) ScrollDelta added in v0.2.0

func (ly *Frame) ScrollDelta(e events.Event)

ScrollDelta processes a scroll event. If only one dimension is processed, and there is a non-zero in other, then the consumed dimension is reset to 0 and the event is left unprocessed, so a higher level can consume the remainder.

func (*Frame) ScrollDimToCenter added in v0.2.0

func (ly *Frame) ScrollDimToCenter(d math32.Dims, posi int) bool

ScrollDimToCenter scrolls to put the given child coordinate position (eg., middle of a view box) at the center of our scroll area, to the extent possible. Returns true if scrolling was needed.

func (*Frame) ScrollDimToContentEnd added in v0.2.0

func (ly *Frame) ScrollDimToContentEnd(d math32.Dims) bool

ScrollDimToContentEnd is a helper function that scrolls the layout to the end of its content (ie: moves the scrollbar to the very end).

func (*Frame) ScrollDimToEnd added in v0.2.0

func (ly *Frame) ScrollDimToEnd(d math32.Dims, posi int) bool

ScrollDimToEnd scrolls to put the given child coordinate position (eg., bottom / right of a view box) at the end (bottom / right) of our scroll area, to the extent possible. Returns true if scrolling was needed.

func (*Frame) ScrollDimToStart added in v0.2.0

func (ly *Frame) ScrollDimToStart(d math32.Dims, posi int) bool

ScrollDimToStart scrolls to put the given child coordinate position (eg., top / left of a view box) at the start (top / left) of our scroll area, to the extent possible. Returns true if scrolling was needed.

func (*Frame) ScrollGeom added in v0.2.0

func (ly *Frame) ScrollGeom(d math32.Dims) (pos, sz math32.Vector2)

ScrollGeom returns the target position and size for scrollbars

func (*Frame) ScrollResetIfNone added in v0.2.0

func (ly *Frame) ScrollResetIfNone()

ScrollResetIfNone resets the scroll offsets if there are no scrollbars

func (*Frame) ScrollToBox added in v0.2.0

func (ly *Frame) ScrollToBox(box image.Rectangle) bool

ScrollToBox scrolls the layout to ensure that given rect box is in view. Returns true if scrolling was needed

func (*Frame) ScrollToBoxDim added in v0.2.0

func (ly *Frame) ScrollToBoxDim(d math32.Dims, tmini, tmaxi int) bool

ScrollToBoxDim scrolls to ensure that given target [min..max] range along one dimension is in view. Returns true if scrolling was needed

func (*Frame) ScrollToItem added in v0.2.0

func (ly *Frame) ScrollToItem(wi Widget) bool

ScrollToItem scrolls the layout to ensure that given item is in view. Returns true if scrolling was needed

func (*Frame) ScrollToPos added in v0.2.0

func (ly *Frame) ScrollToPos(d math32.Dims, pos float32)

ScrollToPos moves the scrollbar in given dimension to given position and DOES NOT emit a ScrollSig signal.

func (*Frame) ScrollUpdateFromGeom added in v0.2.0

func (ly *Frame) ScrollUpdateFromGeom(d math32.Dims)

ScrollUpdateFromGeom updates the scrollbar for given dimension based on the current Geom.Scroll value for that dimension. This can be used to programatically update the scroll value.

func (*Frame) ScrollValues added in v0.2.0

func (ly *Frame) ScrollValues(d math32.Dims) (maxSize, visSize, visPct float32)

ScrollValues returns the maximum size that could be scrolled, the visible size (which could be less than the max size, in which case no scrollbar is needed), and visSize / maxSize as the VisiblePct. This is used in updating the scrollbar and determining whether one is needed in the first place

func (*Frame) SetLayoutStackTopOnly added in v0.2.0

func (t *Frame) SetLayoutStackTopOnly(v bool) *Frame

SetLayoutStackTopOnly sets the [Frame.LayoutStackTopOnly]: LayoutStackTopOnly is whether to only layout the top widget (specified by [Frame.StackTop]) for a styles.Stacked frame. This is appropriate for e.g., Tabs, which do a full redraw on stack changes, but not for e.g., [Switch]es which don't.

func (*Frame) SetScrollParams added in v0.2.0

func (ly *Frame) SetScrollParams(d math32.Dims, sb *Slider)

SetScrollParams sets scrollbar parameters. Must set Step and PageStep, but can also set others as needed. Max and VisiblePct are automatically set based on ScrollValues maxSize, visPct.

func (*Frame) SetScrollsOff added in v0.2.0

func (ly *Frame) SetScrollsOff()

SetScrollsOff turns off the scrollbars

func (*Frame) SetStackTop added in v0.2.0

func (t *Frame) SetStackTop(v int) *Frame

SetStackTop sets the [Frame.StackTop]: StackTop, for a styles.Stacked frame, is the index of the node to use as the top of the stack. Only the node at this index is rendered; if not a valid index, nothing is rendered.

func (*Frame) SizeDown added in v0.2.0

func (ly *Frame) SizeDown(iter int) bool

func (*Frame) SizeDownAllocActual added in v0.2.0

func (ly *Frame) SizeDownAllocActual(iter int)

SizeDownAllocActual sets Alloc to Actual for no-extra case.

func (*Frame) SizeDownAllocActualCells added in v0.2.0

func (ly *Frame) SizeDownAllocActualCells(iter int)

SizeDownAllocActualCells sets Alloc to Actual for no-extra case. Note however that due to max sizing for row / column, this size can actually be different than original actual.

func (*Frame) SizeDownAllocActualStacked added in v0.2.0

func (ly *Frame) SizeDownAllocActualStacked(iter int)

func (*Frame) SizeDownChildren added in v0.2.0

func (ly *Frame) SizeDownChildren(iter int) bool

SizeDownChildren calls SizeDown on the Children. The kids must have their Size.Alloc set prior to this, which is what Layout type does. Other special widget types can do custom layout and call this too.

func (*Frame) SizeDownGrow added in v0.2.0

func (ly *Frame) SizeDownGrow(iter int, extra math32.Vector2) bool

SizeDownGrow grows the element sizes based on total extra and Grow

func (*Frame) SizeDownGrowCells added in v0.2.0

func (ly *Frame) SizeDownGrowCells(iter int, extra math32.Vector2) bool

func (*Frame) SizeDownGrowStacked added in v0.2.0

func (ly *Frame) SizeDownGrowStacked(iter int, extra math32.Vector2) bool

func (*Frame) SizeDownLay added in v0.2.0

func (ly *Frame) SizeDownLay(iter int) bool

SizeDownLay is the Layout standard SizeDown pass, returning true if another iteration is required. It allocates sizes to fit given parent-allocated total size.

func (*Frame) SizeDownSetAllocs added in v0.2.0

func (ly *Frame) SizeDownSetAllocs(iter int)

SizeDownSetAllocs is the key SizeDown step that sets the allocations in the children, based on our allocation. In the default implementation this calls SizeDownGrow if there is extra space to grow, or SizeDownAllocActual to set the allocations as they currrently are.

func (*Frame) SizeDownWrap added in v0.2.0

func (ly *Frame) SizeDownWrap(iter int) bool

func (*Frame) SizeFinal added in v0.2.0

func (ly *Frame) SizeFinal()

func (*Frame) SizeFinalChildren added in v0.2.0

func (ly *Frame) SizeFinalChildren()

SizeFinalChildren calls SizeFinal on all the children of this node

func (*Frame) SizeFinalLay added in v0.2.0

func (ly *Frame) SizeFinalLay()

SizeFinalLay is the Layout standard SizeFinal pass

func (*Frame) SizeFinalUpdateChildrenSizes added in v0.2.0

func (ly *Frame) SizeFinalUpdateChildrenSizes()

SizeFinalUpdateChildrenSizes can optionally be called for layouts that dynamically create child elements based on final layout size. It ensures that the children are properly sized.

func (*Frame) SizeFromChildren added in v0.2.0

func (ly *Frame) SizeFromChildren(iter int, pass LayoutPasses) math32.Vector2

SizeFromChildren gathers Actual size from kids. Different Layout types can alter this to present different Content sizes for the layout process, e.g., if Content is sized to fit allocation, as in the TopAppBar and List types.

func (*Frame) SizeFromChildrenCells added in v0.2.0

func (ly *Frame) SizeFromChildrenCells(iter int, pass LayoutPasses) math32.Vector2

SizeFromChildrenCells for Flex, Grid

func (*Frame) SizeFromChildrenFit added in v0.2.0

func (ly *Frame) SizeFromChildrenFit(iter int, pass LayoutPasses)

SizeFromChildrenFit gathers Actual size from kids, and calls LaySetContentFitOverflow to update Actual and Internal size based on this.

func (*Frame) SizeFromChildrenStacked added in v0.2.0

func (ly *Frame) SizeFromChildrenStacked() math32.Vector2

SizeFromChildrenStacked for stacked case

func (*Frame) SizeUp added in v0.2.0

func (ly *Frame) SizeUp()

func (*Frame) SizeUpChildren added in v0.2.0

func (ly *Frame) SizeUpChildren()

SizeUpChildren calls SizeUp on all the children of this node

func (*Frame) SizeUpLay added in v0.2.0

func (ly *Frame) SizeUpLay()

SizeUpLay is the Layout standard SizeUp pass

func (*Frame) StackTopWidget added in v0.2.0

func (ly *Frame) StackTopWidget() (Widget, *WidgetBase)

StackTopWidget returns the StackTop element as a widget

func (*Frame) Style added in v0.2.0

func (fr *Frame) Style()

func (*Frame) UpdateStackedVisibility added in v0.2.0

func (ly *Frame) UpdateStackedVisibility()

UpdateStackedVisbility updates the visibility for Stacked layouts so the StackTop widget is visible, and others are Invisible.

type FuncArg added in v0.2.0

type FuncArg struct {

	// Name is the name of the argument or return value.
	Name string

	// Tag contains any tags associated with the argument or return value,
	// which can be added programmatically to customize [Value] behavior.
	Tag reflect.StructTag

	// Value is the actual value of the function argument or return value.
	// It can be modified when creating a [FuncButton] to set a default value.
	Value any
}

FuncArg represents one argument or return value of a function in the context of a FuncButton.

func (*FuncArg) SetName added in v0.2.0

func (t *FuncArg) SetName(v string) *FuncArg

SetName sets the [FuncArg.Name]: Name is the name of the argument or return value.

func (*FuncArg) SetTag added in v0.2.0

func (t *FuncArg) SetTag(v reflect.StructTag) *FuncArg

SetTag sets the [FuncArg.Tag]: Tag contains any tags associated with the argument or return value, which can be added programmatically to customize Value behavior.

func (*FuncArg) SetValue added in v0.2.0

func (t *FuncArg) SetValue(v any) *FuncArg

SetValue sets the [FuncArg.Value]: Value is the actual value of the function argument or return value. It can be modified when creating a FuncButton to set a default value.

type FuncButton added in v0.2.0

type FuncButton struct {
	Button

	// Func is the [types.Func] associated with this button.
	// This function can also be a method, but it must be
	// converted to a [types.Func] first. It should typically
	// be set using [FuncButton.SetFunc].
	Func *types.Func `set:"-"`

	// ReflectFunc is the [reflect.Value] of the function or
	// method associated with this button. It should typically
	// bet set using [FuncButton.SetFunc].
	ReflectFunc reflect.Value `set:"-"`

	// Args are the [FuncArg] objects associated with the
	// arguments of the function. They are automatically set in
	// [SetFunc], but they can be customized to configure
	// default values and other options.
	Args []FuncArg `set:"-"`

	// Returns are the [FuncArg] objects associated with the
	// return values of the function. They are automatically
	// set in [SetFunc], but they can be customized to configure
	// options. The [FuncArg.Value]s are not set until the
	// function is called, and are thus not typically applicable
	// to access.
	Returns []FuncArg `set:"-"`

	// Confirm is whether to prompt the user for confirmation
	// before calling the function.
	Confirm bool

	// ShowReturn is whether to display the return values of
	// the function (and a success message if there are none).
	// The way that the return values are shown is determined
	// by ShowReturnAsDialog. Non-nil error return values will
	// always be shown, even if ShowReturn is set to false.
	ShowReturn bool

	// ShowReturnAsDialog, if and only if ShowReturn is true,
	// indicates to show the return values of the function in
	// a dialog, instead of in a snackbar, as they are by default.
	// If there are multiple return values from the function, or if
	// one of them is a complex type (pointer, struct, slice,
	// array, map), then ShowReturnAsDialog will
	// automatically be set to true.
	ShowReturnAsDialog bool

	// NewWindow makes the ReturnDialog a NewWindow dialog
	// (if supported by platform).
	NewWindow bool

	// WarnUnadded is whether to log warnings when a function that
	// has not been added to [types] is used. It is on by default and
	// must be set before [FuncButton.SetFunc] is called for it to
	// have any effect. Warnings are never logged for anonymous functions.
	WarnUnadded bool `default:"true"`

	// Context is used for opening Dialogs if non-nil.
	Context Widget

	// AfterFunc is an optional function called after the func button
	// function is executed
	AfterFunc func()
}

FuncButton is a button that is set up to call a function when it is pressed, using a dialog to prompt the user for any arguments. Also, it automatically sets various properties of the button like the name, text, tooltip, and icon based on the properties of the function, using reflect and types. The function must be registered with types to get documentation information, but that is not required; add a `//types:add` comment directive and run `core generate` if you want tooltips. If the function is a method, both the method and its receiver type must be added to types to get documentation.

func NewFuncButton added in v0.2.0

func NewFuncButton(parent ...tree.Node) *FuncButton

NewFuncButton returns a new FuncButton with the given optional parent: FuncButton is a button that is set up to call a function when it is pressed, using a dialog to prompt the user for any arguments. Also, it automatically sets various properties of the button like the name, text, tooltip, and icon based on the properties of the function, using reflect and types. The function must be registered with types to get documentation information, but that is not required; add a `//types:add` comment directive and run `core generate` if you want tooltips. If the function is a method, both the method and its receiver type must be added to types to get documentation.

func NewSoloFuncButton added in v0.2.0

func NewSoloFuncButton(ctx Widget) *FuncButton

NewSoloFuncButton returns a standalone FuncButton with a fake parent with the given context for popping up any dialogs.

func (*FuncButton) CallFunc added in v0.2.0

func (fb *FuncButton) CallFunc()

CallFunc calls the function associated with this button, prompting the user for any arguments.

func (*FuncButton) Init added in v0.2.0

func (fb *FuncButton) Init()

func (*FuncButton) New added in v0.2.0

func (t *FuncButton) New() tree.Node

New returns a new *FuncButton value

func (*FuncButton) NodeType added in v0.2.0

func (t *FuncButton) NodeType() *types.Type

NodeType returns the *types.Type of FuncButton

func (*FuncButton) OnBind added in v0.2.0

func (fb *FuncButton) OnBind(value any)

func (*FuncButton) SetAfterFunc added in v0.2.0

func (t *FuncButton) SetAfterFunc(v func()) *FuncButton

SetAfterFunc sets the [FuncButton.AfterFunc]: AfterFunc is an optional function called after the func button function is executed

func (*FuncButton) SetConfirm added in v0.2.0

func (t *FuncButton) SetConfirm(v bool) *FuncButton

SetConfirm sets the [FuncButton.Confirm]: Confirm is whether to prompt the user for confirmation before calling the function.

func (*FuncButton) SetContext added in v0.2.0

func (t *FuncButton) SetContext(v Widget) *FuncButton

SetContext sets the [FuncButton.Context]: Context is used for opening Dialogs if non-nil.

func (*FuncButton) SetFunc added in v0.2.0

func (fb *FuncButton) SetFunc(fun any) *FuncButton

SetFunc sets the function associated with the FuncButton to the given function or method value. For documentation information for the function to be obtained, it must be added to types.

func (*FuncButton) SetKey added in v0.2.0

func (fb *FuncButton) SetKey(kf keymap.Functions) *FuncButton

SetKey sets the shortcut of the function button from the given keymap.Functions.

func (*FuncButton) SetNewWindow added in v0.2.0

func (t *FuncButton) SetNewWindow(v bool) *FuncButton

SetNewWindow sets the [FuncButton.NewWindow]: NewWindow makes the ReturnDialog a NewWindow dialog (if supported by platform).

func (*FuncButton) SetShowReturn added in v0.2.0

func (t *FuncButton) SetShowReturn(v bool) *FuncButton

SetShowReturn sets the [FuncButton.ShowReturn]: ShowReturn is whether to display the return values of the function (and a success message if there are none). The way that the return values are shown is determined by ShowReturnAsDialog. Non-nil error return values will always be shown, even if ShowReturn is set to false.

func (*FuncButton) SetShowReturnAsDialog added in v0.2.0

func (t *FuncButton) SetShowReturnAsDialog(v bool) *FuncButton

SetShowReturnAsDialog sets the [FuncButton.ShowReturnAsDialog]: ShowReturnAsDialog, if and only if ShowReturn is true, indicates to show the return values of the function in a dialog, instead of in a snackbar, as they are by default. If there are multiple return values from the function, or if one of them is a complex type (pointer, struct, slice, array, map), then ShowReturnAsDialog will automatically be set to true.

func (*FuncButton) SetText added in v0.2.0

func (fb *FuncButton) SetText(v string) *FuncButton

SetText sets the [FuncButton.Text] and updates the tooltip to correspond to the new name.

func (*FuncButton) SetWarnUnadded added in v0.2.0

func (t *FuncButton) SetWarnUnadded(v bool) *FuncButton

SetWarnUnadded sets the [FuncButton.WarnUnadded]: WarnUnadded is whether to log warnings when a function that has not been added to types is used. It is on by default and must be set before FuncButton.SetFunc is called for it to have any effect. Warnings are never logged for anonymous functions.

func (*FuncButton) SetWidgetValue added in v0.2.0

func (fb *FuncButton) SetWidgetValue(value any) error

func (*FuncButton) WidgetValue added in v0.2.0

func (fb *FuncButton) WidgetValue() any

type GeomCT

type GeomCT struct {
	// Content is for the contents (children, parts) of the widget,
	// excluding the Space (margin, padding, scrollbars).
	// This content includes the InnerSpace factor (Gaps in Layout)
	// which must therefore be subtracted when allocating down to children.
	Content math32.Vector2

	// Total is for the total exterior of the widget: Content + Space
	Total math32.Vector2
}

GeomCT has core layout elements: Content and Total

func (GeomCT) String

func (ct GeomCT) String() string

type GeomSize

type GeomSize struct {
	// Actual is the actual size for the purposes of rendering, representing
	// the "external" demands of the widget for space from its parent.
	// This is initially the bottom-up constraint computed by SizeUp,
	// and only changes during SizeDown when wrapping elements are reshaped
	// based on allocated size, or when scrollbars are added.
	// For elements with scrollbars (OverflowAuto), the Actual size remains
	// at the initial style minimums, "absorbing" is internal size,
	// while Internal records the true size of the contents.
	// For SizeFinal, Actual size can Grow up to the final Alloc size,
	// while Internal records the actual bottom-up contents size.
	Actual GeomCT `display:"inline"`

	// Alloc is the top-down allocated size, based on available visible space,
	// starting from the Scene geometry and working downward, attempting to
	// accommodate the Actual contents, and allocating extra space based on
	// Grow factors.  When Actual < Alloc, alignment factors determine positioning
	// within the allocated space.
	Alloc GeomCT `display:"inline"`

	// Internal is the internal size representing the true size of all contents
	// of the widget.  This can be less than Actual.Content if widget has Grow
	// factors but its internal contents did not grow accordingly, or it can
	// be more than Actual.Content if it has scrollbars (OverflowAuto).
	// Note that this includes InnerSpace (Gap).
	Internal math32.Vector2

	// Space is the padding, total effective margin (border, shadow, etc),
	// and scrollbars that subtracts from Total size to get Content size.
	Space math32.Vector2

	// InnerSpace is total extra space that is included within the Content Size region
	// and must be subtracted from Content when passing sizes down to children.
	InnerSpace math32.Vector2

	// Min is the Styles.Min.Dots() (Ceil int) that constrains the Actual.Content size
	Min math32.Vector2

	// Max is the Styles.Max.Dots() (Ceil int) that constrains the Actual.Content size
	Max math32.Vector2
}

GeomSize has all of the relevant Layout sizes

func (*GeomSize) FitSizeMax

func (ls *GeomSize) FitSizeMax(to *math32.Vector2, fm math32.Vector2)

FitSizeMax increases given size to fit given fm value, subject to Max constraints

func (*GeomSize) SetContentFromTotal

func (ls *GeomSize) SetContentFromTotal(ct *GeomCT)

SetContentFromTotal sets the Content from Total size, subtracting Space

func (*GeomSize) SetInitContentMin

func (ls *GeomSize) SetInitContentMin(styMin math32.Vector2)

SetInitContentMin sets initial Actual.Content size from given Styles.Min, further subject to the current Max constraint.

func (*GeomSize) SetTotalFromContent

func (ls *GeomSize) SetTotalFromContent(ct *GeomCT)

SetTotalFromContent sets the Total size as Content plus Space

func (GeomSize) String

func (ls GeomSize) String() string

type GeomState

type GeomState struct {
	// Size has sizing data for the widget: use Actual for rendering.
	// Alloc shows the potentially larger space top-down allocated.
	Size GeomSize `display:"add-fields"`

	// Pos is position within the overall Scene that we render into,
	// including effects of scroll offset, for both Total outer dimension
	// and inner Content dimension.
	Pos GeomCT `display:"inline" edit:"-" copier:"-" json:"-" xml:"-" set:"-"`

	// Cell is the logical X, Y index coordinates (col, row) of element
	// within its parent layout
	Cell image.Point

	// RelPos is top, left position relative to parent Content size space
	RelPos math32.Vector2

	// Scroll is additional scrolling offset within our parent layout
	Scroll math32.Vector2

	// 2D bounding box for Actual.Total size occupied within parent Scene
	// that we render onto, starting at Pos.Total and ending at Pos.Total + Size.Total.
	// These are the pixels we can draw into, intersected with parent bounding boxes
	// (empty for invisible). Used for render Bounds clipping.
	// This includes all space (margin, padding etc).
	TotalBBox image.Rectangle `edit:"-" copier:"-" json:"-" xml:"-" set:"-"`

	// 2D bounding box for our Content, which excludes our padding, margin, etc.
	// starting at Pos.Content and ending at Pos.Content + Size.Content.
	// It is intersected with parent bounding boxes.
	ContentBBox image.Rectangle `edit:"-" copier:"-" json:"-" xml:"-" set:"-"`
}

GeomState contains the the layout geometry state for each widget. Set by the parent Layout during the Layout process.

func (*GeomState) ContentRangeDim

func (ls *GeomState) ContentRangeDim(d math32.Dims) (cmin, cmax float32)

ContentRangeDim returns the Content bounding box min, max along given dimension

func (*GeomState) ContentRect

func (ls *GeomState) ContentRect() image.Rectangle

ContentRect returns Pos.Content, Size.Actual.Content as an image.Rectangle, e.g., for bounding box.

func (*GeomState) ScrollOffset

func (ls *GeomState) ScrollOffset() image.Point

ScrollOffset computes the net scrolling offset as a function of the difference between the allocated position and the actual content position according to the clipped bounding box.

func (*GeomState) String

func (ls *GeomState) String() string

func (*GeomState) TotalRect

func (ls *GeomState) TotalRect() image.Rectangle

TotalRect returns Pos.Total -- Size.Actual.Total as an image.Rectangle, e.g., for bounding box

type Handle

type Handle struct {
	WidgetBase

	// Min is the minimum value that the handle can go to
	// (typically the lower bound of the dialog/splits)
	Min float32
	// Max is the maximum value that the handle can go to
	// (typically the upper bound of the dialog/splits)
	Max float32
	// Pos is the current position of the handle on the
	// scale of [Handle.Min] to [Handle.Max]
	Pos float32
}

Handle represents a draggable handle that can be used to control the size of an element. The [Handle.Styles.Direction] controls the direction in which the handle moves.

func NewHandle

func NewHandle(parent ...tree.Node) *Handle

NewHandle returns a new Handle with the given optional parent: Handle represents a draggable handle that can be used to control the size of an element. The [Handle.Styles.Direction] controls the direction in which the handle moves.

func (*Handle) Init added in v0.2.0

func (hl *Handle) Init()

func (*Handle) New

func (t *Handle) New() tree.Node

New returns a new *Handle value

func (*Handle) NodeType

func (t *Handle) NodeType() *types.Type

NodeType returns the *types.Type of Handle

func (*Handle) SetMax

func (t *Handle) SetMax(v float32) *Handle

SetMax sets the [Handle.Max]: Max is the maximum value that the handle can go to (typically the upper bound of the dialog/splits)

func (*Handle) SetMin

func (t *Handle) SetMin(v float32) *Handle

SetMin sets the [Handle.Min]: Min is the minimum value that the handle can go to (typically the lower bound of the dialog/splits)

func (*Handle) SetPos

func (t *Handle) SetPos(v float32) *Handle

SetPos sets the [Handle.Pos]: Pos is the current position of the handle on the scale of [Handle.Min] to [Handle.Max]

func (*Handle) Value

func (hl *Handle) Value() float32

Value returns the value on a normalized scale of 0-1, based on [Handle.Pos], [Handle.Min], and [Handle.Max].

type HiStyleName

type HiStyleName string

HiStyleName is a highlighting style name. TODO(config): figure out a better location for this.

type Icon

type Icon struct {
	WidgetBase

	// icon name that has been set.
	Icon icons.Icon `set:"-"`

	// file name for the loaded icon, if loaded
	Filename string `set:"-"`

	// SVG drawing of the icon
	SVG svg.SVG `set:"-" copier:"-"`
}

Icon renders an svg.SVG icon. The rendered version is cached for a given size. Icons do not render a background or border independent of their SVG object. The size of on Icon is determined by the styles.Font.Size property.

func NewIcon

func NewIcon(parent ...tree.Node) *Icon

NewIcon returns a new Icon with the given optional parent: Icon renders an svg.SVG icon. The rendered version is cached for a given size. Icons do not render a background or border independent of their SVG object. The size of on Icon is determined by the styles.Font.Size property.

func (*Icon) Init added in v0.2.0

func (ic *Icon) Init()

func (*Icon) New

func (t *Icon) New() tree.Node

New returns a new *Icon value

func (*Icon) NodeType

func (t *Icon) NodeType() *types.Type

NodeType returns the *types.Type of Icon

func (*Icon) Render

func (ic *Icon) Render()

func (*Icon) RenderSVG

func (ic *Icon) RenderSVG()

RenderSVG renders the [Icon.SVG] to the [Icon.Pixels] if they need to be updated.

func (*Icon) SetIcon

func (ic *Icon) SetIcon(icon icons.Icon) *Icon

SetIcon sets the icon, logging error if not found. Does nothing if Icon is already equal to the given icon.

func (*Icon) SetIconTry

func (ic *Icon) SetIconTry(icon icons.Icon) (bool, error)

SetIconTry sets the icon, returning error message if not found etc, and returning true if a new icon was actually set. Does nothing and returns false if Icon is already equal to the given icon.

func (*Icon) WidgetValue added in v0.2.0

func (ic *Icon) WidgetValue() any

type IconButton added in v0.2.0

type IconButton struct {
	Button
}

IconButton represents an icons.Icon with a Button that opens a dialog for selecting the icon.

func NewIconButton added in v0.2.0

func NewIconButton(parent ...tree.Node) *IconButton

NewIconButton returns a new IconButton with the given optional parent: IconButton represents an icons.Icon with a Button that opens a dialog for selecting the icon.

func (*IconButton) Init added in v0.2.0

func (ib *IconButton) Init()

func (*IconButton) New added in v0.2.0

func (t *IconButton) New() tree.Node

New returns a new *IconButton value

func (*IconButton) NodeType added in v0.2.0

func (t *IconButton) NodeType() *types.Type

NodeType returns the *types.Type of IconButton

func (*IconButton) WidgetValue added in v0.2.0

func (ib *IconButton) WidgetValue() any

type Image

type Image struct {
	WidgetBase

	// Image is the bitmap image.
	Image *image.RGBA `xml:"-" json:"-" set:"-"`
	// contains filtered or unexported fields
}

Image is a widget that renders a static bitmap image. See styles.ObjectFits for how to control the image rendering within the allocated size. The default minimum requested size is the pixel size in units.Dp units (1/160th of an inch).

func NewImage

func NewImage(parent ...tree.Node) *Image

NewImage returns a new Image with the given optional parent: Image is a widget that renders a static bitmap image. See styles.ObjectFits for how to control the image rendering within the allocated size. The default minimum requested size is the pixel size in units.Dp units (1/160th of an inch).

func (*Image) Init added in v0.2.0

func (im *Image) Init()

func (*Image) MakeToolbar added in v0.2.0

func (im *Image) MakeToolbar(p *tree.Plan)

func (*Image) New

func (t *Image) New() tree.Node

New returns a new *Image value

func (*Image) NodeType

func (t *Image) NodeType() *types.Type

NodeType returns the *types.Type of Image

func (*Image) Open

func (im *Image) Open(filename Filename) error

Open sets the image to the image located at the given filename.

func (*Image) OpenFS

func (im *Image) OpenFS(fsys fs.FS, filename string) error

OpenFS sets the image to the image located at the given filename in the given fs.

func (*Image) Render

func (im *Image) Render()

func (*Image) SetImage

func (im *Image) SetImage(img image.Image) *Image

SetImage sets the image to the given image. It copies from the given image into an internal image.

type InlineList added in v0.2.0

type InlineList struct {
	Frame

	// Slice is the slice that we are viewing.
	Slice any `set:"-"`
	// contains filtered or unexported fields
}

InlineList represents a slice within a single line of value widgets. This is typically used for smaller slices.

func NewInlineList added in v0.2.0

func NewInlineList(parent ...tree.Node) *InlineList

NewInlineList returns a new InlineList with the given optional parent: InlineList represents a slice within a single line of value widgets. This is typically used for smaller slices.

func (*InlineList) ContextMenu added in v0.2.0

func (il *InlineList) ContextMenu(m *Scene, idx int)

func (*InlineList) Init added in v0.2.0

func (il *InlineList) Init()

func (*InlineList) New added in v0.2.0

func (t *InlineList) New() tree.Node

New returns a new *InlineList value

func (*InlineList) NodeType added in v0.2.0

func (t *InlineList) NodeType() *types.Type

NodeType returns the *types.Type of InlineList

func (*InlineList) SetSlice added in v0.2.0

func (il *InlineList) SetSlice(sl any) *InlineList

SetSlice sets the source slice that we are viewing -- rebuilds the children to represent this slice

func (*InlineList) SliceDeleteAt added in v0.2.0

func (il *InlineList) SliceDeleteAt(idx int)

SliceDeleteAt deletes element at given index from slice

func (*InlineList) SliceNewAt added in v0.2.0

func (il *InlineList) SliceNewAt(idx int)

SliceNewAt inserts a new blank element at given index in the slice -- -1 means the end

func (*InlineList) WidgetValue added in v0.2.0

func (il *InlineList) WidgetValue() any

type Inspector added in v0.2.0

type Inspector struct {
	Frame

	// Root is the root of the tree being edited.
	Root tree.Node

	// CurrentNode is the currently selected node in the tree.
	CurrentNode tree.Node `set:"-"`

	// Filename is the current filename for saving / loading
	Filename Filename `set:"-"`
}

Inspector represents a struct, creating a property editor of the fields -- constructs Children widgets to show the field names and editor fields for each field, within an overall frame with an optional title, and a button box at the bottom where methods can be invoked

func NewInspector added in v0.2.0

func NewInspector(parent ...tree.Node) *Inspector

NewInspector returns a new Inspector with the given optional parent: Inspector represents a struct, creating a property editor of the fields -- constructs Children widgets to show the field names and editor fields for each field, within an overall frame with an optional title, and a button box at the bottom where methods can be invoked

func (*Inspector) Init added in v0.2.0

func (is *Inspector) Init()

func (*Inspector) InspectApp added in v0.2.0

func (is *Inspector) InspectApp()

InspectApp displays the underlying operating system app

func (*Inspector) MakeToolbar added in v0.2.0

func (is *Inspector) MakeToolbar(p *tree.Plan)

func (*Inspector) New added in v0.2.0

func (t *Inspector) New() tree.Node

New returns a new *Inspector value

func (*Inspector) NodeType added in v0.2.0

func (t *Inspector) NodeType() *types.Type

NodeType returns the *types.Type of Inspector

func (*Inspector) Open added in v0.2.0

func (is *Inspector) Open(filename Filename) error

Open opens tree from given filename, in a standard JSON-formatted file

func (*Inspector) Save added in v0.2.0

func (is *Inspector) Save() error

Save saves tree to current filename, in a standard JSON-formatted file

func (*Inspector) SaveAs added in v0.2.0

func (is *Inspector) SaveAs(filename Filename) error

SaveAs saves tree to given filename, in a standard JSON-formatted file

func (*Inspector) SelectionMonitor added in v0.2.0

func (is *Inspector) SelectionMonitor()

SelectionMonitor monitors for the selected widget

func (*Inspector) SetRoot added in v0.2.0

func (t *Inspector) SetRoot(v tree.Node) *Inspector

SetRoot sets the [Inspector.Root]: Root is the root of the tree being edited.

func (*Inspector) ToggleSelectionMode added in v0.2.0

func (is *Inspector) ToggleSelectionMode()

ToggleSelectionMode toggles the editor between selection mode or not. In selection mode, bounding boxes are rendered around each Widget, and clicking on a Widget pulls it up in the inspector.

func (*Inspector) Tree added in v0.2.0

func (is *Inspector) Tree() *Tree

Tree returns the tree widget.

type KeyChordButton added in v0.2.0

type KeyChordButton struct {
	Button
	Chord key.Chord
}

KeyChordButton represents a key.Chord value with a button.

func NewKeyChordButton added in v0.2.0

func NewKeyChordButton(parent ...tree.Node) *KeyChordButton

NewKeyChordButton returns a new KeyChordButton with the given optional parent: KeyChordButton represents a key.Chord value with a button.

func (*KeyChordButton) Init added in v0.2.0

func (kc *KeyChordButton) Init()

func (*KeyChordButton) New added in v0.2.0

func (t *KeyChordButton) New() tree.Node

New returns a new *KeyChordButton value

func (*KeyChordButton) NodeType added in v0.2.0

func (t *KeyChordButton) NodeType() *types.Type

NodeType returns the *types.Type of KeyChordButton

func (*KeyChordButton) SetChord added in v0.2.0

func (t *KeyChordButton) SetChord(v key.Chord) *KeyChordButton

SetChord sets the [KeyChordButton.Chord]

func (*KeyChordButton) WidgetValue added in v0.2.0

func (kc *KeyChordButton) WidgetValue() any

type KeyMapButton added in v0.2.0

type KeyMapButton struct {
	Button
	MapName keymap.MapName
}

KeyMapButton represents a keymap.MapName value with a button.

func NewKeyMapButton added in v0.2.0

func NewKeyMapButton(parent ...tree.Node) *KeyMapButton

NewKeyMapButton returns a new KeyMapButton with the given optional parent: KeyMapButton represents a keymap.MapName value with a button.

func (*KeyMapButton) Init added in v0.2.0

func (km *KeyMapButton) Init()

func (*KeyMapButton) New added in v0.2.0

func (t *KeyMapButton) New() tree.Node

New returns a new *KeyMapButton value

func (*KeyMapButton) NodeType added in v0.2.0

func (t *KeyMapButton) NodeType() *types.Type

NodeType returns the *types.Type of KeyMapButton

func (*KeyMapButton) SetMapName added in v0.2.0

func (t *KeyMapButton) SetMapName(v keymap.MapName) *KeyMapButton

SetMapName sets the [KeyMapButton.MapName]

func (*KeyMapButton) WidgetValue added in v0.2.0

func (km *KeyMapButton) WidgetValue() any

type KeyedList added in v0.2.0

type KeyedList struct {
	Frame

	// Map is the pointer to the map that we are viewing.
	Map any

	// Inline is whether to display the map in one line.
	Inline bool

	// SortValue is whether to sort by values instead of keys.
	SortValues bool
	// contains filtered or unexported fields
}

KeyedList represents a map value using two columns of editable key and value widgets.

func NewKeyedList added in v0.2.0

func NewKeyedList(parent ...tree.Node) *KeyedList

NewKeyedList returns a new KeyedList with the given optional parent: KeyedList represents a map value using two columns of editable key and value widgets.

func (*KeyedList) ContextMenu added in v0.2.0

func (kl *KeyedList) ContextMenu(m *Scene, keyv reflect.Value)

func (*KeyedList) Init added in v0.2.0

func (kl *KeyedList) Init()

func (*KeyedList) MakeToolbar added in v0.2.0

func (kl *KeyedList) MakeToolbar(p *tree.Plan)

MakeToolbar configures a Toolbar for this view

func (*KeyedList) MapAdd added in v0.2.0

func (kl *KeyedList) MapAdd()

MapAdd adds a new entry to the map

func (*KeyedList) MapDelete added in v0.2.0

func (kl *KeyedList) MapDelete(key reflect.Value)

MapDelete deletes a key-value from the map

func (*KeyedList) New added in v0.2.0

func (t *KeyedList) New() tree.Node

New returns a new *KeyedList value

func (*KeyedList) NodeType added in v0.2.0

func (t *KeyedList) NodeType() *types.Type

NodeType returns the *types.Type of KeyedList

func (*KeyedList) SetInline added in v0.2.0

func (t *KeyedList) SetInline(v bool) *KeyedList

SetInline sets the [KeyedList.Inline]: Inline is whether to display the map in one line.

func (*KeyedList) SetMap added in v0.2.0

func (t *KeyedList) SetMap(v any) *KeyedList

SetMap sets the [KeyedList.Map]: Map is the pointer to the map that we are viewing.

func (*KeyedList) SetSortValues added in v0.2.0

func (t *KeyedList) SetSortValues(v bool) *KeyedList

SetSortValues sets the [KeyedList.SortValues]: SortValue is whether to sort by values instead of keys.

func (*KeyedList) ToggleSort added in v0.2.0

func (kl *KeyedList) ToggleSort()

ToggleSort toggles sorting by values vs. keys

func (*KeyedList) WidgetValue added in v0.2.0

func (kl *KeyedList) WidgetValue() any

type KeyedListButton added in v0.2.0

type KeyedListButton struct {
	Button
	Map any
}

KeyedListButton represents a map value with a button that opens a KeyedList.

func NewKeyedListButton added in v0.2.0

func NewKeyedListButton(parent ...tree.Node) *KeyedListButton

NewKeyedListButton returns a new KeyedListButton with the given optional parent: KeyedListButton represents a map value with a button that opens a KeyedList.

func (*KeyedListButton) Init added in v0.2.0

func (kb *KeyedListButton) Init()

func (*KeyedListButton) New added in v0.2.0

func (t *KeyedListButton) New() tree.Node

New returns a new *KeyedListButton value

func (*KeyedListButton) NodeType added in v0.2.0

func (t *KeyedListButton) NodeType() *types.Type

NodeType returns the *types.Type of KeyedListButton

func (*KeyedListButton) SetMap added in v0.2.0

func (t *KeyedListButton) SetMap(v any) *KeyedListButton

SetMap sets the [KeyedListButton.Map]

func (*KeyedListButton) WidgetValue added in v0.2.0

func (kb *KeyedListButton) WidgetValue() any

type LayoutCell added in v0.2.0

type LayoutCell struct {
	// Size has the Actual size of elements (not Alloc)
	Size math32.Vector2

	// Grow has the Grow factors
	Grow math32.Vector2
}

LayoutCell holds the layout implementation data for col, row Cells

func (*LayoutCell) Reset added in v0.2.0

func (ls *LayoutCell) Reset()

func (*LayoutCell) String added in v0.2.0

func (ls *LayoutCell) String() string

type LayoutCells added in v0.2.0

type LayoutCells struct {
	// Shape is number of cells along each dimension for our ColRow cells,
	Shape image.Point `edit:"-"`

	// ColRow has the data for the columns in [0] and rows in [1]:
	// col Size.X = max(X over rows) (cross axis), .Y = sum(Y over rows) (main axis for col)
	// row Size.X = sum(X over cols) (main axis for row), .Y = max(Y over cols) (cross axis)
	// see: https://docs.google.com/spreadsheets/d/1eimUOIJLyj60so94qUr4Buzruj2ulpG5o6QwG2nyxRw/edit?usp=sharing
	ColRow [2][]LayoutCell `edit:"-"`
}

LayoutCells holds one set of LayoutCell cell elements for rows, cols. There can be multiple of these for Wrap case.

func (*LayoutCells) Cell added in v0.2.0

func (lc *LayoutCells) Cell(d math32.Dims, idx int) *LayoutCell

Cell returns the cell for given dimension and index along that dimension (X = Cols, idx = col, Y = Rows, idx = row)

func (*LayoutCells) CellsSize added in v0.2.0

func (lc *LayoutCells) CellsSize() math32.Vector2

CellsSize returns the total Size represented by the current Cells, which is the Sum of the Max values along each dimension.

func (*LayoutCells) GapSizeDim added in v0.2.0

func (lc *LayoutCells) GapSizeDim(d math32.Dims, gap float32) float32

GapSizeDim returns the gap size for given dimension, based on Shape and given gap size

func (*LayoutCells) Init added in v0.2.0

func (lc *LayoutCells) Init(shape image.Point)

Init initializes Cells for given shape

func (*LayoutCells) String added in v0.2.0

func (lc *LayoutCells) String() string

type LayoutPasses

type LayoutPasses int32 //enums:enum

LayoutPasses is used for the SizeFromChildren method, which can potentially compute different sizes for different passes.

const (
	SizeUpPass LayoutPasses = iota
	SizeDownPass
	SizeFinalPass
)
const LayoutPassesN LayoutPasses = 3

LayoutPassesN is the highest valid value for type LayoutPasses, plus one.

func LayoutPassesValues

func LayoutPassesValues() []LayoutPasses

LayoutPassesValues returns all possible values for the type LayoutPasses.

func (LayoutPasses) Desc

func (i LayoutPasses) Desc() string

Desc returns the description of the LayoutPasses value.

func (LayoutPasses) Int64

func (i LayoutPasses) Int64() int64

Int64 returns the LayoutPasses value as an int64.

func (LayoutPasses) MarshalText

func (i LayoutPasses) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*LayoutPasses) SetInt64

func (i *LayoutPasses) SetInt64(in int64)

SetInt64 sets the LayoutPasses value from an int64.

func (*LayoutPasses) SetString

func (i *LayoutPasses) SetString(s string) error

SetString sets the LayoutPasses value from its string representation, and returns an error if the string is invalid.

func (LayoutPasses) String

func (i LayoutPasses) String() string

String returns the string representation of this LayoutPasses value.

func (*LayoutPasses) UnmarshalText

func (i *LayoutPasses) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (LayoutPasses) Values

func (i LayoutPasses) Values() []enums.Enum

Values returns all possible values for the type LayoutPasses.

type LayoutState added in v0.2.0

type LayoutState struct {
	// Shape is number of cells along each dimension,
	// computed for each layout type:
	// For Grid: Max Col, Row.
	// For Flex no Wrap: Cols,1 (X) or 1,Rows (Y).
	// For Flex Wrap: Cols,Max(Rows) or Max(Cols),Rows
	// For Stacked: 1,1
	Shape image.Point `edit:"-"`

	// MainAxis cached here from Styles, to enable Wrap-based access.
	MainAxis math32.Dims

	// Wraps is the number of actual items in each Wrap for Wrap case:
	// MainAxis X: Len = Rows, Val = Cols; MainAxis Y: Len = Cols, Val = Rows.
	// This should be nil for non-Wrap case.
	Wraps []int

	// Cells has the Actual size and Grow factor data for each of the child elements,
	// organized according to the Shape and Display type.
	// For non-Wrap, has one element in slice, with cells based on Shape.
	// For Wrap, slice is number of CrossAxis wraps allocated:
	// MainAxis X = Rows; MainAxis Y = Cols, and Cells are MainAxis layout x 1 CrossAxis.
	Cells []LayoutCells `edit:"-"`

	// ScrollSize has the scrollbar sizes (widths) for each dim, which adds to Space.
	// If there is a vertical scrollbar, X has width; if horizontal, Y has "width" = height
	ScrollSize math32.Vector2

	// Gap is the Styles.Gap size
	Gap math32.Vector2

	// GapSize has the total extra gap sizing between elements, which adds to Space.
	// This depends on cell layout so it can vary for Wrap case.
	// For SizeUp / Down Gap contributes to Space like other cases,
	// but for BoundingBox rendering and Alignment, it does NOT, and must be
	// subtracted.  This happens in the Position phase.
	GapSize math32.Vector2
}

LayoutState has internal state for implementing layout

func (*LayoutState) Cell added in v0.2.0

func (ls *LayoutState) Cell(d math32.Dims, dIndex, odIndex int) *LayoutCell

Cell returns the cell for given dimension and index along that dimension, and given other-dimension axis which is ignored for non-Wrap cases. Does no range checking and will crash if out of bounds.

func (*LayoutState) CellsSize added in v0.2.0

func (ls *LayoutState) CellsSize() math32.Vector2

CellsSize returns the total Size represented by the current Cells, which is the Sum of the Max values along each dimension within each Cell, Maxed over cross-axis dimension for Wrap case, plus GapSize.

func (*LayoutState) ColWidth added in v0.2.0

func (ls *LayoutState) ColWidth(row, col int) (float32, error)

ColWidth returns the width of given column for given row index (ignored for non-Wrap), with full bounds checking. Returns error if out of range.

func (*LayoutState) InitCells added in v0.2.0

func (ls *LayoutState) InitCells()

InitCells initializes the Cells based on Shape, MainAxis, and Wraps which must be set before calling.

func (*LayoutState) RowHeight added in v0.2.0

func (ls *LayoutState) RowHeight(row, col int) (float32, error)

RowHeight returns the height of given row for given column (ignored for non-Wrap), with full bounds checking. Returns error if out of range.

func (*LayoutState) ShapeCheck added in v0.2.0

func (ls *LayoutState) ShapeCheck(w Widget, phase string) bool

func (*LayoutState) String added in v0.2.0

func (ls *LayoutState) String() string

func (*LayoutState) WrapIndexToCoord added in v0.2.0

func (ls *LayoutState) WrapIndexToCoord(idx int) image.Point

WrapIndexToCoord returns the X,Y coordinates in Wrap case for given sequential idx

type Layouter

type Layouter interface {
	Widget

	// AsFrame returns the Layouter as a [Frame].
	AsFrame() *Frame

	// LayoutSpace sets our Space based on Styles, Scroll, and Gap Spacing.
	// Other layout types can change this if they want to.
	LayoutSpace()

	// SizeFromChildren gathers Actual size from kids into our Actual.Content size.
	// Different Layout types can alter this to present different Content
	// sizes for the layout process, e.g., if Content is sized to fit allocation,
	// as in the TopAppBar and List types.
	SizeFromChildren(iter int, pass LayoutPasses) math32.Vector2

	// SizeDownSetAllocs is the key SizeDown step that sets the allocations
	// in the children, based on our allocation.  In the default implementation
	// this calls SizeDownGrow if there is extra space to grow, or
	// SizeDownAllocActual to set the allocations as they currently are.
	SizeDownSetAllocs(iter int)

	// ManageOverflow uses overflow settings to determine if scrollbars
	// are needed, based on difference between ActualOverflow (full actual size)
	// and Alloc allocation.  Returns true if size changes as a result.
	// If updateSize is false, then the Actual and Alloc sizes are NOT
	// updated as a result of change from adding scrollbars
	// (generally should be true, but some cases not)
	ManageOverflow(iter int, updateSize bool) bool

	// ScrollChanged is called in the OnInput event handler for updating
	// when the scrollbar value has changed, for given dimension
	ScrollChanged(d math32.Dims, sb *Slider)

	// ScrollValues returns the maximum size that could be scrolled,
	// the visible size (which could be less than the max size, in which
	// case no scrollbar is needed), and visSize / maxSize as the VisiblePct.
	// This is used in updating the scrollbar and determining whether one is
	// needed in the first place
	ScrollValues(d math32.Dims) (maxSize, visSize, visPct float32)

	// ScrollGeom returns the target position and size for scrollbars
	ScrollGeom(d math32.Dims) (pos, sz math32.Vector2)

	// SetScrollParams sets scrollbar parameters.  Must set Step and PageStep,
	// but can also set others as needed.
	// Max and VisiblePct are automatically set based on ScrollValues maxSize, visPct.
	SetScrollParams(d math32.Dims, sb *Slider)
}

Layouter is the interface for layout functions, called by Frame during the various layout passes.

type List added in v0.2.0

type List struct {
	ListBase

	// StyleFunc is an optional styling function.
	StyleFunc ListStyleFunc `copier:"-" display:"-" json:"-" xml:"-"`
}

List represents a slice value with a list of value widgets and optional index widgets. Use ListBase.BindSelect to make the list designed for item selection.

func NewList added in v0.2.0

func NewList(parent ...tree.Node) *List

NewList returns a new List with the given optional parent: List represents a slice value with a list of value widgets and optional index widgets. Use ListBase.BindSelect to make the list designed for item selection.

func (*List) HasStyleFunc added in v0.2.0

func (ls *List) HasStyleFunc() bool

func (*List) New added in v0.2.0

func (t *List) New() tree.Node

New returns a new *List value

func (*List) NodeType added in v0.2.0

func (t *List) NodeType() *types.Type

NodeType returns the *types.Type of List

func (*List) SetStyleFunc added in v0.2.0

func (t *List) SetStyleFunc(v ListStyleFunc) *List

SetStyleFunc sets the [List.StyleFunc]: StyleFunc is an optional styling function.

func (*List) StyleRow added in v0.2.0

func (ls *List) StyleRow(w Widget, idx, fidx int)

type ListBase added in v0.2.0

type ListBase struct {
	Frame

	// Slice is the pointer to the slice that we are viewing.
	Slice any `set:"-"`

	// ShowIndexes is whether to show the indexes of rows or not (default false).
	ShowIndexes bool

	// MinRows specifies the minimum number of rows to display, to ensure
	// at least this amount is displayed.
	MinRows int `default:"4"`

	// SelectedValue is the current selection value; initially select this value if set.
	SelectedValue any `copier:"-" display:"-" json:"-" xml:"-"`

	// index of currently selected item
	SelectedIndex int `copier:"-" json:"-" xml:"-"`

	// index of row to select at start
	InitSelectedIndex int `copier:"-" json:"-" xml:"-"`

	// list of currently selected slice indexes
	SelectedIndexes map[int]struct{} `set:"-" copier:"-"`

	// NormalCursor is the cached cursor to display when there
	// is no row being hovered.
	NormalCursor cursors.Cursor `copier:"-" xml:"-" json:"-" set:"-"`

	// CurrentCursor is the cached cursor that should currently be
	// displayed.
	CurrentCursor cursors.Cursor `copier:"-" xml:"-" json:"-" set:"-"`

	// SliceUnderlying is the underlying slice value.
	SliceUnderlying reflect.Value `set:"-" copier:"-" display:"-" json:"-" xml:"-"`

	// list of currently dragged indexes
	DraggedIndexes []int `set:"-" display:"-" copier:"-" json:"-" xml:"-"`

	// total number of rows visible in allocated display size
	VisRows int `set:"-" edit:"-" copier:"-" json:"-" xml:"-"`

	// starting slice index of visible rows
	StartIndex int `set:"-" edit:"-" copier:"-" json:"-" xml:"-"`

	// size of slice
	SliceSize int `set:"-" edit:"-" copier:"-" json:"-" xml:"-"`

	// iteration through the configuration process, reset when a new slice type is set
	MakeIter int `set:"-" edit:"-" copier:"-" json:"-" xml:"-"`

	// ElementValue is a [reflect.Value] representation of the underlying element type
	// which is used whenever there are no slice elements available
	ElementValue reflect.Value `set:"-" copier:"-" display:"-" json:"-" xml:"-"`

	// ReadOnlyKeyNav is whether support key navigation when ReadOnly (default true).
	// It uses a capture of up / down events to manipulate selection, not focus.
	ReadOnlyKeyNav bool

	// SelectMode is whether to be in select rows mode or editing mode.
	SelectMode bool `set:"-" copier:"-" json:"-" xml:"-"`

	// ReadOnlyMultiSelect: if view is ReadOnly, default selection mode is to choose one row only.
	// If this is true, standard multiple selection logic with modifier keys is instead supported.
	ReadOnlyMultiSelect bool

	// InFocusGrab is a guard for recursive focus grabbing.
	InFocusGrab bool `set:"-" edit:"-" copier:"-" json:"-" xml:"-"`
	// contains filtered or unexported fields
}

ListBase is the base for List and Table and any other displays of array-like data. It automatically computes the number of rows that fit within its allocated space, and manages the offset view window into the full list of items, and supports row selection, copy / paste, Drag-n-Drop, etc. Use ListBase.BindSelect to make the list designed for item selection.

func NewListBase added in v0.2.0

func NewListBase(parent ...tree.Node) *ListBase

NewListBase returns a new ListBase with the given optional parent: ListBase is the base for List and Table and any other displays of array-like data. It automatically computes the number of rows that fit within its allocated space, and manages the offset view window into the full list of items, and supports row selection, copy / paste, Drag-n-Drop, etc. Use ListBase.BindSelect to make the list designed for item selection.

func (*ListBase) AsListBase added in v0.2.0

func (lb *ListBase) AsListBase() *ListBase

func (*ListBase) BindSelect added in v0.2.0

func (lb *ListBase) BindSelect(val *int) *ListBase

BindSelect makes the list a read-only selection list and then binds its events to its scene and its current selection index to the given value. It will send an events.Change event when the user changes the selection row.

func (*ListBase) ClickSelectEvent added in v0.2.0

func (lb *ListBase) ClickSelectEvent(e events.Event) bool

ClickSelectEvent is a helper for processing selection events based on a mouse click, which could be a double or triple in addition to a regular click. Returns false if no further processing should occur, because the user clicked outside the range of active rows.

func (*ListBase) ContextMenu added in v0.2.0

func (lb *ListBase) ContextMenu(m *Scene)

func (*ListBase) CopyIndexes added in v0.2.0

func (lb *ListBase) CopyIndexes(reset bool)

CopyIndexes copies selected idxs to system.Clipboard, optionally resetting the selection

func (*ListBase) CopySelectToMime added in v0.2.0

func (lb *ListBase) CopySelectToMime() mimedata.Mimes

CopySelectToMime copies selected rows to mime data

func (*ListBase) CutIndexes added in v0.2.0

func (lb *ListBase) CutIndexes()

CutIndexes copies selected indexes to system.Clipboard and deletes selected indexes

func (*ListBase) DeleteIndexes added in v0.2.0

func (lb *ListBase) DeleteIndexes()

DeleteIndexes deletes all selected indexes

func (*ListBase) DragDrop added in v0.2.0

func (lb *ListBase) DragDrop(e events.Event)

func (*ListBase) DragStart added in v0.2.0

func (lb *ListBase) DragStart(e events.Event)

func (*ListBase) DropDeleteSource added in v0.2.0

func (lb *ListBase) DropDeleteSource(e events.Event)

DropDeleteSource handles delete source event for DropMove case

func (*ListBase) DropFinalize added in v0.2.0

func (lb *ListBase) DropFinalize(de *events.DragDrop)

DropFinalize is called to finalize Drop actions on the Source node. Only relevant for DropMod == DropMove.

func (*ListBase) Duplicate added in v0.2.0

func (lb *ListBase) Duplicate() int

Duplicate copies selected items and inserts them after current selection -- return idx of start of duplicates if successful, else -1

func (*ListBase) FromMimeData added in v0.2.0

func (lb *ListBase) FromMimeData(md mimedata.Mimes) []any

FromMimeData creates a slice of structs from mime data

func (*ListBase) IndexFromPos added in v0.2.0

func (lb *ListBase) IndexFromPos(posY int) (int, bool)

IndexFromPos returns the idx that contains given vertical position, false if not found

func (*ListBase) IndexGrabFocus added in v0.2.0

func (lb *ListBase) IndexGrabFocus(idx int) *WidgetBase

IndexGrabFocus grabs the focus for the first focusable widget in given idx. returns that element or nil if not successful.

func (*ListBase) IndexIsSelected added in v0.2.0

func (lb *ListBase) IndexIsSelected(idx int) bool

IndexIsSelected returns the selected status of given slice index

func (*ListBase) IndexPos added in v0.2.0

func (lb *ListBase) IndexPos(idx int) image.Point

IndexPos returns center of window position of index label for idx (ContextMenuPos)

func (*ListBase) Init added in v0.2.0

func (lb *ListBase) Init()

func (*ListBase) IsIndexVisible added in v0.2.0

func (lb *ListBase) IsIndexVisible(idx int) bool

IsIndexVisible returns true if slice index is currently visible

func (*ListBase) IsNil added in v0.2.0

func (lb *ListBase) IsNil() bool

IsNil returns true if the Slice is nil

func (*ListBase) IsRowInBounds added in v0.2.0

func (lb *ListBase) IsRowInBounds(row int) bool

IsRowInBounds returns true if disp row is in bounds

func (*ListBase) KeyInputEditable added in v0.2.0

func (lb *ListBase) KeyInputEditable(kt events.Event)

func (*ListBase) KeyInputNav added in v0.2.0

func (lb *ListBase) KeyInputNav(kt events.Event)

KeyInputNav supports multiple selection navigation keys

func (*ListBase) KeyInputReadOnly added in v0.2.0

func (lb *ListBase) KeyInputReadOnly(kt events.Event)

func (*ListBase) MakeGrid added in v0.2.0

func (lb *ListBase) MakeGrid(p *tree.Plan, maker func(p *tree.Plan))

func (*ListBase) MakeGridIndex added in v0.2.0

func (lb *ListBase) MakeGridIndex(p *tree.Plan, i, si int, itxt string, invis bool)

func (*ListBase) MakePasteMenu added in v0.2.0

func (lb *ListBase) MakePasteMenu(m *Scene, md mimedata.Mimes, idx int, mod events.DropMods, fun func())

MakePasteMenu makes the menu of options for paste events

func (*ListBase) MakeRow added in v0.2.0

func (lb *ListBase) MakeRow(p *tree.Plan, i int)

func (*ListBase) MakeToolbar added in v0.2.0

func (lb *ListBase) MakeToolbar(p *tree.Plan)

MakeToolbar configures a Toolbar for this view

func (*ListBase) MakeValue added in v0.2.0

func (lb *ListBase) MakeValue(w Value, i int)

func (*ListBase) MimeDataIndex added in v0.2.0

func (lb *ListBase) MimeDataIndex(md *mimedata.Mimes, idx int)

MimeDataIndex adds mimedata for given idx: an application/json of the struct

func (*ListBase) MimeDataType added in v0.2.0

func (lb *ListBase) MimeDataType() string

MimeDataType returns the data type for mime clipboard (copy / paste) data e.g., fileinfo.DataJson

func (*ListBase) MousePosInGrid added in v0.2.0

func (lb *ListBase) MousePosInGrid(e events.Event) bool

MousePosInGrid returns true if the event mouse position is located within the slicegrid.

func (*ListBase) MoveDown added in v0.2.0

func (lb *ListBase) MoveDown(selMode events.SelectModes) int

MoveDown moves the selection down to next row, using given select mode (from keyboard modifiers) -- returns newly selected row or -1 if failed

func (*ListBase) MoveDownAction added in v0.2.0

func (lb *ListBase) MoveDownAction(selMode events.SelectModes) int

MoveDownAction moves the selection down to next row, using given select mode (from keyboard modifiers) -- and emits select event for newly selected row

func (*ListBase) MovePageDown added in v0.2.0

func (lb *ListBase) MovePageDown(selMode events.SelectModes) int

MovePageDown moves the selection down to next page, using given select mode (from keyboard modifiers) -- returns newly selected idx or -1 if failed

func (*ListBase) MovePageDownAction added in v0.2.0

func (lb *ListBase) MovePageDownAction(selMode events.SelectModes) int

MovePageDownAction moves the selection down to next page, using given select mode (from keyboard modifiers) -- and emits select event for newly selected idx

func (*ListBase) MovePageUp added in v0.2.0

func (lb *ListBase) MovePageUp(selMode events.SelectModes) int

MovePageUp moves the selection up to previous page, using given select mode (from keyboard modifiers) -- returns newly selected idx or -1 if failed

func (*ListBase) MovePageUpAction added in v0.2.0

func (lb *ListBase) MovePageUpAction(selMode events.SelectModes) int

MovePageUpAction moves the selection up to previous page, using given select mode (from keyboard modifiers) -- and emits select event for newly selected idx

func (*ListBase) MoveUp added in v0.2.0

func (lb *ListBase) MoveUp(selMode events.SelectModes) int

MoveUp moves the selection up to previous idx, using given select mode (from keyboard modifiers) -- returns newly selected idx or -1 if failed

func (*ListBase) MoveUpAction added in v0.2.0

func (lb *ListBase) MoveUpAction(selMode events.SelectModes) int

MoveUpAction moves the selection up to previous idx, using given select mode (from keyboard modifiers) -- and emits select event for newly selected idx

func (*ListBase) New added in v0.2.0

func (t *ListBase) New() tree.Node

New returns a new *ListBase value

func (*ListBase) NodeType added in v0.2.0

func (t *ListBase) NodeType() *types.Type

NodeType returns the *types.Type of ListBase

func (*ListBase) PasteAssign added in v0.2.0

func (lb *ListBase) PasteAssign(md mimedata.Mimes, idx int)

PasteAssign assigns mime data (only the first one!) to this idx

func (*ListBase) PasteAtIndex added in v0.2.0

func (lb *ListBase) PasteAtIndex(md mimedata.Mimes, idx int)

PasteAtIndex inserts object(s) from mime data at (before) given slice index

func (*ListBase) PasteIndex added in v0.2.0

func (lb *ListBase) PasteIndex(idx int)

PasteIndex pastes clipboard at given idx

func (*ListBase) PasteMenu added in v0.2.0

func (lb *ListBase) PasteMenu(md mimedata.Mimes, idx int)

PasteMenu performs a paste from the clipboard using given data -- pops up a menu to determine what specifically to do

func (*ListBase) ResetSelectedIndexes added in v0.2.0

func (lb *ListBase) ResetSelectedIndexes()

func (*ListBase) RowFirstWidget added in v0.2.0

func (lb *ListBase) RowFirstWidget(row int) (*WidgetBase, bool)

RowFirstWidget returns the first widget for given row (could be index or not) -- false if out of range

func (*ListBase) RowFromEventPos added in v0.2.0

func (lb *ListBase) RowFromEventPos(e events.Event) (row, idx int, isValid bool)

RowFromEventPos returns the widget row, slice index, and whether the index is in slice range, for given event position.

func (*ListBase) RowFromPos added in v0.2.0

func (lb *ListBase) RowFromPos(posY int) (int, bool)

RowFromPos returns the row that contains given vertical position, false if not found

func (*ListBase) RowGrabFocus added in v0.2.0

func (lb *ListBase) RowGrabFocus(row int) *WidgetBase

RowGrabFocus grabs the focus for the first focusable widget in given row. returns that element or nil if not successful note: grid must have already rendered for focus to be grabbed!

func (*ListBase) RowWidgetNs added in v0.2.0

func (lb *ListBase) RowWidgetNs() (nWidgPerRow, idxOff int)

RowWidgetNs returns number of widgets per row and offset for index label

func (*ListBase) SaveDraggedIndexes added in v0.2.0

func (lb *ListBase) SaveDraggedIndexes(idx int)

SaveDraggedIndexes saves selectedindexes into dragged indexes taking into account insertion at idx

func (*ListBase) ScrollToIndex added in v0.2.0

func (lb *ListBase) ScrollToIndex(idx int) bool

ScrollToIndex ensures that given slice idx is visible by scrolling display as needed.

func (*ListBase) ScrollToIndexNoUpdate added in v0.2.0

func (lb *ListBase) ScrollToIndexNoUpdate(idx int) bool

ScrollToIndexNoUpdate ensures that given slice idx is visible by scrolling display as needed. This version does not update the slicegrid. Just computes the StartIndex and updates the scrollbar

func (*ListBase) SelectAllIndexes added in v0.2.0

func (lb *ListBase) SelectAllIndexes()

SelectAllIndexes selects all idxs

func (*ListBase) SelectIndex added in v0.2.0

func (lb *ListBase) SelectIndex(idx int)

SelectIndex selects given idx (if not already selected) -- updates select status of index label

func (*ListBase) SelectIndexAction added in v0.2.0

func (lb *ListBase) SelectIndexAction(idx int, mode events.SelectModes)

SelectIndexAction is called when a select action has been received (e.g., a mouse click) -- translates into selection updates -- gets selection mode from mouse event (ExtendContinuous, ExtendOne)

func (*ListBase) SelectRowIfNone added in v0.2.0

func (lb *ListBase) SelectRowIfNone(e events.Event) bool

SelectRowIfNone selects the row the mouse is on if there are no currently selected items. Returns false if no valid mouse row.

func (*ListBase) SelectValue added in v0.2.0

func (lb *ListBase) SelectValue(val string) bool

SelectValue sets SelVal and attempts to find corresponding row, setting SelectedIndex and selecting row if found -- returns true if found, false otherwise.

func (*ListBase) SelectedIndexesList added in v0.2.0

func (lb *ListBase) SelectedIndexesList(descendingSort bool) []int

SelectedIndexesList returns list of selected indexes, sorted either ascending or descending

func (*ListBase) SetInitSelectedIndex added in v0.2.0

func (t *ListBase) SetInitSelectedIndex(v int) *ListBase

SetInitSelectedIndex sets the [ListBase.InitSelectedIndex]: index of row to select at start

func (*ListBase) SetMinRows added in v0.2.0

func (t *ListBase) SetMinRows(v int) *ListBase

SetMinRows sets the [ListBase.MinRows]: MinRows specifies the minimum number of rows to display, to ensure at least this amount is displayed.

func (*ListBase) SetReadOnlyKeyNav added in v0.2.0

func (t *ListBase) SetReadOnlyKeyNav(v bool) *ListBase

SetReadOnlyKeyNav sets the [ListBase.ReadOnlyKeyNav]: ReadOnlyKeyNav is whether support key navigation when ReadOnly (default true). It uses a capture of up / down events to manipulate selection, not focus.

func (*ListBase) SetReadOnlyMultiSelect added in v0.2.0

func (t *ListBase) SetReadOnlyMultiSelect(v bool) *ListBase

SetReadOnlyMultiSelect sets the [ListBase.ReadOnlyMultiSelect]: ReadOnlyMultiSelect: if view is ReadOnly, default selection mode is to choose one row only. If this is true, standard multiple selection logic with modifier keys is instead supported.

func (*ListBase) SetSelectedIndex added in v0.2.0

func (t *ListBase) SetSelectedIndex(v int) *ListBase

SetSelectedIndex sets the [ListBase.SelectedIndex]: index of currently selected item

func (*ListBase) SetSelectedValue added in v0.2.0

func (t *ListBase) SetSelectedValue(v any) *ListBase

SetSelectedValue sets the [ListBase.SelectedValue]: SelectedValue is the current selection value; initially select this value if set.

func (*ListBase) SetShowIndexes added in v0.2.0

func (t *ListBase) SetShowIndexes(v bool) *ListBase

SetShowIndexes sets the [ListBase.ShowIndexes]: ShowIndexes is whether to show the indexes of rows or not (default false).

func (*ListBase) SetSlice added in v0.2.0

func (lb *ListBase) SetSlice(sl any) *ListBase

SetSlice sets the source slice that we are viewing. This ReMakes the view for this slice if different. Note: it is important to at least set an empty slice of the desired type at the start to enable initial configuration.

func (*ListBase) SetSliceBase added in v0.2.0

func (lb *ListBase) SetSliceBase()

func (*ListBase) SizeFinal added in v0.2.0

func (lb *ListBase) SizeFinal()

func (*ListBase) SliceDeleteAt added in v0.2.0

func (lb *ListBase) SliceDeleteAt(i int)

SliceDeleteAt deletes element at given index from slice

func (*ListBase) SliceDeleteAtRow added in v0.2.0

func (lb *ListBase) SliceDeleteAtRow(row int)

SliceDeleteAtRow deletes element at given display row if update is true, then update the grid after

func (*ListBase) SliceDeleteAtSelect added in v0.2.0

func (lb *ListBase) SliceDeleteAtSelect(i int)

SliceDeleteAtSelect updates selected rows based on deleting element at given index must be called with successful SliceDeleteAt

func (*ListBase) SliceElementValue added in v0.2.0

func (lb *ListBase) SliceElementValue(si int) reflect.Value

SliceElementValue returns an underlying non-pointer reflect.Value of slice element at given index or ElementValue if out of range.

func (*ListBase) SliceGrid added in v0.2.0

func (lb *ListBase) SliceGrid() *ListGrid

SliceGrid returns the SliceGrid grid frame widget, which contains all the fields and values

func (*ListBase) SliceIndex added in v0.2.0

func (lb *ListBase) SliceIndex(i int) (si, vi int, invis bool)

func (*ListBase) SliceNewAt added in v0.2.0

func (lb *ListBase) SliceNewAt(idx int)

SliceNewAt inserts a new blank element at given index in the slice -- -1 means the end

func (*ListBase) SliceNewAtRow added in v0.2.0

func (lb *ListBase) SliceNewAtRow(row int)

SliceNewAtRow inserts a new blank element at given display row

func (*ListBase) SliceNewAtSelect added in v0.2.0

func (lb *ListBase) SliceNewAtSelect(i int)

SliceNewAtSelect updates selected rows based on inserting new element at given index. must be called with successful SliceNewAt

func (*ListBase) SliceValue added in v0.2.0

func (lb *ListBase) SliceValue(idx int) any

SliceValue returns value interface at given slice index.

func (*ListBase) StyleValue added in v0.2.0

func (lb *ListBase) StyleValue(w Widget, s *styles.Style, row, col int)

StyleValue performs additional value widget styling

func (*ListBase) UnselectAllIndexes added in v0.2.0

func (lb *ListBase) UnselectAllIndexes()

UnselectAllIndexes unselects all selected idxs

func (*ListBase) UnselectIndex added in v0.2.0

func (lb *ListBase) UnselectIndex(idx int)

UnselectIndex unselects given idx (if selected)

func (*ListBase) UnselectIndexAction added in v0.2.0

func (lb *ListBase) UnselectIndexAction(idx int)

UnselectIndexAction unselects this idx (if selected) -- and emits a signal

func (*ListBase) UpdateMaxWidths added in v0.2.0

func (lb *ListBase) UpdateMaxWidths()

func (*ListBase) UpdateScroll added in v0.2.0

func (lb *ListBase) UpdateScroll()

UpdateScroll updates the scroll value

func (*ListBase) UpdateSelectIndex added in v0.2.0

func (lb *ListBase) UpdateSelectIndex(idx int, sel bool, selMode events.SelectModes)

UpdateSelectIndex updates the selection for the given index

func (*ListBase) UpdateSelectRow added in v0.2.0

func (lb *ListBase) UpdateSelectRow(row int, selMode events.SelectModes)

UpdateSelectRow updates the selection for the given row

func (*ListBase) UpdateSliceSize added in v0.2.0

func (lb *ListBase) UpdateSliceSize() int

UpdateSliceSize updates and returns the size of the slice and sets SliceSize

func (*ListBase) UpdateStartIndex added in v0.2.0

func (lb *ListBase) UpdateStartIndex()

UpdateStartIndex updates StartIndex to fit current view

func (*ListBase) WidgetIndex added in v0.2.0

func (lb *ListBase) WidgetIndex(w Widget) (row, col int)

WidgetIndex returns the row and column indexes for given widget, from the properties set during construction.

func (*ListBase) WidgetValue added in v0.2.0

func (lb *ListBase) WidgetValue() any

type ListButton added in v0.2.0

type ListButton struct {
	Button
	Slice any
}

ListButton represents a slice or array value with a button that opens a List.

func NewListButton added in v0.2.0

func NewListButton(parent ...tree.Node) *ListButton

NewListButton returns a new ListButton with the given optional parent: ListButton represents a slice or array value with a button that opens a List.

func (*ListButton) Init added in v0.2.0

func (lb *ListButton) Init()

func (*ListButton) New added in v0.2.0

func (t *ListButton) New() tree.Node

New returns a new *ListButton value

func (*ListButton) NodeType added in v0.2.0

func (t *ListButton) NodeType() *types.Type

NodeType returns the *types.Type of ListButton

func (*ListButton) SetSlice added in v0.2.0

func (t *ListButton) SetSlice(v any) *ListButton

SetSlice sets the [ListButton.Slice]

func (*ListButton) WidgetValue added in v0.2.0

func (lb *ListButton) WidgetValue() any

type ListGrid added in v0.2.0

type ListGrid struct {
	Frame

	// MinRows is set from parent SV
	MinRows int `set:"-" edit:"-"`

	// height of a single row, computed during layout
	RowHeight float32 `set:"-" edit:"-" copier:"-" json:"-" xml:"-"`

	// total number of rows visible in allocated display size
	VisRows int `set:"-" edit:"-" copier:"-" json:"-" xml:"-"`

	// Various computed backgrounds
	BgStripe, BgSelect, BgSelectStripe, BgHover, BgHoverStripe, BgHoverSelect, BgHoverSelectStripe image.Image `set:"-" edit:"-" copier:"-" json:"-" xml:"-"`

	// LastBackground is the background for which modified
	// backgrounds were computed -- don't update if same
	LastBackground image.Image
}

ListGrid handles the resizing logic for List, Table.

func NewListGrid added in v0.2.0

func NewListGrid(parent ...tree.Node) *ListGrid

NewListGrid returns a new ListGrid with the given optional parent: ListGrid handles the resizing logic for List, Table.

func (*ListGrid) ChildBackground added in v0.2.0

func (lg *ListGrid) ChildBackground(child Widget) image.Image

func (*ListGrid) IndexFromPixel added in v0.2.0

func (lg *ListGrid) IndexFromPixel(pt image.Point) (row, col int, isValid bool)

IndexFromPixel returns the row, column indexes of given pixel point within grid. Takes a scene-level position.

func (*ListGrid) Init added in v0.2.0

func (lg *ListGrid) Init()

func (*ListGrid) List added in v0.2.0

func (lg *ListGrid) List() (Lister, *ListBase)

func (*ListGrid) MousePosInGrid added in v0.2.0

func (lg *ListGrid) MousePosInGrid(pt image.Point) bool

MousePosInGrid returns true if the event mouse position is located within the slicegrid.

func (*ListGrid) New added in v0.2.0

func (t *ListGrid) New() tree.Node

New returns a new *ListGrid value

func (*ListGrid) NodeType added in v0.2.0

func (t *ListGrid) NodeType() *types.Type

NodeType returns the *types.Type of ListGrid

func (*ListGrid) Render added in v0.2.0

func (lg *ListGrid) Render()

func (*ListGrid) RenderStripes added in v0.2.0

func (lg *ListGrid) RenderStripes()

func (*ListGrid) RowBackground added in v0.2.0

func (lg *ListGrid) RowBackground(sel, stripe, hover bool) image.Image

func (*ListGrid) ScrollChanged added in v0.2.0

func (lg *ListGrid) ScrollChanged(d math32.Dims, sb *Slider)

func (*ListGrid) ScrollValues added in v0.2.0

func (lg *ListGrid) ScrollValues(d math32.Dims) (maxSize, visSize, visPct float32)

func (*ListGrid) SetLastBackground added in v0.2.0

func (t *ListGrid) SetLastBackground(v image.Image) *ListGrid

SetLastBackground sets the [ListGrid.LastBackground]: LastBackground is the background for which modified backgrounds were computed -- don't update if same

func (*ListGrid) SetScrollParams added in v0.2.0

func (lg *ListGrid) SetScrollParams(d math32.Dims, sb *Slider)

func (*ListGrid) SizeFromChildren added in v0.2.0

func (lg *ListGrid) SizeFromChildren(iter int, pass LayoutPasses) math32.Vector2

func (*ListGrid) UpdateBackgrounds added in v0.2.0

func (lg *ListGrid) UpdateBackgrounds()

func (*ListGrid) UpdateScroll added in v0.2.0

func (lg *ListGrid) UpdateScroll(idx int)

type ListStyleFunc added in v0.2.0

type ListStyleFunc func(w Widget, s *styles.Style, row int)

ListStyleFunc is a styling function for custom styling and configuration of elements in the list.

type Lister added in v0.2.0

type Lister interface {
	// AsListBase returns the base for direct access to relevant fields etc
	AsListBase() *ListBase

	// SliceGrid returns the ListGrid grid Layout widget,
	// which contains all the fields and values
	SliceGrid() *ListGrid

	// RowWidgetNs returns number of widgets per row and
	// offset for index label
	RowWidgetNs() (nWidgPerRow, idxOff int)

	// UpdateSliceSize updates the current size of the slice
	// and sets SliceSize if changed.
	UpdateSliceSize() int

	// UpdateMaxWidths updates the maximum widths per column based
	// on estimates from length of strings (for string values)
	UpdateMaxWidths()

	// SliceIndex returns the logical slice index: si = i + StartIndex,
	// the actual value index vi into the slice value (typically = si),
	// which can be different if there is an index indirection as in
	// tensorcore table.IndexView), and a bool that is true if the
	// index is beyond the available data and is thus invisible,
	// given the row index provided.
	SliceIndex(i int) (si, vi int, invis bool)

	// MakeRow adds config for one row at given widget row index.
	// Plan must be the StructGrid Plan.
	MakeRow(p *tree.Plan, i int)

	// StyleValue performs additional value widget styling
	StyleValue(w Widget, s *styles.Style, row, col int)

	// HasStyleFunc returns whether there is a custom style function.
	HasStyleFunc() bool

	// StyleRow calls a custom style function on given row (and field)
	StyleRow(w Widget, idx, fidx int)

	// RowFirstWidget returns the first widget for given row
	// (could be index or not) -- false if out of range
	RowFirstWidget(row int) (*WidgetBase, bool)

	// RowGrabFocus grabs the focus for the first focusable
	// widget in given row.
	// returns that element or nil if not successful
	// note: grid must have already rendered for focus to be grabbed!
	RowGrabFocus(row int) *WidgetBase

	// SliceNewAt inserts a new blank element at given
	// index in the slice. -1 means the end.
	SliceNewAt(idx int)

	// SliceDeleteAt deletes element at given index from slice
	SliceDeleteAt(idx int)

	// MimeDataType returns the data type for mime clipboard
	// (copy / paste) data e.g., fileinfo.DataJson
	MimeDataType() string

	// CopySelectToMime copies selected rows to mime data
	CopySelectToMime() mimedata.Mimes

	// PasteAssign assigns mime data (only the first one!) to this idx
	PasteAssign(md mimedata.Mimes, idx int)

	// PasteAtIndex inserts object(s) from mime data at
	// (before) given slice index
	PasteAtIndex(md mimedata.Mimes, idx int)

	MakePasteMenu(m *Scene, md mimedata.Mimes, idx int, mod events.DropMods, fun func())
	DragStart(e events.Event)
	DragDrop(e events.Event)
	DropFinalize(de *events.DragDrop)
	DropDeleteSource(e events.Event)
}

Lister is the interface used by ListBase to support any abstractions needed for different types of lists.

type Meter

type Meter struct {
	WidgetBase

	// Type is the styling type of the meter.
	Type MeterTypes

	// Value is the current value of the meter.
	// It defaults to 0.5.
	Value float32

	// Min is the minimum possible value of the meter.
	// It defaults to 0.
	Min float32

	// Max is the maximum possible value of the meter.
	// It defaults to 1.
	Max float32

	// Text, for [MeterCircle] and [MeterSemicircle], is the
	// text to render inside of the circle/semicircle.
	Text string

	// ValueColor is the image color that will be used to
	// render the filled value bar. It should be set in Style.
	ValueColor image.Image

	// Width, for [MeterCircle] and [MeterSemicircle], is the
	// width of the circle/semicircle. It should be set in Style.
	Width units.Value
}

Meter is a widget that renders a current value on as a filled bar/semicircle relative to a minimum and maximum potential value.

func NewMeter

func NewMeter(parent ...tree.Node) *Meter

NewMeter returns a new Meter with the given optional parent: Meter is a widget that renders a current value on as a filled bar/semicircle relative to a minimum and maximum potential value.

func (*Meter) Init added in v0.2.0

func (m *Meter) Init()

func (*Meter) New

func (t *Meter) New() tree.Node

New returns a new *Meter value

func (*Meter) NodeType

func (t *Meter) NodeType() *types.Type

NodeType returns the *types.Type of Meter

func (*Meter) Render

func (m *Meter) Render()

func (*Meter) SetMax

func (t *Meter) SetMax(v float32) *Meter

SetMax sets the [Meter.Max]: Max is the maximum possible value of the meter. It defaults to 1.

func (*Meter) SetMin

func (t *Meter) SetMin(v float32) *Meter

SetMin sets the [Meter.Min]: Min is the minimum possible value of the meter. It defaults to 0.

func (*Meter) SetText

func (t *Meter) SetText(v string) *Meter

SetText sets the [Meter.Text]: Text, for MeterCircle and MeterSemicircle, is the text to render inside of the circle/semicircle.

func (*Meter) SetType

func (t *Meter) SetType(v MeterTypes) *Meter

SetType sets the [Meter.Type]: Type is the styling type of the meter.

func (*Meter) SetValue

func (t *Meter) SetValue(v float32) *Meter

SetValue sets the [Meter.Value]: Value is the current value of the meter. It defaults to 0.5.

func (*Meter) SetValueColor

func (t *Meter) SetValueColor(v image.Image) *Meter

SetValueColor sets the [Meter.ValueColor]: ValueColor is the image color that will be used to render the filled value bar. It should be set in Style.

func (*Meter) SetWidth

func (t *Meter) SetWidth(v units.Value) *Meter

SetWidth sets the [Meter.Width]: Width, for MeterCircle and MeterSemicircle, is the width of the circle/semicircle. It should be set in Style.

func (*Meter) Style added in v0.2.0

func (m *Meter) Style()

func (*Meter) WidgetTooltip

func (m *Meter) WidgetTooltip(pos image.Point) (string, image.Point)

func (*Meter) WidgetValue added in v0.2.0

func (m *Meter) WidgetValue() any

type MeterTypes

type MeterTypes int32 //enums:enum -trim-prefix Meter

MeterTypes are the different styling types of [Meter]s.

const (
	// MeterLinear indicates to render a meter that goes in a straight,
	// linear direction, either horizontal or vertical, as specified by
	// [styles.Style.Direction].
	MeterLinear MeterTypes = iota

	// MeterCircle indicates to render the meter as a circle.
	MeterCircle

	// MeterSemicircle indicates to render the meter as a semicircle.
	MeterSemicircle
)
const MeterTypesN MeterTypes = 3

MeterTypesN is the highest valid value for type MeterTypes, plus one.

func MeterTypesValues

func MeterTypesValues() []MeterTypes

MeterTypesValues returns all possible values for the type MeterTypes.

func (MeterTypes) Desc

func (i MeterTypes) Desc() string

Desc returns the description of the MeterTypes value.

func (MeterTypes) Int64

func (i MeterTypes) Int64() int64

Int64 returns the MeterTypes value as an int64.

func (MeterTypes) MarshalText

func (i MeterTypes) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*MeterTypes) SetInt64

func (i *MeterTypes) SetInt64(in int64)

SetInt64 sets the MeterTypes value from an int64.

func (*MeterTypes) SetString

func (i *MeterTypes) SetString(s string) error

SetString sets the MeterTypes value from its string representation, and returns an error if the string is invalid.

func (MeterTypes) String

func (i MeterTypes) String() string

String returns the string representation of this MeterTypes value.

func (*MeterTypes) UnmarshalText

func (i *MeterTypes) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (MeterTypes) Values

func (i MeterTypes) Values() []enums.Enum

Values returns all possible values for the type MeterTypes.

type NewItemsData

type NewItemsData struct {
	// Number is the number of elements to create
	Number int
	// Type is the type of elements to create
	Type *types.Type
}

NewItemsData contains the data necessary to make a certain number of items of a certain type, which can be used with a Form in new item dialogs.

type OnBinder added in v0.2.0

type OnBinder interface {

	// OnBind is called when the widget is bound to given value.
	OnBind(value any)
}

OnBinder is an optional interface that [Value]s can implement to do something when the widget is bound to the given value.

type RenderContext

type RenderContext struct {

	// LogicalDPI is the current logical dots-per-inch resolution of the
	// window, which should be used for most conversion of standard units.
	LogicalDPI float32

	// Geometry of the rendering window, in actual "dot" pixels used for rendering.
	Geom math32.Geom2DInt

	// Mu is mutex for locking out rendering and any destructive updates.
	// It is locked at the RenderWindow level during rendering and
	// event processing to provide exclusive blocking of external updates.
	// Use AsyncLock from any outside routine to grab the lock before
	// doing modifications.
	Mu sync.Mutex

	// Visible is whether the window is visible and should be rendered to.
	Visible bool

	// Rebuild is whether to force a rebuild of all Scene elements.
	Rebuild bool
}

RenderContext provides rendering context from outer RenderWindow window to Stage and Scene elements to inform styling, layout and rendering. It also has the main Mutex for any updates to the window contents: use Lock for anything updating.

func NewRenderContext

func NewRenderContext() *RenderContext

NewRenderContext returns a new RenderContext initialized according to the main Screen size and LogicalDPI as initial defaults. The actual window size is set during Resized method, which is typically called after the window is created by the OS.

func (*RenderContext) Lock

func (rc *RenderContext) Lock()

Lock is called by RenderWindow during RenderWindow and HandleEvent when updating all widgets and rendering the screen. Any outside access to window contents / scene must acquire this lock first. In general, use AsyncLock to do this.

func (*RenderContext) String

func (rc *RenderContext) String() string

func (*RenderContext) Unlock

func (rc *RenderContext) Unlock()

Unlock must be called for each Lock, when done.

type RenderParams

type RenderParams struct {
	// LogicalDPI is the current logical dots-per-inch resolution of the
	// window, which should be used for most conversion of standard units.
	LogicalDPI float32

	// Geometry of the rendering window, in actual "dot" pixels used for rendering.
	Geom math32.Geom2DInt
}

RenderParams are the key RenderWindow params that determine if a scene needs to be restyled since last render, if these params change.

func (*RenderParams) NeedsRestyle

func (rp *RenderParams) NeedsRestyle(rc *RenderContext) bool

NeedsRestyle returns true if the current render context params differ from those used in last render.

func (*RenderParams) SaveRender

func (rp *RenderParams) SaveRender(rc *RenderContext)

SaveRender grabs current render context params

type RenderScenes

type RenderScenes struct {

	// starting index for this set of Scenes
	StartIndex int

	// max index (exclusive) for this set of Scenes
	MaxIndex int

	// set to true to flip Y axis in drawing these images
	FlipY bool

	// ordered list of scenes and direct rendering widgets. Index is Drawer image index.
	Scenes []Widget

	// SceneIndex holds the index for each scene / direct render widget.
	// Used to detect changes in index.
	SceneIndex map[Widget]int
}

RenderScenes are a list of Scene and direct rendering widgets, compiled in rendering order, whose Pixels images are composed directly to the RenderWindow window.

func (*RenderScenes) Add

func (rs *RenderScenes) Add(w Widget, scIndex map[Widget]int) int

Add adds a new node, returning index

func (*RenderScenes) DrawAll

func (rs *RenderScenes) DrawAll(drw system.Drawer)

DrawAll does drw.Copy drawing call for all Scenes, using proper TextureSet for each of system.MaxTexturesPerSet Scenes.

func (*RenderScenes) Reset

func (rs *RenderScenes) Reset()

Reset resets the list

func (*RenderScenes) SetImages

func (rs *RenderScenes) SetImages(drw system.Drawer)

SetImages calls drw.SetGoImage on all updated Scene images

func (*RenderScenes) SetIndexRange

func (rs *RenderScenes) SetIndexRange(st, n int)

SetIndexRange sets the index range based on starting index and n

type RenderWindow

type RenderWindow struct {

	// Name is the name of the window.
	Name string

	// Title is the displayed name of window, for window manager etc.
	// Window object name is the internal handle and is used for tracking property info etc
	Title string

	// SystemWindow is the OS-specific window interface, which handles
	// all the os-specific functions, including delivering events etc
	SystemWindow system.Window `json:"-" xml:"-"`

	// Mains is the stack of main stages in this render window.
	// The [RenderContext] in this manager is the original source for all Stages.
	Mains Stages

	// RenderScenes are the Scene elements that draw directly to the window,
	// arranged in order, and continuously updated during Render.
	RenderScenes RenderScenes
	// contains filtered or unexported fields
}

RenderWindow provides an outer "actual" window where everything is rendered, and is the point of entry for all events coming in from user actions.

RenderWindow contents are all managed by the Stages stack that handles main Stage elements such as WindowStage and DialogStage, which in turn manage their own stack of popup stage elements such as menus and tooltips. The contents of each Stage is provided by a Scene, containing Widgets, and the Stage Pixels image is drawn to the RenderWindow in the RenderWindow method.

Rendering is handled by the system.Drawer. It is akin to a window manager overlaying Go image bitmaps on top of each other in the proper order, based on the Stages stacking order. Sprites are managed by the main stage, as layered textures of the same size, to enable unlimited number packed into a few descriptors for standard sizes.

var CurrentRenderWindow *RenderWindow

CurrentRenderWindow is the current RenderWindow. On single window platforms (mobile, web, and offscreen), this is the sonly render window.

func NewRenderWindow

func NewRenderWindow(name, title string, opts *system.NewWindowOptions) *RenderWindow

NewRenderWindow creates a new window with given internal name handle, display name, and options. This is called by Stage.NewRenderWindow which handles setting the opts and other infrastructure.

func (*RenderWindow) CloseReq

func (w *RenderWindow) CloseReq()

CloseReq requests that the window be closed, which could be rejected. It firsts unlocks and then locks the RenderContext to prevent deadlocks. If this is called asynchronously outside of the main event loop, [RenderWindow.SystemWin.CloseReq] should be called directly instead.

func (*RenderWindow) Closed

func (w *RenderWindow) Closed()

Closed frees any resources after the window has been closed.

func (*RenderWindow) DrawScenes

func (w *RenderWindow) DrawScenes()

DrawScenes does the drawing of RenderScenes to the window.

func (*RenderWindow) EventLoop

func (w *RenderWindow) EventLoop()

EventLoop runs the event processing loop for the RenderWindow -- grabs system events for the window and dispatches them to receiving nodes, and manages other state etc (popups, etc).

func (*RenderWindow) FillInsets

func (w *RenderWindow) FillInsets()

FillInsets fills the window insets, if any, with colors.Scheme.Background.

func (*RenderWindow) GatherScenes

func (w *RenderWindow) GatherScenes() bool

GatherScenes finds all the Scene elements that drive rendering into the RenderScenes list. Returns false on failure / nothing to render.

func (*RenderWindow) GoStartEventLoop

func (w *RenderWindow) GoStartEventLoop()

GoStartEventLoop starts the event processing loop for this window in a new goroutine, and returns immediately. Adds to WindowWait wait group so a main thread can wait on that for all windows to close.

func (*RenderWindow) HandleEvent

func (w *RenderWindow) HandleEvent(e events.Event)

HandleEvent processes given events.Event. All event processing operates under a RenderContext.Lock so that no rendering update can occur during event-driven updates. Because rendering itself is event driven, this extra level of safety is redundant in this case, but other non-event-driven updates require the lock protection.

func (*RenderWindow) HandleWindowEvents

func (w *RenderWindow) HandleWindowEvents(e events.Event)

func (*RenderWindow) IsClosed

func (w *RenderWindow) IsClosed() bool

IsClosed reports if the window has been closed

func (*RenderWindow) IsVisible

func (w *RenderWindow) IsVisible() bool

IsVisible is the main visibility check -- don't do any window updates if not visible!

func (*RenderWindow) LogicalDPI

func (w *RenderWindow) LogicalDPI() float32

LogicalDPI returns the current logical dots-per-inch resolution of the window, which should be used for most conversion of standard units -- physical DPI can be found in the Screen

func (*RenderWindow) MainScene

func (w *RenderWindow) MainScene() *Scene

MainScene returns the current [RenderWindow.Mains] top Scene, which is the current window or full window dialog occupying the RenderWindow.

func (*RenderWindow) Minimize

func (w *RenderWindow) Minimize()

Minimize requests that the window be iconified, making it no longer visible or active -- rendering should not occur for minimized windows.

func (*RenderWindow) Raise

func (w *RenderWindow) Raise()

Raise requests that the window be at the top of the stack of windows, and receive focus. If it is iconified, it will be de-iconified. This is the only supported mechanism for de-iconifying. This also sets CurrentRenderWindow to the window.

func (*RenderWindow) RenderContext

func (w *RenderWindow) RenderContext() *RenderContext

func (*RenderWindow) RenderWindow

func (w *RenderWindow) RenderWindow()

RenderWindow performs all rendering based on current Stages config. It sets the Write lock on RenderContext Mutex, so nothing else can update during this time. All other updates are done with a Read lock so they won't interfere with each other.

func (*RenderWindow) Resized

func (w *RenderWindow) Resized()

Resized updates internal buffers after a window has been resized.

func (*RenderWindow) SendCustomEvent

func (w *RenderWindow) SendCustomEvent(data any)

SendCustomEvent sends a custom event with given data to this window -- widgets can connect to receive CustomEventTypes events to receive them. Sometimes it is useful to send a custom event just to trigger a pass through the event loop, even if nobody is listening (e.g., if a popup is posted without a surrounding event, as in Complete.ShowCompletions

func (*RenderWindow) SendWinFocusEvent

func (w *RenderWindow) SendWinFocusEvent(act events.WinActions)

todo: fix or remove SendWinFocusEvent sends the RenderWinFocusEvent to widgets

func (*RenderWindow) SetCloseCleanFunc

func (w *RenderWindow) SetCloseCleanFunc(fun func(win *RenderWindow))

SetCloseCleanFunc sets the function that is called whenever window is actually about to close (irrevocably) -- can do any necessary last-minute cleanup here.

func (*RenderWindow) SetCloseReqFunc

func (w *RenderWindow) SetCloseReqFunc(fun func(win *RenderWindow))

SetCloseReqFunc sets the function that is called whenever there is a request to close the window (via a OS or a call to CloseReq() method). That function can then adjudicate whether and when to actually call Close.

func (*RenderWindow) SetName

func (w *RenderWindow) SetName(name string)

SetName sets name of this window and also the RenderWindow, and applies any window geometry settings associated with the new name if it is different from before

func (*RenderWindow) SetSize

func (w *RenderWindow) SetSize(sz image.Point)

SetSize requests that the window be resized to the given size in underlying pixel coordinates, which means that the requested size is divided by the screen's DevicePixelRatio

func (*RenderWindow) SetStageTitle

func (w *RenderWindow) SetStageTitle(title string)

SetStageTitle sets the title of the underlying SystemWin to the given stage title combined with the RenderWindow title.

func (*RenderWindow) SetTitle

func (w *RenderWindow) SetTitle(title string)

SetTitle sets title of this window and its underlying SystemWin.

func (*RenderWindow) SetWinSize

func (w *RenderWindow) SetWinSize(sz image.Point)

SetWinSize requests that the window be resized to the given size in OS window manager specific coordinates, which may be different from the underlying pixel-level resolution of the window. This will trigger a resize event and be processed that way when it occurs.

func (*RenderWindow) SetZoom

func (w *RenderWindow) SetZoom(zoom float32)

SetZoom sets [AppearanceSettingsData.Zoom] to the given value and then triggers necessary updating and makes a snackbar.

func (*RenderWindow) StepZoom

func (w *RenderWindow) StepZoom(steps float32)

StepZoom calls [SetZoom] with the current zoom plus 10 times the given number of steps.

type RenderWindowList

type RenderWindowList []*RenderWindow

RenderWindowList is a list of windows.

var AllRenderWindows RenderWindowList

AllRenderWindows is the list of all windows that have been created (dialogs, main windows, etc).

var DialogRenderWindows RenderWindowList

DialogRenderWindows is the list of only dialog windows that have been created.

var MainRenderWindows RenderWindowList

MainRenderWindows is the list of main windows (non-dialogs) that have been created.

func (*RenderWindowList) Add

func (wl *RenderWindowList) Add(w *RenderWindow)

Add adds a window to the list.

func (*RenderWindowList) Delete

func (wl *RenderWindowList) Delete(w *RenderWindow)

Delete removes a window from the list.

func (*RenderWindowList) FindData

func (wl *RenderWindowList) FindData(data any) (*RenderWindow, bool)

FindData finds window with given Data on list -- returns window and true if found, nil, false otherwise. data of type string works fine -- does equality comparison on string contents.

func (*RenderWindowList) FindName

func (wl *RenderWindowList) FindName(name string) (*RenderWindow, bool)

FindName finds window with given name on list (case sensitive) -- returns window and true if found, nil, false otherwise.

func (*RenderWindowList) FindRenderWindow added in v0.1.1

func (wl *RenderWindowList) FindRenderWindow(osw system.Window) (*RenderWindow, bool)

FindRenderWindow finds window with given system.RenderWindow on list -- returns window and true if found, nil, false otherwise.

func (*RenderWindowList) FocusNext

func (wl *RenderWindowList) FocusNext() (*RenderWindow, int)

FocusNext focuses on the next window in the list, after the current Focused() one skips minimized windows

func (*RenderWindowList) Focused

func (wl *RenderWindowList) Focused() (*RenderWindow, int)

Focused returns the (first) window in this list that has the WinGotFocus flag set and the index in the list (nil, -1 if not present)

func (*RenderWindowList) Len

func (wl *RenderWindowList) Len() int

Len returns the length of the list, concurrent-safe

func (*RenderWindowList) Win

func (wl *RenderWindowList) Win(idx int) *RenderWindow

Win gets window at given index, concurrent-safe

type SVG

type SVG struct {
	WidgetBase

	// SVG is the SVG drawing to display in this widget
	SVG *svg.SVG `set:"-"`
	// contains filtered or unexported fields
}

SVG is a Widget that renders an svg.SVG object. If it is not states.ReadOnly, the user can pan and zoom the display. By default, it is states.ReadOnly.

func NewSVG

func NewSVG(parent ...tree.Node) *SVG

NewSVG returns a new SVG with the given optional parent: SVG is a Widget that renders an svg.SVG object. If it is not states.ReadOnly, the user can pan and zoom the display. By default, it is states.ReadOnly.

func (*SVG) Init added in v0.2.0

func (sv *SVG) Init()

func (*SVG) MakeToolbar added in v0.2.0

func (sv *SVG) MakeToolbar(p *tree.Plan)

func (*SVG) New

func (t *SVG) New() tree.Node

New returns a new *SVG value

func (*SVG) NodeType

func (t *SVG) NodeType() *types.Type

NodeType returns the *types.Type of SVG

func (*SVG) Open

func (sv *SVG) Open(filename Filename) error

Open opens an XML-formatted SVG file

func (*SVG) OpenFS

func (sv *SVG) OpenFS(fsys fs.FS, filename string) error

OpenSVG opens an XML-formatted SVG file from the given fs.

func (*SVG) Read

func (sv *SVG) Read(r io.Reader) error

Read reads an XML-formatted SVG file from the given reader.

func (*SVG) ReadBytes

func (sv *SVG) ReadBytes(b []byte) error

ReadBytes reads an XML-formatted SVG file from the given bytes.

func (*SVG) ReadString

func (sv *SVG) ReadString(s string) error

ReadString reads an XML-formatted SVG file from the given string.

func (*SVG) Render

func (sv *SVG) Render()

func (*SVG) RenderSVG added in v0.2.0

func (sv *SVG) RenderSVG()

RenderSVG renders the SVG

func (*SVG) SavePNG

func (sv *SVG) SavePNG(filename Filename) error

SavePNG saves the current rendered SVG image to an PNG image file.

func (*SVG) SaveSVG

func (sv *SVG) SaveSVG(filename Filename) error

SaveSVG saves the current SVG to an XML-encoded standard SVG file.

func (*SVG) SizeFinal

func (sv *SVG) SizeFinal()

type Scene

type Scene struct {
	Frame

	// Bars contains functions for constructing the control bars for this Scene,
	// attached to different sides of a Scene (e.g., TopAppBar at Top,
	// NavBar at Bottom, etc).  Functions are called in forward order
	// so first added are called first.
	Bars styles.Sides[BarFuncs] `json:"-" xml:"-"`

	// BarsInherit determines which of the Bars side functions are inherited
	// from the context widget, for FullWindow Dialogs
	BarsInherit styles.Sides[bool]

	// AppBars contains functions for making the plan for the top app bar.
	AppBars []func(p *tree.Plan) `json:"-" xml:"-"`

	// Body provides the main contents of scenes that use control Bars
	// to allow the main window contents to be specified separately
	// from that dynamic control content.  When constructing scenes using
	// a Body, you can operate directly on the [Body], which has wrappers
	// for most major Scene functions.
	Body *Body

	// Data is the optional data value being represented by this scene.
	// Used e.g., for recycling views of a given item instead of creating new one.
	Data any

	// Size and position relative to overall rendering context.
	SceneGeom math32.Geom2DInt `edit:"-" set:"-"`

	// paint context for rendering
	PaintContext paint.Context `copier:"-" json:"-" xml:"-" display:"-" set:"-"`

	// live pixels that we render into
	Pixels *image.RGBA `copier:"-" json:"-" xml:"-" display:"-" set:"-"`

	// event manager for this scene
	Events Events `copier:"-" json:"-" xml:"-" set:"-"`

	// current stage in which this Scene is set
	Stage *Stage `copier:"-" json:"-" xml:"-" set:"-"`

	// HasShown is whether this scene has been shown.
	// This is used to ensure that [events.Show] is only sent once.
	HasShown bool `copier:"-" json:"-" xml:"-" display:"-" set:"-"`
	// contains filtered or unexported fields
}

Scene contains a Widget tree, rooted in an embedded Frame layout, which renders into its [Scene.Pixels] image. The Scene is set in a Stage, which the Scene has a pointer to.

Each Scene contains state specific to its particular usage within a given Stage and overall rendering context, representing the unit of rendering in the Cogent Core framework.

func NewBodyScene

func NewBodyScene(body *Body) *Scene

NewBodyScene creates a new Scene for use with an associated Body that contains the main content of the Scene (e.g., a Window, Dialog, etc). It will be constructed from the Bars-configured control bars on each side, with the given Body as the central content.

func NewMenuFromStrings

func NewMenuFromStrings(strs []string, sel string, fun func(idx int)) *Scene

NewMenuFromStrings constructs a new menu from given list of strings, calling the given function with the index of the selected string. if string == sel, that menu item is selected initially.

func NewMenuScene

func NewMenuScene(menu func(m *Scene), name ...string) *Scene

NewMenuScene constructs a Scene for displaying a menu, using the given menu constructor function. If no name is provided, it defaults to "menu". If no menu items added, returns nil.

func NewScene

func NewScene(name ...string) *Scene

NewScene creates a new Scene object without a Body, e.g., for use in a Menu, Tooltip or other such simple popups or non-control-bar Scenes.

func NewTooltipScene

func NewTooltipScene(w Widget, tooltip string, pos, sz image.Point) *Scene

NewTooltipScene returns a new tooltip scene for the given widget with the given tooltip based on the given context position and context size.

func (*Scene) AddDirectRender

func (sc *Scene) AddDirectRender(w Widget)

func (*Scene) ApplyStyleScene

func (sc *Scene) ApplyStyleScene()

ApplyStyleScene calls ApplyStyle on all widgets in the Scene, This is needed whenever the window geometry, DPI, etc is updated, which affects styling.

func (*Scene) AssertPixels

func (sc *Scene) AssertPixels(t imagex.TestingT, filename string)

AssertPixels asserts that [Scene.Pixels] is equivalent to the image stored at the given filename in the testdata directory, with ".png" added to the filename if there is no extension (eg: "button" becomes "testdata/button.png"). Forward slashes are automatically replaced with backslashes on Windows. If it is not, it fails the test with an error, but continues its execution. If there is no image at the given filename in the testdata directory, it creates the image.

func (*Scene) BenchmarkFullRender

func (sc *Scene) BenchmarkFullRender()

BenchmarkFullRender runs benchmark of 50 full re-renders (full restyling, layout, and everything), reporting targeted profile results and generating standard Go cpu.prof and mem.prof outputs.

func (*Scene) BenchmarkReRender

func (sc *Scene) BenchmarkReRender()

BenchmarkReRender runs benchmark of 50 re-render-only updates of display (just the raw rendering, no styling or layout), reporting targeted profile results and generating standard Go cpu.prof and mem.prof outputs.

func (*Scene) Close

func (sc *Scene) Close() bool

Close closes the Stage associated with this Scene. This only works for main stages (windows and dialogs). It returns whether the Stage was successfully closed.

func (*Scene) DeleteDirectRender

func (sc *Scene) DeleteDirectRender(w Widget)

func (*Scene) DirectRenderDraw

func (sc *Scene) DirectRenderDraw(drw system.Drawer, idx int, flipY bool)

func (*Scene) DirectRenderImage

func (sc *Scene) DirectRenderImage(drw system.Drawer, idx int)

func (*Scene) DoRebuild

func (sc *Scene) DoRebuild()

DoRebuild does the full re-render and RenderContext Rebuild flag should be used by Widgets to rebuild things that are otherwise cached (e.g., Icon, TextCursor).

func (*Scene) DoUpdate

func (sc *Scene) DoUpdate() bool

DoUpdate checks scene Needs flags to do whatever updating is required. returns false if already updating. This is the main update call made by the RenderWindow at FPS frequency.

func (*Scene) FitInWindow

func (sc *Scene) FitInWindow(winGeom math32.Geom2DInt)

FitInWindow fits Scene geometry (pos, size) into given window geom. Calls resize for the new size.

func (*Scene) GetBar

func (sc *Scene) GetBar(side styles.SideIndexes) *Frame

GetBar returns Bar layout widget at given side, nil if not there.

func (*Scene) GetTopAppBar

func (sc *Scene) GetTopAppBar() *Toolbar

GetTopAppBar returns the TopAppBar Toolbar if it exists, nil otherwise.

func (*Scene) InheritBars

func (sc *Scene) InheritBars(osc *Scene)

InheritBars inherits Bars functions from given other scene for each side that the other scene marks as inherited.

func (*Scene) InheritBarsWidget

func (sc *Scene) InheritBarsWidget(w Widget)

InheritBarsWidget inherits Bar functions based on a source widget (e.g., Context of dialog)

func (*Scene) Init added in v0.2.0

func (sc *Scene) Init()

func (*Scene) LayoutRenderScene

func (sc *Scene) LayoutRenderScene()

LayoutRenderScene does a layout and render of the tree: GetSize, DoLayout, Render. Needed after Config.

func (*Scene) LayoutScene

func (sc *Scene) LayoutScene()

LayoutScene does a layout of the scene: Size, Position

func (*Scene) MakeSceneBars added in v0.2.0

func (sc *Scene) MakeSceneBars()

MakeSceneBars configures the side control bars, for main scenes

func (*Scene) MakeSceneWidgets added in v0.2.0

func (sc *Scene) MakeSceneWidgets()

MakeSceneWidgets calls Config on all widgets in the Scene, which will set NeedsLayout to drive subsequent layout and render. This is a top-level call, typically only done when the window is first drawn, once the full sizing information is available.

func (*Scene) New

func (t *Scene) New() tree.Node

New returns a new *Scene value

func (*Scene) NodeType

func (t *Scene) NodeType() *types.Type

NodeType returns the *types.Type of Scene

func (*Scene) PrefSize

func (sc *Scene) PrefSize(initSz image.Point) image.Point

PrefSize computes the preferred size of the scene based on current contents. initSz is the initial size -- e.g., size of screen. Used for auto-sizing windows.

func (*Scene) RenderContext

func (sc *Scene) RenderContext() *RenderContext

RenderContext returns the current render context. This will be nil prior to actual rendering.

func (*Scene) RenderWindow added in v0.1.1

func (sc *Scene) RenderWindow() *RenderWindow

RenderWindow returns the current render window for this scene. In general it is best to go through RenderContext instead of the window. This will be nil prior to actual rendering.

func (*Scene) Resize

func (sc *Scene) Resize(geom math32.Geom2DInt)

Resize resizes the scene, creating a new image; updates Geom

func (*Scene) ScIsVisible

func (sc *Scene) ScIsVisible() bool

func (*Scene) ScenePos

func (sc *Scene) ScenePos()

func (*Scene) SetAppBars

func (t *Scene) SetAppBars(v ...func(p *tree.Plan)) *Scene

SetAppBars sets the [Scene.AppBars]: AppBars contains functions for making the plan for the top app bar.

func (*Scene) SetBars

func (t *Scene) SetBars(v styles.Sides[BarFuncs]) *Scene

SetBars sets the [Scene.Bars]: Bars contains functions for constructing the control bars for this Scene, attached to different sides of a Scene (e.g., TopAppBar at Top, NavBar at Bottom, etc). Functions are called in forward order so first added are called first.

func (*Scene) SetBarsInherit

func (t *Scene) SetBarsInherit(v styles.Sides[bool]) *Scene

SetBarsInherit sets the [Scene.BarsInherit]: BarsInherit determines which of the Bars side functions are inherited from the context widget, for FullWindow Dialogs

func (*Scene) SetBody

func (t *Scene) SetBody(v *Body) *Scene

SetBody sets the [Scene.Body]: Body provides the main contents of scenes that use control Bars to allow the main window contents to be specified separately from that dynamic control content. When constructing scenes using a Body, you can operate directly on the Body, which has wrappers for most major Scene functions.

func (*Scene) SetData

func (t *Scene) SetData(v any) *Scene

SetData sets the [Scene.Data]: Data is the optional data value being represented by this scene. Used e.g., for recycling views of a given item instead of creating new one.

func (*Scene) UpdateTitle

func (sc *Scene) UpdateTitle(title string)

UpdateTitle updates the title of the Scene's associated Stage, RenderWindow, and Body, if applicable.

type ScreenSettings

type ScreenSettings struct {

	// overall zoom factor as a percentage of the default zoom
	Zoom float32 `default:"100" min:"10" max:"1000" step:"10"`
}

ScreenSettings are the per-screen settings -- see system.App.Screen for info on the different screens -- these prefs are indexed by the Screen.Name -- settings here override those in the global settings.

type Scrim

type Scrim struct {
	WidgetBase
}

A Scrim is just a dummy Widget used for rendering a Scrim. Only used for its type. Everything else managed by RenderWindow.

func NewScrim

func NewScrim(sc *Scene) *Scrim

NewScrim creates a new Scrim for use in rendering. It does not actually add the Scrim to the Scene, just sets its pointers.

func (*Scrim) DirectRenderDraw

func (sr *Scrim) DirectRenderDraw(drw system.Drawer, idx int, flipY bool)

func (*Scrim) DirectRenderImage

func (sr *Scrim) DirectRenderImage(drw system.Drawer, idx int)

func (*Scrim) New

func (t *Scrim) New() tree.Node

New returns a new *Scrim value

func (*Scrim) NodeType

func (t *Scrim) NodeType() *types.Type

NodeType returns the *types.Type of Scrim

type Separator

type Separator struct {
	WidgetBase
}

Separator draws a separator line. It goes in the direction specified by [style.Style.Direction].

func NewSeparator

func NewSeparator(parent ...tree.Node) *Separator

NewSeparator returns a new Separator with the given optional parent: Separator draws a separator line. It goes in the direction specified by [style.Style.Direction].

func (*Separator) Init added in v0.2.0

func (sp *Separator) Init()

func (*Separator) New

func (t *Separator) New() tree.Node

New returns a new *Separator value

func (*Separator) NodeType

func (t *Separator) NodeType() *types.Type

NodeType returns the *types.Type of Separator

type Settings

type Settings interface {

	// Label returns the label text for the settings.
	Label() string

	// Filename returns the full filename/filepath at which the settings are stored.
	Filename() string

	// Defaults sets the default values for all of the settings.
	Defaults()

	// Apply does anything necessary to apply the settings to the app.
	Apply()

	// MakeToolbar is an optional method that settings objects can implement in order to
	// configure the settings view toolbar with settings-related actions that the user can
	// perform.
	MakeToolbar(p *tree.Plan)
}

Settings is the interface that describes the functionality common to all settings data types.

type SettingsBase

type SettingsBase struct {

	// Name is the name of the settings.
	Name string `display:"-" save:"-"`

	// File is the full filename/filepath at which the settings are stored.
	File string `display:"-" save:"-"`
}

SettingsBase contains base settings logic that other settings data types can extend.

func (*SettingsBase) Apply

func (sb *SettingsBase) Apply()

Apply does nothing by default and can be extended by other settings data types.

func (*SettingsBase) Defaults

func (sb *SettingsBase) Defaults()

Defaults does nothing by default and can be extended by other settings data types.

func (*SettingsBase) Filename

func (sb *SettingsBase) Filename() string

Filename returns the full filename/filepath at which the settings are stored.

func (*SettingsBase) Label

func (sb *SettingsBase) Label() string

Label returns the label text for the settings.

func (*SettingsBase) MakeToolbar added in v0.2.0

func (sb *SettingsBase) MakeToolbar(p *tree.Plan)

MakeToolbar does nothing by default and can be extended by other settings data types.

type SettingsOpener

type SettingsOpener interface {
	Settings

	// Open opens the settings
	Open() error
}

SettingsOpener is an optional additional interface that Settings can satisfy to customize the behavior of OpenSettings.

type SettingsSaver

type SettingsSaver interface {
	Settings

	// Save saves the settings
	Save() error
}

SettingsSaver is an optional additional interface that Settings can satisfy to customize the behavior of SaveSettings.

type Shortcuts

type Shortcuts map[key.Chord]*Button

Shortcuts is a map between a key chord and a specific Button that can be triggered. This mapping must be unique, in that each chord has unique Button, and generally each Button only has a single chord as well, though this is not strictly enforced. Shortcuts are evaluated *after* the standard KeyMap event processing, so any conflicts are resolved in favor of the local widget's key event processing, with the shortcut only operating when no conflicting widgets are in focus. Shortcuts are always window-wide and are intended for global window / toolbar buttons. Widget-specific key functions should be handled directly within widget key event processing.

type ShouldShower

type ShouldShower interface {
	// ShouldShow returns whether the given named field should be displayed.
	ShouldShow(field string) bool
}

ShouldShower is an interface determining when you should take a shower. Actually, it determines whether a named field should be displayed (in Form).

type SizeClasses

type SizeClasses int32 //enums:enum -trim-prefix Size

SizeClasses are the different size classes that a window can have.

const (
	// SizeCompact is the size class for windows with a width less than
	// 600dp, which typically happens on phones.
	SizeCompact SizeClasses = iota

	// SizeMedium is the size class for windows with a width between 600dp
	// and 840dp inclusive, which typically happens on tablets.
	SizeMedium

	// SizeExpanded is the size class for windows with a width greater than
	// 840dp, which typically happens on desktop and laptop computers.
	SizeExpanded
)
const SizeClassesN SizeClasses = 3

SizeClassesN is the highest valid value for type SizeClasses, plus one.

func SizeClassesValues

func SizeClassesValues() []SizeClasses

SizeClassesValues returns all possible values for the type SizeClasses.

func (SizeClasses) Desc

func (i SizeClasses) Desc() string

Desc returns the description of the SizeClasses value.

func (SizeClasses) Int64

func (i SizeClasses) Int64() int64

Int64 returns the SizeClasses value as an int64.

func (SizeClasses) MarshalText

func (i SizeClasses) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*SizeClasses) SetInt64

func (i *SizeClasses) SetInt64(in int64)

SetInt64 sets the SizeClasses value from an int64.

func (*SizeClasses) SetString

func (i *SizeClasses) SetString(s string) error

SetString sets the SizeClasses value from its string representation, and returns an error if the string is invalid.

func (SizeClasses) String

func (i SizeClasses) String() string

String returns the string representation of this SizeClasses value.

func (*SizeClasses) UnmarshalText

func (i *SizeClasses) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (SizeClasses) Values

func (i SizeClasses) Values() []enums.Enum

Values returns all possible values for the type SizeClasses.

type Slider

type Slider struct {
	Frame

	// Type is the type of the slider, which determines its visual
	// and functional properties. The default type, [SliderSlider],
	// should work for most end-user use cases.
	Type SliderTypes

	// Value is the current value, represented by the position of the thumb.
	// It defaults to 0.5.
	Value float32 `set:"-"`

	// Min is the minimum possible value.
	// It defaults to 0.
	Min float32

	// Max is the maximum value supported.
	// It defaults to 1.
	Max float32

	// Step is the amount that the arrow keys increment/decrement the value by.
	// It defaults to 0.1.
	Step float32

	// EnforceStep is whether to ensure that the value is always
	// a multiple of [Slider.Step].
	EnforceStep bool

	// PageStep is the amount that the PageUp and PageDown keys
	// increment/decrement the value by.
	// It defaults to 0.2, and will be at least as big as [Slider.Step].
	PageStep float32

	// Icon is an optional icon to use for the dragging knob.
	Icon icons.Icon `display:"show-name"`

	// For Scrollbar type only: proportion (1 max) of the full range of scrolled data
	// that is currently visible.  This determines the thumb size and range of motion:
	// if 1, full slider is the thumb and no motion is possible.
	VisiblePct float32 `set:"-"`

	// Size of the thumb as a proportion of the slider thickness, which is
	// Content size (inside the padding).  This is for actual X,Y dimensions,
	// so must be sensitive to Dim dimension alignment.
	ThumbSize math32.Vector2

	// TrackSize is the proportion of slider thickness for the visible track
	// for the Slider type.  It is often thinner than the thumb, achieved by
	// values < 1 (.5 default)
	TrackSize float32

	// threshold for amount of change in scroll value before emitting an input event
	InputThreshold float32

	// specifies the precision of decimal places (total, not after the decimal point)
	// to use in representing the number. This helps to truncate small weird floating
	// point values in the nether regions.
	Prec int

	// The background color that is used for styling the selected value section of the slider.
	// It should be set in the StyleFuncs, just like the main style object is.
	// If it is set to transparent, no value is rendered, so the value section of the slider
	// just looks like the rest of the slider.
	ValueColor image.Image

	// The background color that is used for styling the thumb (handle) of the slider.
	// It should be set in the StyleFuncs, just like the main style object is.
	// If it is set to transparent, no thumb is rendered, so the thumb section of the slider
	// just looks like the rest of the slider.
	ThumbColor image.Image

	// If true, keep the slider (typically a Scrollbar) within the parent Scene
	// bounding box, if the parent is in view.  This is the default behavior
	// for Layout scrollbars, and setting this flag replicates that behavior
	// in other scrollbars.
	StayInView bool

	// logical position of the slider relative to Size
	Pos float32 `edit:"-" set:"-"`

	// previous Change event emitted value - don't re-emit Change if it is the same
	LastValue float32 `edit:"-" copier:"-" xml:"-" json:"-" set:"-"`

	// previous sliding value - for computing the Input change
	PrevSlide float32 `edit:"-" copier:"-" xml:"-" json:"-" set:"-"`

	// Computed size of the slide box in the relevant dimension
	// range of motion, exclusive of spacing, based on layout allocation.
	Size float32 `edit:"-" set:"-"`

	// underlying drag position of slider -- not subject to snapping
	SlideStartPos float32 `edit:"-" set:"-"`
}

Slider is a slideable widget that provides slider functionality for two Types: Slider type provides a movable thumb that represents Value as the center of thumb Pos position, with room reserved at ends for 1/2 of the thumb size. Scrollbar has a VisiblePct factor that specifies the percent of the content currently visible, which determines the size of the thumb, and thus the range of motion remaining for the thumb Value (VisiblePct = 1 means thumb is full size, and no remaining range of motion). The Content size (inside the margin and padding) determines the outer bounds of the rendered area. The styles.Style.Direction determines the direction in which the slider slides.

func NewSlider

func NewSlider(parent ...tree.Node) *Slider

NewSlider returns a new Slider with the given optional parent: Slider is a slideable widget that provides slider functionality for two Types: Slider type provides a movable thumb that represents Value as the center of thumb Pos position, with room reserved at ends for 1/2 of the thumb size. Scrollbar has a VisiblePct factor that specifies the percent of the content currently visible, which determines the size of the thumb, and thus the range of motion remaining for the thumb Value (VisiblePct = 1 means thumb is full size, and no remaining range of motion). The Content size (inside the margin and padding) determines the outer bounds of the rendered area. The styles.Style.Direction determines the direction in which the slider slides.

func (*Slider) EffectiveMax

func (sr *Slider) EffectiveMax() float32

EffectiveMax returns the effective maximum value represented. For the Slider type, it it is just Max. for the Scrollbar type, it is Max - Value of thumb size

func (*Slider) Init added in v0.2.0

func (sr *Slider) Init()

func (*Slider) New

func (t *Slider) New() tree.Node

New returns a new *Slider value

func (*Slider) NodeType

func (t *Slider) NodeType() *types.Type

NodeType returns the *types.Type of Slider

func (*Slider) OnBind added in v0.2.0

func (sr *Slider) OnBind(value any)

func (*Slider) PointToRelPos

func (sr *Slider) PointToRelPos(pt image.Point) float32

PointToRelPos translates a point in scene local pixel coords into relative position within the slider content range

func (*Slider) Render

func (sr *Slider) Render()

func (*Slider) ScenePos

func (sr *Slider) ScenePos()

func (*Slider) ScrollScale

func (sr *Slider) ScrollScale(del float32) float32

ScrollScale returns scaled value of scroll delta as a function of the step size.

func (*Slider) ScrollThumbValue

func (sr *Slider) ScrollThumbValue() float32

ScrollThumbValue returns the current scroll VisiblePct in terms of the Min - Max range of values.

func (*Slider) SendChanged

func (sr *Slider) SendChanged(e ...events.Event) bool

SendChanged sends a Changed message if given new value is different from the existing Value.

func (*Slider) SetEnforceStep

func (t *Slider) SetEnforceStep(v bool) *Slider

SetEnforceStep sets the [Slider.EnforceStep]: EnforceStep is whether to ensure that the value is always a multiple of [Slider.Step].

func (*Slider) SetIcon

func (t *Slider) SetIcon(v icons.Icon) *Slider

SetIcon sets the [Slider.Icon]: Icon is an optional icon to use for the dragging knob.

func (*Slider) SetInputThreshold

func (t *Slider) SetInputThreshold(v float32) *Slider

SetInputThreshold sets the [Slider.InputThreshold]: threshold for amount of change in scroll value before emitting an input event

func (*Slider) SetMax

func (t *Slider) SetMax(v float32) *Slider

SetMax sets the [Slider.Max]: Max is the maximum value supported. It defaults to 1.

func (*Slider) SetMin

func (t *Slider) SetMin(v float32) *Slider

SetMin sets the [Slider.Min]: Min is the minimum possible value. It defaults to 0.

func (*Slider) SetPageStep

func (t *Slider) SetPageStep(v float32) *Slider

SetPageStep sets the [Slider.PageStep]: PageStep is the amount that the PageUp and PageDown keys increment/decrement the value by. It defaults to 0.2, and will be at least as big as [Slider.Step].

func (*Slider) SetPosFromValue

func (sr *Slider) SetPosFromValue(val float32)

SetPosFromValue sets the slider position based on the given value (typically rs.Value)

func (*Slider) SetPrec

func (t *Slider) SetPrec(v int) *Slider

SetPrec sets the [Slider.Prec]: specifies the precision of decimal places (total, not after the decimal point) to use in representing the number. This helps to truncate small weird floating point values in the nether regions.

func (*Slider) SetSliderPos

func (sr *Slider) SetSliderPos(pos float32)

SetSliderPos sets the position of the slider at the given relative position within the usable Content sliding range, in pixels, and updates the corresponding Value based on that position.

func (*Slider) SetSliderPosAction

func (sr *Slider) SetSliderPosAction(pos float32)

SetSliderPosAction sets the position of the slider at the given position in pixels, and updates the corresponding Value based on that position. This version sends input events.

func (*Slider) SetStayInView

func (t *Slider) SetStayInView(v bool) *Slider

SetStayInView sets the [Slider.StayInView]: If true, keep the slider (typically a Scrollbar) within the parent Scene bounding box, if the parent is in view. This is the default behavior for Layout scrollbars, and setting this flag replicates that behavior in other scrollbars.

func (*Slider) SetStep

func (t *Slider) SetStep(v float32) *Slider

SetStep sets the [Slider.Step]: Step is the amount that the arrow keys increment/decrement the value by. It defaults to 0.1.

func (*Slider) SetThumbColor

func (t *Slider) SetThumbColor(v image.Image) *Slider

SetThumbColor sets the [Slider.ThumbColor]: The background color that is used for styling the thumb (handle) of the slider. It should be set in the StyleFuncs, just like the main style object is. If it is set to transparent, no thumb is rendered, so the thumb section of the slider just looks like the rest of the slider.

func (*Slider) SetThumbSize

func (t *Slider) SetThumbSize(v math32.Vector2) *Slider

SetThumbSize sets the [Slider.ThumbSize]: Size of the thumb as a proportion of the slider thickness, which is Content size (inside the padding). This is for actual X,Y dimensions, so must be sensitive to Dim dimension alignment.

func (*Slider) SetTrackSize

func (t *Slider) SetTrackSize(v float32) *Slider

SetTrackSize sets the [Slider.TrackSize]: TrackSize is the proportion of slider thickness for the visible track for the Slider type. It is often thinner than the thumb, achieved by values < 1 (.5 default)

func (*Slider) SetType

func (t *Slider) SetType(v SliderTypes) *Slider

SetType sets the [Slider.Type]: Type is the type of the slider, which determines its visual and functional properties. The default type, SliderSlider, should work for most end-user use cases.

func (*Slider) SetValue

func (sr *Slider) SetValue(val float32) *Slider

SetValue sets the value and updates the slider position, but does not send a Change event (see Action version)

func (*Slider) SetValueAction

func (sr *Slider) SetValueAction(val float32)

SetValueAction sets the value and updates the slider representation, and emits an input and change event

func (*Slider) SetValueColor

func (t *Slider) SetValueColor(v image.Image) *Slider

SetValueColor sets the [Slider.ValueColor]: The background color that is used for styling the selected value section of the slider. It should be set in the StyleFuncs, just like the main style object is. If it is set to transparent, no value is rendered, so the value section of the slider just looks like the rest of the slider.

func (*Slider) SetVisiblePct

func (sr *Slider) SetVisiblePct(val float32) *Slider

SetVisiblePct sets the visible pct value for Scrollbar type.

func (*Slider) SlideThumbSize

func (sr *Slider) SlideThumbSize() float32

SlideThumbSize returns thumb size, based on type

func (*Slider) SliderSize

func (sr *Slider) SliderSize() float32

SliderSize returns the size available for sliding, based on allocation

func (*Slider) SliderThickness

func (sr *Slider) SliderThickness() float32

SliderThickness returns the thickness of the slider: Content size in other dim.

func (*Slider) SnapValue

func (sr *Slider) SnapValue()

SnapValue snaps the value to [Slider.Step] if [Slider.EnforceStep] is on.

func (*Slider) ThumbSizeDots

func (sr *Slider) ThumbSizeDots() math32.Vector2

ThumbSizeDots returns the thumb size in dots, based on ThumbSize and the content thickness

func (*Slider) WidgetTooltip

func (sr *Slider) WidgetTooltip(pos image.Point) (string, image.Point)

func (*Slider) WidgetValue added in v0.2.0

func (sr *Slider) WidgetValue() any

type SliderTypes

type SliderTypes int32 //enums:enum -trim-prefix Slider

SliderTypes are the different types of sliders

const (
	// SliderSlider indicates a standard, user-controllable slider
	// for setting a numeric value
	SliderSlider SliderTypes = iota

	// SliderScrollbar indicates a slider acting as a scrollbar for content
	// This sets the
	SliderScrollbar
)
const SliderTypesN SliderTypes = 2

SliderTypesN is the highest valid value for type SliderTypes, plus one.

func SliderTypesValues

func SliderTypesValues() []SliderTypes

SliderTypesValues returns all possible values for the type SliderTypes.

func (SliderTypes) Desc

func (i SliderTypes) Desc() string

Desc returns the description of the SliderTypes value.

func (SliderTypes) Int64

func (i SliderTypes) Int64() int64

Int64 returns the SliderTypes value as an int64.

func (SliderTypes) MarshalText

func (i SliderTypes) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*SliderTypes) SetInt64

func (i *SliderTypes) SetInt64(in int64)

SetInt64 sets the SliderTypes value from an int64.

func (*SliderTypes) SetString

func (i *SliderTypes) SetString(s string) error

SetString sets the SliderTypes value from its string representation, and returns an error if the string is invalid.

func (SliderTypes) String

func (i SliderTypes) String() string

String returns the string representation of this SliderTypes value.

func (*SliderTypes) UnmarshalText

func (i *SliderTypes) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (SliderTypes) Values

func (i SliderTypes) Values() []enums.Enum

Values returns all possible values for the type SliderTypes.

type Space

type Space struct {
	WidgetBase
}

Space is a fixed size blank space, with a default width of 1ch and a height of 1em. You can set styles.Style.Min to change its size. It does not render anything.

func NewSpace

func NewSpace(parent ...tree.Node) *Space

NewSpace returns a new Space with the given optional parent: Space is a fixed size blank space, with a default width of 1ch and a height of 1em. You can set styles.Style.Min to change its size. It does not render anything.

func (*Space) Init added in v0.2.0

func (sp *Space) Init()

func (*Space) New

func (t *Space) New() tree.Node

New returns a new *Space value

func (*Space) NodeType

func (t *Space) NodeType() *types.Type

NodeType returns the *types.Type of Space

type Spinner

type Spinner struct {
	TextField

	// Value is the current value.
	Value float32 `set:"-"`

	// HasMin is whether there is a minimum value to enforce.
	HasMin bool `set:"-"`

	// Min, if HasMin is true, is the the minimum value in range.
	Min float32 `set:"-"`

	// HaxMax is whether there is a maximum value to enforce.
	HasMax bool `set:"-"`

	// Max, if HasMax is true, is the maximum value in range.
	Max float32 `set:"-"`

	// Step is the amount that the up and down buttons and arrow keys
	// increment/decrement the value by. It defaults to 0.1.
	Step float32

	// EnforceStep is whether to ensure that the value of the spinner
	// is always a multiple of [Spinner.Step].
	EnforceStep bool

	// PageStep is the amount that the PageUp and PageDown keys
	// increment/decrement the value by.
	// It defaults to 0.2, and will be at least as big as [Spinner.Step].
	PageStep float32

	// Prec specifies the precision of decimal places
	// (total, not after the decimal point) to use in
	// representing the number. This helps to truncate
	// small weird floating point values.
	Prec int

	// Format is the format string to use for printing the value.
	// If it unset, %g is used. If it is decimal based
	// (ends in d, b, c, o, O, q, x, X, or U) then the value is
	// converted to decimal prior to printing.
	Format string
}

Spinner is a TextField for editing numerical values. It comes with fields, methods, buttons, and shortcuts to enhance numerical value editing.

func NewSpinner

func NewSpinner(parent ...tree.Node) *Spinner

NewSpinner returns a new Spinner with the given optional parent: Spinner is a TextField for editing numerical values. It comes with fields, methods, buttons, and shortcuts to enhance numerical value editing.

func (*Spinner) FormatIsInt

func (sp *Spinner) FormatIsInt() bool

FormatIsInt returns true if the format string requires an integer value

func (*Spinner) IncrementValue

func (sp *Spinner) IncrementValue(steps float32) *Spinner

IncrementValue increments the value by given number of steps (+ or -), and enforces it to be an even multiple of the step size (snap-to-value), and sends a change event.

func (*Spinner) Init added in v0.2.0

func (sp *Spinner) Init()

func (*Spinner) New

func (t *Spinner) New() tree.Node

New returns a new *Spinner value

func (*Spinner) NodeType

func (t *Spinner) NodeType() *types.Type

NodeType returns the *types.Type of Spinner

func (*Spinner) OnBind added in v0.2.0

func (sp *Spinner) OnBind(value any)

func (*Spinner) PageIncrementValue

func (sp *Spinner) PageIncrementValue(steps float32) *Spinner

PageIncrementValue increments the value by given number of page steps (+ or -), and enforces it to be an even multiple of the step size (snap-to-value), and sends a change event.

func (*Spinner) SetEnforceStep

func (t *Spinner) SetEnforceStep(v bool) *Spinner

SetEnforceStep sets the [Spinner.EnforceStep]: EnforceStep is whether to ensure that the value of the spinner is always a multiple of [Spinner.Step].

func (*Spinner) SetFormat

func (t *Spinner) SetFormat(v string) *Spinner

SetFormat sets the [Spinner.Format]: Format is the format string to use for printing the value. If it unset, %g is used. If it is decimal based (ends in d, b, c, o, O, q, x, X, or U) then the value is converted to decimal prior to printing.

func (*Spinner) SetMax

func (sp *Spinner) SetMax(max float32) *Spinner

SetMax sets the maximum bound on the value.

func (*Spinner) SetMin

func (sp *Spinner) SetMin(min float32) *Spinner

SetMin sets the minimum bound on the value.

func (*Spinner) SetPageStep

func (t *Spinner) SetPageStep(v float32) *Spinner

SetPageStep sets the [Spinner.PageStep]: PageStep is the amount that the PageUp and PageDown keys increment/decrement the value by. It defaults to 0.2, and will be at least as big as [Spinner.Step].

func (*Spinner) SetPrec

func (t *Spinner) SetPrec(v int) *Spinner

SetPrec sets the [Spinner.Prec]: Prec specifies the precision of decimal places (total, not after the decimal point) to use in representing the number. This helps to truncate small weird floating point values.

func (*Spinner) SetStep

func (t *Spinner) SetStep(v float32) *Spinner

SetStep sets the [Spinner.Step]: Step is the amount that the up and down buttons and arrow keys increment/decrement the value by. It defaults to 0.1.

func (*Spinner) SetTextToValue

func (sp *Spinner) SetTextToValue()

func (*Spinner) SetValue

func (sp *Spinner) SetValue(val float32) *Spinner

SetValue sets the value, enforcing any limits, and updates the display.

func (*Spinner) SetValueAction

func (sp *Spinner) SetValueAction(val float32) *Spinner

SetValueAction calls SetValue and also sends a change event.

func (*Spinner) SetWidgetValue added in v0.2.0

func (sp *Spinner) SetWidgetValue(value any) error

func (*Spinner) SizeUp

func (sp *Spinner) SizeUp()

func (*Spinner) StringToValue

func (sp *Spinner) StringToValue(str string) (float32, error)

StringToValue converts the string field back to float value

func (*Spinner) ValueToString

func (sp *Spinner) ValueToString(val float32) string

ValueToString converts the value to the string representation thereof

func (*Spinner) WidgetTooltip

func (sp *Spinner) WidgetTooltip(pos image.Point) (string, image.Point)

func (*Spinner) WidgetValue added in v0.2.0

func (sp *Spinner) WidgetValue() any

func (*Spinner) WrapAround

func (sp *Spinner) WrapAround(val float32) float32

WrapAround, if the spinner has a min and a max, converts values less than min to max and values greater than max to min.

type Splits

type Splits struct {
	Frame

	// Splits is the proportion (0-1 normalized, enforced) of space
	// allocated to each element. 0 indicates that an element should
	// be completely collapsed. By default, each element gets the
	// same amount of space.
	Splits []float32

	// SavedSplits is a saved version of the splits that can be restored
	// for dynamic collapse/expand operations.
	SavedSplits []float32 `set:"-"`
}

Splits allocates a certain proportion of its space to each of its children along styles.Style.Direction. It adds Handle widgets to its parts that allow the user to customize the amount of space allocated to each child.

func NewSplits

func NewSplits(parent ...tree.Node) *Splits

NewSplits returns a new Splits with the given optional parent: Splits allocates a certain proportion of its space to each of its children along styles.Style.Direction. It adds Handle widgets to its parts that allow the user to customize the amount of space allocated to each child.

func (*Splits) CollapseChild

func (sl *Splits) CollapseChild(save bool, idxs ...int)

CollapseChild collapses given child(ren) (sets split proportion to 0), optionally saving the prior splits for later Restore function -- does an Update -- triggered by double-click of splitter

func (*Splits) EvenSplits

func (sl *Splits) EvenSplits()

EvenSplits splits space evenly across all panels

func (*Splits) Init added in v0.2.0

func (sl *Splits) Init()

func (*Splits) IsCollapsed

func (sl *Splits) IsCollapsed(idx int) bool

IsCollapsed returns true if given split number is collapsed

func (*Splits) New

func (t *Splits) New() tree.Node

New returns a new *Splits value

func (*Splits) NodeType

func (t *Splits) NodeType() *types.Type

NodeType returns the *types.Type of Splits

func (*Splits) Position

func (sl *Splits) Position()

func (*Splits) PositionSplits

func (sl *Splits) PositionSplits()

func (*Splits) RenderWidget

func (sl *Splits) RenderWidget()

func (*Splits) RestoreChild

func (sl *Splits) RestoreChild(idxs ...int)

RestoreChild restores given child(ren) -- does an Update

func (*Splits) RestoreSplits

func (sl *Splits) RestoreSplits()

RestoreSplits restores a previously saved set of splits (if it exists), does an update

func (*Splits) SaveSplits

func (sl *Splits) SaveSplits()

SaveSplits saves the current set of splits in SavedSplits, for a later RestoreSplits

func (*Splits) SetSplitAction

func (sl *Splits) SetSplitAction(idx int, nwval float32)

SetSplitAction sets the new splitter value, for given splitter. New value is 0..1 value of position of that splitter. It is a sum of all the positions up to that point. Splitters are updated to ensure that selected position is achieved, while dividing remainder appropriately.

func (*Splits) SetSplits

func (t *Splits) SetSplits(v ...float32) *Splits

SetSplits sets the [Splits.Splits]: Splits is the proportion (0-1 normalized, enforced) of space allocated to each element. 0 indicates that an element should be completely collapsed. By default, each element gets the same amount of space.

func (*Splits) SizeDownSetAllocs

func (sl *Splits) SizeDownSetAllocs(iter int)

func (*Splits) UpdateSplits

func (sl *Splits) UpdateSplits() *Splits

UpdateSplits normalizes the splits and ensures that there are as many split proportions as children.

type Sprite

type Sprite struct {

	// whether this sprite is active now or not
	Active bool

	// unique name of sprite
	Name string

	// properties for sprite, which allow for user-extensible data
	Properties map[string]any

	// position and size of the image within the RenderWindow
	Geom math32.Geom2DInt

	// pixels to render -- should be same size as Geom.Size
	Pixels *image.RGBA

	// Listeners are event listener functions for processing events on this widget.
	// They are called in sequential descending order (so the last added listener
	// is called first). They should be added using the On function. FirstListeners
	// and FinalListeners are called before and after these listeners, respectively.
	Listeners events.Listeners `copier:"-" json:"-" xml:"-" set:"-"`
}

A Sprite is just an image (with optional background) that can be drawn onto the OverTex overlay texture of a window. Sprites are used for text cursors/carets and for dynamic editing / interactive GUI elements (e.g., drag-n-drop elements)

func NewSprite

func NewSprite(nm string, sz image.Point, pos image.Point) *Sprite

NewSprite returns a new sprite with given name, which must remain invariant and unique among all sprites in use, and is used for all access; prefix with package and type name to ensure uniqueness. Starts out in inactive state; must call ActivateSprite. If size is 0, no image is made.

func (*Sprite) GrabRenderFrom

func (sp *Sprite) GrabRenderFrom(w Widget)

GrabRenderFrom grabs the rendered image from the given widget.

func (*Sprite) HandleEvent added in v0.1.4

func (sp *Sprite) HandleEvent(e events.Event)

Send sends an NEW event of given type to this sprite, optionally starting from values in the given original event (recommended to include where possible). Do NOT send an existing event using this method if you want the Handled state to persist throughout the call chain; call HandleEvent directly for any existing events.

func (*Sprite) On

func (sp *Sprite) On(etype events.Types, fun func(e events.Event)) *Sprite

On adds the given event handler to the sprite's Listeners for the given event type. Listeners are called in sequential descending order, so this listener will be called before all of the ones added before it.

func (*Sprite) OnClick added in v0.1.4

func (sp *Sprite) OnClick(fun func(e events.Event)) *Sprite

OnClick adds an event listener function for events.Click events

func (*Sprite) OnSlideMove added in v0.1.4

func (sp *Sprite) OnSlideMove(fun func(e events.Event)) *Sprite

OnSlideMove adds an event listener function for events.SlideMove events

func (*Sprite) OnSlideStart added in v0.1.4

func (sp *Sprite) OnSlideStart(fun func(e events.Event)) *Sprite

OnSlideStart adds an event listener function for events.SlideStart events

func (*Sprite) OnSlideStop added in v0.1.4

func (sp *Sprite) OnSlideStop(fun func(e events.Event)) *Sprite

OnSlideStop adds an event listener function for events.SlideStop events

func (*Sprite) Send added in v0.1.4

func (sp *Sprite) Send(typ events.Types, orig ...events.Event)

Send sends an NEW event of given type to this sprite, optionally starting from values in the given original event (recommended to include where possible). Do NOT send an existing event using this method if you want the Handled state to persist throughout the call chain; call HandleEvent directly for any existing events.

func (*Sprite) SetBottomPos

func (sp *Sprite) SetBottomPos(pos image.Point)

SetBottomPos sets the sprite's bottom position to given point the Geom.Pos represents its top position

func (*Sprite) SetSize

func (sp *Sprite) SetSize(nwsz image.Point) bool

SetSize sets sprite image to given size -- makes a new image (does not resize) returns true if a new image was set

type Sprites

type Sprites struct {

	// map of uniquely named sprites
	Names ordmap.Map[string, *Sprite]

	// allocation of sprites by size for rendering
	SzAlloc szalloc.SzAlloc

	// set to true if sprites have been modified since last config
	Modified bool

	// number of active sprites
	Active int
}

Sprites manages a collection of sprites organized by size and name

func (*Sprites) ActivateSprite

func (ss *Sprites) ActivateSprite(name string)

ActivateSprite flags the sprite as active, setting Modified if wasn't before

func (*Sprites) Add

func (ss *Sprites) Add(sp *Sprite)

Add adds sprite to list, and returns the image index and layer index within that for given sprite. If name already exists on list, then it is returned, with size allocation updated as needed.

func (*Sprites) AllocSizes

func (ss *Sprites) AllocSizes()

AllocSizes allocates the sprites by size to fixed set of images and layers

func (*Sprites) ConfigSprites

func (ss *Sprites) ConfigSprites(drw system.Drawer)

ConfigSprites updates the Drawer configuration of sprites. Does a new SzAlloc, and sets corresponding images.

func (*Sprites) Delete

func (ss *Sprites) Delete(sp *Sprite)

Delete deletes sprite by name, returning indexes where it was located. All sprite images must be updated when this occurs, as indexes may have shifted.

func (*Sprites) DrawSprites

func (ss *Sprites) DrawSprites(drw system.Drawer)

DrawSprites draws sprites

func (*Sprites) HasSizeChanged

func (ss *Sprites) HasSizeChanged() bool

HasSizeChanged returns true if a sprite's size has changed relative to its last allocated value, in SzAlloc. Returns true and sets Modified flag to true if so.

func (*Sprites) InactivateAllSprites

func (ss *Sprites) InactivateAllSprites()

InactivateAllSprites inactivates all sprites, setting Modified if wasn't before

func (*Sprites) InactivateSprite

func (ss *Sprites) InactivateSprite(name string)

InactivateSprite flags the sprite as inactive, setting Modified if wasn't before

func (*Sprites) Init

func (ss *Sprites) Init()

func (*Sprites) Reset

func (ss *Sprites) Reset()

Reset removes all sprites

func (*Sprites) SpriteByName

func (ss *Sprites) SpriteByName(name string) (*Sprite, bool)

SpriteByName returns the sprite by name

type Stage

type Stage struct {
	// type of Stage: determines behavior and Styling
	Type StageTypes `set:"-"`

	// Scene contents of this Stage (what it displays).
	Scene *Scene `set:"-"`

	// widget in another scene that requested this stage to be created
	// and provides context (stage)
	Context Widget

	// Name is the name of the Stage, which is generally auto-set
	// based on the Scene Name.
	Name string

	// Title is the title of the Stage, which is generally auto-set
	// based on the Scene Title. Used for title of WindowStage and
	// DialogStage types.
	Title string

	// Modal, if true, blocks input to all other stages.
	Modal bool `set:"-"`

	// Scrim, if true, places a darkening scrim over other stages,
	// if not a full window.
	Scrim bool

	// ClickOff, if true, dismisses the Stage if user clicks anywhere
	// off the Stage.
	ClickOff bool

	// IgnoreEvents is whether to send no events to the stage and
	// just pass them down to lower stages.
	IgnoreEvents bool

	// NewWindow, if true, opens a WindowStage or DialogStage in its own
	// separate operating system window (RenderWindow).  This is true by
	// default for WindowStage on non-mobile platforms, otherwise false.
	NewWindow bool

	// FullWindow, if NewWindow is false, makes DialogStages and
	// WindowStages take up the entire window they are created in.
	FullWindow bool

	// CloseOnBack is whether to close the stage when the back button
	// is pressed in the app bar. Otherwise, it goes back to the next
	// stage but keeps this one open. This is on by default for
	// DialogStages and off for WindowStages.
	CloseOnBack bool

	// Closeable, if true, includes a close button for closing dialogs.
	Closeable bool

	// Movable, if true, adds a handle titlebar Decor for moving dialogs.
	Movable bool

	// Resizable, if true, adds a resize handle Decor for resizing dialogs.
	Resizable bool

	// Timeout, if greater than 0, results in a popup stages disappearing
	// after a timeout duration.
	Timeout time.Duration

	// Pos is the target position for Scene to be placed within RenderWindow.
	Pos image.Point

	// Data is item represented by this main stage; used for recycling windows
	Data any

	// If a popup stage, this is the main stage that owns it (via its Popups).
	// If a main stage, it points to itself.
	Main *Stage

	// For main stages, this is the stack of the popups within it
	// (created specifically for the main stage).
	// For popups, this is the pointer to the Popups within the
	// main stage managing it.
	Popups *Stages `set:"-"`

	// For all stages, this is the main [Stages] that lives in a [RenderWindow]
	// and manages the main stages.
	Mains *Stages `set:"-"`

	// rendering context which has info about the RenderWindow onto which we render.
	// This should be used instead of the RenderWindow itself for all relevant
	// rendering information.  This is only available once a Stage is Run,
	// and must always be checked for nil.
	RenderContext *RenderContext

	// sprites are named images that are rendered last overlaying everything else.
	Sprites Sprites `json:"-" xml:"-"`

	// name of sprite that is being dragged -- sprite event function is responsible for setting this.
	SpriteDragging string `json:"-" xml:"-"`
}

Stage is a container and manager for displaying a Scene in different functional ways, defined by StageTypes, in two categories: Main types (WindowStage and DialogStage) and Popup types (Menu, Tooltip, Snackbar, Chooser).

func NewMainStage

func NewMainStage(typ StageTypes, sc *Scene) *Stage

NewMainStage returns a new MainStage with given type and scene contents. Make further configuration choices using Set* methods, which can be chained directly after the NewMainStage call. Use an appropriate Run call at the end to start the Stage running.

func NewMenu

func NewMenu(menu func(m *Scene), ctx Widget, pos image.Point) *Stage

NewMenu returns a new menu stage based on the given menu constructor function, in connection with given widget, which provides key context for constructing the menu at given RenderWindow position (e.g., use ContextMenuPos or WinPos method on ctx Widget). Make further configuration choices using Set* methods, which can be chained directly after the New call. Use Run call at the end to start the Stage running.

func NewMenuStage

func NewMenuStage(sc *Scene, ctx Widget, pos image.Point) *Stage

NewMenuStage returns a new Menu stage with given scene contents, in connection with given widget, which provides key context for constructing the menu, at given RenderWindow position (e.g., use ContextMenuPos or WinPos method on ctx Widget). Make further configuration choices using Set* methods, which can be chained directly after the New call. Use Run call at the end to start the Stage running.

func NewPopupStage

func NewPopupStage(typ StageTypes, sc *Scene, ctx Widget) *Stage

NewPopupStage returns a new PopupStage with given type and scene contents. The given context widget must be non-nil. Make further configuration choices using Set* methods, which can be chained directly after the NewPopupStage call. Use Run call at the end to start the Stage running.

func NewTooltip

func NewTooltip(w Widget, tooltip string, pos image.Point) *Stage

NewTooltip returns a new tooltip stage displaying the given tooltip text for the given widget based at the given window-level position, with the size defaulting to the size of the widget.

func NewTooltipFromScene

func NewTooltipFromScene(sc *Scene, ctx Widget) *Stage

NewTooltipFromScene returns a new Tooltip stage with given scene contents, in connection with given widget (which provides key context). Make further configuration choices using Set* methods, which can be chained directly after the New call. Use an appropriate Run call at the end to start the Stage running.

func NewTooltipTextSize added in v0.1.3

func NewTooltipTextSize(w Widget, tooltip string, pos, sz image.Point) *Stage

NewTooltipTextSize returns a new tooltip stage displaying the given tooltip text for the given widget at the given window-level position with the given size.

func (*Stage) ClosePopup

func (st *Stage) ClosePopup() bool

ClosePopup closes this stage as a popup, returning whether it was closed.

func (*Stage) ClosePopupAndBelow

func (st *Stage) ClosePopupAndBelow() bool

ClosePopupAndBelow closes this stage as a popup, and all those immediately below it of the same type. It returns whether it successfully closed popups.

func (*Stage) ClosePopupAndBelowAsync

func (st *Stage) ClosePopupAndBelowAsync() bool

ClosePopupAndBelowAsync closes this stage as a popup, and all those immediately below it of the same type. This version is for Asynchronous usage outside the main event loop, for example in a delayed callback AfterFunc etc. It returns whether it successfully closed popups.

func (*Stage) ClosePopupAsync

func (st *Stage) ClosePopupAsync()

ClosePopupAsync closes this stage as a popup. This version is for Asynchronous usage outside the main event loop, for example in a delayed callback AfterFunc etc.

func (*Stage) ConfigMainStage

func (st *Stage) ConfigMainStage()

ConfigMainStage does main-stage configuration steps

func (*Stage) Delete

func (st *Stage) Delete()

func (*Stage) DoUpdate

func (st *Stage) DoUpdate() (stageMods, sceneMods bool)

DoUpdate calls DoUpdate on our Scene and UpdateAll on our Popups for Main types. returns stageMods = true if any Popup Stages have been modified and sceneMods = true if any Scenes have been modified.

func (*Stage) FirstWindowStages added in v0.1.1

func (st *Stage) FirstWindowStages() *Stages

FirstWindowStages creates a temporary Stages for the first window to be able to get sizing information prior to having a RenderWindow, based on the system App Screen Size. Only adds a RenderContext.

func (*Stage) GetValidContext

func (st *Stage) GetValidContext() bool

GetValidContext ensures that the Context is non-nil and has a valid Scene pointer, using CurrentRenderWindow if the current Context is not valid. If CurrentRenderWindow is nil (should not happen), then it returns false and the calling function must bail.

func (*Stage) InheritBars

func (st *Stage) InheritBars()

func (*Stage) MainHandleEvent

func (st *Stage) MainHandleEvent(e events.Event)

MainHandleEvent handles main stage events

func (*Stage) NewRenderWindow added in v0.1.1

func (st *Stage) NewRenderWindow() *RenderWindow

func (*Stage) PopupHandleEvent

func (st *Stage) PopupHandleEvent(e events.Event)

func (*Stage) Raise

func (st *Stage) Raise()

Raise moves the Stage to the top of its main Stages and raises the RenderWindow it is in if necessary.

func (*Stage) Run

func (st *Stage) Run() *Stage

Run runs the stage using the default run behavior based on the type of stage.

func (*Stage) RunDialog

func (st *Stage) RunDialog() *Stage

RunDialog runs a Dialog with current settings.

func (*Stage) RunImpl

func (st *Stage) RunImpl() *Stage

RunImpl is the implementation of Stage.Run; it should not typically be called by end-users.

func (*Stage) RunPopup

func (st *Stage) RunPopup() *Stage

RunPopup runs a popup-style Stage in context widget's popups.

func (*Stage) RunPopupAsync

func (st *Stage) RunPopupAsync() *Stage

RunPopupAsync runs a popup-style Stage in context widget's popups. This version is for Asynchronous usage outside the main event loop, for example in a delayed callback AfterFunc etc.

func (*Stage) RunWindow

func (st *Stage) RunWindow() *Stage

RunWindow runs a Window with current settings.

func (*Stage) SetClickOff

func (t *Stage) SetClickOff(v bool) *Stage

SetClickOff sets the [Stage.ClickOff]: ClickOff, if true, dismisses the Stage if user clicks anywhere off the Stage.

func (*Stage) SetCloseOnBack

func (t *Stage) SetCloseOnBack(v bool) *Stage

SetCloseOnBack sets the [Stage.CloseOnBack]: CloseOnBack is whether to close the stage when the back button is pressed in the app bar. Otherwise, it goes back to the next stage but keeps this one open. This is on by default for DialogStages and off for WindowStages.

func (*Stage) SetCloseable

func (t *Stage) SetCloseable(v bool) *Stage

SetCloseable sets the [Stage.Closeable]: Closeable, if true, includes a close button for closing dialogs.

func (*Stage) SetContext

func (t *Stage) SetContext(v Widget) *Stage

SetContext sets the [Stage.Context]: widget in another scene that requested this stage to be created and provides context (stage)

func (*Stage) SetData

func (t *Stage) SetData(v any) *Stage

SetData sets the [Stage.Data]: Data is item represented by this main stage; used for recycling windows

func (*Stage) SetFullWindow

func (t *Stage) SetFullWindow(v bool) *Stage

SetFullWindow sets the [Stage.FullWindow]: FullWindow, if NewWindow is false, makes DialogStages and WindowStages take up the entire window they are created in.

func (*Stage) SetIgnoreEvents

func (t *Stage) SetIgnoreEvents(v bool) *Stage

SetIgnoreEvents sets the [Stage.IgnoreEvents]: IgnoreEvents is whether to send no events to the stage and just pass them down to lower stages.

func (*Stage) SetMain

func (t *Stage) SetMain(v *Stage) *Stage

SetMain sets the [Stage.Main]: If a popup stage, this is the main stage that owns it (via its Popups). If a main stage, it points to itself.

func (*Stage) SetMains added in v0.1.1

func (st *Stage) SetMains(sm *Stages) *Stage

SetMains sets the [Stage.Mains] to the given stack of main stages, and also sets the RenderContext from that.

func (*Stage) SetModal

func (st *Stage) SetModal(modal bool) *Stage

SetModal sets modal flag for blocking other input (for dialogs). Also updates Scrim accordingly if not modal.

func (*Stage) SetMovable

func (t *Stage) SetMovable(v bool) *Stage

SetMovable sets the [Stage.Movable]: Movable, if true, adds a handle titlebar Decor for moving dialogs.

func (*Stage) SetName

func (t *Stage) SetName(v string) *Stage

SetName sets the [Stage.Name]: Name is the name of the Stage, which is generally auto-set based on the Scene Name.

func (*Stage) SetNameFromScene

func (st *Stage) SetNameFromScene() *Stage

SetNameFromString sets the name of this Stage based on existing Scene and Type settings.

func (*Stage) SetNewWindow

func (t *Stage) SetNewWindow(v bool) *Stage

SetNewWindow sets the [Stage.NewWindow]: NewWindow, if true, opens a WindowStage or DialogStage in its own separate operating system window (RenderWindow). This is true by default for WindowStage on non-mobile platforms, otherwise false.

func (*Stage) SetPopups added in v0.1.1

func (st *Stage) SetPopups(mainSt *Stage) *Stage

SetPopups sets the [Stage.Popups] and [Stage.Mains] from the given main stage to which this popup stage belongs.

func (*Stage) SetPos

func (t *Stage) SetPos(v image.Point) *Stage

SetPos sets the [Stage.Pos]: Pos is the target position for Scene to be placed within RenderWindow.

func (*Stage) SetRenderContext

func (t *Stage) SetRenderContext(v *RenderContext) *Stage

SetRenderContext sets the [Stage.RenderContext]: rendering context which has info about the RenderWindow onto which we render. This should be used instead of the RenderWindow itself for all relevant rendering information. This is only available once a Stage is Run, and must always be checked for nil.

func (*Stage) SetResizable

func (t *Stage) SetResizable(v bool) *Stage

SetResizable sets the [Stage.Resizable]: Resizable, if true, adds a resize handle Decor for resizing dialogs.

func (*Stage) SetScene

func (st *Stage) SetScene(sc *Scene) *Stage

func (*Stage) SetScrim

func (t *Stage) SetScrim(v bool) *Stage

SetScrim sets the [Stage.Scrim]: Scrim, if true, places a darkening scrim over other stages, if not a full window.

func (*Stage) SetSpriteDragging

func (t *Stage) SetSpriteDragging(v string) *Stage

SetSpriteDragging sets the [Stage.SpriteDragging]: name of sprite that is being dragged -- sprite event function is responsible for setting this.

func (*Stage) SetSprites

func (t *Stage) SetSprites(v Sprites) *Stage

SetSprites sets the [Stage.Sprites]: sprites are named images that are rendered last overlaying everything else.

func (*Stage) SetTimeout

func (t *Stage) SetTimeout(v time.Duration) *Stage

SetTimeout sets the [Stage.Timeout]: Timeout, if greater than 0, results in a popup stages disappearing after a timeout duration.

func (*Stage) SetTitle

func (t *Stage) SetTitle(v string) *Stage

SetTitle sets the [Stage.Title]: Title is the title of the Stage, which is generally auto-set based on the Scene Title. Used for title of WindowStage and DialogStage types.

func (*Stage) SetType

func (st *Stage) SetType(typ StageTypes) *Stage

SetType sets the type and also sets default parameters based on that type

func (*Stage) String

func (st *Stage) String() string

func (*Stage) Wait

func (st *Stage) Wait()

Wait waits for all windows to close and runs the main app loop. This should be put at the end of the main function.

type StageTypes

type StageTypes int32 //enums:enum

StageTypes are the types of Stage containers. There are two main categories: MainStage and PopupStage. MainStage are WindowStage and DialogStage: large and potentially complex Scenes that persist until dismissed, and can have Decor widgets that control display. PopupStage are Menu, Tooltip, Snackbar, Chooser that are transitory and simple, without additional decor. MainStages live in a Stages associated with a RenderWindow window, and manage their own set of PopupStages via another Stages.

const (
	// WindowStage is a MainStage that displays a Scene in a full window.
	// One of these must be created first, as the primary App contents,
	// and it typically persists throughout.  It fills the RenderWindow window.
	// Additional Windows can be created either within the same RenderWin
	// (Mobile) or in separate RenderWindow windows (Desktop, NewWindow).
	WindowStage StageTypes = iota

	// DialogStage is a MainStage that displays Scene in a smaller dialog window
	// on top of a Window, or in its own RenderWindow (on Desktop only).
	// It can be Modal or not.
	DialogStage

	// MenuStage is a PopupStage that displays a Scene with Action Widgets
	// overlaid on a MainStage.
	// It is typically Modal and ClickOff, and closes when
	// an Action is selected.
	MenuStage

	// TooltipStage is a PopupStage that displays a Scene with extra info
	// overlaid on a MainStage.
	// It is typically ClickOff and not Modal.
	TooltipStage

	// SnackbarStage is a PopupStage displays a Scene with info and typically
	// an additional optional Action, usually displayed at the bottom.
	// It is typically not ClickOff or Modal, but has a timeout.
	SnackbarStage

	// CompleterStage is a PopupStage that displays a Scene with text completions,
	// spelling corrections, or other such dynamic info.
	// It is typically ClickOff, not Modal, dynamically updating,
	// and closes when something is selected or typing renders
	// it no longer relevant.
	CompleterStage
)
const StageTypesN StageTypes = 6

StageTypesN is the highest valid value for type StageTypes, plus one.

func StageTypesValues

func StageTypesValues() []StageTypes

StageTypesValues returns all possible values for the type StageTypes.

func (StageTypes) Desc

func (i StageTypes) Desc() string

Desc returns the description of the StageTypes value.

func (StageTypes) Int64

func (i StageTypes) Int64() int64

Int64 returns the StageTypes value as an int64.

func (StageTypes) IsMain

func (st StageTypes) IsMain() bool

IsMain returns true if this type of Stage is a Main stage that manages its own set of popups

func (StageTypes) IsPopup

func (st StageTypes) IsPopup() bool

IsPopup returns true if this type of Stage is a Popup, managed by another Main stage.

func (StageTypes) MarshalText

func (i StageTypes) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*StageTypes) SetInt64

func (i *StageTypes) SetInt64(in int64)

SetInt64 sets the StageTypes value from an int64.

func (*StageTypes) SetString

func (i *StageTypes) SetString(s string) error

SetString sets the StageTypes value from its string representation, and returns an error if the string is invalid.

func (StageTypes) String

func (i StageTypes) String() string

String returns the string representation of this StageTypes value.

func (*StageTypes) UnmarshalText

func (i *StageTypes) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (StageTypes) Values

func (i StageTypes) Values() []enums.Enum

Values returns all possible values for the type StageTypes.

type Stages added in v0.1.1

type Stages struct {
	// stack of stages managed by this stage manager.
	Stack ordmap.Map[string, *Stage] `set:"-"`

	// Modified is set to true whenever the stack has been modified.
	// This is cleared by the RenderWindow each render cycle.
	Modified bool

	// rendering context provides key rendering information and locking
	// for the RenderWindow in which the stages are running.
	RenderContext *RenderContext

	// render window to which we are rendering.
	// rely on the RenderContext wherever possible.
	RenderWindow *RenderWindow

	// growing stack of viewing history of all stages.
	History []*Stage `set:"-"`

	// Main is the main stage that owns this [Stages].
	// This is only set for popup stages.
	Main *Stage

	// mutex protecting reading / updating of the Stack.
	// Destructive stack updating gets a Write lock, else Read.
	Mu sync.RWMutex `display:"-" set:"-"`
}

Stages manages a stack of Stages.

func (*Stages) DeleteAll added in v0.1.1

func (sm *Stages) DeleteAll()

DeleteAll deletes all of the stages. For when Stage with Popups is Deleted, or when a RenderWindow is closed. requires outer RenderContext mutex!

func (*Stages) DeleteStage added in v0.1.1

func (sm *Stages) DeleteStage(st *Stage) bool

DeleteStage deletes given stage (removing from stack, calling Delete on Stage), returning true if found. It runs under Write lock.

func (*Stages) DeleteStageAndBelow added in v0.1.1

func (sm *Stages) DeleteStageAndBelow(st *Stage) bool

DeleteStageAndBelow deletes given stage (removing from stack, calling Delete on Stage), returning true if found. And also deletes all stages of the same type immediately below it. It runs under Write lock.

func (*Stages) MainHandleEvent added in v0.1.1

func (sm *Stages) MainHandleEvent(e events.Event)

MainHandleEvent calls MainHandleEvent on relevant stages in reverse order.

func (*Stages) MoveToTop added in v0.1.1

func (sm *Stages) MoveToTop(st *Stage) bool

MoveToTop moves the given stage to the top of the stack, returning true if found. It runs under Write lock.

func (*Stages) Pop added in v0.1.1

func (sm *Stages) Pop() *Stage

Pop pops current Stage off the stack, returning it or nil if none. It runs under Write lock.

func (*Stages) PopDelete added in v0.1.1

func (sm *Stages) PopDelete()

PopDelete pops current top--most Stage off the stack and calls Delete on it.

func (*Stages) PopDeleteType added in v0.1.1

func (sm *Stages) PopDeleteType(typ StageTypes)

PopDeleteType pops the top-most Stage of the given type off the stack and calls Delete on it.

func (*Stages) PopType added in v0.1.1

func (sm *Stages) PopType(typ StageTypes) *Stage

PopType pops the top-most Stage of the given type of the stack, returning it or nil if none. It runs under Write lock.

func (*Stages) PopupHandleEvent added in v0.1.1

func (pm *Stages) PopupHandleEvent(e events.Event)

PopupHandleEvent processes Popup events. requires outer RenderContext mutex.

func (*Stages) Push added in v0.1.1

func (sm *Stages) Push(st *Stage)

Push pushes a new Stage to top, under Write lock

func (*Stages) Resize added in v0.1.1

func (sm *Stages) Resize(rg math32.Geom2DInt)

Resize calls Resize on all stages within based on the given window render geom.

func (*Stages) SendShowEvents added in v0.1.1

func (sm *Stages) SendShowEvents()

func (*Stages) Top added in v0.1.1

func (sm *Stages) Top() *Stage

Top returns the top-most Stage in the Stack, under Read Lock

func (*Stages) TopIsModal added in v0.1.1

func (pm *Stages) TopIsModal() bool

TopIsModal returns true if there is a Top PopupStage and it is Modal.

func (*Stages) TopNotType added in v0.1.1

func (sm *Stages) TopNotType(typ StageTypes) *Stage

TopNotType returns the top-most Stage in the Stack that is NOT the given type, under Read Lock

func (*Stages) TopOfType added in v0.1.1

func (sm *Stages) TopOfType(typ StageTypes) *Stage

TopOfType returns the top-most Stage in the Stack of the given type, under Read Lock

func (*Stages) UniqueName added in v0.1.1

func (sm *Stages) UniqueName(nm string) string

UniqueName returns unique name for given item

func (*Stages) UpdateAll added in v0.1.1

func (sm *Stages) UpdateAll() (stageMods, sceneMods bool)

UpdateAll iterates through all Stages and calls DoUpdate on them. returns stageMods = true if any Stages have been modified (Main or Popup), and sceneMods = true if any Scenes have been modified. Stage calls DoUpdate on its Scene, ensuring everything is updated at the Widget level. If nothing is needed, nothing is done. This is called only during RenderWindow.RenderWindow, under the global RenderContext.Mu Write lock so nothing else can happen.

type Stretch

type Stretch struct {
	WidgetBase
}

Stretch adds a stretchy element that grows to fill all available space. You can set styles.Style.Grow to change how much it grows relative to other growing elements. It does not render anything.

func NewStretch

func NewStretch(parent ...tree.Node) *Stretch

NewStretch returns a new Stretch with the given optional parent: Stretch adds a stretchy element that grows to fill all available space. You can set styles.Style.Grow to change how much it grows relative to other growing elements. It does not render anything.

func (*Stretch) Init added in v0.2.0

func (st *Stretch) Init()

func (*Stretch) New

func (t *Stretch) New() tree.Node

New returns a new *Stretch value

func (*Stretch) NodeType

func (t *Stretch) NodeType() *types.Type

NodeType returns the *types.Type of Stretch

type Switch

type Switch struct {
	Frame

	// Type is the styling type of switch.
	Type SwitchTypes `set:"-"`

	// Text is the text for the switch.
	Text string

	// IconOn is the icon to use for the on, checked state of the switch.
	IconOn icons.Icon `display:"show-name"`

	// Iconoff is the icon to use for the off, unchecked state of the switch.
	IconOff icons.Icon `display:"show-name"`

	// IconIndeterminate is the icon to use for the indeterminate (unknown) state.
	IconIndeterminate icons.Icon `display:"show-name"`
}

Switch is a widget that can toggle between an on and off state. It can be displayed as a switch, checkbox, or radio button.

func NewSwitch

func NewSwitch(parent ...tree.Node) *Switch

NewSwitch returns a new Switch with the given optional parent: Switch is a widget that can toggle between an on and off state. It can be displayed as a switch, checkbox, or radio button.

func (*Switch) ClearIcons

func (sw *Switch) ClearIcons() *Switch

ClearIcons sets all of the switch icons to icons.None

func (*Switch) Init added in v0.2.0

func (sw *Switch) Init()

func (*Switch) IsChecked

func (sw *Switch) IsChecked() bool

IsChecked returns whether the switch is checked.

func (*Switch) New

func (t *Switch) New() tree.Node

New returns a new *Switch value

func (*Switch) NodeType

func (t *Switch) NodeType() *types.Type

NodeType returns the *types.Type of Switch

func (*Switch) Render

func (sw *Switch) Render()

func (*Switch) SetChecked

func (sw *Switch) SetChecked(on bool) *Switch

SetChecked sets whether the switch it checked.

func (*Switch) SetIconIndeterminate

func (t *Switch) SetIconIndeterminate(v icons.Icon) *Switch

SetIconIndeterminate sets the [Switch.IconIndeterminate]: IconIndeterminate is the icon to use for the indeterminate (unknown) state.

func (*Switch) SetIconOff

func (t *Switch) SetIconOff(v icons.Icon) *Switch

SetIconOff sets the [Switch.IconOff]: Iconoff is the icon to use for the off, unchecked state of the switch.

func (*Switch) SetIconOn

func (t *Switch) SetIconOn(v icons.Icon) *Switch

SetIconOn sets the [Switch.IconOn]: IconOn is the icon to use for the on, checked state of the switch.

func (*Switch) SetIcons

func (sw *Switch) SetIcons(on, off, ind icons.Icon) *Switch

SetIcons sets the icons for the on (checked), off (unchecked) and indeterminate (unknown) states.

func (*Switch) SetText

func (t *Switch) SetText(v string) *Switch

SetText sets the [Switch.Text]: Text is the text for the switch.

func (*Switch) SetType

func (sw *Switch) SetType(typ SwitchTypes) *Switch

SetType sets the styling type of the switch

func (*Switch) SetWidgetValue added in v0.2.0

func (sw *Switch) SetWidgetValue(value any) error

func (*Switch) UpdateStackTop added in v0.2.0

func (sw *Switch) UpdateStackTop()

UpdateStackTop updates the [Frame.StackTop] of the stack in the switch according to the current icon. It is called automatically to keep the switch up-to-date.

func (*Switch) WidgetValue added in v0.2.0

func (sw *Switch) WidgetValue() any

type SwitchItem

type SwitchItem struct {

	// Value is the underlying value the switch item represents.
	Value any

	// Text is the text displayed to the user for this item.
	// If it is empty, then [labels.ToLabel] of [SwitchItem.Value]
	// is used instead.
	Text string

	// Tooltip is the tooltip displayed to the user for this item.
	Tooltip string
}

SwitchItem contains the properties of one item in a Switches.

func (*SwitchItem) GetText added in v0.2.0

func (si *SwitchItem) GetText() string

GetText returns the effective text for this switch item. If [SwitchItem.Text] is set, it returns that. Otherwise, it returns labels.ToLabel of [SwitchItem.Value].

type SwitchTypes

type SwitchTypes int32 //enums:enum -trim-prefix Switch

SwitchTypes contains the different types of [Switch]es

const (
	// SwitchSwitch indicates to display a switch as a switch (toggle slider).
	SwitchSwitch SwitchTypes = iota

	// SwitchChip indicates to display a switch as chip (like Material Design's filter chip),
	// which is typically only used in the context of [Switches].
	SwitchChip

	// SwitchCheckbox indicates to display a switch as a checkbox.
	SwitchCheckbox

	// SwitchRadioButton indicates to display a switch as a radio button.
	SwitchRadioButton

	// SwitchSegmentedButton indicates to display a segmented button, which is typically only used in
	// the context of [Switches].
	SwitchSegmentedButton
)
const SwitchTypesN SwitchTypes = 5

SwitchTypesN is the highest valid value for type SwitchTypes, plus one.

func SwitchTypesValues

func SwitchTypesValues() []SwitchTypes

SwitchTypesValues returns all possible values for the type SwitchTypes.

func (SwitchTypes) Desc

func (i SwitchTypes) Desc() string

Desc returns the description of the SwitchTypes value.

func (SwitchTypes) Int64

func (i SwitchTypes) Int64() int64

Int64 returns the SwitchTypes value as an int64.

func (SwitchTypes) MarshalText

func (i SwitchTypes) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*SwitchTypes) SetInt64

func (i *SwitchTypes) SetInt64(in int64)

SetInt64 sets the SwitchTypes value from an int64.

func (*SwitchTypes) SetString

func (i *SwitchTypes) SetString(s string) error

SetString sets the SwitchTypes value from its string representation, and returns an error if the string is invalid.

func (SwitchTypes) String

func (i SwitchTypes) String() string

String returns the string representation of this SwitchTypes value.

func (*SwitchTypes) UnmarshalText

func (i *SwitchTypes) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (SwitchTypes) Values

func (i SwitchTypes) Values() []enums.Enum

Values returns all possible values for the type SwitchTypes.

type Switches

type Switches struct {
	Frame

	// Type is the type of switches that will be made.
	Type SwitchTypes

	// Items are the items displayed to the user.
	Items []SwitchItem

	// Mutex is whether to make the items mutually exclusive
	// (checking one turns off all the others).
	Mutex bool

	// AllowNone is whether to allow the user to deselect all items.
	// It is on by default.
	AllowNone bool

	// SelectedIndexes are the indexes in [Switches.Items] of the currently
	// selected switch items.
	SelectedIndexes []int `set:"-"`
	// contains filtered or unexported fields
}

Switches is a widget for containing a set of [Switch]es. It can optionally enforce mutual exclusivity (ie: radio buttons) through the [Switches.Mutex] field. It supports binding to enums.Enum and enums.BitFlag values with appropriate properties automatically set.

func NewSwitches

func NewSwitches(parent ...tree.Node) *Switches

NewSwitches returns a new Switches with the given optional parent: Switches is a widget for containing a set of [Switch]es. It can optionally enforce mutual exclusivity (ie: radio buttons) through the [Switches.Mutex] field. It supports binding to enums.Enum and enums.BitFlag values with appropriate properties automatically set.

func (*Switches) BitFlagFromSelected added in v0.2.0

func (sw *Switches) BitFlagFromSelected(bitflag enums.BitFlagSetter)

BitFlagFromSelected sets the given bit flag value based on which switches are selected.

func (*Switches) Init added in v0.2.0

func (sw *Switches) Init()

func (*Switches) New

func (t *Switches) New() tree.Node

New returns a new *Switches value

func (*Switches) NodeType

func (t *Switches) NodeType() *types.Type

NodeType returns the *types.Type of Switches

func (*Switches) OnBind added in v0.2.0

func (sw *Switches) OnBind(value any)

func (*Switches) SelectFromBitFlag added in v0.2.0

func (sw *Switches) SelectFromBitFlag(bitflag enums.BitFlag)

SelectFromBitFlag sets which switches are selected based on the given bit flag value.

func (*Switches) SelectValue added in v0.2.0

func (sw *Switches) SelectValue(value any) error

SelectValue sets the item with the given [SwitchItem.Value] to be the only selected item.

func (*Switches) SelectedItem

func (sw *Switches) SelectedItem() *SwitchItem

SelectedItem returns the first selected (checked) switch item. It is only useful when [Switches.Mutex] is true; if it is not, use Switches.SelectedItems. If no switches are selected, it returns nil.

func (*Switches) SelectedItems

func (sw *Switches) SelectedItems() []SwitchItem

SelectedItems returns all of the currently selected (checked) switch items. If [Switches.Mutex] is true, you should use Switches.SelectedItem instead.

func (*Switches) SetAllowNone added in v0.2.0

func (t *Switches) SetAllowNone(v bool) *Switches

SetAllowNone sets the [Switches.AllowNone]: AllowNone is whether to allow the user to deselect all items. It is on by default.

func (*Switches) SetEnum

func (sw *Switches) SetEnum(enum enums.Enum) *Switches

SetEnum sets the [Switches.Items] from the enums.Enum.Values of the given enum.

func (*Switches) SetEnums

func (sw *Switches) SetEnums(es ...enums.Enum) *Switches

SetEnums sets the [Switches.Items] from the given enums.

func (*Switches) SetItems

func (t *Switches) SetItems(v ...SwitchItem) *Switches

SetItems sets the [Switches.Items]: Items are the items displayed to the user.

func (*Switches) SetMutex

func (t *Switches) SetMutex(v bool) *Switches

SetMutex sets the [Switches.Mutex]: Mutex is whether to make the items mutually exclusive (checking one turns off all the others).

func (*Switches) SetStrings

func (sw *Switches) SetStrings(ss ...string) *Switches

SetStrings sets the [Switches.Items] from the given strings.

func (*Switches) SetType

func (t *Switches) SetType(v SwitchTypes) *Switches

SetType sets the [Switches.Type]: Type is the type of switches that will be made.

func (*Switches) SetWidgetValue added in v0.2.0

func (sw *Switches) SetWidgetValue(value any) error

func (*Switches) WidgetValue added in v0.2.0

func (sw *Switches) WidgetValue() any

type SystemSettingsData

type SystemSettingsData struct {
	SettingsBase

	// text editor settings
	Editor EditorSettings

	// whether to use a 24-hour clock (instead of AM and PM)
	Clock24 bool `label:"24-hour clock"`

	// SnackbarTimeout is the default amount of time until snackbars
	// disappear (snackbars show short updates about app processes
	// at the bottom of the screen)
	SnackbarTimeout time.Duration `default:"5s"`

	// only support closing the currently selected active tab; if this is set to true, pressing the close button on other tabs will take you to that tab, from which you can close it
	OnlyCloseActiveTab bool `default:"false"`

	// the limit of file size, above which user will be prompted before opening / copying, etc.
	BigFileSize int `default:"10000000"`

	// maximum number of saved paths to save in FilePicker
	SavedPathsMax int `default:"50"`

	// extra font paths, beyond system defaults -- searched first
	FontPaths []string

	// user info, which is partially filled-out automatically if empty when settings are first created
	User User

	// favorite paths, shown in FilePickerer and also editable there
	FavPaths FavPaths

	// column to sort by in FilePicker, and :up or :down for direction -- updated automatically via FilePicker
	FilePickerSort string `display:"-"`

	// the maximum height of any menu popup panel in units of font height;
	// scroll bars are enforced beyond that size.
	MenuMaxHeight int `default:"30" min:"5" step:"1"`

	// the amount of time to wait before offering completions
	CompleteWaitDuration time.Duration `default:"0ms" min:"0ms" max:"10s" step:"10ms"`

	// the maximum number of completions offered in popup
	CompleteMaxItems int `default:"25" min:"5" step:"1"`

	// time interval for cursor blinking on and off -- set to 0 to disable blinking
	CursorBlinkTime time.Duration `default:"500ms" min:"0ms" max:"1s" step:"5ms"`

	// The amount of time to wait before trying to autoscroll again
	LayoutAutoScrollDelay time.Duration `default:"25ms" min:"1ms" step:"5ms"`

	// number of steps to take in PageUp / Down events in terms of number of items
	LayoutPageSteps int `default:"10" min:"1" step:"1"`

	// the amount of time between keypresses to combine characters into name to search for within layout -- starts over after this delay
	LayoutFocusNameTimeout time.Duration `default:"500ms" min:"0ms" max:"5s" step:"20ms"`

	// the amount of time since last focus name event to allow tab to focus on next element with same name.
	LayoutFocusNameTabTime time.Duration `default:"2s" min:"10ms" max:"10s" step:"100ms"`

	// the number of map elements at or below which an inline representation
	// of the map will be presented, which is more convenient for small #'s of properties
	MapInlineLength int `default:"2" min:"1" step:"1"`

	// the number of elemental struct fields at or below which an inline representation
	// of the struct will be presented, which is more convenient for small structs
	StructInlineLength int `default:"4" min:"2" step:"1"`

	// the number of slice elements below which inline will be used
	SliceInlineLength int `default:"4" min:"2" step:"1"`
}

SystemSettingsData is the data type of the global Cogent Core settings.

func (*SystemSettingsData) Apply

func (ss *SystemSettingsData) Apply()

Apply detailed settings to all the relevant settings.

func (*SystemSettingsData) Defaults

func (ss *SystemSettingsData) Defaults()

func (*SystemSettingsData) Open

func (ss *SystemSettingsData) Open() error

func (*SystemSettingsData) TimeFormat

func (ss *SystemSettingsData) TimeFormat() string

TimeFormat returns the Go time format layout string that should be used for displaying times to the user, based on the value of [SystemSettingsData.Clock24].

func (*SystemSettingsData) UpdateUser

func (ss *SystemSettingsData) UpdateUser()

UpdateUser gets the user info from the OS

type Tab

type Tab struct {
	Frame

	// Type is the styling type of the tab. This property
	// must be set on the parent [Tabs] for it to work correctly.
	Type TabTypes

	// Text is the text for the tab.
	// If it is nil, no text is shown.
	// Text is never shown for [NavigationRail] tabs.
	Text string

	// Icon is the icon for the tab.
	// If it is "" or [icons.None], no icon is shown.
	Icon icons.Icon

	// CloseIcon is the icon used as a close button for the tab.
	// If it is "" or [icons.None], the tab is not closeable.
	// The default value is [icons.Close].
	// Only [FunctionalTabs] can be closed; all other types of
	// tabs will not render a close button and can not be closed.
	CloseIcon icons.Icon

	// MaxChars is the maximum number of characters to include in tab text.
	// It elides text that is longer than that.
	MaxChars int
}

Tab is a tab button that contains any, all, or none of a label, an icon, and a close icon. Tabs should be made using the Tabs.NewTab function.

func (*Tab) Init added in v0.2.0

func (tb *Tab) Init()

func (*Tab) New

func (t *Tab) New() tree.Node

New returns a new *Tab value

func (*Tab) NodeType

func (t *Tab) NodeType() *types.Type

NodeType returns the *types.Type of Tab

func (*Tab) SetCloseIcon

func (t *Tab) SetCloseIcon(v icons.Icon) *Tab

SetCloseIcon sets the [Tab.CloseIcon]: CloseIcon is the icon used as a close button for the tab. If it is "" or icons.None, the tab is not closeable. The default value is icons.Close. Only FunctionalTabs can be closed; all other types of tabs will not render a close button and can not be closed.

func (*Tab) SetIcon

func (t *Tab) SetIcon(v icons.Icon) *Tab

SetIcon sets the [Tab.Icon]: Icon is the icon for the tab. If it is "" or icons.None, no icon is shown.

func (*Tab) SetMaxChars

func (t *Tab) SetMaxChars(v int) *Tab

SetMaxChars sets the [Tab.MaxChars]: MaxChars is the maximum number of characters to include in tab text. It elides text that is longer than that.

func (*Tab) SetText

func (t *Tab) SetText(v string) *Tab

SetText sets the [Tab.Text]: Text is the text for the tab. If it is nil, no text is shown. Text is never shown for NavigationRail tabs.

func (*Tab) SetType

func (t *Tab) SetType(v TabTypes) *Tab

SetType sets the [Tab.Type]: Type is the styling type of the tab. This property must be set on the parent Tabs for it to work correctly.

func (*Tab) Tabs

func (tb *Tab) Tabs() *Tabs

Tabs returns the parent Tabs of this Tab.

type TabTypes

type TabTypes int32 //enums:enum

TabTypes are the different styling types of tabs.

const (
	// StandardTabs indicates to render the standard type
	// of Material Design style tabs.
	StandardTabs TabTypes = iota

	// FunctionalTabs indicates to render functional tabs
	// like those in Google Chrome. These tabs take up less
	// space and are the only kind that can be closed.
	// They can also be moved.
	FunctionalTabs

	// NavigationAuto indicates to render the tabs as either
	// [NavigationBar], [NavigationRail], or [NavigationDrawer],
	// if [WidgetBase.SizeClass] is [SizeCompact], [SizeMedium],
	// or [SizeExpanded], respectively. NavigationAuto should
	// typically be used instead of one of the specific navigation
	// types for better cross-platform compatability.
	NavigationAuto

	// NavigationBar indicates to render the tabs as a
	// bottom navigation bar with text and icons.
	NavigationBar

	// NavigationRail indicates to render the tabs as a
	// side navigation rail, which only has icons.
	NavigationRail

	// NavigationDrawer indicates to render the tabs as a
	// side navigation drawer, which has full text and icons.
	NavigationDrawer
)
const TabTypesN TabTypes = 6

TabTypesN is the highest valid value for type TabTypes, plus one.

func TabTypesValues

func TabTypesValues() []TabTypes

TabTypesValues returns all possible values for the type TabTypes.

func (TabTypes) Desc

func (i TabTypes) Desc() string

Desc returns the description of the TabTypes value.

func (TabTypes) Effective

func (tt TabTypes) Effective(w Widget) TabTypes

EffectiveType returns the effective tab type in the context of the given widget, handling NavigationAuto based on WidgetBase.SizeClass.

func (TabTypes) Int64

func (i TabTypes) Int64() int64

Int64 returns the TabTypes value as an int64.

func (TabTypes) IsColumn

func (tt TabTypes) IsColumn() bool

IsColumn returns whether the tabs should be arranged in a column.

func (TabTypes) MarshalText

func (i TabTypes) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*TabTypes) SetInt64

func (i *TabTypes) SetInt64(in int64)

SetInt64 sets the TabTypes value from an int64.

func (*TabTypes) SetString

func (i *TabTypes) SetString(s string) error

SetString sets the TabTypes value from its string representation, and returns an error if the string is invalid.

func (TabTypes) String

func (i TabTypes) String() string

String returns the string representation of this TabTypes value.

func (*TabTypes) UnmarshalText

func (i *TabTypes) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (TabTypes) Values

func (i TabTypes) Values() []enums.Enum

Values returns all possible values for the type TabTypes.

type Table added in v0.2.0

type Table struct {
	ListBase

	// StyleFunc is an optional styling function.
	StyleFunc TableStyleFunc `copier:"-" display:"-" json:"-" xml:"-"`

	// SelectedField is the current selection field; initially select value in this field.
	SelectedField string `copier:"-" display:"-" json:"-" xml:"-"`

	// SortIndex is the current sort index.
	SortIndex int

	// SortDescending is whether the current sort order is descending.
	SortDescending bool
	// contains filtered or unexported fields
}

Table represents a slice of structs as a table, where the fields are the columns and the elements are the rows. It is a full-featured editor with multiple-selection, cut-and-paste, and drag-and-drop. Use ListBase.BindSelect to make the table designed for item selection.

func NewTable added in v0.2.0

func NewTable(parent ...tree.Node) *Table

NewTable returns a new Table with the given optional parent: Table represents a slice of structs as a table, where the fields are the columns and the elements are the rows. It is a full-featured editor with multiple-selection, cut-and-paste, and drag-and-drop. Use ListBase.BindSelect to make the table designed for item selection.

func (*Table) ContextMenu added in v0.2.0

func (tb *Table) ContextMenu(m *Scene)

func (*Table) EditIndex added in v0.2.0

func (tb *Table) EditIndex(idx int)

func (*Table) HasStyleFunc added in v0.2.0

func (tb *Table) HasStyleFunc() bool

func (*Table) Init added in v0.2.0

func (tb *Table) Init()

func (*Table) MakeHeader added in v0.2.0

func (tb *Table) MakeHeader(p *tree.Plan)

func (*Table) MakeRow added in v0.2.0

func (tb *Table) MakeRow(p *tree.Plan, i int)

func (*Table) New added in v0.2.0

func (t *Table) New() tree.Node

New returns a new *Table value

func (*Table) NodeType added in v0.2.0

func (t *Table) NodeType() *types.Type

NodeType returns the *types.Type of Table

func (*Table) RowFirstVisWidget added in v0.2.0

func (tb *Table) RowFirstVisWidget(row int) (*WidgetBase, bool)

RowFirstVisWidget returns the first visible widget for given row (could be index or not) -- false if out of range

func (*Table) RowGrabFocus added in v0.2.0

func (tb *Table) RowGrabFocus(row int) *WidgetBase

RowGrabFocus grabs the focus for the first focusable widget in given row -- returns that element or nil if not successful -- note: grid must have already rendered for focus to be grabbed!

func (*Table) RowWidgetNs added in v0.2.0

func (tb *Table) RowWidgetNs() (nWidgPerRow, idxOff int)

RowWidgetNs returns number of widgets per row and offset for index label

func (*Table) SelectFieldVal added in v0.2.0

func (tb *Table) SelectFieldVal(fld, val string) bool

SelectFieldVal sets SelField and SelVal and attempts to find corresponding row, setting SelectedIndex and selecting row if found -- returns true if found, false otherwise

func (*Table) SetSelectedField added in v0.2.0

func (t *Table) SetSelectedField(v string) *Table

SetSelectedField sets the [Table.SelectedField]: SelectedField is the current selection field; initially select value in this field.

func (*Table) SetSlice added in v0.2.0

func (tb *Table) SetSlice(sl any) *Table

SetSlice sets the source slice that we are viewing. Must call Update if already open.

func (*Table) SetSortDescending added in v0.2.0

func (t *Table) SetSortDescending(v bool) *Table

SetSortDescending sets the [Table.SortDescending]: SortDescending is whether the current sort order is descending.

func (*Table) SetSortFieldName added in v0.2.0

func (tb *Table) SetSortFieldName(nm string)

SetSortFieldName sets sorting to happen on given field and direction -- see SortFieldName for details

func (*Table) SetSortIndex added in v0.2.0

func (t *Table) SetSortIndex(v int) *Table

SetSortIndex sets the [Table.SortIndex]: SortIndex is the current sort index.

func (*Table) SetStyleFunc added in v0.2.0

func (t *Table) SetStyleFunc(v TableStyleFunc) *Table

SetStyleFunc sets the [Table.StyleFunc]: StyleFunc is an optional styling function.

func (*Table) SizeFinal added in v0.2.0

func (tb *Table) SizeFinal()

func (*Table) SliceDeleteAt added in v0.2.0

func (tb *Table) SliceDeleteAt(idx int)

SliceDeleteAt deletes element at given index from slice

func (*Table) SliceHeader added in v0.2.0

func (tb *Table) SliceHeader() *Frame

SliceHeader returns the Frame header for slice grid

func (*Table) SliceNewAt added in v0.2.0

func (tb *Table) SliceNewAt(idx int)

SliceNewAt inserts a new blank element at given index in the slice -- -1 means the end

func (*Table) SortFieldName added in v0.2.0

func (tb *Table) SortFieldName() string

SortFieldName returns the name of the field being sorted, along with :up or :down depending on descending

func (*Table) SortSlice added in v0.2.0

func (tb *Table) SortSlice()

SortSlice sorts the slice according to current settings

func (*Table) SortSliceAction added in v0.2.0

func (tb *Table) SortSliceAction(fldIndex int)

SortSliceAction sorts the slice for given field index -- toggles ascending vs. descending if already sorting on this dimension

func (*Table) StyleRow added in v0.2.0

func (tb *Table) StyleRow(w Widget, idx, fidx int)

func (*Table) StyleValue added in v0.2.0

func (tb *Table) StyleValue(w Widget, s *styles.Style, row, col int)

StyleValue performs additional value widget styling

func (*Table) UpdateMaxWidths added in v0.2.0

func (tb *Table) UpdateMaxWidths()

type TableStyleFunc added in v0.2.0

type TableStyleFunc func(w Widget, s *styles.Style, row, col int)

TableStyleFunc is a styling function for custom styling and configuration of elements in the table.

type Tabs

type Tabs struct {
	Frame

	// Type is the styling type of the tabs. If it is changed after
	// the tabs are first configured, Update needs to be called on
	// the tabs.
	Type TabTypes

	// NewTabButton is whether to show a new tab button at the end of the list of tabs.
	NewTabButton bool

	// MaxChars is the maximum number of characters to include in the tab text.
	// It elides text that are longer than that.
	MaxChars int

	// CloseIcon is the icon used for tab close buttons.
	// If it is "" or [icons.None], the tab is not closeable.
	// The default value is [icons.Close].
	// Only [FunctionalTabs] can be closed; all other types of
	// tabs will not render a close button and can not be closed.
	CloseIcon icons.Icon

	// PrevEffectiveType is the previous effective type of the tabs
	// as computed by [TabTypes.Effective].
	PrevEffectiveType TabTypes `copier:"-" json:"-" xml:"-" set:"-"`

	// Mu is a mutex protecting updates to tabs. Tabs can be driven
	// programmatically and via user input so need extra protection.
	Mu sync.Mutex `copier:"-" json:"-" xml:"-" display:"-" set:"-"`
}

Tabs divide widgets into logical groups and give users the ability to freely navigate between them using tab buttons.

func NewTabs

func NewTabs(parent ...tree.Node) *Tabs

NewTabs returns a new Tabs with the given optional parent: Tabs divide widgets into logical groups and give users the ability to freely navigate between them using tab buttons.

func (*Tabs) AddTab

func (ts *Tabs) AddTab(frame *Frame, label string) int

AddTab adds an already existing frame as a new tab with the given tab label and returns the index of that tab.

func (*Tabs) CurrentTab added in v0.2.0

func (ts *Tabs) CurrentTab() (Widget, int)

CurrentTab returns currently selected tab and its index; returns nil if none.

func (*Tabs) DeleteTabIndex

func (ts *Tabs) DeleteTabIndex(idx int) bool

DeleteTabIndex deletes tab at given index, returning whether it was successful.

func (*Tabs) FrameWidget added in v0.2.0

func (ts *Tabs) FrameWidget() *Frame

Frame returns the stacked frame layout (the second element within us). It configures the Tabs if necessary.

func (*Tabs) Init added in v0.2.0

func (ts *Tabs) Init()

func (*Tabs) InsertNewTab

func (ts *Tabs) InsertNewTab(label string, idx int, icon ...icons.Icon) *Frame

InsertNewTab inserts a new tab with the given label at the given index position within the list of tabs and returns the resulting tab frame. An optional icon can also be passed for the tab button.

func (*Tabs) InsertTab

func (ts *Tabs) InsertTab(frame *Frame, label string, idx int, icon ...icons.Icon)

InsertTab inserts a frame into given index position within list of tabs. An optional icon can also be passed for the tab button.

func (*Tabs) InsertTabOnlyAt

func (ts *Tabs) InsertTabOnlyAt(frame *Frame, label string, idx int, icon ...icons.Icon)

InsertTabOnlyAt inserts just the tab button at given index, after the panel has already been added to the frame; assumed to be wrapped in update. Generally for internal use only. An optional icon can also be passed for the tab button.

func (*Tabs) New

func (t *Tabs) New() tree.Node

New returns a new *Tabs value

func (*Tabs) NewTab

func (ts *Tabs) NewTab(label string, icon ...icons.Icon) *Frame

NewTab adds a new tab with the given label and returns the resulting tab frame. It is the main end-user API for creating new tabs. An optional icon can also be passed for the tab button.

func (*Tabs) NodeType

func (t *Tabs) NodeType() *types.Type

NodeType returns the *types.Type of Tabs

func (*Tabs) NumTabs added in v0.2.0

func (ts *Tabs) NumTabs() int

NumTabs returns the number of tabs.

func (*Tabs) RecycleTab

func (ts *Tabs) RecycleTab(name string, sel bool) *Frame

RecycleTab returns a tab with given name, first by looking for an existing one, and if not found, making a new one. If sel, then select it. It returns the frame for the tab.

func (*Tabs) RecycleTabWidget

func (ts *Tabs) RecycleTabWidget(name string, sel bool, typ *types.Type) Widget

RecycleTabWidget returns a tab with given widget type in the tab frame, first by looking for an existing one, with given name, and if not found, making and configuring a new one. If sel, then select it. It returns the Widget item for the tab.

func (*Tabs) SelectTabByName

func (ts *Tabs) SelectTabByName(name string) *Frame

SelectTabByName selects tab by widget name, returning it. The widget name is the original full tab label, prior to any eliding.

func (*Tabs) SelectTabIndex

func (ts *Tabs) SelectTabIndex(idx int) (*Frame, bool)

SelectTabIndex selects tab at given index, returning it. Returns false if index is invalid. This is the final tab selection path.

func (*Tabs) SetCloseIcon

func (t *Tabs) SetCloseIcon(v icons.Icon) *Tabs

SetCloseIcon sets the [Tabs.CloseIcon]: CloseIcon is the icon used for tab close buttons. If it is "" or icons.None, the tab is not closeable. The default value is icons.Close. Only FunctionalTabs can be closed; all other types of tabs will not render a close button and can not be closed.

func (*Tabs) SetMaxChars

func (t *Tabs) SetMaxChars(v int) *Tabs

SetMaxChars sets the [Tabs.MaxChars]: MaxChars is the maximum number of characters to include in the tab text. It elides text that are longer than that.

func (*Tabs) SetNewTabButton

func (t *Tabs) SetNewTabButton(v bool) *Tabs

SetNewTabButton sets the [Tabs.NewTabButton]: NewTabButton is whether to show a new tab button at the end of the list of tabs.

func (*Tabs) SetType

func (t *Tabs) SetType(v TabTypes) *Tabs

SetType sets the [Tabs.Type]: Type is the styling type of the tabs. If it is changed after the tabs are first configured, Update needs to be called on the tabs.

func (*Tabs) TabAtIndex

func (ts *Tabs) TabAtIndex(idx int) (*Frame, *Tab, bool)

TabAtIndex returns content frame and tab button at given index, false if index out of range (emits log message)

func (*Tabs) TabByName

func (ts *Tabs) TabByName(name string) *Frame

TabByName returns tab Frame with given widget name (nil if not found) The widget name is the original full tab label, prior to any eliding.

func (*Tabs) TabIndexByName

func (ts *Tabs) TabIndexByName(name string) int

TabIndexByName returns the tab index for the given tab widget name and -1 if it can not be found. The widget name is the original full tab label, prior to any eliding.

func (*Tabs) Tabs

func (ts *Tabs) Tabs() *Frame

Tabs returns the layout containing the tabs (the first element within us). It configures the Tabs if necessary.

func (*Tabs) UnselectOtherTabs

func (ts *Tabs) UnselectOtherTabs(idx int)

UnselectOtherTabs turns off all the tabs except given one

type Text added in v0.1.1

type Text struct {
	WidgetBase

	// Text is the text to display.
	Text string

	// Type is the styling type of text to use.
	Type TextTypes
	// contains filtered or unexported fields
}

Text is a widget for rendering text. It supports full HTML styling, including links. By default, text wraps and collapses whitespace, although you can change this by changing styles.Text.WhiteSpace.

func NewText added in v0.1.1

func NewText(parent ...tree.Node) *Text

NewText returns a new Text with the given optional parent: Text is a widget for rendering text. It supports full HTML styling, including links. By default, text wraps and collapses whitespace, although you can change this by changing styles.Text.WhiteSpace.

func (*Text) Copy added in v0.1.1

func (tx *Text) Copy(reset bool)
func (tx *Text) FindLink(pos image.Point) (*paint.TextLink, image.Rectangle)

FindLink finds the text link at the given scene-local position. If it finds it, it returns it and its bounds; otherwise, it returns nil.

func (*Text) HandleTextClick added in v0.1.1

func (tx *Text) HandleTextClick(openLink func(tl *paint.TextLink))

HandleTextClick handles click events such that the given function will be called on any links that are clicked on.

func (*Text) Init added in v0.2.0

func (tx *Text) Init()

func (*Text) Label added in v0.1.1

func (tx *Text) Label() string

func (*Text) New added in v0.1.1

func (t *Text) New() tree.Node

New returns a new *Text value

func (*Text) NodeType added in v0.1.1

func (t *Text) NodeType() *types.Type

NodeType returns the *types.Type of Text

func (*Text) Render added in v0.1.1

func (tx *Text) Render()

func (*Text) SetText added in v0.1.1

func (t *Text) SetText(v string) *Text

SetText sets the [Text.Text]: Text is the text to display.

func (*Text) SetType added in v0.1.1

func (t *Text) SetType(v TextTypes) *Text

SetType sets the [Text.Type]: Type is the styling type of text to use.

func (*Text) SizeDown added in v0.1.1

func (tx *Text) SizeDown(iter int) bool

func (*Text) SizeUp added in v0.1.1

func (tx *Text) SizeUp()

func (*Text) WidgetTooltip added in v0.1.3

func (tx *Text) WidgetTooltip(pos image.Point) (string, image.Point)

func (*Text) WidgetValue added in v0.2.0

func (tx *Text) WidgetValue() any

type TextField

type TextField struct {
	Frame

	// Type is the styling type of the text field.
	Type TextFieldTypes

	// Placeholder is the text that is displayed
	// when the text field is empty.
	Placeholder string

	// Validator is a function used to validate the input
	// of the text field. If it returns a non-nil error,
	// then an error color, icon, and tooltip will be displayed.
	Validator func() error `json:"-" xml:"-"`

	// LeadingIcon, if specified, indicates to add a button
	// at the start of the text field with this icon.
	LeadingIcon icons.Icon `set:"-"`

	// LeadingIconOnClick, if specified, is the function to call when
	// the LeadingIcon is clicked. If this is nil, the leading icon
	// will not be interactive.
	LeadingIconOnClick func(e events.Event) `json:"-" xml:"-"`

	// TrailingIcon, if specified, indicates to add a button
	// at the end of the text field with this icon.
	TrailingIcon icons.Icon `set:"-"`

	// TrailingIconOnClick, if specified, is the function to call when
	// the TrailingIcon is clicked. If this is nil, the trailing icon
	// will not be interactive.
	TrailingIconOnClick func(e events.Event) `json:"-" xml:"-"`

	// NoEcho is whether replace displayed characters with bullets to conceal text
	// (for example, for a password input).
	NoEcho bool

	// CursorWidth is the width of the text field cursor.
	// It should be set in Style like all other style properties.
	// By default, it is 1dp.
	CursorWidth units.Value

	// CursorColor is the color used for the text field cursor (caret).
	// It should be set in Style like all other style properties.
	// By default, it is [colors.Scheme.Primary.Base].
	CursorColor image.Image

	// PlaceholderColor is the color used for the Placeholder text.
	// It should be set in Style like all other style properties.
	// By default, it is [colors.Scheme.OnSurfaceVariant].
	PlaceholderColor image.Image

	// SelectColor is the color used for the text selection background color.
	// It should be set in Style like all other style properties.
	// By default, it is [colors.Scheme.Select.Container]
	SelectColor image.Image

	// Complete contains functions and data for text field completion.
	// It must be set using [TextField.SetCompleter].
	Complete *Complete `copier:"-" json:"-" xml:"-" set:"-"`

	// Txt is the last saved value of the text string being edited.
	Txt string `json:"-" xml:"-" set:"-"`

	// Edited is whether the text has been edited relative to the original.
	Edited bool `json:"-" xml:"-" set:"-"`

	// EditTxt is the live text string being edited, with the latest modifications.
	EditTxt []rune `copier:"-" json:"-" xml:"-" set:"-"`

	// Error is the current validation error of the text field.
	Error error `json:"-" xml:"-" set:"-"`

	// EffPos is the effective position with any leading icon space added.
	EffPos math32.Vector2 `copier:"-" json:"-" xml:"-" set:"-"`

	// EffSize is the effective size, subtracting any leading and trailing icon space.
	EffSize math32.Vector2 `copier:"-" json:"-" xml:"-" set:"-"`

	// StartPos is the starting display position in the string.
	StartPos int `copier:"-" json:"-" xml:"-" set:"-"`

	// EndPos is the ending display position in the string.
	EndPos int `copier:"-" json:"-" xml:"-" set:"-"`

	// CursorPos is the current cursor position.
	CursorPos int `copier:"-" json:"-" xml:"-" set:"-"`

	// CursorLine is the current cursor line position.
	CursorLine int `copier:"-" json:"-" xml:"-" set:"-"`

	// CharWidth is the approximate number of chars that can be
	// displayed at any time, which is computed from the font size.
	CharWidth int `copier:"-" json:"-" xml:"-" set:"-"`

	// SelectStart is the starting position of selection in the string.
	SelectStart int `copier:"-" json:"-" xml:"-" set:"-"`

	// SelectEnd is the ending position of selection in the string.
	SelectEnd int `copier:"-" json:"-" xml:"-" set:"-"`

	// SelectInit is the initial selection position (where it started).
	SelectInit int `copier:"-" json:"-" xml:"-" set:"-"`

	// SelectMode is whether to select text as the cursor moves.
	SelectMode bool `copier:"-" json:"-" xml:"-"`

	// RenderAll is the render version of entire text, for sizing.
	RenderAll paint.Text `copier:"-" json:"-" xml:"-" set:"-"`

	// RenderVis is the render version of just the visible text.
	RenderVis paint.Text `copier:"-" json:"-" xml:"-" set:"-"`

	// number of lines from last render update, for word-wrap version
	NLines int `copier:"-" json:"-" xml:"-" set:"-"`

	// FontHeight is the font height cached during styling.
	FontHeight float32 `copier:"-" json:"-" xml:"-" set:"-"`

	// BlinkOn oscillates between on and off for blinking.
	BlinkOn bool `copier:"-" json:"-" xml:"-" set:"-"`

	// CursorMu is the mutex for updating the cursor between blinker and field.
	CursorMu sync.Mutex `copier:"-" json:"-" xml:"-" display:"-" set:"-"`

	// Undos is the undo manager for the text field.
	Undos TextFieldUndos `json:"-" xml:"-" set:"-"`
}

TextField is a widget for editing a line of text. With the default WhiteSpaceNormal style setting, text will wrap onto multiple lines as needed. Set to WhiteSpaceNowrap (e.g., styles.Style.SetTextWrap(false)) to force everything to be on a single line. With multi-line wrapped text, the text is still treated as a single contiguous line of wrapped text.

func AsTextField

func AsTextField(n tree.Node) *TextField

AsTextField returns the given value as a value of type TextField if the type of the given value embeds TextField, or nil otherwise

func NewTextField

func NewTextField(parent ...tree.Node) *TextField

NewTextField returns a new TextField with the given optional parent: TextField is a widget for editing a line of text. With the default WhiteSpaceNormal style setting, text will wrap onto multiple lines as needed. Set to WhiteSpaceNowrap (e.g., styles.Style.SetTextWrap(false)) to force everything to be on a single line. With multi-line wrapped text, the text is still treated as a single contiguous line of wrapped text.

func (*TextField) AddClearButton

func (tf *TextField) AddClearButton() *TextField

AddClearButton adds a trailing icon button at the end of the textfield that clears the text in the textfield when pressed

func (*TextField) AsTextField

func (t *TextField) AsTextField() *TextField

AsTextField satisfies the TextFieldEmbedder interface

func (*TextField) AutoScroll

func (tf *TextField) AutoScroll()

AutoScroll scrolls the starting position to keep the cursor visible

func (*TextField) CancelComplete

func (tf *TextField) CancelComplete()

CancelComplete cancels any pending completion -- call this when new events have moved beyond any prior completion scenario

func (*TextField) CharPos

func (tf *TextField) CharPos(idx int) math32.Vector2

CharPos returns the relative starting position of the given rune, in the overall RenderAll of all the text. These positions can be out of visible range: see CharRenderPos

func (*TextField) CharRenderPos

func (tf *TextField) CharRenderPos(charidx int, wincoords bool) math32.Vector2

CharRenderPos returns the starting render coords for the given character position in string -- makes no attempt to rationalize that pos (i.e., if not in visible range, position will be out of range too). if wincoords is true, then adds window box offset -- for cursor, popups

func (*TextField) Clear

func (tf *TextField) Clear()

Clear clears any existing text

func (*TextField) ClearCursor

func (tf *TextField) ClearCursor()

ClearCursor turns off cursor and stops it from blinking

func (*TextField) ClearError added in v0.1.4

func (tf *TextField) ClearError()

ClearError clears any existing validation error

func (*TextField) ClearSelected

func (tf *TextField) ClearSelected()

ClearSelected resets both the global selected flag and any current selection

func (*TextField) CompleteText

func (tf *TextField) CompleteText(s string)

CompleteText edits the text field using the string chosen from the completion menu

func (*TextField) ConfigTextSize

func (tf *TextField) ConfigTextSize(sz math32.Vector2) math32.Vector2

func (*TextField) ContextMenu

func (tf *TextField) ContextMenu(m *Scene)

func (*TextField) Copy

func (tf *TextField) Copy(reset bool)

Copy copies any selected text to the clipboard. Satisfies Clipper interface -- can be extended in subtypes. optionally resetting the current selection

func (*TextField) CursorBackspace

func (tf *TextField) CursorBackspace(steps int)

CursorBackspace deletes character(s) immediately before cursor

func (*TextField) CursorBackspaceWord

func (tf *TextField) CursorBackspaceWord(steps int)

CursorBackspaceWord deletes words(s) immediately before cursor

func (*TextField) CursorBackward

func (tf *TextField) CursorBackward(steps int)

CursorBackward moves the cursor backward

func (*TextField) CursorBackwardWord

func (tf *TextField) CursorBackwardWord(steps int)

CursorBackwardWord moves the cursor backward by words

func (*TextField) CursorDelete

func (tf *TextField) CursorDelete(steps int)

CursorDelete deletes character(s) immediately after the cursor

func (*TextField) CursorDeleteWord

func (tf *TextField) CursorDeleteWord(steps int)

CursorDeleteWord deletes word(s) immediately after the cursor

func (*TextField) CursorDown

func (tf *TextField) CursorDown(steps int)

CursorDown moves the cursor down

func (*TextField) CursorEnd

func (tf *TextField) CursorEnd()

CursorEnd moves the cursor to the end of the text

func (*TextField) CursorForward

func (tf *TextField) CursorForward(steps int)

CursorForward moves the cursor forward

func (*TextField) CursorForwardWord

func (tf *TextField) CursorForwardWord(steps int)

CursorForwardWord moves the cursor forward by words

func (*TextField) CursorKill

func (tf *TextField) CursorKill()

CursorKill deletes text from cursor to end of text

func (*TextField) CursorSprite

func (tf *TextField) CursorSprite(on bool) *Sprite

CursorSprite returns the Sprite for the cursor (which is only rendered once with a vertical bar, and just activated and inactivated depending on render status). On sets the On status of the cursor.

func (*TextField) CursorStart

func (tf *TextField) CursorStart()

CursorStart moves the cursor to the start of the text, updating selection if select mode is active

func (*TextField) CursorUp

func (tf *TextField) CursorUp(steps int)

CursorUp moves the cursor up

func (*TextField) Cut

func (tf *TextField) Cut()

Cut cuts any selected text and adds it to the clipboard

func (*TextField) DeleteSelection

func (tf *TextField) DeleteSelection() string

DeleteSelection deletes any selected text, without adding to clipboard -- returns text deleted

func (*TextField) Destroy

func (tf *TextField) Destroy()

func (*TextField) EditDone

func (tf *TextField) EditDone()

EditDone completes editing and copies the active edited text to the text -- called when the return key is pressed or goes out of focus

func (*TextField) HandleKeyEvents

func (tf *TextField) HandleKeyEvents()

func (*TextField) HasSelection

func (tf *TextField) HasSelection() bool

HasSelection returns whether there is a selected region of text

func (*TextField) HasWordWrap

func (tf *TextField) HasWordWrap() bool

HasWordWrap returns true if the layout is multi-line word wrapping

func (*TextField) IconsSize

func (tf *TextField) IconsSize() math32.Vector2

func (*TextField) Init added in v0.2.0

func (tf *TextField) Init()

func (*TextField) InsertAtCursor

func (tf *TextField) InsertAtCursor(str string)

InsertAtCursor inserts given text at current cursor position

func (*TextField) IsWordBreak

func (tf *TextField) IsWordBreak(r rune) bool

IsWordBreak defines what counts as a word break for the purposes of selecting words

func (*TextField) LeadingIconButton

func (tf *TextField) LeadingIconButton() *Button

LeadingIconButton returns the [LeadingIcon] Button if present.

func (*TextField) New

func (t *TextField) New() tree.Node

New returns a new *TextField value

func (*TextField) NodeType

func (t *TextField) NodeType() *types.Type

NodeType returns the *types.Type of TextField

func (*TextField) OfferComplete

func (tf *TextField) OfferComplete()

OfferComplete pops up a menu of possible completions

func (*TextField) Paste

func (tf *TextField) Paste()

Paste inserts text from the clipboard at current cursor position -- if cursor is within a current selection, that selection is replaced. Satisfies Clipper interface -- can be extended in subtypes.

func (*TextField) PixelToCursor

func (tf *TextField) PixelToCursor(pt image.Point) int

PixelToCursor finds the cursor position that corresponds to the given pixel location

func (*TextField) Redo

func (tf *TextField) Redo()

func (*TextField) RelCharPos

func (tf *TextField) RelCharPos(st, ed int) math32.Vector2

RelCharPos returns the text width in dots between the two text string positions (ed is exclusive -- +1 beyond actual char).

func (*TextField) Render

func (tf *TextField) Render()

func (*TextField) RenderCursor

func (tf *TextField) RenderCursor(on bool)

RenderCursor renders the cursor on or off, as a sprite that is either on or off

func (*TextField) RenderSelect

func (tf *TextField) RenderSelect()

RenderSelect renders the selected region, if any, underneath the text

func (*TextField) Revert

func (tf *TextField) Revert()

Revert aborts editing and reverts to last saved text

func (*TextField) SaveUndo

func (tf *TextField) SaveUndo()

func (*TextField) ScenePos

func (tf *TextField) ScenePos()

func (*TextField) ScrollLayoutToCursor

func (tf *TextField) ScrollLayoutToCursor() bool

ScrollLayoutToCursor scrolls any scrolling layout above us so that the cursor is in view

func (*TextField) SelectAll

func (tf *TextField) SelectAll()

SelectAll selects all the text

func (*TextField) SelectModeToggle

func (tf *TextField) SelectModeToggle()

SelectModeToggle toggles the SelectMode, updating selection with cursor movement

func (*TextField) SelectRegUpdate

func (tf *TextField) SelectRegUpdate(pos int)

SelectRegUpdate updates current select region based on given cursor position relative to SelectStart position

func (*TextField) SelectReset

func (tf *TextField) SelectReset()

SelectReset resets the selection

func (*TextField) SelectUpdate

func (tf *TextField) SelectUpdate()

SelectUpdate updates the select region after any change to the text, to keep it in range

func (*TextField) SelectWord

func (tf *TextField) SelectWord()

SelectWord selects the word (whitespace delimited) that the cursor is on

func (*TextField) Selection

func (tf *TextField) Selection() string

Selection returns the currently selected text

func (*TextField) SetCompleter

func (tf *TextField) SetCompleter(data any, matchFun complete.MatchFunc, editFun complete.EditFunc)

SetCompleter sets completion functions so that completions will automatically be offered as the user types

func (*TextField) SetCursorColor

func (t *TextField) SetCursorColor(v image.Image) *TextField

SetCursorColor sets the [TextField.CursorColor]: CursorColor is the color used for the text field cursor (caret). It should be set in Style like all other style properties. By default, it is [colors.Scheme.Primary.Base].

func (*TextField) SetCursorFromPixel

func (tf *TextField) SetCursorFromPixel(pt image.Point, selMode events.SelectModes)

SetCursorFromPixel finds cursor location from given scene-relative pixel location, and sets current cursor to it, updating selection too.

func (*TextField) SetCursorWidth

func (t *TextField) SetCursorWidth(v units.Value) *TextField

SetCursorWidth sets the [TextField.CursorWidth]: CursorWidth is the width of the text field cursor. It should be set in Style like all other style properties. By default, it is 1dp.

func (*TextField) SetEffPosAndSize

func (tf *TextField) SetEffPosAndSize()

SetEffPosAndSize sets the effective position and size of the textfield based on its base position and size and its icons or lack thereof

func (*TextField) SetLeadingIcon

func (tf *TextField) SetLeadingIcon(icon icons.Icon, onClick ...func(e events.Event)) *TextField

SetLeadingIcon sets the leading icon of the text field to the given icon. If an on click function is specified, it also sets the leading icon on click function to that function. If no function is specified, it does not override any already set function.

func (*TextField) SetLeadingIconOnClick

func (t *TextField) SetLeadingIconOnClick(v func(e events.Event)) *TextField

SetLeadingIconOnClick sets the [TextField.LeadingIconOnClick]: LeadingIconOnClick, if specified, is the function to call when the LeadingIcon is clicked. If this is nil, the leading icon will not be interactive.

func (*TextField) SetNoEcho

func (t *TextField) SetNoEcho(v bool) *TextField

SetNoEcho sets the [TextField.NoEcho]: NoEcho is whether replace displayed characters with bullets to conceal text (for example, for a password input).

func (*TextField) SetPlaceholder

func (t *TextField) SetPlaceholder(v string) *TextField

SetPlaceholder sets the [TextField.Placeholder]: Placeholder is the text that is displayed when the text field is empty.

func (*TextField) SetPlaceholderColor

func (t *TextField) SetPlaceholderColor(v image.Image) *TextField

SetPlaceholderColor sets the [TextField.PlaceholderColor]: PlaceholderColor is the color used for the Placeholder text. It should be set in Style like all other style properties. By default, it is colors.Scheme.OnSurfaceVariant.

func (*TextField) SetSelectColor

func (t *TextField) SetSelectColor(v image.Image) *TextField

SetSelectColor sets the [TextField.SelectColor]: SelectColor is the color used for the text selection background color. It should be set in Style like all other style properties. By default, it is [colors.Scheme.Select.Container]

func (*TextField) SetSelectMode

func (t *TextField) SetSelectMode(v bool) *TextField

SetSelectMode sets the [TextField.SelectMode]: SelectMode is whether to select text as the cursor moves.

func (*TextField) SetText

func (tf *TextField) SetText(txt string) *TextField

SetText sets the text to be edited and reverts any current edit to reflect this new text.

func (*TextField) SetTrailingIcon

func (tf *TextField) SetTrailingIcon(icon icons.Icon, onClick ...func(e events.Event)) *TextField

SetTrailingIcon sets the trailing icon of the text field to the given icon. If an on click function is specified, it also sets the trailing icon on click function to that function. If no function is specified, it does not override any already set function.

func (*TextField) SetTrailingIconOnClick

func (t *TextField) SetTrailingIconOnClick(v func(e events.Event)) *TextField

SetTrailingIconOnClick sets the [TextField.TrailingIconOnClick]: TrailingIconOnClick, if specified, is the function to call when the TrailingIcon is clicked. If this is nil, the trailing icon will not be interactive.

func (*TextField) SetType

func (t *TextField) SetType(v TextFieldTypes) *TextField

SetType sets the [TextField.Type]: Type is the styling type of the text field.

func (*TextField) SetTypePassword

func (tf *TextField) SetTypePassword() *TextField

SetTypePassword enables [TextField.NoEcho] and adds a trailing icon button at the end of the textfield that toggles [TextField.NoEcho]. It also sets styles.Style.VirtualKeyboard to styles.KeyboardPassword.

func (*TextField) SetValidator

func (t *TextField) SetValidator(v func() error) *TextField

SetValidator sets the [TextField.Validator]: Validator is a function used to validate the input of the text field. If it returns a non-nil error, then an error color, icon, and tooltip will be displayed.

func (*TextField) ShiftSelect

func (tf *TextField) ShiftSelect(e events.Event)

ShiftSelect sets the selection start if the shift key is down but wasn't previously. If the shift key has been released, the selection info is cleared.

func (*TextField) SizeDown

func (tf *TextField) SizeDown(iter int) bool

func (*TextField) SizeUp

func (tf *TextField) SizeUp()

func (*TextField) StartCursor

func (tf *TextField) StartCursor()

StartCursor starts the cursor blinking and renders it

func (*TextField) StopCursor

func (tf *TextField) StopCursor()

StopCursor stops the cursor from blinking

func (*TextField) Style added in v0.2.0

func (tf *TextField) Style()

func (*TextField) Text

func (tf *TextField) Text() string

Text returns the current text -- applies any unapplied changes first, and sends a signal if so -- this is the end-user method to get the current value of the field.

func (*TextField) TrailingIconButton

func (tf *TextField) TrailingIconButton() *Button

TrailingIconButton returns the [TrailingIcon] Button if present.

func (*TextField) Undo

func (tf *TextField) Undo()

func (*TextField) Validate

func (tf *TextField) Validate()

Validate runs [TextField.Validator] and takes any necessary actions as a result of that.

func (*TextField) WidgetTooltip

func (tf *TextField) WidgetTooltip(pos image.Point) (string, image.Point)

func (*TextField) WidgetValue added in v0.2.0

func (tf *TextField) WidgetValue() any

type TextFieldEmbedder

type TextFieldEmbedder interface {
	AsTextField() *TextField
}

TextFieldEmbedder is an interface that all types that embed TextField satisfy

type TextFieldTypes

type TextFieldTypes int32 //enums:enum -trim-prefix TextField

TextFieldTypes is an enum containing the different possible types of text fields

const (
	// TextFieldFilled represents a filled
	// TextField with a background color
	// and a bottom border
	TextFieldFilled TextFieldTypes = iota
	// TextFieldOutlined represents an outlined
	// TextField with a border on all sides
	// and no background color
	TextFieldOutlined
)
const TextFieldTypesN TextFieldTypes = 2

TextFieldTypesN is the highest valid value for type TextFieldTypes, plus one.

func TextFieldTypesValues

func TextFieldTypesValues() []TextFieldTypes

TextFieldTypesValues returns all possible values for the type TextFieldTypes.

func (TextFieldTypes) Desc

func (i TextFieldTypes) Desc() string

Desc returns the description of the TextFieldTypes value.

func (TextFieldTypes) Int64

func (i TextFieldTypes) Int64() int64

Int64 returns the TextFieldTypes value as an int64.

func (TextFieldTypes) MarshalText

func (i TextFieldTypes) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*TextFieldTypes) SetInt64

func (i *TextFieldTypes) SetInt64(in int64)

SetInt64 sets the TextFieldTypes value from an int64.

func (*TextFieldTypes) SetString

func (i *TextFieldTypes) SetString(s string) error

SetString sets the TextFieldTypes value from its string representation, and returns an error if the string is invalid.

func (TextFieldTypes) String

func (i TextFieldTypes) String() string

String returns the string representation of this TextFieldTypes value.

func (*TextFieldTypes) UnmarshalText

func (i *TextFieldTypes) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (TextFieldTypes) Values

func (i TextFieldTypes) Values() []enums.Enum

Values returns all possible values for the type TextFieldTypes.

type TextFieldUndoRecord added in v0.1.1

type TextFieldUndoRecord struct {
	Text      []rune
	CursorPos int
}

TextFieldUndoRecord holds one undo record

func (*TextFieldUndoRecord) Set added in v0.1.1

func (ur *TextFieldUndoRecord) Set(txt []rune, curpos int)

type TextFieldUndos added in v0.1.1

type TextFieldUndos struct {
	// stack of undo records
	Stack []TextFieldUndoRecord

	// position within the undo stack
	Pos int

	// last time undo was saved, for grouping
	LastSave time.Time
}

TextFieldUndos manages everything about the undo process for a TextField.

func (*TextFieldUndos) Redo added in v0.1.1

func (us *TextFieldUndos) Redo() *TextFieldUndoRecord

func (*TextFieldUndos) SaveUndo added in v0.1.1

func (us *TextFieldUndos) SaveUndo(txt []rune, curpos int)

func (*TextFieldUndos) Undo added in v0.1.1

func (us *TextFieldUndos) Undo(txt []rune, curpos int) *TextFieldUndoRecord

type TextTypes added in v0.1.1

type TextTypes int32 //enums:enum -trim-prefix Text

TextTypes is an enum containing the different possible styling types of Text widgets.

const (
	// TextDisplayLarge is large, short, and important
	// display text with a default font size of 57dp.
	TextDisplayLarge TextTypes = iota
	// TextDisplayMedium is medium-sized, short, and important
	// display text with a default font size of 45dp.
	TextDisplayMedium
	// TextDisplaySmall is small, short, and important
	// display text with a default font size of 36dp.
	TextDisplaySmall

	// TextHeadlineLarge is large, high-emphasis
	// headline text with a default font size of 32dp.
	TextHeadlineLarge
	// TextHeadlineMedium is medium-sized, high-emphasis
	// headline text with a default font size of 28dp.
	TextHeadlineMedium
	// TextHeadlineSmall is small, high-emphasis
	// headline text with a default font size of 24dp.
	TextHeadlineSmall

	// TextTitleLarge is large, medium-emphasis
	// title text with a default font size of 22dp.
	TextTitleLarge
	// TextTitleMedium is medium-sized, medium-emphasis
	// title text with a default font size of 16dp.
	TextTitleMedium
	// TextTitleSmall is small, medium-emphasis
	// title text with a default font size of 14dp.
	TextTitleSmall

	// TextBodyLarge is large body text used for longer
	// passages of text with a default font size of 16dp.
	TextBodyLarge
	// TextBodyMedium is medium-sized body text used for longer
	// passages of text with a default font size of 14dp.
	TextBodyMedium
	// TextBodySmall is small body text used for longer
	// passages of text with a default font size of 12dp.
	TextBodySmall

	// TextLabelLarge is large text used for label text (like a caption
	// or the text inside a button) with a default font size of 14dp.
	TextLabelLarge
	// TextLabelMedium is medium-sized text used for label text (like a caption
	// or the text inside a button) with a default font size of 12dp.
	TextLabelMedium
	// TextLabelSmall is small text used for label text (like a caption
	// or the text inside a button) with a default font size of 11dp.
	TextLabelSmall
)
const TextTypesN TextTypes = 15

TextTypesN is the highest valid value for type TextTypes, plus one.

func TextTypesValues added in v0.1.1

func TextTypesValues() []TextTypes

TextTypesValues returns all possible values for the type TextTypes.

func (TextTypes) Desc added in v0.1.1

func (i TextTypes) Desc() string

Desc returns the description of the TextTypes value.

func (TextTypes) Int64 added in v0.1.1

func (i TextTypes) Int64() int64

Int64 returns the TextTypes value as an int64.

func (TextTypes) MarshalText added in v0.1.1

func (i TextTypes) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*TextTypes) SetInt64 added in v0.1.1

func (i *TextTypes) SetInt64(in int64)

SetInt64 sets the TextTypes value from an int64.

func (*TextTypes) SetString added in v0.1.1

func (i *TextTypes) SetString(s string) error

SetString sets the TextTypes value from its string representation, and returns an error if the string is invalid.

func (TextTypes) String added in v0.1.1

func (i TextTypes) String() string

String returns the string representation of this TextTypes value.

func (*TextTypes) UnmarshalText added in v0.1.1

func (i *TextTypes) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (TextTypes) Values added in v0.1.1

func (i TextTypes) Values() []enums.Enum

Values returns all possible values for the type TextTypes.

type Themes

type Themes int32 //enums:enum -trim-prefix Theme

Themes are the different possible themes that a user can select in their settings.

const (
	// ThemeAuto indicates to use the theme specified by the operating system
	ThemeAuto Themes = iota

	// ThemeLight indicates to use a light theme
	ThemeLight

	// ThemeDark indicates to use a dark theme
	ThemeDark
)
const ThemesN Themes = 3

ThemesN is the highest valid value for type Themes, plus one.

func ThemesValues

func ThemesValues() []Themes

ThemesValues returns all possible values for the type Themes.

func (Themes) Desc

func (i Themes) Desc() string

Desc returns the description of the Themes value.

func (Themes) Int64

func (i Themes) Int64() int64

Int64 returns the Themes value as an int64.

func (Themes) MarshalText

func (i Themes) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Themes) SetInt64

func (i *Themes) SetInt64(in int64)

SetInt64 sets the Themes value from an int64.

func (*Themes) SetString

func (i *Themes) SetString(s string) error

SetString sets the Themes value from its string representation, and returns an error if the string is invalid.

func (Themes) String

func (i Themes) String() string

String returns the string representation of this Themes value.

func (*Themes) UnmarshalText

func (i *Themes) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (Themes) Values

func (i Themes) Values() []enums.Enum

Values returns all possible values for the type Themes.

type TimeInput added in v0.2.0

type TimeInput struct {
	Frame
	Time time.Time
}

TimeInput presents two text fields for editing a date and time, both of which can pull up corresponding picker dialogs.

func NewTimeInput added in v0.2.0

func NewTimeInput(parent ...tree.Node) *TimeInput

NewTimeInput returns a new TimeInput with the given optional parent: TimeInput presents two text fields for editing a date and time, both of which can pull up corresponding picker dialogs.

func (*TimeInput) Init added in v0.2.0

func (ti *TimeInput) Init()

func (*TimeInput) New added in v0.2.0

func (t *TimeInput) New() tree.Node

New returns a new *TimeInput value

func (*TimeInput) NodeType added in v0.2.0

func (t *TimeInput) NodeType() *types.Type

NodeType returns the *types.Type of TimeInput

func (*TimeInput) SetTime added in v0.2.0

func (t *TimeInput) SetTime(v time.Time) *TimeInput

SetTime sets the [TimeInput.Time]

func (*TimeInput) WidgetValue added in v0.2.0

func (ti *TimeInput) WidgetValue() any

type TimePicker added in v0.2.0

type TimePicker struct {
	Frame

	// Time is the time that we are viewing
	Time time.Time

	// the raw input hour
	Hour int `set:"-"`

	// whether we are in PM mode (so we have to add 12h to everything)
	PM bool `set:"-"`
}

TimePicker is a widget for picking a time.

func NewTimePicker added in v0.2.0

func NewTimePicker(parent ...tree.Node) *TimePicker

NewTimePicker returns a new TimePicker with the given optional parent: TimePicker is a widget for picking a time.

func (*TimePicker) Init added in v0.2.0

func (tp *TimePicker) Init()

func (*TimePicker) New added in v0.2.0

func (t *TimePicker) New() tree.Node

New returns a new *TimePicker value

func (*TimePicker) NodeType added in v0.2.0

func (t *TimePicker) NodeType() *types.Type

NodeType returns the *types.Type of TimePicker

func (*TimePicker) SetTime added in v0.2.0

func (t *TimePicker) SetTime(v time.Time) *TimePicker

SetTime sets the [TimePicker.Time]: Time is the time that we are viewing

func (*TimePicker) WidgetValue added in v0.2.0

func (tp *TimePicker) WidgetValue() any

type Toolbar

type Toolbar struct {
	Frame

	// OverflowMenus are functions for configuring the overflow menu of the
	// toolbar. You can use [Toolbar.AddOverflowMenu] to add them.
	// These are processed in reverse order (last in, first called)
	// so that the default items are added last.
	OverflowMenus []func(m *Scene) `set:"-" json:"-" xml:"-"`
	// contains filtered or unexported fields
}

Toolbar is a Frame that is useful for holding [Button]s that do things. It automatically moves items that do not fit into an overflow menu, and manages additional items that are always placed onto this overflow menu. Use Body.AddAppBar to add to the default toolbar at the top of an app.

func NewToolbar

func NewToolbar(parent ...tree.Node) *Toolbar

NewToolbar returns a new Toolbar with the given optional parent: Toolbar is a Frame that is useful for holding [Button]s that do things. It automatically moves items that do not fit into an overflow menu, and manages additional items that are always placed onto this overflow menu. Use Body.AddAppBar to add to the default toolbar at the top of an app.

func RecycleToolbar

func RecycleToolbar(parent Widget) *Toolbar

RecycleToolbar constructs or returns a Toolbar in given parent Widget

func (*Toolbar) AddOverflowMenu

func (tb *Toolbar) AddOverflowMenu(fun func(m *Scene)) *Toolbar

AddOverflowMenu adds the given menu function to the overflow menu list. These functions are called in reverse order such that the last added function is called first when constructing the menu.

func (*Toolbar) AllItemsToChildren

func (tb *Toolbar) AllItemsToChildren()

AllItemsToChildren moves the overflow items back to the children, so the full set is considered for the next layout round, and ensures the overflow button is made and moves it to the end of the list.

func (*Toolbar) Init added in v0.2.0

func (tb *Toolbar) Init()

func (*Toolbar) IsVisible

func (tb *Toolbar) IsVisible() bool

func (*Toolbar) MoveToOverflow

func (tb *Toolbar) MoveToOverflow()

MoveToOverflow moves overflow out of children to the OverflowItems list

func (*Toolbar) New

func (t *Toolbar) New() tree.Node

New returns a new *Toolbar value

func (*Toolbar) NodeType

func (t *Toolbar) NodeType() *types.Type

NodeType returns the *types.Type of Toolbar

func (*Toolbar) OverflowMenu

func (tb *Toolbar) OverflowMenu(m *Scene)

OverflowMenu adds the overflow menu to the given Scene.

func (*Toolbar) ParentSize

func (tb *Toolbar) ParentSize() float32

func (*Toolbar) SizeDown

func (tb *Toolbar) SizeDown(iter int) bool

func (*Toolbar) SizeFromChildren

func (tb *Toolbar) SizeFromChildren(iter int, pass LayoutPasses) math32.Vector2

func (*Toolbar) SizeUp

func (tb *Toolbar) SizeUp()

type ToolbarMaker added in v0.2.0

type ToolbarMaker interface {
	MakeToolbar(p *tree.Plan)
}

ToolbarMaker is an interface that types can implement to make a toolbar plan. It is automatically used when making value view dialogs.

type Tree added in v0.2.0

type Tree struct {
	WidgetBase

	// If non-nil, the [tree.Node] that this widget is viewing in the tree (the source)
	SyncNode tree.Node `set:"-" copier:"-" json:"-" xml:"-"`

	// The text to display for the tree item label, which automatically
	// defaults to the [tree.Node.Name] of the tree node. It has no effect
	// if [Tree.SyncNode] is non-nil.
	Text string

	// optional icon, displayed to the the left of the text label
	Icon icons.Icon

	// icon to use for an open (expanded) branch; defaults to [icons.KeyboardArrowDown]
	IconOpen icons.Icon `display:"show-name"`

	// icon to use for a closed (collapsed) branch; defaults to [icons.KeyboardArrowRight]
	IconClosed icons.Icon `display:"show-name"`

	// icon to use for a terminal node branch that has no children; defaults to [icons.Blank]
	IconLeaf icons.Icon `display:"show-name"`

	// amount to indent children relative to this node
	Indent units.Value `copier:"-" json:"-" xml:"-"`

	// OpenDepth is the depth for nodes be initialized as open (default 4).
	// Nodes beyond this depth will be initialized as closed.
	OpenDepth int `copier:"-" json:"-" xml:"-"`

	// Closed is whether this tree node is currently toggled closed (children not visible).
	Closed bool

	// SelectMode, when set on the root node, determines whether keyboard movements should update selection.
	SelectMode bool

	// Root is the cached root of the tree. It is automatically set and does not need to be
	// set by the end user.
	Root *Tree `copier:"-" json:"-" xml:"-" edit:"-" set:"-"`

	// SelectedNodes holds the currently selected nodes, on the
	// RootView node only.
	SelectedNodes []Treer `copier:"-" json:"-" xml:"-" edit:"-"`
	// contains filtered or unexported fields
}

Tree provides a graphical representation of a tree structure, providing full navigation and manipulation abilities.

It does not handle layout by itself, so if you want it to scroll separately from the rest of the surrounding context, use NewTreeFrame.

If the SyncNode field is non-nil, typically via SyncRootNode method, then the Tree mirrors another tree structure, and tree editing functions apply to the source tree first, and then to the Tree by sync.

Otherwise, data can be directly encoded in a Tree derived type, to represent any kind of tree structure and associated data.

Standard [events.Event]s are sent to any listeners, including Select, Change, and DoubleClick. The selected nodes are in the root SelectedNodes list.

func AsTree added in v0.2.0

func AsTree(n tree.Node) *Tree

AsTree returns the given value as a value of type Tree if the type of the given value embeds Tree, or nil otherwise.

func NewTree added in v0.2.0

func NewTree(parent ...tree.Node) *Tree

NewTree returns a new Tree with the given optional parent: Tree provides a graphical representation of a tree structure, providing full navigation and manipulation abilities.

It does not handle layout by itself, so if you want it to scroll separately from the rest of the surrounding context, use NewTreeFrame.

If the SyncNode field is non-nil, typically via SyncRootNode method, then the Tree mirrors another tree structure, and tree editing functions apply to the source tree first, and then to the Tree by sync.

Otherwise, data can be directly encoded in a Tree derived type, to represent any kind of tree structure and associated data.

Standard [events.Event]s are sent to any listeners, including Select, Change, and DoubleClick. The selected nodes are in the root SelectedNodes list.

func NewTreeFrame added in v0.2.0

func NewTreeFrame(parent ...tree.Node) *Tree

NewTreeFrame adds a new Tree to a new frame with the given optional parent that ensures that the tree scrolls separately from the surrounding context.

func (*Tree) AddChildNode added in v0.2.0

func (tr *Tree) AddChildNode()

AddChildNode adds a new child node to this one in the tree, prompting the user for the type of node to add If SyncNode is set, operates on Sync Tree.

func (*Tree) AddSyncNodes added in v0.2.0

func (tr *Tree) AddSyncNodes(rel, myidx int, typ *types.Type, n int)

func (*Tree) AddTreeNodes added in v0.2.0

func (tr *Tree) AddTreeNodes(rel, myidx int, typ *types.Type, n int)

func (*Tree) AsCoreTree added in v0.2.0

func (tr *Tree) AsCoreTree() *Tree

AsCoreTree satisfies the Treer interface.

func (*Tree) BaseType added in v0.2.0

func (tr *Tree) BaseType() *types.Type

func (*Tree) Branch added in v0.2.0

func (tr *Tree) Branch() (*Switch, bool)

Branch returns the branch widget in parts, if it exists

func (*Tree) CanOpen added in v0.2.0

func (tr *Tree) CanOpen() bool

CanOpen returns true if the node is able to open. By default it checks HasChildren(), but could check other properties to perform lazy building of the tree.

func (*Tree) Close added in v0.2.0

func (tr *Tree) Close()

Close closes the given node and updates the view accordingly (if it is not already closed). Calls OnClose in Treer interface for extensible actions.

func (*Tree) CloseAll added in v0.2.0

func (tr *Tree) CloseAll()

CloseAll closes the given node and all of its sub-nodes.

func (*Tree) ContextMenu added in v0.2.0

func (tr *Tree) ContextMenu(m *Scene)

func (*Tree) ContextMenuPos added in v0.2.0

func (tr *Tree) ContextMenuPos(e events.Event) (pos image.Point)

func (*Tree) ContextMenuReadOnly added in v0.2.0

func (tr *Tree) ContextMenuReadOnly(m *Scene)

func (*Tree) Copy added in v0.2.0

func (tr *Tree) Copy(reset bool)

Copy copies to system.Clipboard, optionally resetting the selection.

func (*Tree) Cut added in v0.2.0

func (tr *Tree) Cut()

Cut copies to system.Clipboard and deletes selected items.

func (*Tree) CutSync added in v0.2.0

func (tr *Tree) CutSync()

CutSync copies to system.Clipboard and deletes selected items.

func (*Tree) DeleteNode added in v0.2.0

func (tr *Tree) DeleteNode()

DeleteNode deletes the tree node or sync node corresponding to this view node in the sync tree. If SyncNode is set, operates on Sync Tree.

func (*Tree) DragClearStates added in v0.2.0

func (tr *Tree) DragClearStates()

DragClearStates clears the drag-drop related states for this widget

func (*Tree) DragDrop added in v0.2.0

func (tr *Tree) DragDrop(e events.Event)

DragDrop handles drag drop event

func (*Tree) DragStart added in v0.2.0

func (tr *Tree) DragStart(e events.Event)

DragStart starts a drag-n-drop on this node -- it includes any other selected nodes as well, each as additional records in mimedata.

func (*Tree) DropDeleteSource added in v0.2.0

func (tr *Tree) DropDeleteSource(e events.Event)

DropDeleteSource handles delete source event for DropMove case

func (*Tree) DropDeleteSourceSync added in v0.2.0

func (tr *Tree) DropDeleteSourceSync(de *events.DragDrop)

DropDeleteSourceSync handles delete source event for DropMove case, for Sync

func (*Tree) DropExternal added in v0.2.0

func (tr *Tree) DropExternal(md mimedata.Mimes, mod events.DropMods)

DropExternal is not handled by base case but could be in derived

func (*Tree) DropFinalize added in v0.2.0

func (tr *Tree) DropFinalize(de *events.DragDrop)

DropFinalize is called to finalize Drop actions on the Source node. Only relevant for DropMod == DropMove.

func (*Tree) Duplicate added in v0.2.0

func (tr *Tree) Duplicate()

Duplicate duplicates the sync node corresponding to this view node in the tree, and inserts the duplicate after this node (as a new sibling). If SyncNode is set, operates on Sync Tree.

func (*Tree) DuplicateSync added in v0.2.0

func (tr *Tree) DuplicateSync()

func (*Tree) EditNode added in v0.2.0

func (tr *Tree) EditNode()

EditNode pulls up a Form dialog for the node. If SyncNode is set, operates on Sync Tree.

func (*Tree) FindSyncNode added in v0.2.0

func (tr *Tree) FindSyncNode(kn tree.Node) *Tree

FindSyncNode finds Tree node for given source node, or nil if not found

func (*Tree) HasSelection added in v0.2.0

func (tr *Tree) HasSelection() bool

HasSelection returns true if there are currently selected items

func (*Tree) Init added in v0.2.0

func (tr *Tree) Init()

func (*Tree) InsertAfter added in v0.2.0

func (tr *Tree) InsertAfter()

InsertAfter inserts a new node in the tree after this node, at the same (sibling) level, prompting for the type of node to insert. If SyncNode is set, operates on Sync Tree.

func (*Tree) InsertAt added in v0.2.0

func (tr *Tree) InsertAt(rel int, actNm string)

InsertAt inserts a new node in the tree at given relative offset from this node, at the same (sibling) level, prompting for the type of node to insert If SyncNode is set, operates on Sync Tree.

func (*Tree) InsertBefore added in v0.2.0

func (tr *Tree) InsertBefore()

InsertBefore inserts a new node in the tree before this node, at the same (sibling) level, prompting for the type of node to insert If SyncNode is set, operates on Sync Tree.

func (*Tree) InspectNode added in v0.2.0

func (tr *Tree) InspectNode()

InspectNode pulls up a new Inspector window on the node. If SyncNode is set, operates on Sync Tree.

func (*Tree) IsRoot added in v0.2.0

func (tr *Tree) IsRoot(op string) bool

IsRoot returns true if given node is the root of the tree.

func (*Tree) Label added in v0.2.0

func (tr *Tree) Label() string

Label returns the display label for this node, satisfying the Labeler interface

func (*Tree) MakePasteMenu added in v0.2.0

func (tr *Tree) MakePasteMenu(m *Scene, md mimedata.Mimes, fun func())

MakePasteMenu makes the menu of options for paste events optional function is typically the DropFinalize but could also be other actions to take after each optional action.

func (*Tree) MimeData added in v0.2.0

func (tr *Tree) MimeData(md *mimedata.Mimes)

MimeData adds mimedata for this node: a text/plain of the Path.

func (*Tree) MimeDataSync added in v0.2.0

func (tr *Tree) MimeDataSync(md *mimedata.Mimes)

MimeDataSync adds mimedata for this node: a text/plain of the Path, and an application/json of the sync node.

func (*Tree) MoveDown added in v0.2.0

func (tr *Tree) MoveDown(selMode events.SelectModes) *Tree

MoveDown moves the selection down to next element in the tree, using given select mode (from keyboard modifiers). Returns newly selected node.

func (*Tree) MoveDownAction added in v0.2.0

func (tr *Tree) MoveDownAction(selMode events.SelectModes) *Tree

MoveDownAction moves the selection down to next element in the tree, using given select mode (from keyboard modifiers). Sends select event for newly selected item.

func (*Tree) MoveDownSibling added in v0.2.0

func (tr *Tree) MoveDownSibling(selMode events.SelectModes) *Tree

MoveDownSibling moves down only to siblings, not down into children, using given select mode (from keyboard modifiers)

func (*Tree) MoveEndAction added in v0.2.0

func (tr *Tree) MoveEndAction(selMode events.SelectModes) *Tree

MoveEndAction moves the selection to the very last node in the tree, using given select mode (from keyboard modifiers) Sends select event for newly selected item.

func (*Tree) MoveHomeAction added in v0.2.0

func (tr *Tree) MoveHomeAction(selMode events.SelectModes) *Tree

MoveHomeAction moves the selection up to top of the tree, using given select mode (from keyboard modifiers) and emits select event for newly selected item

func (*Tree) MovePageDownAction added in v0.2.0

func (tr *Tree) MovePageDownAction(selMode events.SelectModes) *Tree

MovePageDownAction moves the selection up to previous TreePageSteps elements in the tree, using given select mode (from keyboard modifiers). Sends select event for newly selected item.

func (*Tree) MovePageUpAction added in v0.2.0

func (tr *Tree) MovePageUpAction(selMode events.SelectModes) *Tree

MovePageUpAction moves the selection up to previous TreePageSteps elements in the tree, using given select mode (from keyboard modifiers). Sends select event for newly selected item.

func (*Tree) MoveToLastChild added in v0.2.0

func (tr *Tree) MoveToLastChild(selMode events.SelectModes) *Tree

MoveToLastChild moves to the last child under me, using given select mode (from keyboard modifiers)

func (*Tree) MoveUp added in v0.2.0

func (tr *Tree) MoveUp(selMode events.SelectModes) *Tree

MoveUp moves selection up to previous element in the tree, using given select mode (from keyboard modifiers). Returns newly selected node

func (*Tree) MoveUpAction added in v0.2.0

func (tr *Tree) MoveUpAction(selMode events.SelectModes) *Tree

MoveUpAction moves the selection up to previous element in the tree, using given select mode (from keyboard modifiers). Sends select event for newly selected item.

func (*Tree) New added in v0.2.0

func (t *Tree) New() tree.Node

New returns a new *Tree value

func (*Tree) NodeType added in v0.2.0

func (t *Tree) NodeType() *types.Type

NodeType returns the *types.Type of Tree

func (*Tree) NodesFromMimeData added in v0.2.0

func (tr *Tree) NodesFromMimeData(md mimedata.Mimes) ([]tree.Node, []string)

NodesFromMimeData returns a slice of tree nodes for the Tree nodes and paths from mime data.

func (*Tree) OnAdd added in v0.2.0

func (tr *Tree) OnAdd()

func (*Tree) OnClose added in v0.2.0

func (tr *Tree) OnClose()

OnClose is called when a node is closed. The base version does nothing.

func (*Tree) OnDoubleClick added in v0.2.0

func (tr *Tree) OnDoubleClick(e events.Event)

func (*Tree) OnOpen added in v0.2.0

func (tr *Tree) OnOpen()

OnOpen is called when a node is opened. The base version does nothing.

func (*Tree) Open added in v0.2.0

func (tr *Tree) Open()

Open opens the given node and updates the view accordingly (if it is not already opened). Calls OnOpen in Treer interface for extensible actions.

func (*Tree) OpenAll added in v0.2.0

func (tr *Tree) OpenAll()

OpenAll opens the given node and all of its sub-nodes

func (*Tree) OpenParents added in v0.2.0

func (tr *Tree) OpenParents()

OpenParents opens all the parents of this node, so that it will be visible.

func (*Tree) Paste added in v0.2.0

func (tr *Tree) Paste()

Paste pastes clipboard at given node.

func (*Tree) PasteAfter added in v0.2.0

func (tr *Tree) PasteAfter(md mimedata.Mimes, mod events.DropMods)

PasteAfter inserts object(s) from mime data after this node. If another item with the same name already exists, it will append _Copy on the name of the inserted objects

func (*Tree) PasteAssign added in v0.2.0

func (tr *Tree) PasteAssign(md mimedata.Mimes)

PasteAssign assigns mime data (only the first one!) to this node

func (*Tree) PasteAssignSync added in v0.2.0

func (tr *Tree) PasteAssignSync(md mimedata.Mimes)

PasteAssignSync assigns mime data (only the first one!) to this node

func (*Tree) PasteAt added in v0.2.0

func (tr *Tree) PasteAt(md mimedata.Mimes, mod events.DropMods, rel int, actNm string)

PasteAt inserts object(s) from mime data at rel position to this node. If another item with the same name already exists, it will append _Copy on the name of the inserted objects

func (*Tree) PasteAtSync added in v0.2.0

func (tr *Tree) PasteAtSync(md mimedata.Mimes, mod events.DropMods, rel int, actNm string)

PasteAtSync inserts object(s) from mime data at rel position to this node. If another item with the same name already exists, it will append _Copy on the name of the inserted objects

func (*Tree) PasteBefore added in v0.2.0

func (tr *Tree) PasteBefore(md mimedata.Mimes, mod events.DropMods)

PasteBefore inserts object(s) from mime data before this node. If another item with the same name already exists, it will append _Copy on the name of the inserted objects

func (*Tree) PasteChildren added in v0.2.0

func (tr *Tree) PasteChildren(md mimedata.Mimes, mod events.DropMods)

PasteChildren inserts object(s) from mime data at end of children of this node

func (*Tree) PasteChildrenSync added in v0.2.0

func (tr *Tree) PasteChildrenSync(md mimedata.Mimes, mod events.DropMods)

PasteChildrenSync inserts object(s) from mime data at end of children of this node

func (*Tree) PasteMenu added in v0.2.0

func (tr *Tree) PasteMenu(md mimedata.Mimes)

PasteMenu performs a paste from the clipboard using given data, by popping up a menu to determine what specifically to do.

func (*Tree) Position added in v0.2.0

func (tr *Tree) Position()

func (*Tree) ReSync added in v0.2.0

func (tr *Tree) ReSync()

ReSync resynchronizes the view relative to the underlying nodes and forces a full rerender

func (*Tree) Render added in v0.2.0

func (tr *Tree) Render()

func (*Tree) RenderWidget added in v0.2.0

func (tr *Tree) RenderWidget()

func (*Tree) RootIsReadOnly added in v0.2.0

func (tr *Tree) RootIsReadOnly() bool

RootIsReadOnly returns the ReadOnly status of the root node, which is what controls the functional inactivity of the tree if individual nodes are ReadOnly that only affects display typically.

func (*Tree) RootSetViewIndex added in v0.2.0

func (tr *Tree) RootSetViewIndex() int

RootSetViewIndex sets the RootView and ViewIndex for all nodes. This must be called from the root node after construction or any modification to the tree. Returns the total number of leaves in the tree.

func (*Tree) ScenePos added in v0.2.0

func (tr *Tree) ScenePos()

func (*Tree) Select added in v0.2.0

func (tr *Tree) Select()

Select selects this node (if not already selected). Must use this method to update global selection list

func (*Tree) SelectAction added in v0.2.0

func (tr *Tree) SelectAction(mode events.SelectModes) bool

SelectAction updates selection to include this node, using selectmode from mouse event (ExtendContinuous, ExtendOne), and Root sends selection event. Returns true if signal emitted.

func (*Tree) SelectAll added in v0.2.0

func (tr *Tree) SelectAll()

SelectAll all items in view

func (*Tree) SelectUpdate added in v0.2.0

func (tr *Tree) SelectUpdate(mode events.SelectModes) bool

SelectUpdate updates selection to include this node, using selectmode from mouse event (ExtendContinuous, ExtendOne). Returns true if this node selected

func (*Tree) SelectedSyncNodes added in v0.2.0

func (tr *Tree) SelectedSyncNodes() []tree.Node

SelectedSyncNodes returns a slice of the currently selected sync source nodes in the entire tree

func (*Tree) SelectedViews added in v0.2.0

func (tr *Tree) SelectedViews() []Treer

SelectedViews returns a slice of the currently selected Trees within the entire tree, using a list maintained by the root node

func (*Tree) SendChangeEvent added in v0.2.0

func (tr *Tree) SendChangeEvent(original ...events.Event)

SendChangeEvent sends an events.Change event on the RootView node.

func (*Tree) SendChangeEventReSync added in v0.2.0

func (tr *Tree) SendChangeEventReSync(original ...events.Event)

SendChangeEventReSync sends an events.Change event on the RootView node. If SyncNode != nil, it also does a re-sync from root.

func (*Tree) SendSelectEvent added in v0.2.0

func (tr *Tree) SendSelectEvent(original ...events.Event)

SendSelectEvent sends an events.Select event on the RootView node.

func (*Tree) SetBranchState added in v0.2.0

func (tr *Tree) SetBranchState()

func (*Tree) SetClosed added in v0.2.0

func (t *Tree) SetClosed(v bool) *Tree

SetClosed sets the [Tree.Closed]: Closed is whether this tree node is currently toggled closed (children not visible).

func (*Tree) SetIcon added in v0.2.0

func (t *Tree) SetIcon(v icons.Icon) *Tree

SetIcon sets the [Tree.Icon]: optional icon, displayed to the the left of the text label

func (*Tree) SetIconClosed added in v0.2.0

func (t *Tree) SetIconClosed(v icons.Icon) *Tree

SetIconClosed sets the [Tree.IconClosed]: icon to use for a closed (collapsed) branch; defaults to icons.KeyboardArrowRight

func (*Tree) SetIconLeaf added in v0.2.0

func (t *Tree) SetIconLeaf(v icons.Icon) *Tree

SetIconLeaf sets the [Tree.IconLeaf]: icon to use for a terminal node branch that has no children; defaults to icons.Blank

func (*Tree) SetIconOpen added in v0.2.0

func (t *Tree) SetIconOpen(v icons.Icon) *Tree

SetIconOpen sets the [Tree.IconOpen]: icon to use for an open (expanded) branch; defaults to icons.KeyboardArrowDown

func (*Tree) SetIndent added in v0.2.0

func (t *Tree) SetIndent(v units.Value) *Tree

SetIndent sets the [Tree.Indent]: amount to indent children relative to this node

func (*Tree) SetKidsVisibility added in v0.2.0

func (tr *Tree) SetKidsVisibility(parentClosed bool)

func (*Tree) SetOpenDepth added in v0.2.0

func (t *Tree) SetOpenDepth(v int) *Tree

SetOpenDepth sets the [Tree.OpenDepth]: OpenDepth is the depth for nodes be initialized as open (default 4). Nodes beyond this depth will be initialized as closed.

func (*Tree) SetSelectMode added in v0.2.0

func (t *Tree) SetSelectMode(v bool) *Tree

SetSelectMode sets the [Tree.SelectMode]: SelectMode, when set on the root node, determines whether keyboard movements should update selection.

func (*Tree) SetSelectedNodes added in v0.2.0

func (t *Tree) SetSelectedNodes(v ...Treer) *Tree

SetSelectedNodes sets the [Tree.SelectedNodes]: SelectedNodes holds the currently selected nodes, on the RootView node only.

func (*Tree) SetSelectedViews added in v0.2.0

func (tr *Tree) SetSelectedViews(sl []Treer)

SetSelectedViews updates the selected views to given list

func (*Tree) SetSyncNode added in v0.2.0

func (tr *Tree) SetSyncNode(sn tree.Node, tvIndex *int, init bool, depth int)

SetSyncNode sets the sync source node that we are viewing, and syncs the view of its tree. It is called routinely via SyncToSrc during tree updating. It uses tree Config mechanism to perform minimal updates to remain in sync.

func (*Tree) SetText added in v0.2.0

func (t *Tree) SetText(v string) *Tree

SetText sets the [Tree.Text]: The text to display for the tree item label, which automatically defaults to the tree.Node.Name of the tree node. It has no effect if [Tree.SyncNode] is non-nil.

func (*Tree) SizeDown added in v0.2.0

func (tr *Tree) SizeDown(iter int) bool

func (*Tree) SizeUp added in v0.2.0

func (tr *Tree) SizeUp()

func (*Tree) Style added in v0.2.0

func (tr *Tree) Style()

func (*Tree) SyncNodesFromMimeData added in v0.2.0

func (tr *Tree) SyncNodesFromMimeData(md mimedata.Mimes) ([]tree.Node, []string)

SyncNodesFromMimeData creates a slice of tree node(s) from given mime data and also a corresponding slice of original paths.

func (*Tree) SyncToSrc added in v0.2.0

func (tr *Tree) SyncToSrc(tvIndex *int, init bool, depth int)

SyncToSrc updates the view tree to match the sync tree, using ConfigChildren to maximally preserve existing tree elements. init means we are doing initial build, and depth tracks depth (only during init).

func (*Tree) SyncTree added in v0.2.0

func (tr *Tree) SyncTree(n tree.Node) *Tree

SyncTree sets the root view to the root of the sync source tree node for this Tree, and syncs the rest of the tree to match. The source tree must have unique names for each child within a given parent.

func (*Tree) ToggleClose added in v0.2.0

func (tr *Tree) ToggleClose()

ToggleClose toggles the close / open status: if closed, opens, and vice-versa

func (*Tree) TreeChanged added in v0.2.0

func (tr *Tree) TreeChanged(original ...events.Event)

TreeChanged must be called after any structural change to the Tree (adding or deleting nodes). It calls RootSetViewIndex to update indexes and SendChangeEvent to notify of changes.

func (*Tree) Unselect added in v0.2.0

func (tr *Tree) Unselect()

Unselect unselects this node (if selected). Must use this method to update global selection list.

func (*Tree) UnselectAction added in v0.2.0

func (tr *Tree) UnselectAction()

UnselectAction unselects this node (if selected), and Root sends a selection event.

func (*Tree) UnselectAll added in v0.2.0

func (tr *Tree) UnselectAll()

UnselectAll unselects all selected items in the view

func (*Tree) UpdateBranchIcons added in v0.2.0

func (tr *Tree) UpdateBranchIcons()

func (*Tree) UpdateReadOnly added in v0.2.0

func (tr *Tree) UpdateReadOnly() bool

UpdateReadOnly updates the ReadOnly state based on SyncNode. Returns true if ReadOnly. The inactivity of individual nodes only affects display properties typically, and not overall functional behavior, which is controlled by inactivity of the root node (i.e, make the root ReadOnly to make entire tree read-only and non-modifiable)

type TreeButton added in v0.2.0

type TreeButton struct {
	Button
	Tree tree.Node
}

TreeButton represents a tree.Node value with a button.

func NewTreeButton added in v0.2.0

func NewTreeButton(parent ...tree.Node) *TreeButton

NewTreeButton returns a new TreeButton with the given optional parent: TreeButton represents a tree.Node value with a button.

func (*TreeButton) Init added in v0.2.0

func (tb *TreeButton) Init()

func (*TreeButton) New added in v0.2.0

func (t *TreeButton) New() tree.Node

New returns a new *TreeButton value

func (*TreeButton) NodeType added in v0.2.0

func (t *TreeButton) NodeType() *types.Type

NodeType returns the *types.Type of TreeButton

func (*TreeButton) SetTree added in v0.2.0

func (t *TreeButton) SetTree(v tree.Node) *TreeButton

SetTree sets the [TreeButton.Tree]

func (*TreeButton) WidgetValue added in v0.2.0

func (tb *TreeButton) WidgetValue() any

type Treer added in v0.2.0

type Treer interface {
	Widget

	// AsTree returns the base [Tree] for this node.
	AsCoreTree() *Tree

	// CanOpen returns true if the node is able to open.
	// By default it checks HasChildren(), but could check other properties
	// to perform lazy building of the tree.
	CanOpen() bool

	// OnOpen is called when a node is opened.
	// The base version does nothing.
	OnOpen()

	// OnClose is called when a node is closed
	// The base version does nothing.
	OnClose()

	// OnDoubleClick is called when a node is double-clicked
	// The base version does ToggleClose
	OnDoubleClick(e events.Event)

	// UpdateBranchIcons is called during DoLayout to update branch icons
	// when everything should be configured, prior to rendering.
	UpdateBranchIcons()

	// Following are all tree editing functions:
	DeleteNode()
	Duplicate()
	AddChildNode()
	InsertBefore()
	InsertAfter()
	MimeData(md *mimedata.Mimes)
	Cut()
	Copy(reset bool)
	Paste()
	DragStart(e events.Event)
	DragDrop(e events.Event)
	DropFinalize(de *events.DragDrop)
	DropDeleteSource(e events.Event)
	MakePasteMenu(m *Scene, md mimedata.Mimes, fun func())
}

Treer is an interface for Tree types providing access to the base Tree and overridable method hooks for actions taken on the Tree, including OnOpen, OnClose, etc.

type TypeChooser added in v0.2.0

type TypeChooser struct {
	Chooser
}

TypeChooser represents a types.Type value with a chooser.

func NewTypeChooser added in v0.2.0

func NewTypeChooser(parent ...tree.Node) *TypeChooser

NewTypeChooser returns a new TypeChooser with the given optional parent: TypeChooser represents a types.Type value with a chooser.

func (*TypeChooser) Init added in v0.2.0

func (tc *TypeChooser) Init()

func (*TypeChooser) New added in v0.2.0

func (t *TypeChooser) New() tree.Node

New returns a new *TypeChooser value

func (*TypeChooser) NodeType added in v0.2.0

func (t *TypeChooser) NodeType() *types.Type

NodeType returns the *types.Type of TypeChooser

type User

type User struct {
	user.User

	// default email address -- e.g., for recording changes in a version control system
	Email string
}

User basic user information that might be needed for different apps

type Validator

type Validator interface {
	// Validate returns an error if the value is invalid.
	Validate() error
}

Validator is an interface for types to provide a Validate method that is used to validate string [Value]s using [TextField.Validator].

type Value added in v0.2.0

type Value interface {
	Widget

	// WidgetValue returns the pointer to the associated value of the widget.
	WidgetValue() any
}

Value is a widget that has an associated value representation. It can be bound to a value using Bind.

func NewValue added in v0.2.0

func NewValue(value any, tags reflect.StructTag, parent ...tree.Node) Value

NewValue converts the given value into an appropriate Value whose associated value is bound to the given value. The given value must be a pointer. It uses the given optional struct tags for additional context and to determine styling properties via StyleFromTags. It also adds the resulting Value to the given optional parent if it specified. The specifics on how it determines what type of Value to make are further documented on ToValue.

func ToValue added in v0.2.0

func ToValue(value any, tags reflect.StructTag) Value

ToValue converts the given value into an appropriate Value, using the given optional struct tags for additional context. The given value should typically be a pointer. It does NOT call Bind; see NewValue for a version that does. It first checks the Valuer interface, then the ValueTypes, then the ValueConverters, and finally it falls back on a set of default bindings. If any step results in nil, it falls back on the next step.

type ValueSetter added in v0.2.0

type ValueSetter interface {

	// SetWidgetValue sets the associated widget value from the given value.
	SetWidgetValue(value any) error
}

ValueSetter is an optional interface that [Value]s can implement to customize how the associated widget value is set from the given value.

type Valuer added in v0.2.0

type Valuer interface {

	// Value returns the [Value] that should be used to represent
	// the value in the GUI. If it returns nil, then [ToValue] will
	// fall back onto the next step. This function must NOT call [Bind].
	Value() Value
}

Valuer is an interface that types can implement to specify the Value that should be used to represent them in the GUI.

type Widget

type Widget interface {
	tree.Node

	// AsWidget returns the [WidgetBase] of this Widget. Most
	// core widget functionality is implemented on [WidgetBase].
	AsWidget() *WidgetBase

	// See [WidgetBase.Style].
	Style() // TODO(config): remove

	// SizeUp (bottom-up) gathers Actual sizes from our Children & Parts,
	// based on Styles.Min / Max sizes and actual content sizing
	// (e.g., text size).  Flexible elements (e.g., Text, Flex Wrap,
	// TopAppBar) should reserve the _minimum_ size possible at this stage,
	// and then Grow based on SizeDown allocation.
	SizeUp()

	// SizeDown (top-down, multiple iterations possible) provides top-down
	// size allocations based initially on Scene available size and
	// the SizeUp Actual sizes.  If there is extra space available, it is
	// allocated according to the Grow factors.
	// Flexible elements (e.g., Flex Wrap layouts and Text with word wrap)
	// update their Actual size based on available Alloc size (re-wrap),
	// to fit the allocated shape vs. the initial bottom-up guess.
	// However, do NOT grow the Actual size to match Alloc at this stage,
	// as Actual sizes must always represent the minimums (see Position).
	// Returns true if any change in Actual size occurred.
	SizeDown(iter int) bool

	// SizeFinal: (bottom-up) similar to SizeUp but done at the end of the
	// Sizing phase: first grows widget Actual sizes based on their Grow
	// factors, up to their Alloc sizes.  Then gathers this updated final
	// actual Size information for layouts to register their actual sizes
	// prior to positioning, which requires accurate Actual vs. Alloc
	// sizes to perform correct alignment calculations.
	SizeFinal()

	// Position uses the final sizes to set relative positions within layouts
	// according to alignment settings, and Grow elements to their actual
	// Alloc size per Styles settings and widget-specific behavior.
	Position()

	// ScenePos computes scene-based absolute positions and final BBox
	// bounding boxes for rendering, based on relative positions from
	// Position step and parents accumulated position and scroll offset.
	// This is the only step needed when scrolling (very fast).
	ScenePos()

	// Render is the method that widgets should implement to define their
	// custom rendering steps. It should not typically be called outside of
	// [Widget.RenderWidget], which also does other steps applicable
	// for all widgets. The base [WidgetBase.Render] implementation
	// renders the standard box model.
	Render()

	// RenderWidget renders the widget and any parts and children that it has.
	// It does not render if the widget is invisible. It calls [Widget.Render]
	// for widget-specific rendering.
	RenderWidget()

	// WidgetTooltip returns the tooltip text that should be used for this
	// widget, and the window-relative position to use for the upper-left corner
	// of the tooltip. The current mouse position in scene-local coordinates
	// is passed to the function; if it is {-1, -1}, that indicates that
	// WidgetTooltip is being called in a Style function to determine whether
	// the widget should be [abilities.LongHoverable] and [abilities.LongPressable]
	// (if the return string is not "", then it will have those abilities
	// so that the tooltip can be displayed).
	//
	// By default, WidgetTooltip just returns [WidgetBase.Tooltip]
	// and [WidgetBase.DefaultTooltipPos], but widgets can override
	// it to do different things. For example, buttons add their
	// shortcut to the tooltip here.
	WidgetTooltip(pos image.Point) (string, image.Point)

	// ContextMenuPos returns the default position for popup menus;
	// by default in the middle its Bounding Box, but can be adapted as
	// appropriate for different widgets.
	ContextMenuPos(e events.Event) image.Point

	// ShowContextMenu displays the context menu of various actions
	// to perform on a Widget, activated by default on the ShowContextMenu
	// event, triggered by a Right mouse click.
	// Returns immediately, and actions are all executed directly
	// (later) via the action signals. Calls ContextMenu and
	// ContextMenuPos.
	ShowContextMenu(e events.Event)

	// IsVisible returns true if a node is visible for rendering according
	// to the [states.Invisible] flag on it or any of its parents.
	// This flag is also set by [styles.DisplayNone] during [ApplyStyle].
	// This does *not* check for an empty TotalBBox, indicating that the widget
	// is out of render range -- that is done by [PushBounds] prior to rendering.
	// Non-visible nodes are automatically not rendered and do not get
	// window events.
	// This call recursively calls the parent, which is typically a short path.
	IsVisible() bool

	// ChildBackground returns the background color (Image) for given child Widget.
	// By default, this is just our [Styles.Actualbackground] but it can be computed
	// specifically for the child (e.g., for zebra stripes in [ListGrid])
	ChildBackground(child Widget) image.Image

	// DirectRenderImage uploads image directly into given system.Drawer at given index
	// Typically this is a drw.SetGoImage call with an [image.RGBA], or
	// drw.SetFrameImage with a [vgpu.FrameBuffer]
	DirectRenderImage(drw system.Drawer, idx int)

	// DirectRenderDraw draws the current image at index onto the RenderWindow window,
	// typically using drw.Copy, drw.Scale, or drw.Fill.
	// flipY is the default setting for whether the Y axis needs to be flipped during drawing,
	// which is typically passed along to the Copy or Scale methods.
	DirectRenderDraw(drw system.Drawer, idx int, flipY bool)
}

Widget is the interface that all Cogent Core satisfy. The core widget functionality is defined on WidgetBase, and all higher-level widget types must embed it. This interface only contains the methods that higher-level widget types may need to override. You can call [Widget.AsWidget] to get the WidgetBase of a Widget and access the core widget functionality.

func WidgetLastChild

func WidgetLastChild(w Widget) Widget

WidgetLastChild returns the last child under given node, or node itself if no children. Starts with Children, not Parts

func WidgetLastChildParts

func WidgetLastChildParts(w Widget) Widget

WidgetLastChildParts returns the last child under given node, or node itself if no children. Starts with Parts,

func WidgetNext

func WidgetNext(w Widget) Widget

WidgetNext returns the next widget in the tree, including Parts, which are considered to come after Children. returns nil if no more.

func WidgetNextFunc

func WidgetNextFunc(w Widget, fun func(w Widget) bool) Widget

WidgetNextFunc returns the next widget in the tree, including Parts, which are considered to come after children, continuing until the given function returns true. nil if no more.

func WidgetNextSibling

func WidgetNextSibling(w Widget) Widget

WidgetNextSibling returns next sibling or nil if none, including Parts, which are considered to come after Children.

func WidgetPrev

func WidgetPrev(w Widget) Widget

WidgetPrev returns the previous widget in the tree, including Parts, which are considered to come after Children. nil if no more.

func WidgetPrevFunc

func WidgetPrevFunc(w Widget, fun func(w Widget) bool) Widget

WidgetPrevFunc returns the previous widget in the tree, including Parts, which are considered to come after children, continuing until the given function returns true. nil if no more.

type WidgetBase

type WidgetBase struct {
	tree.NodeBase

	// Tooltip is the text for the tooltip for this widget,
	// which can use HTML formatting.
	Tooltip string `json:",omitempty"`

	// Parts are a separate tree of sub-widgets that can be used to store
	// orthogonal parts of a widget when necessary to separate them from children.
	// For example, trees use parts to separate their internal parts from
	// the other child tree nodes. Composite widgets like buttons should
	// NOT use parts to store their components; parts should only be used when
	// absolutely necessary.
	Parts *Frame `copier:"-" json:"-" xml:"-" set:"-"`

	// Geom has the full layout geometry for size and position of this Widget
	Geom GeomState `edit:"-" copier:"-" json:"-" xml:"-" set:"-"`

	// If true, override the computed styles and allow directly editing Styles.
	OverrideStyle bool `copier:"-" json:"-" xml:"-" set:"-"`

	// Styles are styling settings for this widget.
	// These are set in SetApplyStyle which should be called after any Config
	// change (e.g., as done by the Update method).  See Stylers for functions
	// that set all of the styles, ordered from initial base defaults to later
	// added overrides.
	Styles styles.Style `json:"-" xml:"-" set:"-"`

	// Stylers is a tiered set of functions that are called in sequential
	// ascending order (so the last added styler is called last and
	// thus can override all other stylers) to style the element.
	// These should be set using the [WidgetBase.Styler], [WidgetBase.FirstStyler],
	// and [WidgetBase.FinalStyler] functions.
	Stylers tiered.Tiered[[]func(s *styles.Style)] `copier:"-" json:"-" xml:"-" set:"-" edit:"-" display:"add-fields"`

	// Listeners is a tiered set of event listener functions for processing events on this widget.
	// They are called in sequential descending order (so the last added listener
	// is called first). They should be added using the [WidgetBase.On], [WidgetBase.OnFirst],
	// and [WidgetBase.OnFinal] functions, or any of the various On{EventType} helper functions.
	Listeners tiered.Tiered[events.Listeners] `copier:"-" json:"-" xml:"-" set:"-" edit:"-" display:"add-fields"`

	// A slice of functions to call on all widgets that are added as children
	// to this widget or its children. These functions are called in sequential
	// ascending order, so the last added one is called last and thus can
	// override anything set by the other ones. These should be set using
	// OnWidgetAdded, which can be called by both end-user and internal code.
	OnWidgetAdders []func(w Widget) `copier:"-" json:"-" xml:"-" set:"-" edit:"-"`

	// ContextMenus is a slice of menu functions to call to construct
	// the widget's context menu on an [events.ContextMenu]. The
	// functions are called in reverse order such that the elements
	// added in the last function are the first in the menu.
	// Context menus should be added through [WidgetBase.AddContextMenu].
	// Separators will be added between each context menu function.
	ContextMenus []func(m *Scene) `copier:"-" json:"-" xml:"-" set:"-" edit:"-"`

	// Scene is the overall Scene to which we belong. It is automatically
	// by widgets whenever they are added to another widget parent.
	Scene *Scene `copier:"-" json:"-" xml:"-" set:"-"`

	// ValueUpdate is a function set by [Bind] that is called in
	// [WidgetBase.UpdateWidget] to update the widget's value from the bound value.
	ValueUpdate func() `copier:"-" json:"-" xml:"-" set:"-"`

	// ValueOnChange is a function set by [Bind] that is called when
	// the widget receives an [events.Change] event to update the bound value
	// from the widget's value.
	ValueOnChange func() `copier:"-" json:"-" xml:"-" set:"-"`

	// ValueTitle is the title to display for a dialog for this [Value].
	ValueTitle string

	// ValueNewWindow indicates that the dialog of a [Value] should be opened
	// as a new window, instead of a typical full window in the same current window.
	// This is set by [InitValueButton] and handled by [OpenValueDialog].
	// This is triggered by holding down the Shift key while clicking on a
	// [Value] button. Certain values such as [FileButton] may set this to true
	// in their [InitValueButton] function.
	ValueNewWindow bool `copier:"-" json:"-" xml:"-"`
	// contains filtered or unexported fields
}

WidgetBase implements the Widget interface and provides the core functionality of a widget. You must use WidgetBase as an embedded struct in all higher-level widget types. It renders the standard box model, but does not layout or render any children; see Frame for that.

func NewWidgetBase added in v0.2.0

func NewWidgetBase(parent ...tree.Node) *WidgetBase

NewWidgetBase returns a new WidgetBase with the given optional parent: WidgetBase implements the Widget interface and provides the core functionality of a widget. You must use WidgetBase as an embedded struct in all higher-level widget types. It renders the standard box model, but does not layout or render any children; see Frame for that.

func (*WidgetBase) AbilityIs

func (wb *WidgetBase) AbilityIs(able abilities.Abilities) bool

AbilityIs returns whether the widget has the given abilities.Abilities flag set.

func (*WidgetBase) AddCloseDialog

func (wb *WidgetBase) AddCloseDialog(config func(d *Body) bool) *WidgetBase

AddCloseDialog adds a dialog that confirms that the user wants to close the Scene associated with this widget when they try to close it. It calls the given config function to configure the dialog. It is the responsibility of this config function to add the title and close button to the dialog, which is necessary so that the close dialog can be fully customized. If this function returns false, it does not make the dialog. This can be used to make the dialog conditional on other things, like whether something is saved.

Example
b := NewBody()
b.AddCloseDialog(func(d *Body) bool {
	d.AddTitle("Are you sure?").AddText("Are you sure you want to close the Cogent Core Demo?")
	d.AddBottomBar(func(parent Widget) {
		d.AddOK(parent).SetText("Close").OnClick(func(e events.Event) {
			b.Scene.Close()
		})
	})
	return true
})
b.RunMainWindow()
Output:

func (*WidgetBase) AddContextMenu

func (wb *WidgetBase) AddContextMenu(menu func(m *Scene)) *WidgetBase

AddContextMenu adds the given context menu to [WidgetBase.ContextMenus]. It is the main way that code should modify a widget's context menus. Context menu functions are run in reverse order, and separators are automatically added between each context menu function.

func (*WidgetBase) ApplyContextMenus

func (wb *WidgetBase) ApplyContextMenus(m *Scene)

ApplyContextMenus adds the [Widget.ContextMenus] to the given menu scene in reverse order. It also adds separators between each context menu function.

func (*WidgetBase) AsWidget

func (wb *WidgetBase) AsWidget() *WidgetBase

func (*WidgetBase) AsyncLock

func (wb *WidgetBase) AsyncLock()

AsyncLock must be called before making any updates in a separate goroutine outside of the main configuration, rendering, and event handling structure. It must have a matching WidgetBase.AsyncUnlock after it.

func (*WidgetBase) AsyncUnlock

func (wb *WidgetBase) AsyncUnlock()

AsyncUnlock must be called after making any updates in a separate goroutine outside of the main configuration, rendering, and event handling structure. It must have a matching WidgetBase.AsyncLock before it.

func (*WidgetBase) BaseType

func (wb *WidgetBase) BaseType() *types.Type

func (*WidgetBase) CanFocus

func (wb *WidgetBase) CanFocus() bool

CanFocus returns whether this node can receive keyboard focus.

func (*WidgetBase) ChildBackground

func (wb *WidgetBase) ChildBackground(child Widget) image.Image

ChildBackground returns the background color (Image) for given child Widget. By default, this is just our [Styles.Actualbackground] but it can be computed specifically for the child (e.g., for zebra stripes in ListGrid)

func (*WidgetBase) Clipboard

func (wb *WidgetBase) Clipboard() system.Clipboard

Clipboard returns the clipboard for the Widget to use.

func (*WidgetBase) ContainsFocus

func (wb *WidgetBase) ContainsFocus() bool

ContainsFocus returns true if this widget contains the current focus widget as maintained in the RenderWin

func (*WidgetBase) ContextMenuPos

func (wb *WidgetBase) ContextMenuPos(e events.Event) image.Point

ContextMenuPos returns the default position for the context menu upper left corner. The event will be from a mouse ContextMenu event if non-nil: should handle both cases.

func (*WidgetBase) CopyFieldsFrom

func (wb *WidgetBase) CopyFieldsFrom(from tree.Node)

func (*WidgetBase) DefaultTooltipPos added in v0.1.3

func (wb *WidgetBase) DefaultTooltipPos() image.Point

DefaultTooltipPos returns the default position for the tooltip, in Window coordinates, using the Window bounding box.

func (*WidgetBase) DeleteParts

func (wb *WidgetBase) DeleteParts()

DeleteParts deletes the widget's parts (and the children of the parts).

func (*WidgetBase) Destroy

func (wb *WidgetBase) Destroy()

func (*WidgetBase) DirectRenderDraw

func (wb *WidgetBase) DirectRenderDraw(drw system.Drawer, idx int, flipY bool)

DirectRenderDraw draws the current image at index onto the RenderWindow window, typically using drw.Copy, drw.Scale, or drw.Fill. flipY is the default setting for whether the Y axis needs to be flipped during drawing, which is typically passed along to the Copy or Scale methods.

func (*WidgetBase) DirectRenderImage

func (wb *WidgetBase) DirectRenderImage(drw system.Drawer, idx int)

DirectRenderImage uploads image directly into given system.Drawer at given index Typically this is a drw.SetGoImage call with an image.RGBA, or drw.SetFrameImage with a [vgpu.FrameBuffer]

func (*WidgetBase) DoNeedsRender

func (wb *WidgetBase) DoNeedsRender()

DoNeedsRender calls Render on tree from me for nodes with NeedsRender flags set

func (*WidgetBase) Events added in v0.1.1

func (wb *WidgetBase) Events() *Events

Events returns the higher-level core event manager for this Widget's Scene.

func (*WidgetBase) FinalHandleEvent

func (wb *WidgetBase) FinalHandleEvent(e events.Event)

FinalHandleEvent sends the given event to the FinalListeners for that event type. Does NOT do any state updating.

func (*WidgetBase) FinalStyler added in v0.2.0

func (wb *WidgetBase) FinalStyler(s func(s *styles.Style)) *WidgetBase

FinalStyler adds the given function for setting the style properties of the widget to [WidgetBase.Stylers.Final]. It is one of the main ways to specify the styles of a widget, in addition to FirstStyler and Styler, which add stylers that are called before the stylers added by this function.

func (*WidgetBase) FirstHandleEvent

func (wb *WidgetBase) FirstHandleEvent(e events.Event)

FirstHandleEvent sends the given event to the FirstListeners for that event type. Does NOT do any state updating.

func (*WidgetBase) FirstStyler added in v0.2.0

func (wb *WidgetBase) FirstStyler(s func(s *styles.Style)) *WidgetBase

FirstStyler adds the given function for setting the style properties of the widget to [WidgetBase.Stylers.First]. It is one of the main ways to specify the styles of a widget, in addition to Styler and FinalStyler, which add stylers that are called after the stylers added by this function.

func (*WidgetBase) FocusClear

func (wb *WidgetBase) FocusClear()

FocusClear resets focus to nil, but keeps the previous focus to pick up next time..

func (*WidgetBase) FocusNext

func (wb *WidgetBase) FocusNext()

FocusNext moves the focus onto the next item

func (*WidgetBase) FocusPrev

func (wb *WidgetBase) FocusPrev()

FocusPrev moves the focus onto the previous item

func (*WidgetBase) FocusableInMe

func (wb *WidgetBase) FocusableInMe() Widget

FocusableInMe returns the first Focusable element within this widget

func (*WidgetBase) GrowToAlloc

func (wb *WidgetBase) GrowToAlloc() bool

GrowToAlloc grows our Actual size up to current Alloc size for any dimension with a non-zero Grow factor. If Grow is < 1, then the size is increased in proportion, but any factor > 1 produces a full fill along that dimension. Returns true if this resulted in a change in our Total size.

func (*WidgetBase) GrowToAllocSize

func (wb *WidgetBase) GrowToAllocSize(act, alloc math32.Vector2) (math32.Vector2, bool)

GrowToAllocSize returns the potential size that widget could grow, for any dimension with a non-zero Grow factor. If Grow is < 1, then the size is increased in proportion, but any factor > 1 produces a full fill along that dimension. Returns true if this resulted in a change.

func (*WidgetBase) HandleClickOnEnterSpace

func (wb *WidgetBase) HandleClickOnEnterSpace()

HandleClickOnEnterSpace adds key event handler for Enter or Space to generate a Click action. This is not added by default, but is added in Button and Switch Widgets for example.

func (*WidgetBase) HandleEvent

func (wb *WidgetBase) HandleEvent(e events.Event)

HandleEvent sends the given event to all Listeners for that event type. It also checks if the State has changed and calls ApplyStyle if so. If more significant Config level changes are needed due to an event, the event handler must do this itself.

func (*WidgetBase) HandleLongHoverTooltip

func (wb *WidgetBase) HandleLongHoverTooltip()

HandleLongHoverTooltip listens for LongHover and LongPress events and pops up and deletes tooltips based on those. Most widgets should call this as part of their event handler methods.

func (*WidgetBase) HandleSelectToggle

func (wb *WidgetBase) HandleSelectToggle()

HandleSelectToggle does basic selection handling logic on widget, as just a toggle on individual selection state, including ensuring consistent selection flagging for parts. This is not called by WidgetBase but should be called for simple Widget types. More complex container / View widgets likely implement their own more complex selection logic.

func (*WidgetBase) HandleValueOnChange added in v0.2.0

func (wb *WidgetBase) HandleValueOnChange()

HandleValueOnChange adds a handler that calls [WidgetBase.ValueOnChange].

func (*WidgetBase) HandleWidgetClick

func (wb *WidgetBase) HandleWidgetClick()

HandleWidgetClick handles the Click event for basic Widget behavior. For Left button: If Checkable, toggles Checked. if Focusable, Focuses or clears, If Selectable, updates state and sends Select, Deselect.

func (*WidgetBase) HandleWidgetContextMenu

func (wb *WidgetBase) HandleWidgetContextMenu()

func (*WidgetBase) HandleWidgetMagnify

func (wb *WidgetBase) HandleWidgetMagnify()

HandleWidgetMagnifyEvent calls RenderWindow.StepZoom on events.Magnify

func (*WidgetBase) HandleWidgetStateFromFocus

func (wb *WidgetBase) HandleWidgetStateFromFocus()

HandleWidgetStateFromFocus updates standard State flags based on Focus events

func (*WidgetBase) HandleWidgetStateFromMouse

func (wb *WidgetBase) HandleWidgetStateFromMouse()

HandleWidgetStateFromMouse updates all standard State flags based on mouse events, such as MouseDown / Up -> Active and MouseEnter / Leave -> Hovered. None of these "consume" the event by setting Handled flag, as they are designed to work in conjunction with more specific handlers. Note that Disabled and Invisible widgets do NOT receive these events so it is not necessary to check that.

func (*WidgetBase) HasStateWithin

func (wb *WidgetBase) HasStateWithin(state states.States) bool

HasStateWithin returns whether the current node or any of its children have the given state flag.

func (*WidgetBase) Init added in v0.2.0

func (wb *WidgetBase) Init()

Init should be called by every Widget type in its custom Init if it has one to establish all the default styling and event handling that applies to all widgets.

func (*WidgetBase) IsDisabled

func (wb *WidgetBase) IsDisabled() bool

IsDisabled returns whether this node is flagged as [Disabled]. If so, behave and style appropriately.

func (*WidgetBase) IsReadOnly

func (wb *WidgetBase) IsReadOnly() bool

IsReadOnly returns whether this node is flagged as [ReadOnly] or [Disabled]. If so, behave appropriately. Styling is based on each state separately, but behaviors are often the same for both of these states.

func (*WidgetBase) IsVisible

func (wb *WidgetBase) IsVisible() bool

IsVisible returns true if a node is visible for rendering according to the states.Invisible flag on it or any of its parents. This flag is also set by styles.DisplayNone during [ApplyStyle]. This does *not* check for an empty TotalBBox, indicating that the widget is out of render range -- that is done by [PushBounds] prior to rendering. Non-visible nodes are automatically not rendered and do not get window events. This call recursively calls the parent, which is typically a short path.

func (*WidgetBase) NeedsLayout

func (wb *WidgetBase) NeedsLayout()

NeedsLayout specifies that the widget's scene needs to do a layout. This needs to be called after any changes that affect the structure and/or size of elements.

func (*WidgetBase) NeedsRebuild

func (wb *WidgetBase) NeedsRebuild() bool

NeedsRebuild returns true if the RenderContext indicates a full rebuild is needed.

func (*WidgetBase) NeedsRender

func (wb *WidgetBase) NeedsRender()

NeedsRender specifies that the widget needs to be rendered.

func (*WidgetBase) New

func (t *WidgetBase) New() tree.Node

New returns a new *WidgetBase value

func (*WidgetBase) NewParts

func (wb *WidgetBase) NewParts() *Frame

NewParts makes the [WidgetBase.Parts] if they don't already exist. It returns the parts regardless.

func (*WidgetBase) NodeType

func (t *WidgetBase) NodeType() *types.Type

NodeType returns the *types.Type of WidgetBase

func (*WidgetBase) NodeWalkDown

func (wb *WidgetBase) NodeWalkDown(fun func(tree.Node) bool)

NodeWalkDown extends tree.Node.WalkDown to [WidgetBase.Parts], which is key for getting full tree traversal to work when updating, configuring, and styling. This implements tree.Node.NodeWalkDown.

func (*WidgetBase) On

func (wb *WidgetBase) On(etype events.Types, fun func(e events.Event)) *WidgetBase

On adds the given event handler to the [WidgetBase.Listeners.Normal] for the given event type. Listeners are called in sequential descending order, so this listener will be called before all of the ones added before it. On is one of the main ways for both end-user and internal code to add an event handler to a widget, in addition to OnFirst and OnFinal, which add event handlers that are called before and after those added by this function, respectively.

func (*WidgetBase) OnAdd

func (wb *WidgetBase) OnAdd()

OnAdd is called when widgets are added to a parent. It sets the scene of the widget to its widget parent. It should be called by all other OnAdd functions defined by widget types.

func (*WidgetBase) OnChange

func (wb *WidgetBase) OnChange(fun func(e events.Event)) *WidgetBase

OnChange adds an event listener function for events.Change events.

func (*WidgetBase) OnChildAdded

func (wb *WidgetBase) OnChildAdded(child tree.Node)

func (*WidgetBase) OnClick

func (wb *WidgetBase) OnClick(fun func(e events.Event)) *WidgetBase

OnClick adds an event listener function for events.Click events.

func (*WidgetBase) OnClose

func (wb *WidgetBase) OnClose(fun func(e events.Event)) *WidgetBase

OnClose adds an event listener function for events.Close events.

func (*WidgetBase) OnDoubleClick

func (wb *WidgetBase) OnDoubleClick(fun func(e events.Event)) *WidgetBase

OnDoubleClick adds an event listener function for events.DoubleClick events.

func (*WidgetBase) OnFinal

func (wb *WidgetBase) OnFinal(etype events.Types, fun func(e events.Event)) *WidgetBase

OnFinal adds the given event handler to the [WidgetBase.Listeners.Final] for the given event type. FinalListeners are called in sequential descending order, so this final listener will be called before all of the ones added before it. OnFinal is one of the main ways for both end-user and internal code to add an event handler to a widget, in addition to OnFirst and On, which add event handlers that are called before those added by this function.

func (*WidgetBase) OnFirst

func (wb *WidgetBase) OnFirst(etype events.Types, fun func(e events.Event)) *WidgetBase

OnFirst adds the given event handler to the [WidgetBase.Listeners.First] for the given event type. FirstListeners are called in sequential descending order, so this first listener will be called before all of the ones added before it. OnFirst is one of the main ways for both end-user and internal code to add an event handler to a widget, in addition to On and OnFinal, which add event handlers that are called after those added by this function.

func (*WidgetBase) OnFocus

func (wb *WidgetBase) OnFocus(fun func(e events.Event)) *WidgetBase

OnFocus adds an event listener function for events.Focus events.

func (*WidgetBase) OnFocusLost

func (wb *WidgetBase) OnFocusLost(fun func(e events.Event)) *WidgetBase

OnFocusLost adds an event listener function for events.FocusLost events.

func (*WidgetBase) OnInput

func (wb *WidgetBase) OnInput(fun func(e events.Event)) *WidgetBase

OnInput adds an event listener function for events.Input events.

func (*WidgetBase) OnKeyChord

func (wb *WidgetBase) OnKeyChord(fun func(e events.Event)) *WidgetBase

OnKeyChord adds an event listener function for events.KeyChord events.

func (*WidgetBase) OnSelect

func (wb *WidgetBase) OnSelect(fun func(e events.Event)) *WidgetBase

OnSelect adds an event listener function for events.Select events.

func (*WidgetBase) OnShow

func (wb *WidgetBase) OnShow(fun func(e events.Event)) *WidgetBase

OnShow adds an event listener function for events.Show events.

func (*WidgetBase) OnWidgetAdded

func (wb *WidgetBase) OnWidgetAdded(fun func(w Widget)) *WidgetBase

OnWidgetAdded adds a function to call when a widget is added as a child to the widget or any of its children.

func (*WidgetBase) ParentActualBackground

func (wb *WidgetBase) ParentActualBackground() image.Image

ParentActualBackground returns the actual background of the parent of the widget. If it has no parent, it returns nil.

func (*WidgetBase) ParentLayout

func (wb *WidgetBase) ParentLayout() *Frame

ParentLayout returns the parent layout

func (*WidgetBase) ParentScrollLayout

func (wb *WidgetBase) ParentScrollLayout() *Frame

ParentScrollLayout returns the parent layout that has active scrollbars

func (*WidgetBase) ParentWidget

func (wb *WidgetBase) ParentWidget() *WidgetBase

ParentWidget returns the parent as a WidgetBase or nil if this is the root and has no parent.

func (*WidgetBase) ParentWidgetIf

func (wb *WidgetBase) ParentWidgetIf(fun func(p *WidgetBase) bool) *WidgetBase

ParentWidgetIf returns the nearest widget parent of the widget for which the given function returns true. It returns nil if no such parent is found.

func (*WidgetBase) PointToRelPos

func (wb *WidgetBase) PointToRelPos(pt image.Point) image.Point

PointToRelPos translates a point in Scene pixel coords into relative position within node, based on the Content BBox

func (*WidgetBase) PopBounds

func (wb *WidgetBase) PopBounds()

PopBounds pops our bounding box bounds. This is the last step in Render implementations after rendering children.

func (*WidgetBase) PosInScBBox

func (wb *WidgetBase) PosInScBBox(pos image.Point) bool

PosInScBBox returns true if given position is within this node's scene bbox

func (*WidgetBase) Position

func (wb *WidgetBase) Position()

Position uses the final sizes to set relative positions within layouts according to alignment settings.

func (*WidgetBase) PositionChildren

func (wb *WidgetBase) PositionChildren()

PositionChildren runs Position on the children

func (*WidgetBase) PositionParts

func (wb *WidgetBase) PositionParts()

func (*WidgetBase) PositionWidget

func (wb *WidgetBase) PositionWidget()

func (*WidgetBase) PositionWithinAllocMainX

func (wb *WidgetBase) PositionWithinAllocMainX(pos math32.Vector2, parJustify, parAlign styles.Aligns)

func (*WidgetBase) PositionWithinAllocMainY

func (wb *WidgetBase) PositionWithinAllocMainY(pos math32.Vector2, parJustify, parAlign styles.Aligns)

func (*WidgetBase) PushBounds

func (wb *WidgetBase) PushBounds() bool

PushBounds pushes our bounding box bounds onto the bounds stack if they are non-empty. This automatically limits our drawing to our own bounding box. This must be called as the first step in Render implementations. It returns whether the new bounds are empty or not; if they are empty, then don't render.

func (*WidgetBase) Render

func (wb *WidgetBase) Render()

Render is the method that widgets should implement to define their custom rendering steps. It should not typically be called outside of [Widget.RenderWidget], which also does other steps applicable for all widgets. The base WidgetBase.Render implementation renders the standard box model.

func (*WidgetBase) RenderBoxImpl

func (wb *WidgetBase) RenderBoxImpl(pos math32.Vector2, sz math32.Vector2, bs styles.Border)

RenderBoxImpl implements the standard box model rendering, assuming all paint parameters have already been set.

func (*WidgetBase) RenderChildren

func (wb *WidgetBase) RenderChildren()

RenderChildren renders all of the widget's children.

func (*WidgetBase) RenderParts

func (wb *WidgetBase) RenderParts()

func (*WidgetBase) RenderStandardBox

func (wb *WidgetBase) RenderStandardBox()

RenderStandardBox renders the standard box model.

func (*WidgetBase) RenderWidget

func (wb *WidgetBase) RenderWidget()

RenderWidget renders the widget and any parts and children that it has. It does not render if the widget is invisible. It calls Widget.Render] for widget-specific rendering.

func (*WidgetBase) Restyle added in v0.2.0

func (wb *WidgetBase) Restyle()

Restyle ensures that the styling of the widget and all of its children is updated and rendered by calling WidgetBase.StyleTree and WidgetBase.NeedsRender. It does not trigger a new update or layout pass, so it should only be used for non-structural styling changes.

func (*WidgetBase) ScenePos

func (wb *WidgetBase) ScenePos()

ScenePos computes scene-based absolute positions and final BBox bounding boxes for rendering, based on relative positions from Position step and parents accumulated position and scroll offset. This is the only step needed when scrolling (very fast).

func (*WidgetBase) ScenePosChildren

func (wb *WidgetBase) ScenePosChildren()

ScenePosChildren runs ScenePos on the children

func (*WidgetBase) ScenePosParts

func (wb *WidgetBase) ScenePosParts()

func (*WidgetBase) ScenePosWidget

func (wb *WidgetBase) ScenePosWidget()

func (*WidgetBase) ScrollToMe

func (wb *WidgetBase) ScrollToMe() bool

ScrollToMe tells this widget's parent layout to scroll to keep this widget in view. It returns whether any scrolling was done.

func (*WidgetBase) Send

func (wb *WidgetBase) Send(typ events.Types, original ...events.Event)

Send sends an NEW event of given type to this widget, optionally starting from values in the given original event (recommended to include where possible). Do NOT send an existing event using this method if you want the Handled state to persist throughout the call chain; call HandleEvent directly for any existing events.

func (*WidgetBase) SendChange

func (wb *WidgetBase) SendChange(original ...events.Event)

SendChange sends the events.Change event, which is widely used to signal updating for most widgets. It takes the event that the new change event is derived from, if any.

func (*WidgetBase) SendKey

func (wb *WidgetBase) SendKey(kf keymap.Functions, original ...events.Event)

func (*WidgetBase) SendKeyChord

func (wb *WidgetBase) SendKeyChord(kc key.Chord, original ...events.Event)

func (*WidgetBase) SendKeyChordRune

func (wb *WidgetBase) SendKeyChordRune(r rune, code key.Codes, mods key.Modifiers, original ...events.Event)

func (*WidgetBase) SetAbilities

func (wb *WidgetBase) SetAbilities(on bool, able ...abilities.Abilities) *WidgetBase

SetAbilities sets the given abilities.Abilities flags to the given value.

func (*WidgetBase) SetBBoxes

func (wb *WidgetBase) SetBBoxes()

func (*WidgetBase) SetBBoxesFromAllocs

func (wb *WidgetBase) SetBBoxesFromAllocs()

SetBBoxesFromAllocs sets BBox and ContentBBox from Geom.Pos and .Size This does NOT intersect with parent content BBox, which is done in SetBBoxes. Use this for elements that are dynamically positioned outside of parent BBox.

func (*WidgetBase) SetContentPosFromPos

func (wb *WidgetBase) SetContentPosFromPos()

SetContentPosFromPos sets the Pos.Content position based on current Pos plus the BoxSpace position offset.

func (*WidgetBase) SetEnabled

func (wb *WidgetBase) SetEnabled(enabled bool) *WidgetBase

SetEnabled sets the states.Disabled flag to the opposite of the given value.

func (*WidgetBase) SetFocus

func (wb *WidgetBase) SetFocus()

SetFocus sets the keyboard input focus on this item or the first item within it that can be focused (if none, then goes ahead and sets focus to this object). This does NOT send an events.Focus event, which typically results in the widget being styled as focused. See [SetFocusEvent] for one that does.

func (*WidgetBase) SetFocusEvent

func (wb *WidgetBase) SetFocusEvent()

SetFocusEvent sets the keyboard input focus on this item or the first item within it that can be focused (if none, then goes ahead and sets focus to this object). This sends an events.Focus event, which typically results in the widget being styled as focused. See [SetFocus] for one that does not.

func (*WidgetBase) SetPosFromParent

func (wb *WidgetBase) SetPosFromParent()

func (*WidgetBase) SetReadOnly

func (wb *WidgetBase) SetReadOnly(ro bool) *WidgetBase

SetReadOnly sets the states.ReadOnly flag to the given value.

func (*WidgetBase) SetScene

func (wb *WidgetBase) SetScene(sc *Scene)

SetScene sets the Scene pointer for this widget and all of its children. This can be necessary when creating widgets outside the usual "NewWidget" paradigm, e.g., when reading from a JSON file.

func (*WidgetBase) SetSelected

func (wb *WidgetBase) SetSelected(sel bool) *WidgetBase

SetSelected sets the states.Selected flag to given value for the entire Widget and calls WidgetBase.Restyle to apply any resultant style changes.

func (*WidgetBase) SetState

func (wb *WidgetBase) SetState(on bool, state ...states.States) *WidgetBase

SetState sets the given states.State flags to the given value.

func (*WidgetBase) SetTooltip

func (t *WidgetBase) SetTooltip(v string) *WidgetBase

SetTooltip sets the [WidgetBase.Tooltip]: Tooltip is the text for the tooltip for this widget, which can use HTML formatting.

func (*WidgetBase) SetValueNewWindow added in v0.2.0

func (t *WidgetBase) SetValueNewWindow(v bool) *WidgetBase

SetValueNewWindow sets the [WidgetBase.ValueNewWindow]: ValueNewWindow indicates that the dialog of a Value should be opened as a new window, instead of a typical full window in the same current window. This is set by InitValueButton and handled by OpenValueDialog. This is triggered by holding down the Shift key while clicking on a Value button. Certain values such as FileButton may set this to true in their InitValueButton function.

func (*WidgetBase) SetValueTitle added in v0.2.0

func (t *WidgetBase) SetValueTitle(v string) *WidgetBase

SetValueTitle sets the [WidgetBase.ValueTitle]: ValueTitle is the title to display for a dialog for this Value.

func (*WidgetBase) ShowContextMenu

func (wb *WidgetBase) ShowContextMenu(e events.Event)

func (*WidgetBase) SizeClass

func (wb *WidgetBase) SizeClass() SizeClasses

SizeClass returns the size class of the scene in which the widget is contained.

func (*WidgetBase) SizeDown

func (wb *WidgetBase) SizeDown(iter int) bool

SizeDown (top-down, multiple iterations possible) provides top-down size allocations based initially on Scene available size and the SizeUp Actual sizes. If there is extra space available, it is allocated according to the Grow factors. Flexible elements (e.g., Flex Wrap layouts and Text with word wrap) update their Actual size based on available Alloc size (re-wrap), to fit the allocated shape vs. the initial bottom-up guess. However, do NOT grow the Actual size to match Alloc at this stage, as Actual sizes must always represent the minimums (see Position). Returns true if any change in Actual size occurred.

func (*WidgetBase) SizeDownChildren

func (wb *WidgetBase) SizeDownChildren(iter int) bool

SizeDownChildren calls SizeDown on the Children. The kids must have their Size.Alloc set prior to this, which is what Layout type does. Other special widget types can do custom layout and call this too.

func (*WidgetBase) SizeDownParts

func (wb *WidgetBase) SizeDownParts(iter int) bool

func (*WidgetBase) SizeDownWidget

func (wb *WidgetBase) SizeDownWidget(iter int) bool

SizeDownWidget is the standard widget implementation of SizeDown. It just delegates to the Parts.

func (*WidgetBase) SizeFinal

func (wb *WidgetBase) SizeFinal()

SizeFinal: (bottom-up) similar to SizeUp but done at the end of the Sizing phase: first grows widget Actual sizes based on their Grow factors, up to their Alloc sizes. Then gathers this updated final actual Size information for layouts to register their actual sizes prior to positioning, which requires accurate Actual vs. Alloc sizes to perform correct alignment calculations.

func (*WidgetBase) SizeFinalChildren

func (wb *WidgetBase) SizeFinalChildren()

SizeFinalChildren calls SizeFinal on all the children of this node

func (*WidgetBase) SizeFinalParts

func (wb *WidgetBase) SizeFinalParts()

SizeFinalParts adjusts the Content size to hold the Parts Final sizes

func (*WidgetBase) SizeFinalWidget

func (wb *WidgetBase) SizeFinalWidget()

SizeFinalWidget is the standard Widget SizeFinal pass

func (*WidgetBase) SizeFromStyle

func (wb *WidgetBase) SizeFromStyle()

SizeFromStyle sets the initial Actual Sizes from Style.Min, Max. Required first call in SizeUp.

func (*WidgetBase) SizeUp

func (wb *WidgetBase) SizeUp()

SizeUp (bottom-up) gathers Actual sizes from our Children & Parts, based on Styles.Min / Max sizes and actual content sizing (e.g., text size). Flexible elements (e.g., Text, Flex Wrap, TopAppBar) should reserve the _minimum_ size possible at this stage, and then Grow based on SizeDown allocation.

func (*WidgetBase) SizeUpChildren

func (wb *WidgetBase) SizeUpChildren()

SizeUpChildren calls SizeUp on all the children of this node

func (*WidgetBase) SizeUpParts

func (wb *WidgetBase) SizeUpParts()

SizeUpParts adjusts the Content size to hold the Parts layout if present

func (*WidgetBase) SizeUpWidget

func (wb *WidgetBase) SizeUpWidget()

SizeUpWidget is the standard Widget SizeUp pass

func (*WidgetBase) SpaceFromStyle

func (wb *WidgetBase) SpaceFromStyle()

SpaceFromStyle sets the Space based on Style BoxSpace().Size()

func (*WidgetBase) StartFocus

func (wb *WidgetBase) StartFocus()

StartFocus specifies this widget to give focus to when the window opens

func (*WidgetBase) StateIs

func (wb *WidgetBase) StateIs(state states.States) bool

StateIs returns whether the widget has the given states.States flag set.

func (*WidgetBase) Style

func (wb *WidgetBase) Style()

Style updates the style properties of the widget based on [WidgetBase.Stylers]. To specify the style properties of a widget, use WidgetBase.Styler.

func (*WidgetBase) StyleSizeUpdate

func (wb *WidgetBase) StyleSizeUpdate() bool

StyleSizeUpdate updates styling size values for widget and its parent, which should be called after these are updated. Returns true if any changed.

func (*WidgetBase) StyleTree added in v0.2.0

func (wb *WidgetBase) StyleTree()

StyleTree calls WidgetBase.Style on every widget in tree underneath and including this widget.

func (*WidgetBase) Styler added in v0.2.0

func (wb *WidgetBase) Styler(s func(s *styles.Style)) *WidgetBase

Styler adds the given function for setting the style properties of the widget to [WidgetBase.Stylers.Normal]. It is one of the main ways to specify the styles of a widget, in addition to FirstStyler and FinalStyler, which add stylers that are called before and after the stylers added by this function, respectively.

func (*WidgetBase) SystemEvents added in v0.1.1

func (wb *WidgetBase) SystemEvents() *events.Source

SystemEvents returns the lower-level system event manager for this Widget's Scene.

func (*WidgetBase) Update

func (wb *WidgetBase) Update()

Update updates the widget and all of its children by running WidgetBase.UpdateWidget and WidgetBase.Style on each one, and triggering a new layout pass with WidgetBase.NeedsLayout. It is the main way that end users should trigger widget updates, and it is guaranteed to fully update a widget to the current state. For example, it should be called after making any changes to the core properties of a widget, such as the text of Text, the icon of a Button, or the slice of a Table.

Update differs from WidgetBase.UpdateWidget in that it updates the widget and all of its children down the tree, whereas WidgetBase.UpdateWidget only updates the widget itself. Also, Update also calls WidgetBase.Style and WidgetBase.NeedsLayout, whereas WidgetBase.UpdateWidget does not. End-user code should typically call Update, not WidgetBase.UpdateWidget.

If you are calling this in a separate goroutine outside of the main configuration, rendering, and event handling structure, you need to call WidgetBase.AsyncLock and WidgetBase.AsyncUnlock before and after this, respectively.

func (*WidgetBase) UpdateTree added in v0.2.0

func (wb *WidgetBase) UpdateTree()

UpdateTree calls WidgetBase.UpdateWidget on every widget in the tree starting with this one and going down.

func (*WidgetBase) UpdateWidget added in v0.2.0

func (wb *WidgetBase) UpdateWidget() *WidgetBase

UpdateWidget updates the widget by running [WidgetBase.Updaters] in sequential descending (reverse) order after calling [WidgetBase.ValueUpdate]. This includes applying the result of [WidgetBase.Make].

UpdateWidget differs from WidgetBase.Update in that it only updates the widget itself and not any of its children. Also, it does not restyle the widget or trigger a new layout pass, while WidgetBase.Update does. End-user code should typically call WidgetBase.Update, not UpdateWidget.

func (*WidgetBase) VisibleKidsIter

func (wb *WidgetBase) VisibleKidsIter(fun func(i int, w Widget, cwb *WidgetBase) bool)

VisibleKidsIter iterates through the Kids, as widgets, calling the given function, excluding any with the *local* states.Invisible flag set (does not check parents). This is used e.g., for layout functions to exclude non-visible direct children. Return tree.Continue (true) to continue, and tree.Break (false) to terminate.

func (*WidgetBase) WidgetKidsIter

func (wb *WidgetBase) WidgetKidsIter(fun func(i int, w Widget, cwb *WidgetBase) bool)

WidgetKidsIter iterates through the Kids, as widgets, calling the given function. Return tree.Continue (true) to continue, and tree.Break (false) to terminate.

func (*WidgetBase) WidgetTooltip

func (wb *WidgetBase) WidgetTooltip(pos image.Point) (string, image.Point)

WidgetTooltip is the base implementation of [Widget.WidgetTooltip], which just returns [WidgetBase.Tooltip] and WidgetBase.DefaultTooltipPos.

func (*WidgetBase) WidgetWalkDown added in v0.2.0

func (wb *WidgetBase) WidgetWalkDown(fun func(kwi Widget, kwb *WidgetBase) bool)

WidgetWalkDown is a version of tree.Node.WalkDown that automatically filters nil or deleted items and operates on Widget types. Return tree.Continue to continue and tree.Break to terminate.

func (*WidgetBase) WinBBox

func (wb *WidgetBase) WinBBox() image.Rectangle

WinBBox returns the RenderWindow based bounding box for the widget by adding the Scene position to the ScBBox

func (*WidgetBase) WinPos

func (wb *WidgetBase) WinPos(x, y float32) image.Point

WinPos returns the RenderWindow based position within the bounding box of the widget, where the x, y coordinates are the proportion across the bounding box to use: 0 = left / top, 1 = right / bottom

type WindowGeometries

type WindowGeometries map[string]map[string]WindowGeometry

WindowGeometries is the data structure for recording the window geometries by window name and screen name.

type WindowGeometry

type WindowGeometry struct {
	DPI        float32
	DPR        float32
	SX         int
	SY         int
	PX         int
	PY         int
	Fullscreen bool
}

WindowGeometry records the geometry settings used for a given window

func (*WindowGeometry) ConstrainGeom

func (wg *WindowGeometry) ConstrainGeom(sc *system.Screen)

ConstrainGeom constrains geometry based on screen params

func (*WindowGeometry) Pos

func (wg *WindowGeometry) Pos() image.Point

func (*WindowGeometry) SetPos

func (wg *WindowGeometry) SetPos(ps image.Point)

func (*WindowGeometry) SetSize

func (wg *WindowGeometry) SetSize(sz image.Point)

func (*WindowGeometry) Size

func (wg *WindowGeometry) Size() image.Point

type WindowGeometrySaver

type WindowGeometrySaver struct {

	// the full set of window geometries
	Geometries WindowGeometries

	// temporary cached geometries -- saved to Geometries after SaveDelay
	Cache WindowGeometries

	// base name of the settings file in Cogent Core settings directory
	Filename string

	// when settings were last saved -- if we weren't the last to save, then we need to re-open before modifying
	LastSave time.Time

	// if true, we are setting geometry so don't save -- caller must call SettingStart() SettingEnd() to block
	SettingNoSave bool

	// read-write mutex that protects updating of WindowGeometry
	Mu sync.RWMutex

	// wait time before trying to lock file again
	LockSleep time.Duration

	// wait time before saving the Cache into Geometries
	SaveDelay time.Duration
	// contains filtered or unexported fields
}

WindowGeometrySaver records window geometries in a persistent file, which is then used when opening new windows to restore.

func (*WindowGeometrySaver) AbortSave

func (mgr *WindowGeometrySaver) AbortSave()

AbortSave cancels any pending saving of the currently cached info. this is called if a screen event occured

func (*WindowGeometrySaver) DeleteAll

func (mgr *WindowGeometrySaver) DeleteAll()

DeleteAll deletes the file that saves the position and size of each window, by screen, and clear current in-memory cache. You shouldn't need to use this but sometimes useful for testing.

func (*WindowGeometrySaver) Init

func (mgr *WindowGeometrySaver) Init()

Init does initialization if not yet initialized

func (*WindowGeometrySaver) LockFile

func (mgr *WindowGeometrySaver) LockFile() error

LockFile attempts to create the window geometry lock file

func (*WindowGeometrySaver) NeedToReload

func (mgr *WindowGeometrySaver) NeedToReload() bool

NeedToReload returns true if the last save time of settings file is more recent than when we last saved. Called under mutex.

func (*WindowGeometrySaver) Open

func (mgr *WindowGeometrySaver) Open() error

Open RenderWindow Geom settings from Cogent Core standard settings directory called under mutex or at start

func (*WindowGeometrySaver) Pref

func (mgr *WindowGeometrySaver) Pref(winName string, scrn *system.Screen) *WindowGeometry

Pref returns an existing preference for given window name, for given screen. if the window name has a colon, only the part prior to the colon is used. if no saved pref is available for that screen, nil is returned.

func (*WindowGeometrySaver) RecordPref

func (mgr *WindowGeometrySaver) RecordPref(win *RenderWindow)

RecordPref records current state of window as preference

func (*WindowGeometrySaver) ResetCache

func (mgr *WindowGeometrySaver) ResetCache()

ResetCache resets the cache -- call under mutex

func (*WindowGeometrySaver) RestoreAll

func (mgr *WindowGeometrySaver) RestoreAll()

RestoreAll restores size and position of all windows, for current screen. Called when screen changes.

func (*WindowGeometrySaver) Save

func (mgr *WindowGeometrySaver) Save() error

Save RenderWindow Geom Settings to Cogent Core standard prefs directory assumed to be under mutex and lock still

func (*WindowGeometrySaver) SaveCached

func (mgr *WindowGeometrySaver) SaveCached()

SaveCached saves the cached prefs -- called after timer delay, under the Mu.Lock

func (*WindowGeometrySaver) SaveLastSave

func (mgr *WindowGeometrySaver) SaveLastSave()

SaveLastSave saves timestamp (now) of last save to win geom

func (*WindowGeometrySaver) SettingEnd

func (mgr *WindowGeometrySaver) SettingEnd()

SettingEnd turns off SettingNoSave -- safe to call even if Start not called.

func (*WindowGeometrySaver) SettingStart

func (mgr *WindowGeometrySaver) SettingStart()

SettingStart turns on SettingNoSave to prevent subsequent redundant calls to save a geometry that was being set from already-saved settings. Must call SettingEnd to turn off (safe to call even if Start not called).

func (*WindowGeometrySaver) UnlockFile

func (mgr *WindowGeometrySaver) UnlockFile()

UnLockFile unlocks the window geometry lock file (just removes it)

func (*WindowGeometrySaver) WinName

func (mgr *WindowGeometrySaver) WinName(winName string) string

WinName returns window name before first colon, if exists. This is the part of the name used to record settings

Jump to

Keyboard shortcuts

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