core

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: BSD-3-Clause Imports: 70 Imported by: 83

Documentation

Overview

Package core provides the core GUI functionality of Cogent Core.

Index

Examples

Constants

View Source
const (
	// ListRowProperty is the tree property name for the row of a list element.
	ListRowProperty = "ls-row"

	// ListColProperty is the tree property name for the column of a list element.
	ListColProperty = "ls-col"
)

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.CogentCore] otherwise.
	AppIcon string = string(icons.CogentCore)
)
View Source
var AllRenderWindows renderWindowList

AllRenderWindows is the list of all [renderWindow]s that have been created (dialogs, main windows, etc).

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 DebugSettings = &DebugSettingsData{
	SettingsBase: SettingsBase{
		Name: "Debug",
		File: filepath.Join(TheApp.CogentCoreDataDir(), "debug-settings.toml"),
	},
}

DebugSettings are the currently active debugging settings

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 ForceAppColor bool

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

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 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 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.

Functions

func AddValueType added in v0.2.0

func AddValueType[T any, W tree.NodeValue]()

AddValueType binds the given value type to the given Value tree.NodeValue 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 Bind added in v0.2.0

func Bind[T Value](value any, vw T, tags ...string) 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 WidgetBase.UpdateWidget. It returns the widget to enable method chaining. It also accepts an optional reflect.StructTag, which is used to set properties of certain value widgets.

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 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 ConstantSpacing added in v0.2.1

func ConstantSpacing(value float32) float32

ConstantSpacing returns a spacing value (padding, margin, gap) that will remain constant regardless of changes in the [AppearanceSettings.Spacing] setting.

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 SnackbarStage 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 FilePickerDirOnlyFilter added in v0.2.0

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

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

func FilePickerExtensionOnlyFilter added in v0.2.1

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

FilePickerExtensionOnlyFilter is a FilePickerFilterer that only shows files that match the target extensions, and directories.

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 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 LoadAllSettings

func LoadAllSettings() error

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

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 SnackbarStage displaying the given message in the context of the given widget.

func ProfileToggle

func ProfileToggle()

ProfileToggle turns profiling on or off, which does both targeted profiling 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 RecycleTabWidget added in v0.2.1

func RecycleTabWidget[T tree.NodeValue](ts *Tabs, name string) *T

RecycleTabWidget returns a tab with the given widget type in the tab frame, first by looking for an existing one with the given name, and if not found, making and configuring a new one. It returns the resulting widget.

func ResetWidgetValue added in v0.2.1

func ResetWidgetValue(vw Value)

ResetWidgetValue resets the Value if it was already bound to another value previously. We first need to reset the widget value to zero to avoid any issues with the pointer from the old value persisting and being updated. For example, that issue happened with slice and map pointers persisting in forms when a new struct was set. It should not be called by end-user code; it must be exported since it is referenced in a generic function added to yaegi (Bind).

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 SettingsWindow

func SettingsWindow()

SettingsWindow opens a window for editing user settings.

func StyleMenuScene added in v0.2.1

func StyleMenuScene(msc *Scene)

StyleMenuScene 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 ToHTML added in v0.3.1

func ToHTML(w Widget) ([]byte, error)

ToHTML converts the given widget and all of its children to HTML. This is not guaranteed to be perfect HTML, and it should not be used as a replacement for a Cogent Core app. However, it is good enough to be used as a preview or for SEO purposes (see generatehtml.go).

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 if Body.RunMainWindow is not used.

Types

type App

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

	// SceneInit is a function called on every newly created [Scene].
	// This can be used to set global configuration and styling for all
	// widgets in conjunction with [Scene.WidgetInit].
	SceneInit func(sc *Scene) `edit:"-"`
}

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) SetSceneInit added in v0.3.0

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

SetSceneInit sets the [App.SceneInit]: SceneInit is a function called on every newly created Scene. This can be used to set global configuration and styling for all widgets in conjunction with [Scene.WidgetInit].

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
	Highlighting HighlightingName `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) SaveScreenZoom

func (as *AppearanceSettingsData) SaveScreenZoom()

SaveScreenZoom saves the current zoom factor for the current screen.

func (*AppearanceSettingsData) ShouldDisplay added in v0.2.1

func (as *AppearanceSettingsData) ShouldDisplay(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 Blinker

type Blinker struct {

	// Ticker is the [time.Ticker] used to control the blinking.
	Ticker *time.Ticker

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

	// Func is the function called every tick.
	// The mutex is locked at the start but must be unlocked
	// when transitioning to locking the render context mutex.
	Func func()

	// Use Lock and Unlock on blinker directly.
	sync.Mutex
	// contains filtered or unexported fields
}

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 set up.

func (*Blinker) QuitClean

func (bl *Blinker) QuitClean()

QuitClean is a cleanup function to pass to [TheApp.AddQuitCleanFunc] that breaks out of the ticker loop.

func (*Blinker) ResetWidget

func (bl *Blinker) ResetWidget(w Widget)

ResetWidget sets [Blinker.Widget] to nil if it is currently set to the given one.

func (*Blinker) SetWidget

func (bl *Blinker) SetWidget(w Widget)

SetWidget sets the [Blinker.Widget] 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 styles.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 a cancel button to the given parent widget (typically in Body.AddBottomBar), connecting to keymap.Abort. Clicking on the cancel button automatically results in the dialog being closed; you can add your own WidgetBase.OnClick listener to do things beyond that.

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 the given parent widget (typically in Body.AddBottomBar), connecting to keymap.Accept. Clicking on the OK button automatically results in the dialog being closed; you can add your own WidgetBase.OnClick listener to do things beyond that. Also see Body.AddOKOnly.

func (*Body) AddOKOnly

func (bd *Body) AddOKOnly() *Body

AddOKOnly adds an OK button to the bottom bar of the Body through Body.AddBottomBar, connecting to keymap.Accept. Clicking on the OK button automatically results in the dialog being closed. Also see Body.AddOK.

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 [Body.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) 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) 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) 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.

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

	// 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

	// 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. Also see [Button.SetKey].
	Shortcut key.Chord

	// 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 WidgetBase.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 WidgetBase.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

Label returns the text of the button if it is set; otherwise it returns the name.

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. Also see Button.SetKey.

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)
	// contains filtered or unexported fields
}

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) 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

	// Indicator is the icon to use for the indicator displayed on the
	// right side of the chooser.
	Indicator icons.Icon

	// 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

	// 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:"-"`
	// contains filtered or unexported fields
}

Chooser is a dropdown 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 dropdown 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 an editable chooser.

func (*Chooser) Init added in v0.2.0

func (ch *Chooser) Init()

func (*Chooser) OnBind added in v0.2.0

func (ch *Chooser) OnBind(value any, tags reflect.StructTag)

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) 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) 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 that opens a ColorPicker.

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 that opens a ColorPicker.

func (*ColorButton) Init added in v0.2.0

func (cb *ColorButton) Init()

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 colormap.Map 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 colormap.Map 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) 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 colormap.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

	// Color is the current color.
	Color hct.HCT `set:"-"`
}

ColorPicker represents a color value with an interactive color picker composed of history buttons, a hex input, three HCT sliders, and standard named color buttons.

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 history buttons, a hex input, three HCT sliders, and standard named color buttons.

func (*ColorPicker) Init added in v0.2.0

func (cp *ColorPicker) Init()

func (*ColorPicker) SetColor added in v0.2.0

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

SetColor sets the color of the color picker.

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 context object that implements the completion functions
	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

	// current completion seed
	Seed string

	// the user's completion selection
	Completion string
	// contains filtered or unexported fields
}

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 popup Stage associated with it.

func NewComplete

func NewComplete() *Complete

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

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) GetCompletion

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

GetCompletion returns the completion with the given text.

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 events.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) SetContext

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

SetContext sets the [Complete.Context]: the context object that implements the completion functions

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) 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

type DatePicker added in v0.2.0

type DatePicker struct {
	Frame

	// Time is the time that we are viewing.
	Time time.Time
	// contains filtered or unexported fields
}

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) SetTime added in v0.2.0

func (t *DatePicker) SetTime(v time.Time) *DatePicker

SetTime sets the [DatePicker.Time]: Time is the time that we are viewing.

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 duration over which the current scroll widget retains scroll focus,
	// such that subsequent scroll events are sent to it.
	ScrollFocusTime time.Duration `default:"1s" min:"100ms" step:"50ms"`

	// 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:"150ms" 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) 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 {
	// contains filtered or unexported fields
}

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) Clipboard added in v0.1.1

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

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

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. It returns true if a focus item is found.

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) SetStartFocus added in v0.1.1

func (em *Events) SetStartFocus(k Widget)

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

type FileButton added in v0.2.0

type FileButton struct {
	Button
	Filename string

	// Extensions are the target file extensions for the file picker.
	Extensions 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) OnBind added in v0.3.0

func (fb *FileButton) OnBind(value any, tags reflect.StructTag)

func (*FileButton) SetExtensions added in v0.3.0

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

SetExtensions sets the [FileButton.Extensions]: Extensions are the target file extensions for the file picker.

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.

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

	// Filterer is an optional filtering function for which files to display.
	Filterer FilePickerFilterer `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) Destroy added in v0.2.1

func (fp *FilePicker) Destroy()

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) 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

SelectedFileInfo returns the currently selected fileinfo.FileInfo or nil.

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) SetFilterer added in v0.2.1

func (t *FilePicker) SetFilterer(v FilePickerFilterer) *FilePicker

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

type FilePickerFilterer added in v0.2.1

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

FilePickerFilterer 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) 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) 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) 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 it is
	// 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 widgets such as [Tabs], which do a full
	// redraw on stack changes, but not for widgets such as [Switch]es
	// which don't.
	LayoutStackTopOnly bool

	// HasScroll is whether scrollbars exist for each dimension.
	HasScroll [2]bool `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(n 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) ApplyScenePos added in v0.2.1

func (fr *Frame) ApplyScenePos()

ApplyScenePos: 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) 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 (fr *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) ConfigScrolls added in v0.2.0

func (fr *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) Destroy added in v0.2.0

func (fr *Frame) Destroy()

func (*Frame) Init added in v0.2.0

func (fr *Frame) Init()

func (*Frame) LayoutSpace added in v0.2.0

func (fr *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 (fr *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) Position added in v0.2.0

func (fr *Frame) Position()

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

func (*Frame) PositionScrolls added in v0.2.0

func (fr *Frame) PositionScrolls()

PositionScrolls arranges scrollbars

func (*Frame) RenderChildren added in v0.2.0

func (fr *Frame) RenderChildren()

func (*Frame) RenderScrolls added in v0.2.0

func (fr *Frame) RenderScrolls()

RenderScrolls renders the scrollbars.

func (*Frame) RenderWidget

func (fr *Frame) RenderWidget()

func (*Frame) ScrollChanged added in v0.2.0

func (fr *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) ScrollDimToCenter added in v0.2.0

func (fr *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 (fr *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) ScrollDimToContentStart added in v0.3.0

func (fr *Frame) ScrollDimToContentStart(d math32.Dims) bool

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

func (*Frame) ScrollDimToEnd added in v0.2.0

func (fr *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 (fr *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 (fr *Frame) ScrollGeom(d math32.Dims) (pos, sz math32.Vector2)

ScrollGeom returns the target position and size for scrollbars

func (*Frame) ScrollToBox added in v0.2.0

func (fr *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) ScrollUpdateFromGeom added in v0.2.0

func (fr *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 (fr *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 widgets such as Tabs, which do a full redraw on stack changes, but not for widgets such as [Switch]es which don't.

func (*Frame) SetScrollParams added in v0.2.0

func (fr *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) 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 it is not a valid index, nothing is rendered.

func (*Frame) SizeDown added in v0.2.0

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

func (*Frame) SizeDownSetAllocs added in v0.2.0

func (fr *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) SizeFinal added in v0.2.0

func (fr *Frame) SizeFinal()

func (*Frame) SizeFromChildren added in v0.2.0

func (fr *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) SizeUp added in v0.2.0

func (fr *Frame) SizeUp()

func (*Frame) StackTopWidget added in v0.2.0

func (fr *Frame) StackTopWidget() *WidgetBase

StackTopWidget returns the [Frame.StackTop] element as a WidgetBase.

func (*Frame) Style added in v0.2.0

func (fr *Frame) Style()

func (*Frame) UpdateStackedVisibility added in v0.2.0

func (fr *Frame) UpdateStackedVisibility()

UpdateStackedVisibility 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

	// Args are the [FuncArg] objects associated with the
	// arguments of the function. They are automatically set in
	// [FuncButton.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 [FuncButton.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 return value dialog a NewWindow dialog.
	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()
	// contains filtered or unexported fields
}

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 text and tooltip 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. The main function to call first is FuncButton.SetFunc.

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 text and tooltip 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. The main function to call first is FuncButton.SetFunc.

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) OnBind added in v0.2.0

func (fb *FuncButton) OnBind(value any, tags reflect.StructTag)

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) SetNewWindow added in v0.2.0

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

SetNewWindow sets the [FuncButton.NewWindow]: NewWindow makes the return value dialog a NewWindow dialog.

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 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 styles.Style.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 styles.Style.Direction controls the direction in which the handle moves.

func (*Handle) Init added in v0.2.0

func (hl *Handle) Init()

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 HighlightingName added in v0.2.3

type HighlightingName string

HighlightingName is a highlighting style name. TODO: move this to texteditor/highlighting.

type Icon

type Icon struct {
	WidgetBase

	// Icon is the [icons.Icon] used to render the [Icon].
	Icon icons.Icon
	// contains filtered or unexported fields
}

Icon renders an icons.Icon. The rendered version is cached for the current size. Icons do not render a background or border independent of their SVG object. The size of an 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 icons.Icon. The rendered version is cached for the current size. Icons do not render a background or border independent of their SVG object. The size of an Icon is determined by the styles.Font.Size property.

func (*Icon) Init added in v0.2.0

func (ic *Icon) Init()

func (*Icon) Render

func (ic *Icon) Render()

func (*Icon) SetIcon

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

SetIcon sets the [Icon.Icon]: Icon is the icons.Icon used to render the 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) WidgetValue added in v0.2.0

func (ib *IconButton) WidgetValue() any

type Image

type Image struct {
	WidgetBase

	// Image is the [image.Image].
	Image image.Image `xml:"-" json:"-"`
	// contains filtered or unexported fields
}

Image is a widget that renders an image.Image. See styles.Style.ObjectFit 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 an image.Image. See styles.Style.ObjectFit 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) 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 (t *Image) SetImage(v image.Image) *Image

SetImage sets the [Image.Image]: Image is the image.Image.

func (*Image) SizeUp added in v0.3.0

func (im *Image) SizeUp()

func (*Image) WidgetValue added in v0.2.1

func (im *Image) WidgetValue() any

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) DeleteAt added in v0.2.1

func (il *InlineList) DeleteAt(idx int)

DeleteAt deletes the element at the given index from the slice.

func (*InlineList) Init added in v0.2.0

func (il *InlineList) Init()

func (*InlineList) NewAt added in v0.2.1

func (il *InlineList) NewAt(idx int)

NewAt inserts a new blank element at the given index in the slice. -1 indicates to insert the element at the end.

func (*InlineList) SetSlice added in v0.2.0

func (il *InlineList) SetSlice(sl any) *InlineList

SetSlice sets the source slice that we are viewing. It rebuilds the children to represent this slice.

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
	// contains filtered or unexported fields
}

Inspector represents a tree.Node with a Tree and a Form.

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 tree.Node with a Tree and a Form.

func (*Inspector) Init added in v0.2.0

func (is *Inspector) Init()

func (*Inspector) MakeToolbar added in v0.2.0

func (is *Inspector) MakeToolbar(p *tree.Plan)

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.

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) 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) 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

	// SortByValues is whether to sort by values instead of keys.
	SortByValues 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) AddItem added in v0.2.1

func (kl *KeyedList) AddItem()

AddItem adds a new key-value item to the map.

func (*KeyedList) DeleteItem added in v0.2.1

func (kl *KeyedList) DeleteItem(key reflect.Value)

DeleteItem deletes a key-value item from the map.

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)

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) SetSortByValues added in v0.2.1

func (t *KeyedList) SetSortByValues(v bool) *KeyedList

SetSortByValues sets the [KeyedList.SortByValues]: SortByValues is whether to sort by values instead of 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) 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 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 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 an interface containing layout functions implemented by all types embedding Frame.

type List added in v0.2.0

type List struct {
	ListBase

	// ListStyler is an optional styler for list items.
	ListStyler ListStyler `copier:"-" 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) HasStyler added in v0.2.1

func (ls *List) HasStyler() bool

func (*List) SetListStyler added in v0.2.1

func (t *List) SetListStyler(v ListStyler) *List

SetListStyler sets the [List.ListStyler]: ListStyler is an optional styler for list items.

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.
	// If it is set, it is used as the initially selected value.
	SelectedValue any `copier:"-" display:"-" json:"-" xml:"-"`

	// SelectedIndex is the index of the currently selected item.
	SelectedIndex int `copier:"-" json:"-" xml:"-"`

	// InitSelectedIndex is the index of the row to select at the start.
	InitSelectedIndex int `copier:"-" json:"-" xml:"-"`

	// SelectedIndexes is a list of currently selected slice indexes.
	SelectedIndexes map[int]struct{} `set:"-" copier:"-"`

	// VisibleRows is the total number of rows visible in allocated display size.
	VisibleRows int `set:"-" edit:"-" copier:"-" json:"-" xml:"-"`

	// StartIndex is the starting slice index of visible rows.
	StartIndex int `set:"-" edit:"-" copier:"-" json:"-" xml:"-"`

	// SliceSize is the size of the slice.
	SliceSize int `set:"-" edit:"-" copier:"-" json:"-" xml:"-"`

	// MakeIter is the iteration through the configuration process,
	// which is reset when a new slice type is set.
	MakeIter int `set:"-" edit:"-" copier:"-" 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 `default:"true"`

	// SelectMode is whether to be in select rows mode or editing mode.
	SelectMode bool `set:"-" copier:"-" json:"-" xml:"-"`

	// ReadOnlyMultiSelect: if list 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:"-"`

	// ListGrid is the [ListGrid] widget.
	ListGrid *ListGrid `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 (*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) CopySelectToMime added in v0.2.0

func (lb *ListBase) CopySelectToMime() mimedata.Mimes

CopySelectToMime copies selected rows to mime data

func (*ListBase) DeleteAt added in v0.2.1

func (lb *ListBase) DeleteAt(i int)

DeleteAt deletes the element at the given index from the slice.

func (*ListBase) DeleteAtSelect added in v0.2.1

func (lb *ListBase) DeleteAtSelect(i int)

DeleteAtSelect updates the selected rows based on deleting the element at the given index.

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) Init added in v0.2.0

func (lb *ListBase) Init()

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) 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) 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)

func (*ListBase) MakeValue added in v0.2.0

func (lb *ListBase) MakeValue(w Value, i int)

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) NewAt added in v0.2.1

func (lb *ListBase) NewAt(idx int)

NewAt inserts a new blank element at the given index in the slice. -1 indicates to insert the element at the end.

func (*ListBase) NewAtSelect added in v0.2.1

func (lb *ListBase) NewAtSelect(i int)

NewAtSelect updates the selected rows based on inserting a new element at the given index.

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) ResetSelectedIndexes added in v0.2.0

func (lb *ListBase) ResetSelectedIndexes()

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) 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) 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) SelectIndexEvent added in v0.2.1

func (lb *ListBase) SelectIndexEvent(idx int, mode events.SelectModes)

SelectIndexEvent is called when a select event has been received (e.g., a mouse click) -- translates into selection updates -- gets selection mode from mouse event (ExtendContinuous, ExtendOne)

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]: InitSelectedIndex is the index of the row to select at the 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 list 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]: SelectedIndex is the index of the 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. If it is set, it is used as the initially selected value.

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) SliceIndex added in v0.2.0

func (lb *ListBase) SliceIndex(i int) (si, vi int, invis bool)

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) UpdateMaxWidths added in v0.2.0

func (lb *ListBase) UpdateMaxWidths()

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) 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) 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
	// contains filtered or unexported fields
}

ListGrid handles the resizing logic for all [Lister]s.

func (*ListGrid) ChildBackground added in v0.2.0

func (lg *ListGrid) ChildBackground(child Widget) image.Image

func (*ListGrid) Init added in v0.2.0

func (lg *ListGrid) Init()

func (*ListGrid) Render added in v0.2.0

func (lg *ListGrid) Render()

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) 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

type ListStyler added in v0.2.1

type ListStyler func(w Widget, s *styles.Style, row int)

ListStyler is a styling function for custom styling and configuration of elements in the list.

type Lister added in v0.2.0

type Lister interface {
	tree.Node

	// AsListBase returns the base for direct access to relevant fields etc
	AsListBase() *ListBase

	// 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)

	// HasStyler returns whether there is a custom style function.
	HasStyler() bool

	// StyleRow calls a custom style function on given row (and field)
	StyleRow(w Widget, idx, fidx int)

	// 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

	// NewAt inserts a new blank element at the given index in the slice.
	// -1 indicates to insert the element at the end.
	NewAt(idx int)

	// DeleteAt deletes the element at the given index from the slice.
	DeleteAt(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)
}

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 a Styler.
	ValueColor image.Image

	// Width, for [MeterCircle] and [MeterSemicircle], is the
	// width of the circle/semicircle. It should be set in a Styler.
	Width units.Value
}

Meter is a widget that renders a current value on as a filled bar/circle/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/circle/semicircle relative to a minimum and maximum potential value.

func (*Meter) Init added in v0.2.0

func (m *Meter) Init()

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 a Styler.

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 a Styler.

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 OnBinder added in v0.2.0

type OnBinder interface {

	// OnBind is called when the widget is bound to the given value
	// with the given optional struct tags.
	OnBind(value any, tags reflect.StructTag)
}

OnBinder is an optional interface that [Value]s can implement to do something when the widget is bound to the given value.

type SVG

type SVG struct {
	WidgetBase

	// SVG is the SVG drawing to display.
	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) 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) 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) 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

	// 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 `json:"-" xml:"-" set:"-"`

	// WidgetInit is a function called on every newly created [Widget].
	// This can be used to set global configuration and styling for all
	// widgets in conjunction with [App.SceneInit].
	WidgetInit func(w Widget) `json:"-" xml:"-" edit:"-"`

	// 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:"-"`

	// 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

	// 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:"-"`
	// 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 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 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 (*Scene) AddDirectRender

func (sc *Scene) AddDirectRender(w Widget)

func (*Scene) ApplyScenePos added in v0.2.1

func (sc *Scene) ApplyScenePos()

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) 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) Init added in v0.2.0

func (sc *Scene) Init()

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) 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) 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) SetWidgetInit added in v0.3.0

func (t *Scene) SetWidgetInit(v func(w Widget)) *Scene

SetWidgetInit sets the [Scene.WidgetInit]: WidgetInit is a function called on every newly created Widget. This can be used to set global configuration and styling for all widgets in conjunction with [App.SceneInit].

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" format:"%g%%"`
}

ScreenSettings are per-screen settings that override the global settings.

type Separator

type Separator struct {
	WidgetBase
}

Separator draws a separator line. It goes in the direction specified by styles.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 styles.Style.Direction.

func (*Separator) Init added in v0.2.0

func (sp *Separator) Init()

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 ShouldDisplayer added in v0.2.1

type ShouldDisplayer interface {

	// ShouldDisplay returns whether the given named field should be displayed.
	ShouldDisplay(field string) bool
}

ShouldDisplayer is an interface that 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 thumb.
	Icon icons.Icon

	// ThumbSize is the size of the thumb as a proportion of the slider thickness,
	// which is the content size (inside the padding).
	ThumbSize math32.Vector2

	// TrackSize is the proportion of slider thickness for the visible track
	// for the [SliderSlider] type. It is often thinner than the thumb, achieved
	// by values less than 1 (0.5 default).
	TrackSize float32 `default:"0.5"`

	// InputThreshold is the threshold for the amount of change in scroll
	// value before emitting an input event.
	InputThreshold float32

	// Precision 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.
	Precision int

	// ValueColor is the background color that is used for styling the selected value
	// section of the slider. It should be set in a Styler, 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

	// ThumbColor is the background color that is used for styling the thumb (handle)
	// of the slider. It should be set in a Styler, 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

	// StayInView is whether to keep the slider (typically a [SliderScrollbar]) within
	// the parent [Scene] bounding box, if the parent is in view. This is the default
	// behavior for [Frame] scrollbars, and setting this flag replicates that behavior
	// in other scrollbars.
	StayInView bool
	// contains filtered or unexported fields
}

Slider is a slideable widget that provides slider functionality with a draggable thumb and a clickable track. 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 with a draggable thumb and a clickable track. The styles.Style.Direction determines the direction in which the slider slides.

func (*Slider) ApplyScenePos added in v0.2.1

func (sr *Slider) ApplyScenePos()

func (*Slider) Init added in v0.2.0

func (sr *Slider) Init()

func (*Slider) OnBind added in v0.2.0

func (sr *Slider) OnBind(value any, tags reflect.StructTag)

func (*Slider) Render

func (sr *Slider) Render()

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 thumb.

func (*Slider) SetInputThreshold

func (t *Slider) SetInputThreshold(v float32) *Slider

SetInputThreshold sets the [Slider.InputThreshold]: InputThreshold is the threshold for the 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) SetPrecision added in v0.2.1

func (t *Slider) SetPrecision(v int) *Slider

SetPrecision sets the [Slider.Precision]: Precision 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 (*Slider) SetStayInView

func (t *Slider) SetStayInView(v bool) *Slider

SetStayInView sets the [Slider.StayInView]: StayInView is whether to keep the slider (typically a SliderScrollbar) within the parent Scene bounding box, if the parent is in view. This is the default behavior for Frame 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]: ThumbColor is the background color that is used for styling the thumb (handle) of the slider. It should be set in a Styler, 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]: ThumbSize is the size of the thumb as a proportion of the slider thickness, which is the content size (inside the padding).

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 SliderSlider type. It is often thinner than the thumb, achieved by values less than 1 (0.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(value float32) *Slider

SetValue sets the value and updates the slider position, but does not send an events.Change event.

func (*Slider) SetValueColor

func (t *Slider) SetValueColor(v image.Image) *Slider

SetValueColor sets the [Slider.ValueColor]: ValueColor is the background color that is used for styling the selected value section of the slider. It should be set in a Styler, 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) 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.
	// It has a [Slider.visiblePercent] 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 ([Slider.visiblePercent] = 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.
	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()

type Spinner

type Spinner struct {
	TextField

	// Value is the current value.
	Value float32 `set:"-"`

	// HasMin is whether there is a minimum value to enforce.
	// It should be set using [Spinner.SetMin].
	HasMin bool `set:"-"`

	// Min, if [Spinner.HasMin] is true, is the the minimum value in range.
	// It should be set using [Spinner.SetMin].
	Min float32 `set:"-"`

	// HaxMax is whether there is a maximum value to enforce.
	// It should be set using [Spinner.SetMax].
	HasMax bool `set:"-"`

	// Max, if [Spinner.HasMax] is true, is the maximum value in range.
	// It should be set using [Spinner.SetMax].
	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

	// Precision 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.
	Precision 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) Init added in v0.2.0

func (sp *Spinner) Init()

func (*Spinner) OnBind added in v0.2.0

func (sp *Spinner) OnBind(value any, tags reflect.StructTag)

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) SetPrecision added in v0.2.1

func (t *Spinner) SetPrecision(v int) *Spinner

SetPrecision sets the [Spinner.Precision]: Precision 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) SetValue

func (sp *Spinner) SetValue(val float32) *Spinner

SetValue sets the value, enforcing any limits, and updates the display.

func (*Spinner) SetWidgetValue added in v0.2.0

func (sp *Spinner) SetWidgetValue(value any) error

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

type Splits

type Splits struct {
	Frame

	// Tiles specifies the 2D layout of elements along the [styles.Style.Direction]
	// main axis and the orthogonal cross axis.  If all Tiles are TileSpan, then
	// a 1D line is generated.  There is always a split between each Tile segment,
	// and different tiles consume different numbers of elements in order, and
	// have different numbers of SubSplits.  Because each Tile can represent a
	// different number of elements, care must be taken to ensure that the full
	// set of tiles corresponds to the actual number of children.  A default
	// 1D configuration will be imposed if there is a mismatch.
	Tiles []SplitsTiles

	// TileSplits is the proportion (0-1 normalized, enforced) of space
	// allocated to each Tile element along the main axis.
	// 0 indicates that an element should  be completely collapsed.
	// By default, each element gets the same amount of space.
	TileSplits []float32

	// SubSplits contains splits proportions for each Tile element, with
	// a variable number depending on the Tile.  For the First and Second Long
	// elements, there are 2 subsets of sub-splits, with 4 total subsplits.
	SubSplits [][]float32
	// contains filtered or unexported fields
}

Splits allocates a certain proportion of its space to each of its children, organized along styles.Style.Direction as the main axis, and supporting SplitsTiles of 2D splits configurations along the cross axis. There is always a split between each Tile segment along the main axis, with the proportion of the total main axis space per Tile allocated according to normalized Splits factors. If all Tiles are Span then a 1D line is generated. Children are allocated in order along the main axis, according to each of the Tiles, which consume 1 to 4 elements, and have 0 to 3 splits internally. The internal split proportion are stored separately in SubSplits. A Handle widget is added to the Parts for each split, allowing the user to drag the relative size of each splits region. If more complex geometries are required, use nested Splits.

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, organized along styles.Style.Direction as the main axis, and supporting SplitsTiles of 2D splits configurations along the cross axis. There is always a split between each Tile segment along the main axis, with the proportion of the total main axis space per Tile allocated according to normalized Splits factors. If all Tiles are Span then a 1D line is generated. Children are allocated in order along the main axis, according to each of the Tiles, which consume 1 to 4 elements, and have 0 to 3 splits internally. The internal split proportion are stored separately in SubSplits. A Handle widget is added to the Parts for each split, allowing the user to drag the relative size of each splits region. If more complex geometries are required, use nested Splits.

func (*Splits) ChildIsCollapsed added in v0.3.0

func (sl *Splits) ChildIsCollapsed(idx int) bool

ChildIsCollapsed returns true if the split proportion for given child index is 0. Also checks the overall tile splits for the child.

func (*Splits) Init added in v0.2.0

func (sl *Splits) Init()

func (*Splits) Position

func (sl *Splits) Position()

func (*Splits) RenderWidget

func (sl *Splits) RenderWidget()

func (*Splits) SetSplit added in v0.3.0

func (sl *Splits) SetSplit(idx int, val float32)

SetSplit sets the split proportion of relevant display width specific to given child index. Also updates other split values in proportion.

func (*Splits) SetSplits

func (sl *Splits) SetSplits(splits ...float32) *Splits

SetSplits sets the split proportions for the children. In general you should pass the same number of args as there are children, though fewer could be passed.

func (*Splits) SetSubSplits added in v0.3.0

func (t *Splits) SetSubSplits(v ...[]float32) *Splits

SetSubSplits sets the [Splits.SubSplits]: SubSplits contains splits proportions for each Tile element, with a variable number depending on the Tile. For the First and Second Long elements, there are 2 subsets of sub-splits, with 4 total subsplits.

func (*Splits) SetTileSplits added in v0.3.0

func (t *Splits) SetTileSplits(v ...float32) *Splits

SetTileSplits sets the [Splits.TileSplits]: TileSplits is the proportion (0-1 normalized, enforced) of space allocated to each Tile element along the main axis. 0 indicates that an element should be completely collapsed. By default, each element gets the same amount of space.

func (*Splits) SetTiles added in v0.3.0

func (t *Splits) SetTiles(v ...SplitsTiles) *Splits

SetTiles sets the [Splits.Tiles]: Tiles specifies the 2D layout of elements along the styles.Style.Direction main axis and the orthogonal cross axis. If all Tiles are TileSpan, then a 1D line is generated. There is always a split between each Tile segment, and different tiles consume different numbers of elements in order, and have different numbers of SubSplits. Because each Tile can represent a different number of elements, care must be taken to ensure that the full set of tiles corresponds to the actual number of children. A default 1D configuration will be imposed if there is a mismatch.

func (*Splits) SizeDownSetAllocs

func (sl *Splits) SizeDownSetAllocs(iter int)

func (*Splits) Split added in v0.3.0

func (sl *Splits) Split(idx int) float32

Split returns the split proportion for given child index

func (*Splits) Splits

func (sl *Splits) Splits() []float32

Splits returns the split proportion for each child element.

type SplitsTiles added in v0.3.0

type SplitsTiles int32 //enums:enum -trim-prefix Tile

SplitsTiles specifies 2D tiles for organizing elements within the Splits Widget. The styles.Style.Direction defines the main axis, and the cross axis is orthogonal to that, which is organized into chunks of 2 cross-axis "rows". In the case of a 1D pattern, only Span is relevant, indicating a single element per split.

const (
	// Span has a single element spanning the cross dimension, i.e.,
	// a vertical span for a horizontal main axis, or a horizontal
	// span for a vertical main axis.  It is the only valid value
	// for 1D Splits, where it specifies a single element per split.
	// If all tiles are Span, then a 1D line is generated.
	TileSpan SplitsTiles = iota

	// Split has a split between elements along the cross dimension,
	// with the first of 2 elements in the first main axis line and
	// the second in the second line.
	TileSplit

	// FirstLong has a long span of first element along the first
	// main axis line and a split between the next two elements
	// along the second line, with a split between the two lines.
	// Visually, the splits form a T shape for a horizontal main axis.
	TileFirstLong

	// SecondLong has the first two elements split along the first line,
	//	and the third with a long span along the second main axis line,
	// with a split between the two lines.  Visually, the splits form
	// an inverted T shape for a horizontal main axis.
	TileSecondLong

	// Plus is arranged like a plus sign + with the main split along
	// the main axis line, and then individual cross-axis splits
	// between the first two and next two elements.
	TilePlus
)
const SplitsTilesN SplitsTiles = 5

SplitsTilesN is the highest valid value for type SplitsTiles, plus one.

func SplitsTilesValues added in v0.3.0

func SplitsTilesValues() []SplitsTiles

SplitsTilesValues returns all possible values for the type SplitsTiles.

func (SplitsTiles) Desc added in v0.3.0

func (i SplitsTiles) Desc() string

Desc returns the description of the SplitsTiles value.

func (SplitsTiles) Int64 added in v0.3.0

func (i SplitsTiles) Int64() int64

Int64 returns the SplitsTiles value as an int64.

func (SplitsTiles) MarshalText added in v0.3.0

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

MarshalText implements the encoding.TextMarshaler interface.

func (*SplitsTiles) SetInt64 added in v0.3.0

func (i *SplitsTiles) SetInt64(in int64)

SetInt64 sets the SplitsTiles value from an int64.

func (*SplitsTiles) SetString added in v0.3.0

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

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

func (SplitsTiles) String added in v0.3.0

func (i SplitsTiles) String() string

String returns the string representation of this SplitsTiles value.

func (*SplitsTiles) UnmarshalText added in v0.3.0

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

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (SplitsTiles) Values added in v0.3.0

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

Values returns all possible values for the type SplitsTiles.

type Sprite

type Sprite struct {

	// Active is whether this sprite is Active now or not.
	Active bool

	// Name is the unique name of the 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, which should be the same size as [Sprite.Geom.Size]
	Pixels *image.RGBA
	// contains filtered or unexported fields
}

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(name string, sz image.Point, pos image.Point) *Sprite

NewSprite returns a new Sprite with the 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) 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) 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]

	// set to true if sprites have been modified since last config
	Modified bool
	// contains filtered or unexported fields
}

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) 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) InactivateSprite

func (ss *Sprites) InactivateSprite(name string)

InactivateSprite flags the sprite as inactive, setting Modified if wasn't before.

func (*Sprites) SpriteByName

func (ss *Sprites) SpriteByName(name string) (*Sprite, bool)

SpriteByName returns the sprite by name

type Stage

type Stage struct {

	// Type is the type of [Stage], which determines behavior and styling.
	Type StageTypes `set:"-"`

	// Scene contents of this [Stage] (what it displays).
	Scene *Scene `set:"-"`

	// Context is a widget in another scene that requested this stage to be created
	// and provides context.
	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 [Body.Title]. It used for the 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.
	Scrim bool

	// ClickOff, if true, dismisses the [Stage] if the user clicks anywhere
	// off of the [Stage].
	ClickOff 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 [Stage.NewWindow] is false, makes [DialogStage]s and
	// [WindowStage]s 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
	// [DialogStage]s and off for [WindowStage]s.
	CloseOnBack bool

	// Timeout, if greater than 0, results in a popup stages disappearing
	// after this timeout duration.
	Timeout time.Duration

	// Pos is the target position for the [Stage] to be placed within
	// the surrounding window.
	Pos image.Point

	// If a popup stage, this is the main stage that owns it (via its [Stage.popups]).
	// If a main stage, it points to itself.
	Main *Stage `set:"-"`

	// For all stages, this is the main [Stages] that lives in a [renderWindow]
	// and manages the main stages.
	Mains *stages `set:"-"`

	// Sprites are named images that are rendered last overlaying everything else.
	Sprites Sprites `json:"-" xml:"-" set:"-"`
	// contains filtered or unexported fields
}

Stage is a container and manager for displaying a Scene in different functional ways, defined by StageTypes.

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 (*Stage) ClosePopup

func (st *Stage) ClosePopup() bool

ClosePopup closes this stage as a popup, returning whether it was closed.

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) SetClickOff

func (t *Stage) SetClickOff(v bool) *Stage

SetClickOff sets the [Stage.ClickOff]: ClickOff, if true, dismisses the Stage if the user clicks anywhere off of 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 [DialogStage]s and off for [WindowStage]s.

func (*Stage) SetContext

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

SetContext sets the [Stage.Context]: Context is a widget in another scene that requested this stage to be created and provides context.

func (*Stage) SetFullWindow

func (t *Stage) SetFullWindow(v bool) *Stage

SetFullWindow sets the [Stage.FullWindow]: FullWindow, if [Stage.NewWindow] is false, makes [DialogStage]s and [WindowStage]s take up the entire window they are created in.

func (*Stage) SetModal

func (st *Stage) SetModal(modal bool) *Stage

SetModal sets modal flag for blocking other input (for dialogs). Also updates [Stage.Scrim] accordingly if not modal.

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) 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) SetPos

func (t *Stage) SetPos(v image.Point) *Stage

SetPos sets the [Stage.Pos]: Pos is the target position for the Stage to be placed within the surrounding window.

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.

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 this 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 [Body.Title]. It used for the title of WindowStage and DialogStage types.

func (*Stage) String

func (st *Stage) String() string

type StageTypes

type StageTypes int32 //enums:enum

StageTypes are the types of Stage containers. There are two main categories: MainStage and PopupStage. MainStages are WindowStage and DialogStage, which are large and potentially complex [Scene]s that persist until dismissed. PopupStages are MenuStage, TooltipStage, SnackbarStage, and CompleterStage, which are transitory and simple, without additional decorations. MainStages live in a [stages] associated with a [renderWindow] 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 content,
	// and it typically persists throughout. It fills the [renderWindow].
	// Additional windows can be created either within the same [renderWindow]
	// on all platforms or in separate [renderWindow]s on desktop platforms.
	WindowStage StageTypes = iota

	// DialogStage is a MainStage that displays a [Scene] in a smaller dialog
	// window on top of a [WindowStage], or in a full or separate window.
	// It can be [Stage.Modal] or not.
	DialogStage

	// MenuStage is a PopupStage that displays a [Scene] typically containing
	// [Button]s overlaid on a MainStage. It is typically [Stage.Modal] and
	// [Stage.ClickOff], and closes when an button is clicked.
	MenuStage

	// TooltipStage is a PopupStage that displays a [Scene] with extra text
	// info for a widget overlaid on a MainStage. It is typically [Stage.ClickOff]
	// and not [Stage.Modal].
	TooltipStage

	// SnackbarStage is a PopupStage that displays a [Scene] with text info
	// and an optional additional button. It is displayed at the bottom of the
	// screen. It is typically not [Stage.ClickOff] or [Stage.Modal], but has a
	// [Stage.Timeout].
	SnackbarStage

	// CompleterStage is a PopupStage that displays a [Scene] with text completion
	// options, spelling corrections, or other such dynamic info. It is typically
	// [Stage.ClickOff], not [Stage.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) 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 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()

type Switch

type Switch struct {
	Frame

	// Type is the styling type of switch.
	// It must be set using [Switch.SetType].
	Type SwitchTypes `set:"-"`

	// Text is the optional text of the switch.
	Text string

	// IconOn is the icon to use for the on, checked state of the switch.
	IconOn icons.Icon

	// Iconoff is the icon to use for the off, unchecked state of the switch.
	IconOff icons.Icon

	// IconIndeterminate is the icon to use for the indeterminate (unknown) state.
	IconIndeterminate icons.Icon
}

Switch is a widget that can toggle between an on and off state. It can be displayed as a switch, chip, checkbox, radio button, or segmented 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, chip, checkbox, radio button, or segmented button.

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) OnBind added in v0.3.0

func (sw *Switch) OnBind(value any, tags reflect.StructTag)

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) SetText

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

SetText sets the [Switch.Text]: Text is the optional text of 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) 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.

type SwitchTypes

type SwitchTypes int32 //enums:enum -trim-prefix Switch -transform kebab

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 `default:"true"`
	// 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) Init added in v0.2.0

func (sw *Switches) Init()

func (*Switches) OnBind added in v0.2.0

func (sw *Switches) OnBind(value any, tags reflect.StructTag)

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 favoritePaths

	// 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].

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 blank, 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
	// contains filtered or unexported fields
}

Tab is a tab button that contains one or more 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) 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) SetText

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

SetText sets the [Tab.Text]: Text is the text for the tab. If it is blank, 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.

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 will also support being moved at some point.
	FunctionalTabs

	// NavigationAuto indicates to render the tabs as either
	// [NavigationBar] or [NavigationDrawer] if
	// [WidgetBase.SizeClass] is [SizeCompact] or not, 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

	// NavigationDrawer indicates to render the tabs as a
	// side navigation drawer with text and icons.
	NavigationDrawer
)
const TabTypesN TabTypes = 5

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) Int64

func (i TabTypes) Int64() int64

Int64 returns the TabTypes value as an int64.

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

	// TableStyler is an optional styling function for table items.
	TableStyler TableStyler `copier:"-" json:"-" xml:"-"`

	// SelectedField is the current selection field; initially select value in this field.
	SelectedField string `copier:"-" display:"-" json:"-" xml:"-"`
	// 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) DeleteAt added in v0.2.1

func (tb *Table) DeleteAt(idx int)

DeleteAt deletes the element at the given index from the slice.

func (*Table) HasStyler added in v0.2.1

func (tb *Table) HasStyler() bool

func (*Table) Init added in v0.2.0

func (tb *Table) Init()

func (*Table) MakeRow added in v0.2.0

func (tb *Table) MakeRow(p *tree.Plan, i int)

func (*Table) NewAt added in v0.2.1

func (tb *Table) NewAt(idx int)

NewAt inserts a new blank element at the given index in the slice. -1 indicates to insert the element at the end.

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) 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.

func (*Table) SetTableStyler added in v0.2.1

func (t *Table) SetTableStyler(v TableStyler) *Table

SetTableStyler sets the [Table.TableStyler]: TableStyler is an optional styling function for table items.

func (*Table) SizeFinal added in v0.2.0

func (tb *Table) SizeFinal()

func (*Table) SortColumn added in v0.2.1

func (tb *Table) SortColumn(fieldIndex int)

SortColumn sorts the slice for the given field index. It toggles between ascending and descending if already sorting on this field.

func (*Table) SortSlice added in v0.2.0

func (tb *Table) SortSlice()

SortSlice sorts the slice according to current settings.

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 TableStyler added in v0.2.1

type TableStyler func(w Widget, s *styles.Style, row, col int)

TableStyler 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

	// 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
	// contains filtered or unexported fields
}

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) 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) Init added in v0.2.0

func (ts *Tabs) Init()

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) 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) *Frame

RecycleTab returns a tab with the given name, first by looking for an existing one, and if not found, making a new one. It returns the frame for the tab.

func (*Tabs) SelectTabByName

func (ts *Tabs) SelectTabByName(name string) *Frame

SelectTabByName selects the 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

SelectTabIndex selects the tab at the given index, returning it or nil. 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) 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) TabByName

func (ts *Tabs) TabByName(name string) *Frame

TabByName returns the tab Frame with the given widget name (nil if not found). The widget name is the original full tab label, prior to any eliding.

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.
	// It defaults to [TextBodyLarge].
	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) 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) 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. It defaults to TextBodyLarge.

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.
	// See [TextField.SetLeadingIcon].
	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. See [TextField.SetLeadingIcon].
	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.
	// See [TextField.SetTrailingIcon].
	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. See [TextField.SetTrailingIcon].
	TrailingIconOnClick func(e events.Event) `json:"-" xml:"-"`

	// NoEcho is whether replace displayed characters with bullets
	// to conceal text (for example, for a password input). Also
	// see [TextField.SetTypePassword].
	NoEcho bool

	// CursorWidth is the width of the text field cursor.
	// It should be set in a Styler 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 a Styler like all other style properties.
	// By default, it is [colors.Scheme.Primary.Base].
	CursorColor image.Image

	// PlaceholderColor is the color used for the [TextField.Placeholder] text.
	// It should be set in a Styler 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 a Styler like all other style properties.
	// By default, it is [colors.Scheme.Select.Container].
	SelectColor image.Image
	// contains filtered or unexported fields
}

TextField is a widget for editing a line of text.

With the default styles.WhiteSpaceNormal setting, text will wrap onto multiple lines as needed. You can call styles.Style.SetTextWrap(false) to force everything to be rendered 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 styles.WhiteSpaceNormal setting, text will wrap onto multiple lines as needed. You can call styles.Style.SetTextWrap(false) to force everything to be rendered 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 text field that clears the text in the text field when it is clicked.

func (*TextField) ApplyScenePos added in v0.2.1

func (tf *TextField) ApplyScenePos()

func (*TextField) AsTextField

func (t *TextField) AsTextField() *TextField

AsTextField satisfies the TextFieldEmbedder interface

func (*TextField) Destroy

func (tf *TextField) Destroy()

func (*TextField) Init added in v0.2.0

func (tf *TextField) Init()

func (*TextField) OnBind added in v0.2.1

func (tf *TextField) OnBind(value any, tags reflect.StructTag)

func (*TextField) Render

func (tf *TextField) Render()

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 a Styler like all other style properties. By default, it is [colors.Scheme.Primary.Base].

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 a Styler like all other style properties. By default, it is 1dp.

func (*TextField) SetLeadingIcon

func (tf *TextField) SetLeadingIcon(icon icons.Icon, onClick ...func(e events.Event)) *TextField

SetLeadingIcon sets the [TextField.LeadingIcon] to the given icon. If an on click function is specified, it also sets the [TextField.LeadingIconOnClick] 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. See TextField.SetLeadingIcon.

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). Also see TextField.SetTypePassword.

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 [TextField.Placeholder] text. It should be set in a Styler 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 a Styler like all other style properties. By default, it is [colors.Scheme.Select.Container].

func (*TextField) SetText

func (tf *TextField) SetText(text string) *TextField

SetText sets the text of the text field and reverts any current edits to reflect this new text.

func (*TextField) SetTrailingIcon

func (tf *TextField) SetTrailingIcon(icon icons.Icon, onClick ...func(e events.Event)) *TextField

SetTrailingIcon sets the [TextField.TrailingIcon] to the given icon. If an on click function is specified, it also sets the [TextField.TrailingIconOnClick] 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. See TextField.SetTrailingIcon.

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) SizeDown

func (tf *TextField) SizeDown(iter int) bool

func (*TextField) SizeUp

func (tf *TextField) SizeUp()

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 of the text field. It applies any unapplied changes first, and sends an events.Change event if applicable. This is the main end-user method to get the current value of the text field.

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 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) 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
	// contains filtered or unexported fields
}

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) 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 the 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 the app.

func (*Toolbar) AddOverflowMenu

func (tb *Toolbar) AddOverflowMenu(fun func(m *Scene))

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) Init added in v0.2.0

func (tb *Toolbar) Init()

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 dialogs.

type Tree added in v0.2.0

type Tree struct {
	WidgetBase

	// SyncNode, if non-nil, is the [tree.Node] that this widget is
	// viewing in the tree (the source). It should be set using
	// [Tree.SyncTree].
	SyncNode tree.Node `set:"-" copier:"-" json:"-" xml:"-"`

	// Text is 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

	// Icon is an optional icon displayed to the the left of the text label.
	Icon icons.Icon

	// IconOpen is the icon to use for an open (expanded) branch;
	// it defaults to [icons.KeyboardArrowDown].
	IconOpen icons.Icon

	// IconClosed is the icon to use for a closed (collapsed) branch;
	// it defaults to [icons.KeyboardArrowRight].
	IconClosed icons.Icon

	// IconLeaf is the icon to use for a terminal node branch that has no children;
	// it defaults to [icons.Blank].
	IconLeaf icons.Icon

	// TreeInit is a function set on the root node that is called
	// with each child tree node when it is initialized (but not
	// with the root node itself).
	TreeInit func(tr *Tree)

	// Indent is the amount to indent children relative to this node.
	// It should be set in a Styler like all other style properties.
	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

	// SelectedNodes holds the currently selected nodes.
	// It is only set on the root node. See [Tree.GetSelectedNodes]
	// for a version that also works on non-root nodes.
	SelectedNodes []Treer `copier:"-" json:"-" xml:"-" edit:"-" set:"-"`

	// Branch is the branch widget that is used to open and close the tree node.
	Branch *Switch `json:"-" xml:"-" copier:"-" set:"-" display:"-"`
	// 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, you must place it in a Frame.

If the [Tree.SyncNode] field is non-nil, typically via the Tree.SyncTree 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 events.Select, events.Change, and events.DoubleClick. The selected nodes are in the root [Tree.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, you must place it in a Frame.

If the [Tree.SyncNode] field is non-nil, typically via the Tree.SyncTree 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 events.Select, events.Change, and events.DoubleClick. The selected nodes are in the root [Tree.SelectedNodes] list.

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) ApplyScenePos added in v0.2.1

func (tr *Tree) ApplyScenePos()

func (*Tree) AsCoreTree added in v0.2.0

func (tr *Tree) AsCoreTree() *Tree

AsCoreTree satisfies the Treer interface.

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 tree accordingly (if it is not already closed). It calls OnClose in the Treer interface for extensible actions.

func (*Tree) CloseAll added in v0.2.0

func (tr *Tree) CloseAll()

CloseAll closes the node and all of its sub-nodes.

func (*Tree) ContextMenuPos added in v0.2.0

func (tr *Tree) ContextMenuPos(e events.Event) (pos image.Point)

func (*Tree) Copy added in v0.2.0

func (tr *Tree) Copy()

Copy copies the tree to the clipboard.

func (*Tree) Cut added in v0.2.0

func (tr *Tree) Cut()

Cut 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) DragDrop added in v0.2.0

func (tr *Tree) DragDrop(e events.Event)

DragDrop handles drag drop event

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) 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) FindSyncNode added in v0.2.0

func (tr *Tree) FindSyncNode(n tree.Node) *Tree

FindSyncNode returns the Tree node for the corresponding given source tree.Node in [Tree.SyncNode] or nil if not found.

func (*Tree) GetSelectedNodes added in v0.2.1

func (tr *Tree) GetSelectedNodes() []Treer

GetSelectedNodes returns a slice of the currently selected Trees within the entire tree, using a list maintained by the root node.

func (*Tree) HasSelection added in v0.2.0

func (tr *Tree) HasSelection() bool

HasSelection returns whether 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) 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) IsRoot added in v0.2.0

func (tr *Tree) IsRoot(action string) bool

IsRoot returns true if given node is the root of the tree, creating an error snackbar if it is and action is non-empty.

func (*Tree) Label added in v0.2.0

func (tr *Tree) Label() string

Label returns the display label for this node, satisfying the labels.Labeler interface.

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) 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) 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 tree accordingly (if it is not already opened). It calls OnOpen in the Treer interface for extensible actions.

func (*Tree) OpenAll added in v0.2.0

func (tr *Tree) OpenAll()

OpenAll opens the 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) Position added in v0.2.0

func (tr *Tree) Position()

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) Resync added in v0.2.1

func (tr *Tree) Resync()

Resync resynchronizes the Tree relative to the [Tree.SyncNode] underlying nodes and triggers an update.

func (*Tree) Select added in v0.2.0

func (tr *Tree) Select()

Select selects this node (if not already selected). You must use this method to update global selection list.

func (*Tree) SelectAll added in v0.2.0

func (tr *Tree) SelectAll()

SelectAll selects all items in the tree.

func (*Tree) SelectEvent added in v0.2.1

func (tr *Tree) SelectEvent(mode events.SelectModes) bool

SelectEvent updates selection to include this node, using selectmode from mouse event (ExtendContinuous, ExtendOne), and root sends selection event. Returns true if event sent.

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]: Icon is an 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]: IconClosed is the icon to use for a closed (collapsed) branch; it 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]: IconLeaf is the icon to use for a terminal node branch that has no children; it 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]: IconOpen is the icon to use for an open (expanded) branch; it 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]: Indent is the amount to indent children relative to this node. It should be set in a Styler like all other style properties.

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 (tr *Tree) SetSelectedNodes(sl []Treer)

SetSelectedNodes updates the selected nodes on the root node to the given list.

func (*Tree) SetText added in v0.2.0

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

SetText sets the [Tree.Text]: Text is 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) SetTreeInit added in v0.3.0

func (t *Tree) SetTreeInit(v func(tr *Tree)) *Tree

SetTreeInit sets the [Tree.TreeInit]: TreeInit is a function set on the root node that is called with each child tree node when it is initialized (but not with the root node itself).

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) SyncTree added in v0.2.0

func (tr *Tree) SyncTree(n tree.Node) *Tree

SyncTree sets the root [Tree.SyncNode] to the root of the given tree.Node and synchronizes 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) Unselect added in v0.2.0

func (tr *Tree) Unselect()

Unselect unselects this node (if selected). You must use this method to update global selection list.

func (*Tree) UnselectAll added in v0.2.0

func (tr *Tree) UnselectAll()

UnselectAll unselects all selected items in the tree.

func (*Tree) UnselectEvent added in v0.2.1

func (tr *Tree) UnselectEvent()

UnselectEvent unselects this node (if selected), and root sends a selection event.

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) 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()

	MimeData(md *mimedata.Mimes)
	Cut()
	Copy()
	Paste()
	DragDrop(e events.Event)
	DropDeleteSource(e events.Event)
}

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()

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].

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

	// Style updates the style properties of the widget based on [WidgetBase.Stylers].
	// To specify the style properties of a widget, use [WidgetBase.Styler].
	// Widgets can implement this method if necessary to add additional styling behavior,
	// such as calling [units.Value.ToDots] on a custom [units.Value] field.
	Style()

	// 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()

	// ApplyScenePos 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).
	ApplyScenePos()

	// 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)

	// ChildBackground returns the background color (Image) for given child Widget.
	// By default, this is just our [styles.Style.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 widgets 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.

var ExternalParent Widget

ExternalParent is a parent widget external to this program. If it is set, calls to Body.RunWindow before Wait and calls to Body.RunMainWindow will add the Body to this parent instead of creating a new window. It should typically not be used by end users; it is used in yaegicore and for pre-rendering apps as HTML that can be used as a preview and for SEO purposes.

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, [Tree]s 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. Use [WidgetBase.newParts] to make the parts.
	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:"-"`

	// OverrideStyle, if true, indicates override the computed styles of the widget
	// and allow directly editing [WidgetBase.Styles]. It is typically only set in
	// the inspector.
	OverrideStyle bool `copier:"-" json:"-" xml:"-" set:"-"`

	// Styles are styling settings for this widget. They are set by
	// [WidgetBase.Stylers] in [WidgetBase.Style].
	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"`

	// 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.
	// It should not be accessed by end users.
	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. It should not be accessed by end users.
	ValueOnChange func() `copier:"-" json:"-" xml:"-" set:"-"`

	// ValueTitle is the title to display for a dialog for this [Value].
	ValueTitle string
	// 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 AsWidget

func AsWidget(n tree.Node) *WidgetBase

AsWidget returns the given tree.Node as a WidgetBase or nil.

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)

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))

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) ApplyScenePos added in v0.2.1

func (wb *WidgetBase) ApplyScenePos()

ApplyScenePos 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) 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) 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 whether this widget contains the current focus widget.

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 for this widget in window coordinates using the window bounding box.

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) 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) FinalStyler added in v0.2.0

func (wb *WidgetBase) FinalStyler(s func(s *styles.Style))

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) FirstStyler added in v0.2.0

func (wb *WidgetBase) FirstStyler(s func(s *styles.Style))

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) ForWidgetChildren added in v0.2.3

func (wb *WidgetBase) ForWidgetChildren(fun func(i int, cw Widget, cwb *WidgetBase) bool)

ForWidgetChildren iterates through the children as widgets, calling the given function. Return tree.Continue (true) to continue, and tree.Break (false) to terminate.

func (*WidgetBase) HandleClickOnEnterSpace

func (wb *WidgetBase) HandleClickOnEnterSpace()

HandleClickOnEnterSpace adds a key event handler for Enter and Space keys to generate an events.Click event. This is not added by default, but is added in Button and Switch for example.

func (*WidgetBase) HandleEvent

func (wb *WidgetBase) HandleEvent(e events.Event)

HandleEvent sends the given event to all [WidgetBase.Listeners] for that event type. It also checks if the State has changed and calls WidgetBase.Restyle if so.

func (*WidgetBase) HasStateWithin

func (wb *WidgetBase) HasStateWithin(state states.States) bool

HasStateWithin returns whether this widget 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 widget 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 WidgetBase.Style. This does *not* check for an empty TotalBBox, indicating that the widget is out of render range; that is done by WidgetBase.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 whether the [renderContext] indicates a full rebuild is needed. This is typically used to detect when the settings have been changed, such as when the color scheme or zoom is changed.

func (*WidgetBase) NeedsRender

func (wb *WidgetBase) NeedsRender()

NeedsRender specifies that the widget needs to be rendered.

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))

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 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))

OnChange adds an event listener function for events.Change events.

func (*WidgetBase) OnClick

func (wb *WidgetBase) OnClick(fun func(e events.Event))

OnClick adds an event listener function for events.Click events.

func (*WidgetBase) OnClose

func (wb *WidgetBase) OnClose(fun func(e events.Event))

OnClose adds an event listener function for events.Close events.

func (*WidgetBase) OnDoubleClick

func (wb *WidgetBase) OnDoubleClick(fun func(e events.Event))

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))

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 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))

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 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))

OnFocus adds an event listener function for events.Focus events.

func (*WidgetBase) OnFocusLost

func (wb *WidgetBase) OnFocusLost(fun func(e events.Event))

OnFocusLost adds an event listener function for events.FocusLost events.

func (*WidgetBase) OnInput

func (wb *WidgetBase) OnInput(fun func(e events.Event))

OnInput adds an event listener function for events.Input events.

func (*WidgetBase) OnKeyChord

func (wb *WidgetBase) OnKeyChord(fun func(e events.Event))

OnKeyChord adds an event listener function for events.KeyChord events.

func (*WidgetBase) OnSelect

func (wb *WidgetBase) OnSelect(fun func(e events.Event))

OnSelect adds an event listener function for events.Select events.

func (*WidgetBase) OnShow

func (wb *WidgetBase) OnShow(fun func(e events.Event))

OnShow adds an event listener function for events.Show events.

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) Position

func (wb *WidgetBase) Position()

Position uses the final sizes to set relative positions within layouts according to alignment settings.

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) RenderBoxGeom added in v0.2.1

func (wb *WidgetBase) RenderBoxGeom(pos math32.Vector2, sz math32.Vector2, bs styles.Border)

RenderBoxGeom renders a box with the given geometry.

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) ScrollToThis added in v0.2.1

func (wb *WidgetBase) ScrollToThis() bool

ScrollToThis tells this widget's parent frame 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 the 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 a new events.Change event, which is widely used to signal value changing for most widgets. It takes the event that the new change event is derived from, if any.

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 just sets focus to this object). This does not send an events.Focus event, which typically results in the widget being styled as focused. See WidgetBase.SetFocusEvent for a version 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 just sets focus to this object). This sends an events.Focus event, which typically results in the widget being styled as focused. See WidgetBase.SetFocus for a version that does not.

func (*WidgetBase) SetReadOnly

func (wb *WidgetBase) SetReadOnly(ro bool) *WidgetBase

SetReadOnly sets the states.ReadOnly flag to the given value.

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) 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) 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) 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) SizeUpWidget

func (wb *WidgetBase) SizeUpWidget()

SizeUpWidget is the standard Widget SizeUp pass

func (*WidgetBase) StartFocus

func (wb *WidgetBase) StartFocus()

StartFocus specifies that this widget should get focus when the Scene is shown.

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) 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))

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) UpdateChange added in v0.2.1

func (wb *WidgetBase) UpdateChange(original ...events.Event)

UpdateChange is a helper function that calls WidgetBase.SendChange and then WidgetBase.Update. That is the correct order, since calling WidgetBase.Update first would cause the value of the widget to be incorrectly overridden in a Value context.

func (*WidgetBase) UpdateRender added in v0.2.1

func (wb *WidgetBase) UpdateRender()

UpdateRender is the same as WidgetBase.Update, except that it calls WidgetBase.NeedsRender instead of WidgetBase.NeedsLayout. This should be called when the changes made to the widget do not require a new layout pass (if you change the size, spacing, alignment, or other layout properties of the widget, you need a new layout pass and should call WidgetBase.Update instead).

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) 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(cw Widget, cwb *WidgetBase) bool)

WidgetWalkDown is a version of tree.NodeBase.WalkDown that operates on Widget types. Return tree.Continue to continue and tree.Break to terminate.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL