giv

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: BSD-3-Clause Imports: 46 Imported by: 0

Documentation

Overview

Package GiV (Cogent Core Views) provides a model / view framework to view Go data using reflection

Views are Widgets that automatically display and interact with standard Go data, including structs, maps, slices, and the primitive data elements (string, int, etc). This implements a form of model / view separation between data and GUI representation thereof, where the models are the Go data elements themselves.

This provides automatic, powerful GUI access to essentially any data in any other Go package. Furthermore, the Value framework allows for easy customization and extension of the GUI representation, based on the classic Go "Stringer"-like interface paradigm -- simply define a Value() method on any type, returning giv.Value that manages the interface between data structures and GUI representations.

See the wiki at: https://cogentcore.org/core/gi/v2/wiki/Views for more extensive docs.

Some of the most important view elements are:

Value

The Value provides a common API for representing values (int, string, etc) in the GUI, and are used by more complex views (StructView, MapView, SliceView, etc) to represents the elements of those data structures.

Do Ctrl+Alt+I in any window to pull up the Inspector which will show you ample examples of the Value interface in action, and also allow you to customize your GUI.

TreeView

The TreeView displays Cogent Core Node Trees, using a standard tree-browser with collapse / open widgets and a menu for typical actions such as adding and deleting child nodes, along with full drag-n-drop and clipboard Copy/Cut/Paste functionality. You can connect to the selection signal to e.g., display a StructView field / property editor of the selected node.

TableView

TableView displays a slice-of-struct as a table with columns as the struct fields and rows as the elements in the struct. You can sort by the column headers and it supports full editing with drag-n-drop etc. If set to ReadOnly, then it serves as a chooser, as in the FileView.

FuncButton

Provides GUI for calling methods, prompting the user for any args, using the Value system. The gti tool can capture comment data to provide tooltips for users: specify //gti:add for types and methods that are called. Much of your toolbar and menu level GUI can be implemented in this system. See gi/settings.go and giv/settingsview.go for how the Cogent Core Prefs dialog is implemented, and see the Cogent Code project for a more complex case.

Index

Constants

View Source
const (
	SliceViewRowProp = "sv-row"
	SliceViewColProp = "sv-col"
)
View Source
const TreeViewTempMovedTag = `_\&MOVED\&`

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

Variables

View Source
var ArgViewType = gti.AddType(&gti.Type{Name: "cogentcore.org/core/giv.ArgView", IDName: "arg-view", Doc: "ArgView represents a slice of reflect.Value's and associated names, for the\npurpose of supplying arguments to methods called via the MethodView\nframework.", Embeds: []gti.Field{{Name: "Frame"}}, Fields: []gti.Field{{Name: "Args", Doc: "Args are the args that we are a view onto"}}, Instance: &ArgView{}})

ArgViewType is the gti.Type for ArgView

View Source
var ColorViewType = gti.AddType(&gti.Type{Name: "cogentcore.org/core/giv.ColorView", IDName: "color-view", Doc: "ColorView shows a color, using sliders or numbers to set values.", Embeds: []gti.Field{{Name: "Frame"}}, Fields: []gti.Field{{Name: "Color", Doc: "the color that we view"}}, Instance: &ColorView{}})

ColorViewType is the gti.Type for ColorView

View Source
var DateViewType = gti.AddType(&gti.Type{Name: "cogentcore.org/core/giv.DateView", IDName: "date-view", Doc: "DateView is a view for selecting a date", Embeds: []gti.Field{{Name: "Frame"}}, Fields: []gti.Field{{Name: "Time", Doc: "the time that we are viewing"}, {Name: "ConfigTime", Doc: "ConfigTime is the time that was configured"}}, Instance: &DateView{}})

DateViewType is the gti.Type for DateView

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

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

View Source
var FileViewType = gti.AddType(&gti.Type{Name: "cogentcore.org/core/giv.FileView", IDName: "file-view", Doc: "FileView is a viewer onto files -- core of the file chooser dialog", Methods: []gti.Method{{Name: "UpdateFilesAction", Doc: "UpdateFilesAction updates the list of files and other views for the current path.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}}, {Name: "AddPathToFavs", Doc: "AddPathToFavs adds the current path to favorites", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}}, {Name: "DirPathUp", Doc: "DirPathUp moves up one directory in the path", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}}, {Name: "NewFolder", Doc: "NewFolder creates a new folder with the given name in the current directory.", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Args: []string{"name"}, Returns: []string{"error"}}}, Embeds: []gti.Field{{Name: "Frame"}}, Fields: []gti.Field{{Name: "DirPath", Doc: "path to directory of files to display"}, {Name: "SelFile", Doc: "selected file"}, {Name: "Ext", Doc: "target extension(s) (comma separated if multiple, including initial .), if any"}, {Name: "FilterFunc", Doc: "optional styling function"}, {Name: "ExtMap", Doc: "map of lower-cased extensions from Ext -- used for highlighting files with one of these extensions -- maps onto original ext value"}, {Name: "Files", Doc: "files for current directory"}, {Name: "SelectedIdx", Doc: "index of currently-selected file in Files list (-1 if none)"}, {Name: "Watcher", Doc: "change notify for current dir"}, {Name: "DoneWatcher", Doc: "channel to close watcher watcher"}, {Name: "UpdtMu", Doc: "UpdateFiles mutex"}, {Name: "PrevPath", Doc: "Previous path that was processed via UpdateFiles"}}, Instance: &FileView{}})

FileViewType is the gti.Type for FileView

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

FuncButtonType is the gti.Type for FuncButton

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

InspectorType is the gti.Type for Inspector

View Source
var MapViewInlineType = gti.AddType(&gti.Type{Name: "cogentcore.org/core/giv.MapViewInline", IDName: "map-view-inline", Doc: "MapViewInline represents a map as a single line widget,\nfor smaller maps and those explicitly marked inline.", Embeds: []gti.Field{{Name: "Layout"}}, Fields: []gti.Field{{Name: "Map", Doc: "the map that we are a view onto"}, {Name: "MapValue", Doc: "MapValue is the Value for the map itself\nif this was created within the Value framework.\nOtherwise, it is nil."}, {Name: "Changed", Doc: "has the map been edited?"}, {Name: "Keys", Doc: "Value representations of the map keys"}, {Name: "Values", Doc: "Value representations of the fields"}, {Name: "ViewPath", Doc: "a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows"}, {Name: "ConfigSize", Doc: "size of map when gui configed"}}, Instance: &MapViewInline{}})

MapViewInlineType is the gti.Type for MapViewInline

View Source
var MapViewType = gti.AddType(&gti.Type{Name: "cogentcore.org/core/giv.MapView", IDName: "map-view", Doc: "MapView represents a map, creating a property editor of the values --\nconstructs Children widgets to show the key / value pairs, within an\noverall frame.", Embeds: []gti.Field{{Name: "Frame"}}, Fields: []gti.Field{{Name: "Map", Doc: "the map that we are a view onto"}, {Name: "MapValView", Doc: "Value for the map itself, if this was created within value view framework; otherwise nil"}, {Name: "Changed", Doc: "has the map been edited?"}, {Name: "Keys", Doc: "Value representations of the map keys"}, {Name: "Values", Doc: "Value representations of the map values"}, {Name: "SortVals", Doc: "sort by values instead of keys"}, {Name: "NCols", Doc: "the number of columns in the map; do not set externally;\ngenerally only access internally"}, {Name: "ViewPath", Doc: "a record of parent View names that have led up to this view.\nDisplayed as extra contextual information in view dialog windows."}}, Instance: &MapView{}})

MapViewType is the gti.Type for MapView

View Source
var NoSentenceCaseFor []string

NoSentenceCaseFor indicates to not transform field names in [StructView]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 SliceViewBaseType = gti.AddType(&gti.Type{Name: "cogentcore.org/core/giv.SliceViewBase", IDName: "slice-view-base", Doc: "SliceViewBase is the base for SliceView and TableView and any other viewers\nof array-like data.  It automatically computes the number of rows that fit\nwithin its allocated space, and manages the offset view window into the full\nlist of items, and supports row selection, copy / paste, Drag-n-Drop, etc.\nSet to ReadOnly for select-only mode, which emits WidgetSig WidgetSelected\nsignals when selection is updated.", Methods: []gti.Method{{Name: "CopyIdxs", Doc: "CopyIdxs copies selected idxs to goosi.Clipboard, optionally resetting the selection", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Args: []string{"reset"}}, {Name: "DeleteIdxs", Doc: "DeleteIdxs deletes all selected indexes", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}}, {Name: "CutIdxs", Doc: "CutIdxs copies selected indexes to goosi.Clipboard and deletes selected indexes", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}}, {Name: "PasteIdx", Doc: "PasteIdx pastes clipboard at given idx", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Args: []string{"idx"}}, {Name: "Duplicate", Doc: "Duplicate copies selected items and inserts them after current selection --\nreturn idx of start of duplicates if successful, else -1", Directives: []gti.Directive{{Tool: "gti", Directive: "add"}}, Returns: []string{"int"}}}, Embeds: []gti.Field{{Name: "Frame"}}, Fields: []gti.Field{{Name: "Slice", Doc: "the slice that we are a view onto -- must be a pointer to that slice"}, {Name: "MinRows", Doc: "MinRows specifies the minimum number of rows to display, to ensure\nat least this amount is displayed."}, {Name: "ViewPath", Doc: "a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows"}, {Name: "ViewMu", Doc: "optional mutex that, if non-nil, will be used around any updates that\nread / modify the underlying Slice data.\nCan be used to protect against random updating if your code has specific\nupdate points that can be likewise protected with this same mutex."}, {Name: "Changed", Doc: "Changed indicates whether the underlying slice\nhas been edited in any way"}, {Name: "SelVal", Doc: "current selection value -- initially select this value if set"}, {Name: "SelectedIndex", Doc: "index of currently selected item"}, {Name: "InitSelectedIndex", Doc: "index of row to select at start"}, {Name: "SelectedIndexs", Doc: "list of currently-selected slice indexes"}, {Name: "LastClick", Doc: "LastClick is the last row that has been clicked on.\nThis is used to prevent erroneous double click events\nfrom being sent when the user clicks on multiple different\nrows in quick succession."}, {Name: "NormalCursor", Doc: "NormalCursor is the cached cursor to display when there\nis no row being hovered."}, {Name: "CurrentCursor", Doc: "CurrentCursor is the cached cursor that should currently be\ndisplayed."}, {Name: "SliceNPVal", Doc: "non-ptr reflect.Value of the slice"}, {Name: "SliceValue", Doc: "Value for the slice itself, if this was created within value view framework -- otherwise nil"}, {Name: "Values", Doc: "Value representations of the slice values"}, {Name: "HoverRow", Doc: "currently-hovered row"}, {Name: "DraggedIndexes", Doc: "list of currently-dragged indexes"}, {Name: "VisRows", Doc: "total number of rows visible in allocated display size"}, {Name: "StartIndex", Doc: "starting slice index of visible rows"}, {Name: "SliceSize", Doc: "size of slice"}, {Name: "ConfigIter", Doc: "iteration through the configuration process, reset when a new slice type is set"}, {Name: "TmpIndex", Doc: "temp idx state for e.g., dnd"}, {Name: "ElVal", Doc: "ElVal is a Value representation of the underlying element type\nwhich is used whenever there are no slice elements available"}, {Name: "MaxWidth", Doc: "maximum width of value column in chars, if string"}}, Instance: &SliceViewBase{}})

SliceViewBaseType is the gti.Type for SliceViewBase

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

SliceViewGridType is the gti.Type for SliceViewGrid

View Source
var SliceViewInlineType = gti.AddType(&gti.Type{Name: "cogentcore.org/core/giv.SliceViewInline", IDName: "slice-view-inline", Doc: "SliceViewInline represents a slice as a single line widget,\nfor smaller slices and those explicitly marked inline.", Embeds: []gti.Field{{Name: "Layout"}}, Fields: []gti.Field{{Name: "Slice", Doc: "the slice that we are a view onto"}, {Name: "SliceValue", Doc: "SliceValue is the Value for the slice itself\nif this was created within the Value framework.\nOtherwise, it is nil."}, {Name: "IsArray", Doc: "whether the slice is actually an array -- no modifications"}, {Name: "IsFixedLen", Doc: "whether the slice has a fixed-len flag on it"}, {Name: "Changed", Doc: "has the slice been edited?"}, {Name: "Values", Doc: "Value representations of the fields"}, {Name: "ViewPath", Doc: "a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows"}, {Name: "ConfigSize", Doc: "size of map when gui was configured"}}, Instance: &SliceViewInline{}})

SliceViewInlineType is the gti.Type for SliceViewInline

View Source
var SliceViewType = gti.AddType(&gti.Type{Name: "cogentcore.org/core/giv.SliceView", IDName: "slice-view", Doc: "SliceView represents a slice, creating an interactive viewer / editor of the\nelements as rows in a table.  Widgets to show the index / value pairs, within an\noverall frame.\nSet to ReadOnly for select-only mode, which emits WidgetSig WidgetSelected\nsignals when selection is updated.", Embeds: []gti.Field{{Name: "SliceViewBase"}}, Fields: []gti.Field{{Name: "StyleFunc", Doc: "optional styling function"}}, Instance: &SliceView{}})

SliceViewType is the gti.Type for SliceView

View Source
var StructViewInlineType = gti.AddType(&gti.Type{Name: "cogentcore.org/core/giv.StructViewInline", IDName: "struct-view-inline", Doc: "StructViewInline represents a struct as a single line widget,\nfor smaller structs and those explicitly marked inline.", Embeds: []gti.Field{{Name: "Layout"}}, Fields: []gti.Field{{Name: "Struct", Doc: "the struct that we are a view onto"}, {Name: "StructValue", Doc: "Value for the struct itself, if this was created within value view framework -- otherwise nil"}, {Name: "AddButton", Doc: "if true, add an edit button at the end"}, {Name: "FieldViews", Doc: "Value representations of the fields"}, {Name: "ViewPath", Doc: "a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows"}, {Name: "IsShouldShower", Doc: "IsShouldShower is whether the struct implements [gi.ShouldShower], which results\nin additional updating being done at certain points."}}, Instance: &StructViewInline{}})

StructViewInlineType is the gti.Type for StructViewInline

View Source
var StructViewType = gti.AddType(&gti.Type{Name: "cogentcore.org/core/giv.StructView", IDName: "struct-view", Doc: "StructView represents a struct, creating a property editor of the fields --\nconstructs Children widgets to show the field names and editor fields for\neach field, within an overall frame.", Embeds: []gti.Field{{Name: "Frame"}}, Fields: []gti.Field{{Name: "Struct", Doc: "the struct that we are a view onto"}, {Name: "StructValue", Doc: "StructValue is the Value for the struct itself\nif this was created within the Value framework.\nOtherwise, it is nil."}, {Name: "Changed", Doc: "has the value of any field changed?  updated by the ViewSig signals from fields"}, {Name: "FieldViews", Doc: "Value representations of the fields"}, {Name: "ViewPath", Doc: "a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows"}, {Name: "IsShouldShower", Doc: "IsShouldShower is whether the struct implements [gi.ShouldShower], which results\nin additional updating being done at certain points."}, {Name: "TypeFieldTags", Doc: "extra tags by field name -- from type properties"}}, Instance: &StructView{}})

StructViewType is the gti.Type for StructView

View Source
var TableViewType = gti.AddType(&gti.Type{Name: "cogentcore.org/core/giv.TableView", IDName: "table-view", Doc: "TableView represents a slice-of-structs as a table, where the fields are\nthe columns, within an overall frame.  It is a full-featured editor with\nmultiple-selection, cut-and-paste, and drag-and-drop.\nIf ReadOnly, it functions as a mutually-exclusive item\nselector, highlighting the selected row and emitting a Selected action.", Embeds: []gti.Field{{Name: "SliceViewBase"}}, Fields: []gti.Field{{Name: "StyleFunc", Doc: "optional styling function"}, {Name: "SelectedField", Doc: "current selection field -- initially select value in this field"}, {Name: "SortIndex", Doc: "current sort index"}, {Name: "SortDesc", Doc: "whether current sort order is descending"}, {Name: "StruType", Doc: "struct type for each row"}, {Name: "VisFields", Doc: "the visible fields"}, {Name: "NVisFields", Doc: "number of visible fields"}, {Name: "HeaderWidths", Doc: "HeaderWidths has number of characters in each header, per visfields"}, {Name: "ColMaxWidths", Doc: "ColMaxWidths records maximum width in chars of string type fields"}}, Instance: &TableView{}})

TableViewType is the gti.Type for TableView

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

TimeViewType is the gti.Type for TimeView

View Source
var TreeTableViewType = gti.AddType(&gti.Type{Name: "cogentcore.org/core/giv.TreeTableView", IDName: "tree-table-view", Doc: "TreeTableView combines a [TreeView] and [TableView].", Embeds: []gti.Field{{Name: "Frame"}}, Fields: []gti.Field{{Name: "Tree", Doc: "Tree is the tree view component of the tree table view."}, {Name: "Table", Doc: "Table is the table view component of the tree table view."}}, Instance: &TreeTableView{}})

TreeTableViewType is the gti.Type for TreeTableView

View Source
var TreeViewPageSteps = 10

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

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

TreeViewType is the gti.Type for TreeView

View Source
var ValueMap = map[string]func() Value{}

ValueMap is a map from fully package path qualified type names to the corresponding Value objects that should be used to represent those types. You should add to this using AddValue.

Functions

func AddValue added in v0.0.8

func AddValue(val any, fun func() Value)

AddValue indicates that the given value should be represented by the given Value object. For example:

AddValue(icons.Icon(""), func() Value { return &IconValue{} })

func CallFunc

func CallFunc(ctx gi.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 Config added in v0.0.8

func Config(v Value, w gi.Widget)

Config configures the given gi.Widget to represent the given Value.

func ConfigBase added in v0.0.8

func ConfigBase(v Value, w gi.Widget)

ConfigBase does the base configuration for the given gi.Widget to represent the given Value.

func ConfigDialogWidget

func ConfigDialogWidget(v Value, allowReadOnly bool)

ConfigDialogWidget configures the widget for the given value to open the dialog for the given value when clicked and have the appropriate tooltip for that. If allowReadOnly is false, the dialog will not be opened if the value is read only.

func ConfigImageToolbar added in v0.0.3

func ConfigImageToolbar(tb *gi.Toolbar, im *gi.Image)

ConfigImageToolbar configures the given toolbar for the given image.

func ConfigSVGToolbar added in v0.0.3

func ConfigSVGToolbar(tb *gi.Toolbar, sv *gi.SVG)

ConfigSVGToolbar configures the given toolbar for the given SVG.

func FileViewDialog

func FileViewDialog(ctx gi.Widget, filename, exts, title string, fun func(selfile string))

FileViewDialog opens a dialog for selecting a file.

func FileViewDirOnlyFilter

func FileViewDirOnlyFilter(fv *FileView, fi *fi.FileInfo) bool

FileViewDirOnlyFilter is a FileViewFilterFunc that only shows directories (folders).

func FileViewExtOnlyFilter

func FileViewExtOnlyFilter(fv *FileView, fi *fi.FileInfo) bool

FileViewExtOnlyFilter is a FileViewFilterFunc that only shows files that match the target extensions, and directories.

func InspectorView

func InspectorView(b *gi.Body, k ki.Ki)

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

func InspectorWindow

func InspectorWindow(k ki.Ki)

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

func JoinViewPath added in v0.0.7

func JoinViewPath(a, b string) string

JoinViewPath returns a view path composed of two elements, with a • path separator, handling the cases where either or both can be empty.

func KeyMapsView

func KeyMapsView(km *keyfun.Maps)

KeyMapsView opens a view of a key maps table

func NoSentenceCaseForType added in v0.0.4

func NoSentenceCaseForType(tnm string) bool

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

func OpenDialog added in v0.0.8

func OpenDialog(v Value, ctx gi.Widget, fun, beforeFunc func()) bool

OpenDialog opens any applicable dialog for the given value in the context of the given widget. It first tries OpenDialoger, then ConfigDialoger with OpenDialogBase. If both of those fail, it returns false. It calls the given beforeFunc before opening any dialog.

func OpenDialogBase added in v0.0.8

func OpenDialogBase(v Value, cd ConfigDialoger, ctx gi.Widget, fun func())

OpenDialogBase is a helper for OpenDialog for cases that do not implement OpenDialoger but do implement ConfigDialoger to configure the dialog contents.

func SetSoloValueIface

func SetSoloValueIface(v *ValueData, val any)

SetSoloValueIface sets the value for a singleton standalone value using an interface for the value -- you must pass a pointer. for now, this cannot be a method because gopy doesn't find the key comment below that tells it what to do with the interface gopy:interface=handle

func SettingsView

func SettingsView(b *gi.Body)

SettingsView adds to the given body a view of user settings

func SettingsViewToolbarBase added in v0.0.5

func SettingsViewToolbarBase(tb *gi.Toolbar)

SettingsViewToolbarBase is the base toolbar configuration function used in SettingsView.

func SettingsWindow

func SettingsWindow()

SettingsWindow makes and runs a new window for viewing user settings.

func SliceIdxByValue

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

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

func StructFieldIsDef

func StructFieldIsDef(defs string, valPtr any, kind reflect.Kind) (bool, string)

StructFieldIsDef processses "default" tag for default value(s) of field defs = default values as strings as either comma-separated list of valid values or low:high value range (only for int or float numeric types) valPtr = pointer to value returns true if value is default, and string to add to tooltip for default values. Uses JSON format for composite types (struct, slice, map), replacing " with ' so it is easier to use in def tag.

func StructNonDefFieldsStr

func StructNonDefFieldsStr(structPtr any, path string) string

StructNonDefFieldsStr processses "default" tag for default value(s) of fields in given struct, and returns a string of all those not at their default values, in format: Path.Field: val // default value(s) Uses a recursive strategy -- any fields that are themselves structs are expanded, and the field name represented by dots path separators.

func StructSliceIdxByValue

func StructSliceIdxByValue(struSlice any, fldName string, fldVal any) (int, error)

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

func StructViewDialog added in v0.0.3

func StructViewDialog(ctx gi.Widget, stru any, title string, newWindow bool)

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

func StructViewFieldTags

func StructViewFieldTags(vv Value, lbl *gi.Label, w gi.Widget, isReadOnly bool) (hasDef, readOnlyTag bool)

StructViewFieldTags processes the tags for a field in a struct view, setting the properties on the label or widget appropriately returns true if there were any "default" default tags -- if so, needs updating

func ViewStdKeyMaps

func ViewStdKeyMaps()

ViewStdKeyMaps shows the standard maps that are compiled into the program and have all the lastest key functions bound to standard values. Useful for comparing against custom maps.

Types

type ArgView

type ArgView struct {
	gi.Frame

	// Args are the args that we are a view onto
	Args []Value
}

ArgView represents a slice of reflect.Value's and associated names, for the purpose of supplying arguments to methods called via the MethodView framework.

func NewArgView

func NewArgView(par ki.Ki, name ...string) *ArgView

NewArgView adds a new ArgView with the given name to the given parent: ArgView represents a slice of reflect.Value's and associated names, for the purpose of supplying arguments to methods called via the MethodView framework.

func (*ArgView) ArgsGrid

func (av *ArgView) ArgsGrid() *gi.Frame

ArgsGrid returns the grid layout widget, which contains all the fields and values

func (*ArgView) Config added in v0.0.8

func (av *ArgView) Config()

Config configures the view

func (*ArgView) ConfigArgsGrid

func (av *ArgView) ConfigArgsGrid()

ConfigArgsGrid configures the ArgsGrid for the current struct

func (*ArgView) KiType

func (t *ArgView) KiType() *gti.Type

KiType returns the *gti.Type of ArgView

func (*ArgView) New

func (t *ArgView) New() ki.Ki

New returns a new *ArgView value

func (*ArgView) OnInit

func (av *ArgView) OnInit()

func (*ArgView) SetArgs

func (t *ArgView) SetArgs(v ...Value) *ArgView

SetArgs sets the [ArgView.Args]: Args are the args that we are a view onto

func (*ArgView) SetStackTop

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

SetStackTop sets the [ArgView.StackTop]

func (*ArgView) SetStyles

func (av *ArgView) SetStyles()

func (*ArgView) SetTooltip

func (t *ArgView) SetTooltip(v string) *ArgView

SetTooltip sets the [ArgView.Tooltip]

func (*ArgView) TitleWidget

func (av *ArgView) TitleWidget() *gi.Label

TitleWidget returns the title label widget

type BitFlagValue

type BitFlagValue struct {
	ValueBase[*gi.Switches]
}

BitFlagValue represents an enums.BitFlag value with chip switches.

func (*BitFlagValue) Config added in v0.0.8

func (v *BitFlagValue) Config()

func (*BitFlagValue) EnumValue

func (v *BitFlagValue) EnumValue() enums.BitFlagSetter

EnumValue returns the underlying enums.BitFlagSetter value.

func (*BitFlagValue) Update added in v0.0.8

func (v *BitFlagValue) Update()

type BoolValue

type BoolValue struct {
	ValueBase[*gi.Switch]
}

BoolValue represents a bool value with a switch.

func (*BoolValue) Config added in v0.0.8

func (v *BoolValue) Config()

func (*BoolValue) Update added in v0.0.8

func (v *BoolValue) Update()

type ByteSliceValue

type ByteSliceValue struct {
	ValueBase[*gi.TextField]
}

ByteSliceValue represents a slice of bytes with a text field.

func (*ByteSliceValue) Config added in v0.0.8

func (v *ByteSliceValue) Config()

func (*ByteSliceValue) Update added in v0.0.8

func (v *ByteSliceValue) Update()

type ColorMapName

type ColorMapName string

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

func (ColorMapName) Value

func (cmn ColorMapName) Value() Value

type ColorMapValue

type ColorMapValue struct {
	ValueBase[*gi.Frame]
}

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

func (*ColorMapValue) Config added in v0.0.8

func (v *ColorMapValue) Config()

func (*ColorMapValue) ConfigDialog

func (v *ColorMapValue) ConfigDialog(d *gi.Body) (bool, func())

func (*ColorMapValue) Update added in v0.0.8

func (v *ColorMapValue) Update()

type ColorValue

type ColorValue struct {
	ValueBase[*gi.Button]
}

ColorValue represents a color value with a button.

func (*ColorValue) ColorValue added in v0.0.8

func (v *ColorValue) ColorValue() color.RGBA

ColorValue returns a standardized color value from whatever value is represented internally, or nil.

func (*ColorValue) Config added in v0.0.8

func (v *ColorValue) Config()

func (*ColorValue) ConfigDialog

func (v *ColorValue) ConfigDialog(d *gi.Body) (bool, func())

func (*ColorValue) Update added in v0.0.8

func (v *ColorValue) Update()

type ColorView

type ColorView struct {
	gi.Frame

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

ColorView shows a color, using sliders or numbers to set values.

func NewColorView

func NewColorView(par ki.Ki, name ...string) *ColorView

NewColorView adds a new ColorView with the given name to the given parent: ColorView shows a color, using sliders or numbers to set values.

func (*ColorView) Config added in v0.0.8

func (cv *ColorView) Config()

Config configures a standard setup of entire view

func (*ColorView) KiType

func (t *ColorView) KiType() *gti.Type

KiType returns the *gti.Type of ColorView

func (*ColorView) New

func (t *ColorView) New() ki.Ki

New returns a new *ColorView value

func (*ColorView) OnInit

func (cv *ColorView) OnInit()

func (*ColorView) SetColor

func (cv *ColorView) SetColor(clr color.Color) *ColorView

SetColor sets the source color

func (*ColorView) SetHCT

func (cv *ColorView) SetHCT(hct hct.HCT) *ColorView

SetHCT sets the source color in terms of HCT

func (*ColorView) SetStackTop

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

SetStackTop sets the [ColorView.StackTop]

func (*ColorView) SetTooltip

func (t *ColorView) SetTooltip(v string) *ColorView

SetTooltip sets the [ColorView.Tooltip]

type ConfigDialoger added in v0.0.8

type ConfigDialoger interface {
	// ConfigDialog adds content to the given dialog body for this value.
	// The bool return is false if the value does not use this method
	// (e.g., for simple menu choosers).
	// The returned function is an optional closure to be called
	// in the Ok case, for cases where extra logic is required.
	ConfigDialog(d *gi.Body) (bool, func())
}

ConfigDialoger is an optional interface that [Value]s may implement to indicate that they have a dialog associated with them that is configured with the ConfigDialog method. The dialog body itself is constructed and run using OpenDialog.

type DateView

type DateView struct {
	gi.Frame

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

	// ConfigTime is the time that was configured
	ConfigTime time.Time `set:"-" view:"-"`
}

DateView is a view for selecting a date

func NewDateView

func NewDateView(par ki.Ki, name ...string) *DateView

NewDateView adds a new DateView with the given name to the given parent: DateView is a view for selecting a date

func (*DateView) Config added in v0.0.8

func (dv *DateView) Config()

func (*DateView) ConfigDateGrid

func (dv *DateView) ConfigDateGrid()

func (*DateView) KiType

func (t *DateView) KiType() *gti.Type

KiType returns the *gti.Type of DateView

func (*DateView) New

func (t *DateView) New() ki.Ki

New returns a new *DateView value

func (*DateView) SetStackTop

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

SetStackTop sets the [DateView.StackTop]

func (*DateView) SetTime

func (dv *DateView) SetTime(tim time.Time) *DateView

SetTime sets the source time and updates the view

func (*DateView) SetTooltip

func (t *DateView) SetTooltip(v string) *DateView

SetTooltip sets the [DateView.Tooltip]

type DurationValue

type DurationValue struct {
	ValueBase[*gi.Layout]
}

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

func (*DurationValue) Config added in v0.0.8

func (v *DurationValue) Config()

func (*DurationValue) Update added in v0.0.8

func (v *DurationValue) Update()

type EnumValue

type EnumValue struct {
	ValueBase[*gi.Chooser]
}

EnumValue represents an enums.Enum value with a chooser.

func (*EnumValue) Config added in v0.0.8

func (v *EnumValue) Config()

func (*EnumValue) Update added in v0.0.8

func (v *EnumValue) Update()

type FieldValuer

type FieldValuer interface {
	FieldValue(field string, fval any) Value
}

FieldValuer is an interface that struct types can implement to specify the Value that should be used to represent their fields in the GUI. If the return value is nil, then the default Value for the value will be used.

type FileValue

type FileValue struct {
	ValueBase[*gi.Button]
}

FileValue represents a gi.Filename value with a button.

func (*FileValue) Config added in v0.0.8

func (v *FileValue) Config()

func (*FileValue) ConfigDialog

func (v *FileValue) ConfigDialog(d *gi.Body) (bool, func())

func (*FileValue) Update added in v0.0.8

func (v *FileValue) Update()

type FileView

type FileView struct {
	gi.Frame

	// path to directory of files to display
	DirPath string

	// selected file
	SelFile string

	// target extension(s) (comma separated if multiple, including initial .), if any
	Ext string `set:"-"`

	// optional styling function
	FilterFunc FileViewFilterFunc `view:"-" json:"-" xml:"-"`

	// map of lower-cased extensions from Ext -- used for highlighting files with one of these extensions -- maps onto original ext value
	ExtMap map[string]string

	// files for current directory
	Files []*fi.FileInfo

	// index of currently-selected file in Files list (-1 if none)
	SelectedIdx int `set:"-" edit:"-"`

	// change notify for current dir
	Watcher *fsnotify.Watcher `set:"-" view:"-"`

	// channel to close watcher watcher
	DoneWatcher chan bool `set:"-" view:"-"`

	// UpdateFiles mutex
	UpdtMu sync.Mutex `set:"-" view:"-"`

	// Previous path that was processed via UpdateFiles
	PrevPath string `set:"-" view:"-"`
}

FileView is a viewer onto files -- core of the file chooser dialog

func NewFileView

func NewFileView(par ki.Ki, name ...string) *FileView

NewFileView adds a new FileView with the given name to the given parent: FileView is a viewer onto files -- core of the file chooser dialog

func (*FileView) AddPathToFavs

func (fv *FileView) AddPathToFavs()

AddPathToFavs adds the current path to favorites

func (*FileView) ApplyStyle

func (fv *FileView) ApplyStyle()

func (*FileView) Config added in v0.0.8

func (fv *FileView) Config()

func (*FileView) ConfigFileView

func (fv *FileView) ConfigFileView()

func (*FileView) ConfigFilesRow

func (fv *FileView) ConfigFilesRow()

func (*FileView) ConfigSelRow

func (fv *FileView) ConfigSelRow()

func (*FileView) ConfigToolbar added in v0.0.4

func (fv *FileView) ConfigToolbar(tb *gi.Toolbar)

ConfigToolbar configures the given toolbar to have file view actions and completions.

func (*FileView) ConfigWatcher

func (fv *FileView) ConfigWatcher() error

func (*FileView) DirPathUp

func (fv *FileView) DirPathUp()

DirPathUp moves up one directory in the path

func (*FileView) Disconnect

func (fv *FileView) Disconnect()

func (*FileView) EditRecentPaths added in v0.0.4

func (fv *FileView) EditRecentPaths()

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

func (*FileView) ExtField

func (fv *FileView) ExtField() *gi.TextField

ExtField returns the TextField of the extension

func (*FileView) FavSelect

func (fv *FileView) FavSelect(idx int)

FavSelect selects a favorite path and goes there

func (*FileView) FavsView

func (fv *FileView) FavsView() *TableView

FavsView returns the TableView of the favorites

func (*FileView) FileComplete

func (fv *FileView) FileComplete(data any, text string, posLn, posCh int) (md complete.Matches)

FileComplete finds the possible completions for the file field

func (*FileView) FileCompleteEdit

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

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

func (*FileView) FileSelectAction

func (fv *FileView) FileSelectAction(idx int)

FileSelectAction updates selection with given selected file and emits selected signal on WidgetSig with full name of selected item

func (*FileView) FilesRow

func (fv *FileView) FilesRow() *gi.Layout

func (*FileView) FilesView

func (fv *FileView) FilesView() *TableView

FilesView returns the TableView of the files

func (*FileView) HandleEvents

func (fv *FileView) HandleEvents()

func (*FileView) KeyInput

func (fv *FileView) KeyInput(kt events.Event)

func (*FileView) KiType

func (t *FileView) KiType() *gti.Type

KiType returns the *gti.Type of FileView

func (*FileView) New

func (t *FileView) New() ki.Ki

New returns a new *FileView value

func (*FileView) NewFolder

func (fv *FileView) NewFolder(name string) error

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

func (*FileView) OnInit

func (fv *FileView) OnInit()

func (*FileView) PathComplete

func (fv *FileView) PathComplete(data any, path string, posLn, posCh int) (md complete.Matches)

PathComplete finds the possible completions for the path field

func (*FileView) PathCompleteEdit

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

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

func (*FileView) ReadFiles

func (fv *FileView) ReadFiles()

func (*FileView) SaveSortPrefs

func (fv *FileView) SaveSortPrefs()

SaveSortPrefs saves current sorting preferences

func (*FileView) SelField

func (fv *FileView) SelField() *gi.TextField

SelField returns the TextField of the selected file

func (*FileView) SelRow

func (fv *FileView) SelRow() *gi.Layout

func (*FileView) SelectFile

func (fv *FileView) SelectFile() bool

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

func (*FileView) SelectedFile

func (fv *FileView) SelectedFile() string

SelectedFile returns the full path to selected file

func (*FileView) SelectedFileInfo

func (fv *FileView) SelectedFileInfo() (*fi.FileInfo, bool)

SelectedFileInfo returns the currently-selected fileinfo, returns false if none

func (*FileView) SetDirPath

func (t *FileView) SetDirPath(v string) *FileView

SetDirPath sets the [FileView.DirPath]: path to directory of files to display

func (*FileView) SetExt

func (fv *FileView) SetExt(ext string) *FileView

SetExt updates the ext to given (list of, comma separated) extensions

func (*FileView) SetExtAction

func (fv *FileView) SetExtAction(ext string) *FileView

SetExtAction sets the current extension to highlight, and redisplays files

func (*FileView) SetExtMap

func (t *FileView) SetExtMap(v map[string]string) *FileView

SetExtMap sets the [FileView.ExtMap]: map of lower-cased extensions from Ext -- used for highlighting files with one of these extensions -- maps onto original ext value

func (*FileView) SetFilename

func (fv *FileView) SetFilename(filename, ext string) *FileView

SetFilename sets the initial filename (splitting out path and filename) and initializes the view

func (*FileView) SetFiles

func (t *FileView) SetFiles(v ...*fi.FileInfo) *FileView

SetFiles sets the [FileView.Files]: files for current directory

func (*FileView) SetFilterFunc

func (t *FileView) SetFilterFunc(v FileViewFilterFunc) *FileView

SetFilterFunc sets the [FileView.FilterFunc]: optional styling function

func (*FileView) SetPathFile

func (fv *FileView) SetPathFile(path, file, ext string) *FileView

SetPathFile sets the path, initial select file (or "") and initializes the view

func (*FileView) SetSelFile

func (t *FileView) SetSelFile(v string) *FileView

SetSelFile sets the [FileView.SelFile]: selected file

func (*FileView) SetSelFileAction

func (fv *FileView) SetSelFileAction(sel string)

SetSelFileAction sets the currently selected file to given name, and sends selection action with current full file name, and updates selection in table view

func (*FileView) SetStackTop

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

SetStackTop sets the [FileView.StackTop]

func (*FileView) SetStyles

func (fv *FileView) SetStyles()

func (*FileView) SetTooltip

func (t *FileView) SetTooltip(v string) *FileView

SetTooltip sets the [FileView.Tooltip]

func (*FileView) UpdateFavs

func (fv *FileView) UpdateFavs()

UpdateFavs updates list of files and other views for current path

func (*FileView) UpdateFiles

func (fv *FileView) UpdateFiles()

UpdateFiles updates list of files and other views for current path

func (*FileView) UpdateFilesAction

func (fv *FileView) UpdateFilesAction()

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

func (*FileView) UpdatePath

func (fv *FileView) UpdatePath()

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

func (*FileView) WatchWatcher

func (fv *FileView) WatchWatcher()

type FileViewFilterFunc

type FileViewFilterFunc func(fv *FileView, fi *fi.FileInfo) bool

FileViewFilterFunc is a filtering function for files -- returns true if the file should be visible in the view, and false if not

type FontValue

type FontValue struct {
	ValueBase[*gi.Button]
}

FontValue represents a gi.FontName value with a button.

func (*FontValue) Config added in v0.0.8

func (v *FontValue) Config()

func (*FontValue) ConfigDialog

func (v *FontValue) ConfigDialog(d *gi.Body) (bool, func())

func (*FontValue) Update added in v0.0.8

func (v *FontValue) Update()

type FuncButton

type FuncButton struct {
	gi.Button

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

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

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

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

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

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

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

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

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

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

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

FuncButton is a button that is set up to call a function when it is pressed, using a dialog to prompt the user for any arguments. Also, it automatically sets various properties of the button like the name, text, tooltip, and icon based on the properties of the function, using reflect and gti. The function must be registered with gti to get documentation information, but that is not required; add a `//gti: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 gti to get documentation.

func NewFuncButton

func NewFuncButton(par ki.Ki, fun any) *FuncButton

NewFuncButton adds a new FuncButton with the given function to the given parent.

func NewSoloFuncButton

func NewSoloFuncButton(ctx gi.Widget, fun any) *FuncButton

NewSoloFuncButton returns a standalone FuncButton with the given context for popping up any dialog elements.

func (*FuncButton) CallFunc

func (fb *FuncButton) CallFunc()

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

func (*FuncButton) CallFuncShowReturns

func (fb *FuncButton) CallFuncShowReturns()

func (*FuncButton) ConfirmDialog

func (fb *FuncButton) ConfirmDialog()

ConfirmDialog runs the confirm dialog

func (*FuncButton) GoodContext

func (fb *FuncButton) GoodContext() gi.Widget

func (*FuncButton) KiType

func (t *FuncButton) KiType() *gti.Type

KiType returns the *gti.Type of FuncButton

func (*FuncButton) New

func (t *FuncButton) New() ki.Ki

New returns a new *FuncButton value

func (*FuncButton) OnInit

func (fb *FuncButton) OnInit()

func (*FuncButton) SetAfterFunc added in v0.0.7

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

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

func (*FuncButton) SetArgs

func (fb *FuncButton) SetArgs()

SetArgs sets the appropriate Value objects for the arguments of the function associated with the function button. It is called in FuncButton.SetFunc and should typically not be called by end-user code.

func (*FuncButton) SetConfirm

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

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

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

func (*FuncButton) SetFunc

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 gti. SetFunc is automatically called by NewFuncButton.

func (*FuncButton) SetFuncImpl

func (fb *FuncButton) SetFuncImpl(gfun *gti.Func, rfun reflect.Value) *FuncButton

SetFuncImpl is the underlying implementation of FuncButton.SetFunc. It should typically not be used by end-user code.

func (*FuncButton) SetIcon

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

SetIcon sets the [FuncButton.Icon]

func (*FuncButton) SetIndicator

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

SetIndicator sets the [FuncButton.Indicator]

func (*FuncButton) SetKey

func (fb *FuncButton) SetKey(kf keyfun.Funs) *FuncButton

SetKey sets the shortcut of the function button from the given keyfun.Funs

func (*FuncButton) SetMenu

func (t *FuncButton) SetMenu(v func(m *gi.Scene)) *FuncButton

SetMenu sets the [FuncButton.Menu]

func (*FuncButton) SetMethodImpl

func (fb *FuncButton) SetMethodImpl(gmet *gti.Method, rmet reflect.Value) *FuncButton

SetMethodImpl is the underlying implementation of FuncButton.SetFunc for methods. It should typically not be used by end-user code.

func (*FuncButton) SetNewWindow

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

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

func (*FuncButton) SetReturnValues

func (fb *FuncButton) SetReturnValues(rets []reflect.Value)

SetReturnValues sets the [reflect.Value]s of the return value Value objects. It assumes that FuncButton.SetReturns has already been called. It is called in FuncButton.CallFunc and should typically not be called by end-user code.

func (*FuncButton) SetReturns

func (fb *FuncButton) SetReturns()

SetReturns sets the appropriate Value objects for the return values of the function associated with the function button. It is called in FuncButton.SetFunc and should typically not be called by end-user code.

func (*FuncButton) SetShortcut

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

SetShortcut sets the [FuncButton.Shortcut]

func (*FuncButton) SetShowReturn

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

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

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

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

func (*FuncButton) SetTooltip

func (t *FuncButton) SetTooltip(v string) *FuncButton

SetTooltip sets the [FuncButton.Tooltip]

func (*FuncButton) SetType

func (t *FuncButton) SetType(v gi.ButtonTypes) *FuncButton

SetType sets the [FuncButton.Type]

func (*FuncButton) SetWarnUnadded

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 gti is used. It is on by default and must be set before FuncButton.SetFunc is called for it to have any effect.

func (*FuncButton) ShowReturnsDialog

func (fb *FuncButton) ShowReturnsDialog(rets []reflect.Value)

ShowReturnsDialog runs a dialog displaying the given function return values for the function associated with the function button. It does nothing if [FuncButton.ShowReturn] is dialog

type FuncValue

type FuncValue struct {
	ValueBase[*FuncButton]
}

FuncValue represents a function value with a FuncButton.

func (*FuncValue) Config added in v0.0.8

func (v *FuncValue) Config()

func (*FuncValue) Update added in v0.0.8

func (v *FuncValue) Update()

type IconValue

type IconValue struct {
	ValueBase[*gi.Button]
}

IconValue represents an icons.Icon value with a button.

func (*IconValue) Config added in v0.0.8

func (v *IconValue) Config()

func (*IconValue) ConfigDialog

func (v *IconValue) ConfigDialog(d *gi.Body) (bool, func())

func (*IconValue) Update added in v0.0.8

func (v *IconValue) Update()

type Inspector

type Inspector struct {
	gi.Frame

	// root of tree being edited
	KiRoot ki.Ki

	// has the root changed via gui actions?  updated from treeview and structview for changes
	Changed bool `set:"-"`

	// current filename for saving / loading
	Filename gi.Filename
}

Inspector represents a struct, creating a property editor of the fields -- constructs Children widgets to show the field names and editor fields for each field, within an overall frame with an optional title, and a button box at the bottom where methods can be invoked

func NewInspector

func NewInspector(par ki.Ki, name ...string) *Inspector

NewInspector adds a new Inspector with the given name to the given parent: Inspector represents a struct, creating a property editor of the fields -- constructs Children widgets to show the field names and editor fields for each field, within an overall frame with an optional title, and a button box at the bottom where methods can be invoked

func (*Inspector) Config added in v0.0.8

func (is *Inspector) Config()

Config configures the widget

func (*Inspector) ConfigSplits

func (is *Inspector) ConfigSplits()

ConfigSplits configures the Splits.

func (*Inspector) ConfigToolbar

func (is *Inspector) ConfigToolbar(tb *gi.Toolbar)

func (*Inspector) InspectApp

func (is *Inspector) InspectApp()

InspectApp displays the underlying operating system app

func (*Inspector) KiType

func (t *Inspector) KiType() *gti.Type

KiType returns the *gti.Type of Inspector

func (*Inspector) New

func (t *Inspector) New() ki.Ki

New returns a new *Inspector value

func (*Inspector) OnInit

func (is *Inspector) OnInit()

func (*Inspector) Open

func (is *Inspector) Open(filename gi.Filename) error

Open opens tree from given filename, in a standard JSON-formatted file

func (*Inspector) Save

func (is *Inspector) Save() error

Save saves tree to current filename, in a standard JSON-formatted file

func (*Inspector) SaveAs

func (is *Inspector) SaveAs(filename gi.Filename) error

SaveAs saves tree to given filename, in a standard JSON-formatted file

func (*Inspector) SelectionMonitor

func (is *Inspector) SelectionMonitor()

SelectionMonitor monitors for the selected widget

func (*Inspector) SetFilename

func (t *Inspector) SetFilename(v gi.Filename) *Inspector

SetFilename sets the [Inspector.Filename]: current filename for saving / loading

func (*Inspector) SetKiRoot

func (t *Inspector) SetKiRoot(v ki.Ki) *Inspector

SetKiRoot sets the [Inspector.KiRoot]: root of tree being edited

func (*Inspector) SetRoot

func (is *Inspector) SetRoot(root ki.Ki)

SetRoot sets the source root and ensures everything is configured

func (*Inspector) SetStackTop

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

SetStackTop sets the [Inspector.StackTop]

func (*Inspector) SetStyles

func (is *Inspector) SetStyles()

func (*Inspector) SetTitle

func (is *Inspector) SetTitle(k ki.Ki)

SetTitle sets the title to correspond to the given node.

func (*Inspector) SetTooltip

func (t *Inspector) SetTooltip(v string) *Inspector

SetTooltip sets the [Inspector.Tooltip]

func (*Inspector) Splits

func (is *Inspector) Splits() *gi.Splits

Splits returns the main Splits

func (*Inspector) StructView

func (is *Inspector) StructView() *StructView

StructView returns the main StructView

func (*Inspector) TitleWidget

func (is *Inspector) TitleWidget() *gi.Label

TitleWidget returns the title label widget

func (*Inspector) ToggleSelectionMode

func (is *Inspector) ToggleSelectionMode()

ToggleSelectionMode toggles the editor between selection mode or not. In selection mode, bounding boxes are rendered around each Widget, and clicking on a Widget pulls it up in the inspector.

func (*Inspector) TreeView

func (is *Inspector) TreeView() *TreeView

TreeView returns the main TreeSyncView

type KeyChordValue

type KeyChordValue struct {
	ValueBase[*gi.Button]
}

KeyChordValue represents a key.Chord value with a button.

func (*KeyChordValue) Config added in v0.0.8

func (v *KeyChordValue) Config()

func (*KeyChordValue) Update added in v0.0.8

func (v *KeyChordValue) Update()

type KeyMapValue

type KeyMapValue struct {
	ValueBase[*gi.Button]
}

KeyMapValue represents a keyfun.MapName value with a button.

func (*KeyMapValue) Config added in v0.0.8

func (v *KeyMapValue) Config()

func (*KeyMapValue) ConfigDialog

func (v *KeyMapValue) ConfigDialog(d *gi.Body) (bool, func())

func (*KeyMapValue) Update added in v0.0.8

func (v *KeyMapValue) Update()

type KiValue added in v0.0.8

type KiValue struct {
	ValueBase[*gi.Button]
}

KiValue represents a ki.Ki value with a button.

func (*KiValue) Config added in v0.0.8

func (v *KiValue) Config()

func (*KiValue) ConfigDialog added in v0.0.8

func (v *KiValue) ConfigDialog(d *gi.Body) (bool, func())

func (*KiValue) KiValue added in v0.0.8

func (vv *KiValue) KiValue() ki.Ki

KiValue returns the actual underlying ki.Ki value, or nil.

func (*KiValue) Update added in v0.0.8

func (v *KiValue) Update()

type MapInlineValue

type MapInlineValue struct {
	ValueBase[*MapViewInline]
}

MapInlineValue represents a map value with a MapViewInline.

func (*MapInlineValue) Config added in v0.0.8

func (v *MapInlineValue) Config()

func (*MapInlineValue) Update added in v0.0.8

func (v *MapInlineValue) Update()

type MapValue

type MapValue struct {
	ValueBase[*gi.Button]
}

MapValue represents a map value with a button.

func (*MapValue) Config added in v0.0.8

func (v *MapValue) Config()

func (*MapValue) ConfigDialog

func (v *MapValue) ConfigDialog(d *gi.Body) (bool, func())

func (*MapValue) Update added in v0.0.8

func (v *MapValue) Update()

type MapView

type MapView struct {
	gi.Frame

	// the map that we are a view onto
	Map any `set:"-"`

	// Value for the map itself, if this was created within value view framework; otherwise nil
	MapValView Value

	// has the map been edited?
	Changed bool `set:"-"`

	// Value representations of the map keys
	Keys []Value `json:"-" xml:"-" set:"-"`

	// Value representations of the map values
	Values []Value `json:"-" xml:"-" set:"-"`

	// sort by values instead of keys
	SortVals bool

	// the number of columns in the map; do not set externally;
	// generally only access internally
	NCols int `set:"-"`

	// a record of parent View names that have led up to this view.
	// Displayed as extra contextual information in view dialog windows.
	ViewPath string
}

MapView represents a map, creating a property editor of the values -- constructs Children widgets to show the key / value pairs, within an overall frame.

func NewMapView

func NewMapView(par ki.Ki, name ...string) *MapView

NewMapView adds a new MapView with the given name to the given parent: MapView represents a map, creating a property editor of the values -- constructs Children widgets to show the key / value pairs, within an overall frame.

func (*MapView) Config added in v0.0.8

func (mv *MapView) Config()

Config configures the view

func (*MapView) ConfigMapGrid

func (mv *MapView) ConfigMapGrid()

ConfigMapGrid configures the MapGrid for the current map

func (*MapView) ConfigToolbar

func (mv *MapView) ConfigToolbar(tb *gi.Toolbar)

ConfigToolbar configures a gi.Toolbar for this view

func (*MapView) ContextMenu added in v0.0.6

func (mv *MapView) ContextMenu(m *gi.Scene, keyv reflect.Value)

func (*MapView) IsConfiged

func (mv *MapView) IsConfiged() bool

IsConfiged returns true if the widget is fully configured

func (*MapView) KiPropTag

func (mv *MapView) KiPropTag() string

KiPropTag returns the PropTag value from Ki owner of this map, if it is..

func (*MapView) KiType

func (t *MapView) KiType() *gti.Type

KiType returns the *gti.Type of MapView

func (*MapView) MapAdd

func (mv *MapView) MapAdd()

MapAdd adds a new entry to the map

func (*MapView) MapChangeValueType

func (mv *MapView) MapChangeValueType(idx int, typ reflect.Type)

MapChangeValueType changes the type of the value for given map element at idx -- for maps with any values

func (*MapView) MapDelete

func (mv *MapView) MapDelete(key reflect.Value)

MapDelete deletes a key-value from the map

func (*MapView) MapGrid

func (mv *MapView) MapGrid() *gi.Frame

MapGrid returns the MapGrid grid layout widget, which contains all the fields and values

func (*MapView) New

func (t *MapView) New() ki.Ki

New returns a new *MapView value

func (*MapView) OnInit

func (mv *MapView) OnInit()

func (*MapView) SetChanged

func (mv *MapView) SetChanged()

SetChanged sets the Changed flag and emits the ViewSig signal for the MapView, indicating that some kind of edit / change has taken place to the table data.

func (*MapView) SetMap

func (mv *MapView) SetMap(mp any) *MapView

SetMap sets the source map that we are viewing. Rebuilds the children to represent this map

func (*MapView) SetMapValView

func (t *MapView) SetMapValView(v Value) *MapView

SetMapValView sets the [MapView.MapValView]: Value for the map itself, if this was created within value view framework; otherwise nil

func (*MapView) SetSortVals

func (t *MapView) SetSortVals(v bool) *MapView

SetSortVals sets the [MapView.SortVals]: sort by values instead of keys

func (*MapView) SetStackTop

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

SetStackTop sets the [MapView.StackTop]

func (*MapView) SetStyles

func (mv *MapView) SetStyles()

func (*MapView) SetTooltip

func (t *MapView) SetTooltip(v string) *MapView

SetTooltip sets the [MapView.Tooltip]

func (*MapView) SetViewPath

func (t *MapView) SetViewPath(v string) *MapView

SetViewPath sets the [MapView.ViewPath]: a record of parent View names that have led up to this view. Displayed as extra contextual information in view dialog windows.

func (*MapView) ToggleSort

func (mv *MapView) ToggleSort()

ToggleSort toggles sorting by values vs. keys

func (*MapView) UpdateValues

func (mv *MapView) UpdateValues()

UpdateValues updates the widget display of slice values, assuming same slice config

type MapViewInline

type MapViewInline struct {
	gi.Layout

	// the map that we are a view onto
	Map any `set:"-"`

	// MapValue is the Value for the map itself
	// if this was created within the Value framework.
	// Otherwise, it is nil.
	MapValue Value `set:"-"`

	// has the map been edited?
	Changed bool `set:"-"`

	// Value representations of the map keys
	Keys []Value `json:"-" xml:"-" set:"-"`

	// Value representations of the fields
	Values []Value `json:"-" xml:"-" set:"-"`

	// a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows
	ViewPath string

	// size of map when gui configed
	ConfigSize int `set:"-"`
}

MapViewInline represents a map as a single line widget, for smaller maps and those explicitly marked inline.

func NewMapViewInline

func NewMapViewInline(par ki.Ki, name ...string) *MapViewInline

NewMapViewInline adds a new MapViewInline with the given name to the given parent: MapViewInline represents a map as a single line widget, for smaller maps and those explicitly marked inline.

func (*MapViewInline) Config added in v0.0.8

func (mv *MapViewInline) Config()

func (*MapViewInline) ContextMenu added in v0.0.7

func (mv *MapViewInline) ContextMenu(m *gi.Scene, keyv reflect.Value)

func (*MapViewInline) KiType

func (t *MapViewInline) KiType() *gti.Type

KiType returns the *gti.Type of MapViewInline

func (*MapViewInline) MapAdd

func (mv *MapViewInline) MapAdd()

MapAdd adds a new entry to the map

func (*MapViewInline) MapDelete added in v0.0.7

func (mv *MapViewInline) MapDelete(key reflect.Value)

MapDelete deletes a key-value from the map

func (*MapViewInline) MapSizeChanged added in v0.0.7

func (mv *MapViewInline) MapSizeChanged() bool

func (*MapViewInline) New

func (t *MapViewInline) New() ki.Ki

New returns a new *MapViewInline value

func (*MapViewInline) OnInit

func (mv *MapViewInline) OnInit()

func (*MapViewInline) SetChanged

func (mv *MapViewInline) SetChanged()

SetChanged sets the Changed flag and emits the ViewSig signal for the SliceView, indicating that some kind of edit / change has taken place to the table data. It isn't really practical to record all the different types of changes, so this is just generic.

func (*MapViewInline) SetMap

func (mv *MapViewInline) SetMap(mp any) *MapViewInline

SetMap sets the source map that we are viewing -- rebuilds the children to represent this map

func (*MapViewInline) SetStackTop

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

SetStackTop sets the [MapViewInline.StackTop]

func (*MapViewInline) SetStyles

func (mv *MapViewInline) SetStyles()

func (*MapViewInline) SetTooltip

func (t *MapViewInline) SetTooltip(v string) *MapViewInline

SetTooltip sets the [MapViewInline.Tooltip]

func (*MapViewInline) SetViewPath

func (t *MapViewInline) SetViewPath(v string) *MapViewInline

SetViewPath sets the [MapViewInline.ViewPath]: a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows

func (*MapViewInline) SizeUp added in v0.0.7

func (mv *MapViewInline) SizeUp()

func (*MapViewInline) UpdateValues

func (mv *MapViewInline) UpdateValues()

type NilValue

type NilValue struct {
	ValueBase[*gi.Label]
}

NilValue represents a nil value with a label that has text "None".

func (*NilValue) Config added in v0.0.8

func (v *NilValue) Config()

func (*NilValue) Update added in v0.0.8

func (vv *NilValue) Update()

type NumberValue added in v0.0.8

type NumberValue struct {
	ValueBase[*gi.Spinner]
}

NumberValue represents an integer or float value with a spinner.

func (*NumberValue) Config added in v0.0.8

func (v *NumberValue) Config()

func (*NumberValue) Update added in v0.0.8

func (v *NumberValue) Update()

type OpenDialoger added in v0.0.8

type OpenDialoger interface {
	// OpenDialog opens the dialog for this Value.
	// Given function closure is called for the Ok action, after value
	// has been updated, if using the dialog as part of another control flow.
	// Note that some cases just pop up a menu chooser, not a full dialog.
	OpenDialog(ctx gi.Widget, fun func())
}

OpenDialoger is an optional interface that [Value]s may implement to indicate that they have a dialog associated with them that is created, configured, and run with the OpenDialog method. This method typically calls a separate ConfigDialog method. If the Value does not implement OpenDialoger but does implement ConfigDialoger, then OpenDialogBase will be used to create and run the dialog, and [ConfigDialoger.ConfigDialog] will be used to configure it.

type RuneSliceValue

type RuneSliceValue struct {
	ValueBase[*gi.TextField]
}

RuneSliceValue represents a slice of runes with a text field.

func (*RuneSliceValue) Config added in v0.0.8

func (v *RuneSliceValue) Config()

func (*RuneSliceValue) Update added in v0.0.8

func (v *RuneSliceValue) Update()

type SliceInlineValue

type SliceInlineValue struct {
	ValueBase[*SliceViewInline]
}

SliceInlineValue represents a slice or array value with a SliceViewInline.

func (*SliceInlineValue) Config added in v0.0.8

func (v *SliceInlineValue) Config()

func (*SliceInlineValue) Update added in v0.0.8

func (v *SliceInlineValue) Update()

type SliceValue

type SliceValue struct {
	ValueBase[*gi.Button]
}

SliceValue represents a slice or array value with a button.

func (*SliceValue) Config added in v0.0.8

func (v *SliceValue) Config()

func (*SliceValue) ConfigDialog

func (v *SliceValue) ConfigDialog(d *gi.Body) (bool, func())

func (*SliceValue) Update added in v0.0.8

func (v *SliceValue) Update()

type SliceView

type SliceView struct {
	SliceViewBase

	// optional styling function
	StyleFunc SliceViewStyleFunc `copier:"-" view:"-" json:"-" xml:"-"`
}

SliceView represents a slice, creating an interactive viewer / editor of the elements as rows in a table. Widgets to show the index / value pairs, within an overall frame. Set to ReadOnly for select-only mode, which emits WidgetSig WidgetSelected signals when selection is updated.

func NewSliceView

func NewSliceView(par ki.Ki, name ...string) *SliceView

NewSliceView adds a new SliceView with the given name to the given parent: SliceView represents a slice, creating an interactive viewer / editor of the elements as rows in a table. Widgets to show the index / value pairs, within an overall frame. Set to ReadOnly for select-only mode, which emits WidgetSig WidgetSelected signals when selection is updated.

func (*SliceView) HasStyleFunc added in v0.0.5

func (sv *SliceView) HasStyleFunc() bool

func (*SliceView) KiType

func (t *SliceView) KiType() *gti.Type

KiType returns the *gti.Type of SliceView

func (*SliceView) New

func (t *SliceView) New() ki.Ki

New returns a new *SliceView value

func (*SliceView) SetInitSelectedIndex added in v0.0.8

func (t *SliceView) SetInitSelectedIndex(v int) *SliceView

SetInitSelectedIndex sets the [SliceView.InitSelectedIndex]

func (*SliceView) SetMinRows

func (t *SliceView) SetMinRows(v int) *SliceView

SetMinRows sets the [SliceView.MinRows]

func (*SliceView) SetSelVal

func (t *SliceView) SetSelVal(v any) *SliceView

SetSelVal sets the [SliceView.SelVal]

func (*SliceView) SetSelectedIndex added in v0.0.8

func (t *SliceView) SetSelectedIndex(v int) *SliceView

SetSelectedIndex sets the [SliceView.SelectedIndex]

func (*SliceView) SetStackTop

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

SetStackTop sets the [SliceView.StackTop]

func (*SliceView) SetStyleFunc

func (t *SliceView) SetStyleFunc(v SliceViewStyleFunc) *SliceView

SetStyleFunc sets the [SliceView.StyleFunc]: optional styling function

func (*SliceView) SetTooltip

func (t *SliceView) SetTooltip(v string) *SliceView

SetTooltip sets the [SliceView.Tooltip]

func (*SliceView) SetViewMu

func (t *SliceView) SetViewMu(v *sync.Mutex) *SliceView

SetViewMu sets the [SliceView.ViewMu]

func (*SliceView) SetViewPath

func (t *SliceView) SetViewPath(v string) *SliceView

SetViewPath sets the [SliceView.ViewPath]

func (*SliceView) StyleRow

func (sv *SliceView) StyleRow(w gi.Widget, idx, fidx int)

type SliceViewBase

type SliceViewBase struct {
	gi.Frame

	// the slice that we are a view onto -- must be a pointer to that slice
	Slice any `set:"-" json:"-" xml:"-"`

	// MinRows specifies the minimum number of rows to display, to ensure
	// at least this amount is displayed.
	MinRows int `default:"4"`

	// a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows
	ViewPath string

	// optional mutex that, if non-nil, will be used around any updates that
	// read / modify the underlying Slice data.
	// Can be used to protect against random updating if your code has specific
	// update points that can be likewise protected with this same mutex.
	ViewMu *sync.Mutex `copier:"-" view:"-" json:"-" xml:"-"`

	// Changed indicates whether the underlying slice
	// has been edited in any way
	Changed bool `set:"-"`

	// current selection value -- initially select this value if set
	SelVal any `copier:"-" view:"-" json:"-" xml:"-"`

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

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

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

	// LastClick is the last row that has been clicked on.
	// This is used to prevent erroneous double click events
	// from being sent when the user clicks on multiple different
	// rows in quick succession.
	LastClick int `set:"-" copier:"-" json:"-" xml:"-"`

	// NormalCursor is the cached cursor to display when there
	// is no row being hovered.
	NormalCursor cursors.Cursor `copier:"-" xml:"-" json:"-" set:"-"`

	// CurrentCursor is the cached cursor that should currently be
	// displayed.
	CurrentCursor cursors.Cursor `copier:"-" xml:"-" json:"-" set:"-"`

	// non-ptr reflect.Value of the slice
	SliceNPVal reflect.Value `set:"-" copier:"-" view:"-" json:"-" xml:"-"`

	// Value for the slice itself, if this was created within value view framework -- otherwise nil
	SliceValue Value `set:"-" copier:"-" view:"-" json:"-" xml:"-"`

	// Value representations of the slice values
	Values []Value `set:"-" copier:"-" view:"-" json:"-" xml:"-"`

	// currently-hovered row
	HoverRow int `set:"-" view:"-" copier:"-" json:"-" xml:"-"`

	// list of currently-dragged indexes
	DraggedIndexes []int `set:"-" view:"-" copier:"-" json:"-" xml:"-"`

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

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

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

	// iteration through the configuration process, reset when a new slice type is set
	ConfigIter int `set:"-" edit:"-" copier:"-" json:"-" xml:"-"`

	// temp idx state for e.g., dnd
	TmpIndex int `set:"-" copier:"-" view:"-" json:"-" xml:"-"`

	// ElVal is a Value representation of the underlying element type
	// which is used whenever there are no slice elements available
	ElVal reflect.Value `set:"-" copier:"-" view:"-" json:"-" xml:"-"`

	// maximum width of value column in chars, if string
	MaxWidth int `set:"-" copier:"-" json:"-" xml:"-"`
}

SliceViewBase is the base for SliceView and TableView and any other viewers 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. Set to ReadOnly for select-only mode, which emits WidgetSig WidgetSelected signals when selection is updated.

func NewSliceViewBase

func NewSliceViewBase(par ki.Ki, name ...string) *SliceViewBase

NewSliceViewBase adds a new SliceViewBase with the given name to the given parent: SliceViewBase is the base for SliceView and TableView and any other viewers 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. Set to ReadOnly for select-only mode, which emits WidgetSig WidgetSelected signals when selection is updated.

func (*SliceViewBase) AsSliceViewBase

func (sv *SliceViewBase) AsSliceViewBase() *SliceViewBase

func (*SliceViewBase) BindSelect added in v0.0.4

func (sv *SliceViewBase) BindSelect(val *int) *SliceViewBase

BindSelect makes the slice view a read-only selection slice view and then binds its events to its scene and its current selection index to the given value.

func (*SliceViewBase) ClickSelectEvent added in v0.0.4

func (sv *SliceViewBase) ClickSelectEvent(e events.Event) bool

ClickSelectEvent is a helper for processing selection events based on a mouse click, which could be a double or triple in addition to a regular click. Returns false if no further processing should occur, because the user clicked outside the range of active rows.

func (*SliceViewBase) Config added in v0.0.8

func (sv *SliceViewBase) Config()

Config configures a standard setup of the overall Frame

func (*SliceViewBase) ConfigFrame

func (sv *SliceViewBase) ConfigFrame()

func (*SliceViewBase) ConfigRows

func (sv *SliceViewBase) ConfigRows()

ConfigRows configures VisRows worth of widgets to display slice data.

func (*SliceViewBase) ConfigSliceView

func (sv *SliceViewBase) ConfigSliceView()

ConfigSliceView handles entire config. ReConfig calls this, followed by ApplyStyleTree so we don't need to call that.

func (*SliceViewBase) ConfigToolbar

func (sv *SliceViewBase) ConfigToolbar(tb *gi.Toolbar)

ConfigToolbar configures a gi.Toolbar for this view

func (*SliceViewBase) ContextMenu

func (sv *SliceViewBase) ContextMenu(m *gi.Scene)

func (*SliceViewBase) CopyIdxs

func (sv *SliceViewBase) CopyIdxs(reset bool)

CopyIdxs copies selected idxs to goosi.Clipboard, optionally resetting the selection

func (*SliceViewBase) CopySelToMime

func (sv *SliceViewBase) CopySelToMime() mimedata.Mimes

CopySelToMime copies selected rows to mime data

func (*SliceViewBase) CutIdxs

func (sv *SliceViewBase) CutIdxs()

CutIdxs copies selected indexes to goosi.Clipboard and deletes selected indexes

func (*SliceViewBase) DeleteIdxs

func (sv *SliceViewBase) DeleteIdxs()

DeleteIdxs deletes all selected indexes

func (*SliceViewBase) DragDrop

func (sv *SliceViewBase) DragDrop(e events.Event)

func (*SliceViewBase) DragStart

func (sv *SliceViewBase) DragStart(e events.Event)

func (*SliceViewBase) DropDeleteSource

func (sv *SliceViewBase) DropDeleteSource(e events.Event)

DropDeleteSource handles delete source event for DropMove case

func (*SliceViewBase) DropFinalize

func (sv *SliceViewBase) DropFinalize(de *events.DragDrop)

DropFinalize is called to finalize Drop actions on the Source node. Only relevant for DropMod == DropMove.

func (*SliceViewBase) Duplicate

func (sv *SliceViewBase) Duplicate() int

Duplicate copies selected items and inserts them after current selection -- return idx of start of duplicates if successful, else -1

func (*SliceViewBase) FlagType

func (sv *SliceViewBase) FlagType() enums.BitFlagSetter

func (*SliceViewBase) FromMimeData

func (sv *SliceViewBase) FromMimeData(md mimedata.Mimes) []any

FromMimeData creates a slice of structs from mime data

func (*SliceViewBase) HandleEvents

func (sv *SliceViewBase) HandleEvents()

func (*SliceViewBase) IdxFromPos

func (sv *SliceViewBase) IdxFromPos(posY int) (int, bool)

IdxFromPos returns the idx that contains given vertical position, false if not found

func (*SliceViewBase) IdxGrabFocus

func (sv *SliceViewBase) IdxGrabFocus(idx int) *gi.WidgetBase

IdxGrabFocus grabs the focus for the first focusable widget in given idx. returns that element or nil if not successful.

func (*SliceViewBase) IdxIsSelected

func (sv *SliceViewBase) IdxIsSelected(idx int) bool

IdxIsSelected returns the selected status of given slice index

func (*SliceViewBase) IdxPos

func (sv *SliceViewBase) IdxPos(idx int) image.Point

IdxPos returns center of window position of index label for idx (ContextMenuPos)

func (*SliceViewBase) IsIdxVisible

func (sv *SliceViewBase) IsIdxVisible(idx int) bool

IsIdxVisible returns true if slice index is currently visible

func (*SliceViewBase) IsNil

func (sv *SliceViewBase) IsNil() bool

IsNil returns true if the Slice is nil

func (*SliceViewBase) IsRowInBounds

func (sv *SliceViewBase) IsRowInBounds(row int) bool

IsRowInBounds returns true if disp row is in bounds

func (*SliceViewBase) KeyInputEditable

func (sv *SliceViewBase) KeyInputEditable(kt events.Event)

func (*SliceViewBase) KeyInputNav

func (sv *SliceViewBase) KeyInputNav(kt events.Event)

KeyInputNav supports multiple selection navigation keys

func (*SliceViewBase) KeyInputReadOnly

func (sv *SliceViewBase) KeyInputReadOnly(kt events.Event)

func (*SliceViewBase) KiType

func (t *SliceViewBase) KiType() *gti.Type

KiType returns the *gti.Type of SliceViewBase

func (*SliceViewBase) MakePasteMenu

func (sv *SliceViewBase) MakePasteMenu(m *gi.Scene, md mimedata.Mimes, idx int, mod events.DropMods, fun func())

MakePasteMenu makes the menu of options for paste events

func (*SliceViewBase) MimeDataIdx

func (sv *SliceViewBase) MimeDataIdx(md *mimedata.Mimes, idx int)

MimeDataIdx adds mimedata for given idx: an application/json of the struct

func (*SliceViewBase) MimeDataType

func (sv *SliceViewBase) MimeDataType() string

MimeDataType returns the data type for mime clipboard (copy / paste) data e.g., fi.DataJson

func (*SliceViewBase) MousePosInGrid added in v0.0.7

func (sv *SliceViewBase) MousePosInGrid(e events.Event) bool

MousePosInGrid returns true if the event mouse position is located within the slicegrid.

func (*SliceViewBase) MoveDown

func (sv *SliceViewBase) MoveDown(selMode events.SelectModes) int

MoveDown moves the selection down to next row, using given select mode (from keyboard modifiers) -- returns newly selected row or -1 if failed

func (*SliceViewBase) MoveDownAction

func (sv *SliceViewBase) MoveDownAction(selMode events.SelectModes) int

MoveDownAction moves the selection down to next row, using given select mode (from keyboard modifiers) -- and emits select event for newly selected row

func (*SliceViewBase) MovePageDown

func (sv *SliceViewBase) MovePageDown(selMode events.SelectModes) int

MovePageDown moves the selection down to next page, using given select mode (from keyboard modifiers) -- returns newly selected idx or -1 if failed

func (*SliceViewBase) MovePageDownAction

func (sv *SliceViewBase) MovePageDownAction(selMode events.SelectModes) int

MovePageDownAction moves the selection down to next page, using given select mode (from keyboard modifiers) -- and emits select event for newly selected idx

func (*SliceViewBase) MovePageUp

func (sv *SliceViewBase) MovePageUp(selMode events.SelectModes) int

MovePageUp moves the selection up to previous page, using given select mode (from keyboard modifiers) -- returns newly selected idx or -1 if failed

func (*SliceViewBase) MovePageUpAction

func (sv *SliceViewBase) MovePageUpAction(selMode events.SelectModes) int

MovePageUpAction moves the selection up to previous page, using given select mode (from keyboard modifiers) -- and emits select event for newly selected idx

func (*SliceViewBase) MoveUp

func (sv *SliceViewBase) MoveUp(selMode events.SelectModes) int

MoveUp moves the selection up to previous idx, using given select mode (from keyboard modifiers) -- returns newly selected idx or -1 if failed

func (*SliceViewBase) MoveUpAction

func (sv *SliceViewBase) MoveUpAction(selMode events.SelectModes) int

MoveUpAction moves the selection up to previous idx, using given select mode (from keyboard modifiers) -- and emits select event for newly selected idx

func (*SliceViewBase) New

func (t *SliceViewBase) New() ki.Ki

New returns a new *SliceViewBase value

func (*SliceViewBase) OnInit

func (sv *SliceViewBase) OnInit()

func (*SliceViewBase) PasteAssign

func (sv *SliceViewBase) PasteAssign(md mimedata.Mimes, idx int)

PasteAssign assigns mime data (only the first one!) to this idx

func (*SliceViewBase) PasteAtIdx

func (sv *SliceViewBase) PasteAtIdx(md mimedata.Mimes, idx int)

PasteAtIdx inserts object(s) from mime data at (before) given slice index

func (*SliceViewBase) PasteIdx

func (sv *SliceViewBase) PasteIdx(idx int)

PasteIdx pastes clipboard at given idx

func (*SliceViewBase) PasteMenu

func (sv *SliceViewBase) PasteMenu(md mimedata.Mimes, idx int)

PasteMenu performs a paste from the clipboard using given data -- pops up a menu to determine what specifically to do

func (*SliceViewBase) ResetSelectedIdxs

func (sv *SliceViewBase) ResetSelectedIdxs()

func (*SliceViewBase) RowFirstWidget

func (sv *SliceViewBase) RowFirstWidget(row int) (*gi.WidgetBase, bool)

RowFirstWidget returns the first widget for given row (could be index or not) -- false if out of range

func (*SliceViewBase) RowFromEventPos added in v0.0.4

func (sv *SliceViewBase) RowFromEventPos(e events.Event) (row, idx int, isValid bool)

RowFromEventPos returns the widget row, slice index, and whether the index is in slice range, for given event position.

func (*SliceViewBase) RowFromPos

func (sv *SliceViewBase) RowFromPos(posY int) (int, bool)

RowFromPos returns the row that contains given vertical position, false if not found

func (*SliceViewBase) RowGrabFocus

func (sv *SliceViewBase) RowGrabFocus(row int) *gi.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 (*SliceViewBase) RowWidgetNs

func (sv *SliceViewBase) RowWidgetNs() (nWidgPerRow, idxOff int)

RowWidgetNs returns number of widgets per row and offset for index label

func (*SliceViewBase) RowWidgetsFunc added in v0.0.4

func (sv *SliceViewBase) RowWidgetsFunc(row int, fun func(w gi.Widget))

RowWidgetsFunc calls function on each widget in given row (row, not index), with an UpdateStart / EndRender wrapper

func (*SliceViewBase) SaveDraggedIdxs

func (sv *SliceViewBase) SaveDraggedIdxs(idx int)

SaveDraggedIdxs saves selectedindexes into dragged indexes taking into account insertion at idx

func (*SliceViewBase) ScrollToIdx

func (sv *SliceViewBase) ScrollToIdx(idx int) bool

ScrollToIdx ensures that given slice idx is visible by scrolling display as needed.

func (*SliceViewBase) ScrollToIdxNoUpdt

func (sv *SliceViewBase) ScrollToIdxNoUpdt(idx int) bool

ScrollToIdxNoUpdt ensures that given slice idx is visible by scrolling display as needed. This version does not update the slicegrid. Just computes the StartIdx and updates the scrollbar

func (*SliceViewBase) SelectAllIdxs

func (sv *SliceViewBase) SelectAllIdxs()

SelectAllIdxs selects all idxs

func (*SliceViewBase) SelectIdx

func (sv *SliceViewBase) SelectIdx(idx int)

SelectIdx selects given idx (if not already selected) -- updates select status of index label

func (*SliceViewBase) SelectIdxAction

func (sv *SliceViewBase) SelectIdxAction(idx int, mode events.SelectModes)

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

func (*SliceViewBase) SelectIdxWidgets

func (sv *SliceViewBase) SelectIdxWidgets(idx int, sel bool) bool

SelectIdxWidgets sets the selection state of given slice index returns false if index is not visible

func (*SliceViewBase) SelectRowIfNone added in v0.0.7

func (sv *SliceViewBase) SelectRowIfNone(e events.Event) bool

SelectRowIfNone selects the row the mouse is on if there are no currently selected items. Returns false if no valid mouse row.

func (*SliceViewBase) SelectRowWidgets

func (sv *SliceViewBase) SelectRowWidgets(row int, sel bool)

SelectRowWidgets sets the selection state of given row of widgets

func (*SliceViewBase) SelectVal

func (sv *SliceViewBase) SelectVal(val string) bool

SelectVal sets SelVal and attempts to find corresponding row, setting SelectedIdx and selecting row if found -- returns true if found, false otherwise.

func (*SliceViewBase) SelectedIdxsList

func (sv *SliceViewBase) SelectedIdxsList(descendingSort bool) []int

SelectedIdxsList returns list of selected indexes, sorted either ascending or descending

func (*SliceViewBase) SetChanged

func (sv *SliceViewBase) SetChanged()

SetChanged sets the Changed flag and emits the ViewSig signal for the SliceViewBase, indicating that some kind of edit / change has taken place to the table data. It isn't really practical to record all the different types of changes, so this is just generic.

func (*SliceViewBase) SetInitSelectedIndex added in v0.0.8

func (t *SliceViewBase) SetInitSelectedIndex(v int) *SliceViewBase

SetInitSelectedIndex sets the [SliceViewBase.InitSelectedIndex]: index of row to select at start

func (*SliceViewBase) SetMinRows

func (t *SliceViewBase) SetMinRows(v int) *SliceViewBase

SetMinRows sets the [SliceViewBase.MinRows]: MinRows specifies the minimum number of rows to display, to ensure at least this amount is displayed.

func (*SliceViewBase) SetRowWidgetsState added in v0.0.4

func (sv *SliceViewBase) SetRowWidgetsState(row int, ability abilities.Abilities, on bool, state states.States)

SetRowWidgetsState sets given state conditional on given ability for widget

func (*SliceViewBase) SetRowWidgetsStateEvent added in v0.0.4

func (sv *SliceViewBase) SetRowWidgetsStateEvent(e events.Event, ability abilities.Abilities, on bool, state states.States) (int, bool)

SetRowWidgetsStateEvent sets given state conditional on given ability for widget, for given event. returns the row and whether it represents an valid slice idex

func (*SliceViewBase) SetSelVal

func (t *SliceViewBase) SetSelVal(v any) *SliceViewBase

SetSelVal sets the [SliceViewBase.SelVal]: current selection value -- initially select this value if set

func (*SliceViewBase) SetSelectedIndex added in v0.0.8

func (t *SliceViewBase) SetSelectedIndex(v int) *SliceViewBase

SetSelectedIndex sets the [SliceViewBase.SelectedIndex]: index of currently selected item

func (*SliceViewBase) SetSlice

func (sv *SliceViewBase) SetSlice(sl any) *SliceViewBase

SetSlice sets the source slice that we are viewing. This ReConfigs 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 (*SliceViewBase) SetSliceBase added in v0.0.4

func (sv *SliceViewBase) SetSliceBase()

func (*SliceViewBase) SetStackTop

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

SetStackTop sets the [SliceViewBase.StackTop]

func (*SliceViewBase) SetStyles

func (sv *SliceViewBase) SetStyles()

func (*SliceViewBase) SetTooltip

func (t *SliceViewBase) SetTooltip(v string) *SliceViewBase

SetTooltip sets the [SliceViewBase.Tooltip]

func (*SliceViewBase) SetViewMu

func (t *SliceViewBase) SetViewMu(v *sync.Mutex) *SliceViewBase

SetViewMu sets the [SliceViewBase.ViewMu]: optional mutex that, if non-nil, will be used around any updates that read / modify the underlying Slice data. Can be used to protect against random updating if your code has specific update points that can be likewise protected with this same mutex.

func (*SliceViewBase) SetViewPath

func (t *SliceViewBase) SetViewPath(v string) *SliceViewBase

SetViewPath sets the [SliceViewBase.ViewPath]: a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows

func (*SliceViewBase) SizeFinal

func (sv *SliceViewBase) SizeFinal()

func (*SliceViewBase) SliceDeleteAt

func (sv *SliceViewBase) SliceDeleteAt(idx int)

SliceDeleteAt deletes element at given index from slice

func (*SliceViewBase) SliceDeleteAtRow

func (sv *SliceViewBase) SliceDeleteAtRow(row int)

SliceDeleteAtRow deletes element at given display row if updt is true, then update the grid after

func (*SliceViewBase) SliceDeleteAtSel

func (sv *SliceViewBase) SliceDeleteAtSel(idx int)

SliceDeleteAtSel updates selected rows based on deleting element at given index must be called with successful SliceDeleteAt

func (*SliceViewBase) SliceGrid

func (sv *SliceViewBase) SliceGrid() *SliceViewGrid

SliceGrid returns the SliceGrid grid frame widget, which contains all the fields and values

func (*SliceViewBase) SliceNewAt

func (sv *SliceViewBase) SliceNewAt(idx int)

SliceNewAt inserts a new blank element at given index in the slice -- -1 means the end

func (*SliceViewBase) SliceNewAtRow

func (sv *SliceViewBase) SliceNewAtRow(row int)

SliceNewAtRow inserts a new blank element at given display row

func (*SliceViewBase) SliceNewAtSel

func (sv *SliceViewBase) SliceNewAtSel(idx int)

SliceNewAtSel updates selected rows based on inserting new element at given index. must be called with successful SliceNewAt

func (*SliceViewBase) SliceVal

func (sv *SliceViewBase) SliceVal(idx int) any

SliceVal returns value interface at given slice index must be protected by mutex

func (*SliceViewBase) StyleValueWidget added in v0.0.4

func (sv *SliceViewBase) StyleValueWidget(w gi.Widget, s *styles.Style, row, col int)

StyleValueWidget performs additional value widget styling

func (*SliceViewBase) UnselectAllIdxs

func (sv *SliceViewBase) UnselectAllIdxs()

UnselectAllIdxs unselects all selected idxs

func (*SliceViewBase) UnselectIdx

func (sv *SliceViewBase) UnselectIdx(idx int)

UnselectIdx unselects given idx (if selected)

func (*SliceViewBase) UnselectIdxAction

func (sv *SliceViewBase) UnselectIdxAction(idx int)

UnselectIdxAction unselects this idx (if selected) -- and emits a signal

func (*SliceViewBase) UpdateScroll

func (sv *SliceViewBase) UpdateScroll()

UpdateScroll updates the scroll value

func (*SliceViewBase) UpdateSelectIdx

func (sv *SliceViewBase) UpdateSelectIdx(idx int, sel bool, selMode events.SelectModes)

UpdateSelectIdx updates the selection for the given index

func (*SliceViewBase) UpdateSelectRow

func (sv *SliceViewBase) UpdateSelectRow(row int, selMode events.SelectModes)

UpdateSelectRow updates the selection for the given row

func (*SliceViewBase) UpdateStartIdx

func (sv *SliceViewBase) UpdateStartIdx()

UpdateStartIdx updates StartIdx to fit current view

func (*SliceViewBase) UpdateWidgets

func (sv *SliceViewBase) UpdateWidgets()

UpdateWidgets updates the row widget display to represent the current state of the slice data, including which range of data is being displayed. This is called for scrolling, navigation etc.

func (*SliceViewBase) UpdtSliceSize

func (sv *SliceViewBase) UpdtSliceSize() int

UpdtSliceSize updates and returns the size of the slice and sets SliceSize

func (*SliceViewBase) ViewMuLock

func (sv *SliceViewBase) ViewMuLock()

ViewMuLock locks the ViewMu if non-nil

func (*SliceViewBase) ViewMuUnlock

func (sv *SliceViewBase) ViewMuUnlock()

ViewMuUnlock Unlocks the ViewMu if non-nil

func (*SliceViewBase) WidgetIndex added in v0.0.4

func (sv *SliceViewBase) WidgetIndex(w gi.Widget) (row, col int)

WidgetIndex returns the row and column indexes for given widget, from the props set during construction.

type SliceViewFlags

type SliceViewFlags gi.WidgetFlags //enums:bitflag -trim-prefix SliceView

SliceViewFlags extend WidgetFlags to hold SliceView state

const (
	// SliceViewConfigured indicates that the widgets have been configured
	SliceViewConfigured SliceViewFlags = SliceViewFlags(gi.WidgetFlagsN) + iota

	// SliceViewIsArray is whether the slice is actually an array -- no modifications -- set by SetSlice
	SliceViewIsArray

	// SliceViewShowIndex is whether to show index or not
	SliceViewShowIndex

	// SliceViewReadOnlyKeyNav is whether support key navigation when ReadOnly (default true).
	// uses a capture of up / down events to manipulate selection, not focus.
	SliceViewReadOnlyKeyNav

	// SliceViewSelectMode is whether to be in select rows mode or editing mode
	SliceViewSelectMode

	// SliceViewReadOnlyMultiSel: if view is ReadOnly, default selection mode is to choose one row only.
	// If this is true, standard multiple selection logic with modifier keys is instead supported
	SliceViewReadOnlyMultiSel

	// SliceViewInFocusGrab is a guard for recursive focus grabbing
	SliceViewInFocusGrab

	// SliceViewInFullRebuild is a guard for recursive rebuild
	SliceViewInFullRebuild
)
const SliceViewFlagsN SliceViewFlags = 10

SliceViewFlagsN is the highest valid value for type SliceViewFlags, plus one.

func SliceViewFlagsValues

func SliceViewFlagsValues() []SliceViewFlags

SliceViewFlagsValues returns all possible values for the type SliceViewFlags.

func (SliceViewFlags) BitIndexString

func (i SliceViewFlags) BitIndexString() string

BitIndexString returns the string representation of this SliceViewFlags value if it is a bit index value (typically an enum constant), and not an actual bit flag value.

func (SliceViewFlags) Desc

func (i SliceViewFlags) Desc() string

Desc returns the description of the SliceViewFlags value.

func (SliceViewFlags) HasFlag

func (i SliceViewFlags) HasFlag(f enums.BitFlag) bool

HasFlag returns whether these bit flags have the given bit flag set.

func (SliceViewFlags) Int64

func (i SliceViewFlags) Int64() int64

Int64 returns the SliceViewFlags value as an int64.

func (SliceViewFlags) MarshalText

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

MarshalText implements the encoding.TextMarshaler interface.

func (*SliceViewFlags) SetFlag

func (i *SliceViewFlags) SetFlag(on bool, f ...enums.BitFlag)

SetFlag sets the value of the given flags in these flags to the given value.

func (*SliceViewFlags) SetInt64

func (i *SliceViewFlags) SetInt64(in int64)

SetInt64 sets the SliceViewFlags value from an int64.

func (*SliceViewFlags) SetString

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

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

func (*SliceViewFlags) SetStringOr

func (i *SliceViewFlags) SetStringOr(s string) error

SetStringOr sets the SliceViewFlags value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.

func (SliceViewFlags) String

func (i SliceViewFlags) String() string

String returns the string representation of this SliceViewFlags value.

func (*SliceViewFlags) UnmarshalText

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

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (SliceViewFlags) Values

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

Values returns all possible values for the type SliceViewFlags.

type SliceViewGrid

type SliceViewGrid struct {
	gi.Frame // note: must be a frame to support stripes!

	// MinRows is set from parent SV
	MinRows int `set:"-" edit:"-"`

	// height of a single row, computed during layout
	RowHeight float32 `set:"-" edit:"-" copier:"-" json:"-" xml:"-"`

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

	// Various computed backgrounds
	BgStripe, BgSelect, BgSelectStripe, BgHover, BgHoverStripe, BgHoverSelect, BgHoverSelectStripe image.Image `set:"-" edit:"-" copier:"-" json:"-" xml:"-"`

	// LastBackground is the background for which modified
	// backgrounds were computed -- don't update if same
	LastBackground image.Image
}

SliceViewGrid handles the resizing logic for SliceView, TableView.

func NewSliceViewGrid

func NewSliceViewGrid(par ki.Ki, name ...string) *SliceViewGrid

NewSliceViewGrid adds a new SliceViewGrid with the given name to the given parent: SliceViewGrid handles the resizing logic for SliceView, TableView.

func (*SliceViewGrid) ChildBackground added in v0.0.4

func (sg *SliceViewGrid) ChildBackground(child gi.Widget) image.Image

func (*SliceViewGrid) IndexFromPixel added in v0.0.4

func (sg *SliceViewGrid) IndexFromPixel(pt image.Point) (row, col int, isValid bool)

IndexFromPixel returns the row, column indexes of given pixel point within grid. Takes a scene-level position.

func (*SliceViewGrid) KiType

func (t *SliceViewGrid) KiType() *gti.Type

KiType returns the *gti.Type of SliceViewGrid

func (*SliceViewGrid) MousePosInGrid added in v0.0.7

func (sg *SliceViewGrid) MousePosInGrid(pt image.Point) bool

MousePosInGrid returns true if the event mouse position is located within the slicegrid.

func (*SliceViewGrid) New

func (t *SliceViewGrid) New() ki.Ki

New returns a new *SliceViewGrid value

func (*SliceViewGrid) OnInit

func (sg *SliceViewGrid) OnInit()

func (*SliceViewGrid) Render added in v0.0.4

func (sg *SliceViewGrid) Render()

func (*SliceViewGrid) RenderStripes added in v0.0.4

func (sg *SliceViewGrid) RenderStripes()

func (*SliceViewGrid) RowBackground added in v0.0.4

func (sg *SliceViewGrid) RowBackground(sel, stripe, hover bool) image.Image

func (*SliceViewGrid) ScrollChanged

func (sg *SliceViewGrid) ScrollChanged(d mat32.Dims, sb *gi.Slider)

func (*SliceViewGrid) ScrollValues

func (sg *SliceViewGrid) ScrollValues(d mat32.Dims) (maxSize, visSize, visPct float32)

func (*SliceViewGrid) SetLastBackground added in v0.0.4

func (t *SliceViewGrid) SetLastBackground(v image.Image) *SliceViewGrid

SetLastBackground sets the [SliceViewGrid.LastBackground]: LastBackground is the background for which modified backgrounds were computed -- don't update if same

func (*SliceViewGrid) SetScrollParams

func (sg *SliceViewGrid) SetScrollParams(d mat32.Dims, sb *gi.Slider)

func (*SliceViewGrid) SetStackTop

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

SetStackTop sets the [SliceViewGrid.StackTop]

func (*SliceViewGrid) SetTooltip

func (t *SliceViewGrid) SetTooltip(v string) *SliceViewGrid

SetTooltip sets the [SliceViewGrid.Tooltip]

func (*SliceViewGrid) SizeFromChildren

func (sg *SliceViewGrid) SizeFromChildren(iter int, pass gi.LayoutPasses) mat32.Vec2

func (*SliceViewGrid) SliceView

func (sg *SliceViewGrid) SliceView() (SliceViewer, *SliceViewBase)

func (*SliceViewGrid) UpdateBackgrounds added in v0.0.4

func (sg *SliceViewGrid) UpdateBackgrounds()

func (*SliceViewGrid) UpdateScroll

func (sg *SliceViewGrid) UpdateScroll(idx int)

type SliceViewInline

type SliceViewInline struct {
	gi.Layout

	// the slice that we are a view onto
	Slice any `set:"-"`

	// SliceValue is the Value for the slice itself
	// if this was created within the Value framework.
	// Otherwise, it is nil.
	SliceValue Value `set:"-"`

	// whether the slice is actually an array -- no modifications
	IsArray bool `set:"-"`

	// whether the slice has a fixed-len flag on it
	IsFixedLen bool `set:"-"`

	// has the slice been edited?
	Changed bool `set:"-"`

	// Value representations of the fields
	Values []Value `json:"-" xml:"-" set:"-"`

	// a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows
	ViewPath string

	// size of map when gui was configured
	ConfigSize int `set:"-"`
}

SliceViewInline represents a slice as a single line widget, for smaller slices and those explicitly marked inline.

func NewSliceViewInline

func NewSliceViewInline(par ki.Ki, name ...string) *SliceViewInline

NewSliceViewInline adds a new SliceViewInline with the given name to the given parent: SliceViewInline represents a slice as a single line widget, for smaller slices and those explicitly marked inline.

func (*SliceViewInline) Config added in v0.0.8

func (sv *SliceViewInline) Config()

func (*SliceViewInline) ContextMenu added in v0.0.7

func (sv *SliceViewInline) ContextMenu(m *gi.Scene, idx int)

func (*SliceViewInline) KiType

func (t *SliceViewInline) KiType() *gti.Type

KiType returns the *gti.Type of SliceViewInline

func (*SliceViewInline) New

func (t *SliceViewInline) New() ki.Ki

New returns a new *SliceViewInline value

func (*SliceViewInline) OnInit

func (sv *SliceViewInline) OnInit()

func (*SliceViewInline) SetChanged

func (sv *SliceViewInline) SetChanged()

SetChanged sets the Changed flag and emits the ViewSig signal for the SliceView, indicating that some kind of edit / change has taken place to the table data. It isn't really practical to record all the different types of changes, so this is just generic.

func (*SliceViewInline) SetSlice

func (sv *SliceViewInline) SetSlice(sl any) *SliceViewInline

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

func (*SliceViewInline) SetStackTop

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

SetStackTop sets the [SliceViewInline.StackTop]

func (*SliceViewInline) SetStyles

func (sv *SliceViewInline) SetStyles()

func (*SliceViewInline) SetTooltip

func (t *SliceViewInline) SetTooltip(v string) *SliceViewInline

SetTooltip sets the [SliceViewInline.Tooltip]

func (*SliceViewInline) SetViewPath

func (t *SliceViewInline) SetViewPath(v string) *SliceViewInline

SetViewPath sets the [SliceViewInline.ViewPath]: a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows

func (*SliceViewInline) SizeUp added in v0.0.7

func (sv *SliceViewInline) SizeUp()

func (*SliceViewInline) SliceDeleteAt added in v0.0.7

func (sv *SliceViewInline) SliceDeleteAt(idx int)

SliceDeleteAt deletes element at given index from slice

func (*SliceViewInline) SliceNewAt

func (sv *SliceViewInline) SliceNewAt(idx int)

SliceNewAt inserts a new blank element at given index in the slice -- -1 means the end

func (*SliceViewInline) SliceSizeChanged added in v0.0.7

func (sv *SliceViewInline) SliceSizeChanged() bool

func (*SliceViewInline) UpdateValues

func (sv *SliceViewInline) UpdateValues()

type SliceViewStyleFunc

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

SliceViewStyleFunc is a styling function for custom styling and configuration of elements in the slice view.

type SliceViewer

type SliceViewer interface {
	// AsSliceViewBase returns the base for direct access to relevant fields etc
	AsSliceViewBase() *SliceViewBase

	// SliceGrid returns the SliceViewGrid grid Layout widget,
	// which contains all the fields and values
	SliceGrid() *SliceViewGrid

	// RowWidgetNs returns number of widgets per row and
	// offset for index label
	RowWidgetNs() (nWidgPerRow, idxOff int)

	// UpdtSliceSize updates the current size of the slice
	// and sets SliceSize if changed.
	UpdtSliceSize() int

	// StyleValueWidget performs additional value widget styling
	StyleValueWidget(w gi.Widget, s *styles.Style, row, col int)

	// ConfigRows configures VisRows worth of widgets
	// to display slice data.
	ConfigRows()

	// UpdateWidgets updates the row widget display to
	// represent the current state of the slice data,
	// including which range of data is being displayed.
	// This is called for scrolling, navigation etc.
	UpdateWidgets()

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

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

	// RowFirstWidget returns the first widget for given row
	// (could be index or not) -- false if out of range
	RowFirstWidget(row int) (*gi.WidgetBase, bool)

	// RowGrabFocus grabs the focus for the first focusable
	// widget in given row.
	// returns that element or nil if not successful
	// note: grid must have already rendered for focus to be grabbed!
	RowGrabFocus(row int) *gi.WidgetBase

	// SliceNewAt inserts a new blank element at given
	// index in the slice. -1 means the end.
	SliceNewAt(idx int)

	// SliceDeleteAt deletes element at given index from slice
	// if updt is true, then update the grid after
	SliceDeleteAt(idx int)

	// MimeDataType returns the data type for mime clipboard
	// (copy / paste) data e.g., fi.DataJson
	MimeDataType() string

	// CopySelToMime copies selected rows to mime data
	CopySelToMime() mimedata.Mimes

	// PasteAssign assigns mime data (only the first one!) to this idx
	PasteAssign(md mimedata.Mimes, idx int)

	// PasteAtIdx inserts object(s) from mime data at
	// (before) given slice index
	PasteAtIdx(md mimedata.Mimes, idx int)

	MakePasteMenu(m *gi.Scene, md mimedata.Mimes, idx int, mod events.DropMods, fun func())
	DragStart(e events.Event)
	DragDrop(e events.Event)
	DropFinalize(de *events.DragDrop)
	DropDeleteSource(e events.Event)
}

SliceViewer is the interface used by SliceViewBase to support any abstractions needed for different types of slice views.

type SliderValue

type SliderValue struct {
	ValueBase[*gi.Slider]
}

SliderValue represents an integer or float value with a slider.

func (*SliderValue) Config added in v0.0.8

func (v *SliderValue) Config()

func (*SliderValue) Update added in v0.0.8

func (v *SliderValue) Update()

type StringValue added in v0.0.8

type StringValue struct {
	ValueBase[*gi.TextField]
}

StringValue represents any value with a text field.

func (*StringValue) Config added in v0.0.8

func (v *StringValue) Config()

func (*StringValue) Update added in v0.0.8

func (v *StringValue) Update()

type StructFieldVals

type StructFieldVals struct {

	// path of field.field parent fields to this field
	Path string

	// type information for field
	Field reflect.StructField

	// value of field (as a pointer)
	Val reflect.Value

	// def tag information for default values
	Defs string
}

StructFieldVals represents field values in a struct, at multiple levels of depth potentially (represented by the Path field) used for StructNonDefFields for example.

func StructNonDefFields

func StructNonDefFields(structPtr any, path string) []StructFieldVals

StructNonDefFields processses "default" tag for default value(s) of fields in given struct and starting path, and returns all fields not at their default values. See also StructNoDefFieldsStr for a string representation of this information. Uses laser.FlatFieldsValueFunc to get all embedded fields. Uses a recursive strategy -- any fields that are themselves structs are expanded, and the field name represented by dots path separators.

type StructInlineValue

type StructInlineValue struct {
	ValueBase[*StructViewInline]
}

StructInlineValue represents a struct value with a StructViewInline.

func (*StructInlineValue) Config added in v0.0.8

func (v *StructInlineValue) Config()

func (*StructInlineValue) Update added in v0.0.8

func (v *StructInlineValue) Update()

type StructValue

type StructValue struct {
	ValueBase[*gi.Button]
}

StructValue represents a struct value with a button.

func (*StructValue) Config added in v0.0.8

func (v *StructValue) Config()

func (*StructValue) ConfigDialog

func (v *StructValue) ConfigDialog(d *gi.Body) (bool, func())

func (*StructValue) Update added in v0.0.8

func (v *StructValue) Update()

type StructView

type StructView struct {
	gi.Frame

	// the struct that we are a view onto
	Struct any `set:"-"`

	// StructValue is the Value for the struct itself
	// if this was created within the Value framework.
	// Otherwise, it is nil.
	StructValue Value `set:"-"`

	// has the value of any field changed?  updated by the ViewSig signals from fields
	Changed bool `set:"-"`

	// Value representations of the fields
	FieldViews []Value `set:"-" json:"-" xml:"-"`

	// a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows
	ViewPath string

	// IsShouldShower is whether the struct implements [gi.ShouldShower], which results
	// in additional updating being done at certain points.
	IsShouldShower bool `set:"-" json:"-" xml:"-" edit:"-"`

	// extra tags by field name -- from type properties
	TypeFieldTags map[string]string `set:"-" json:"-" xml:"-" edit:"-"`
}

StructView represents a struct, creating a property editor of the fields -- constructs Children widgets to show the field names and editor fields for each field, within an overall frame.

func NewStructView

func NewStructView(par ki.Ki, name ...string) *StructView

NewStructView adds a new StructView with the given name to the given parent: StructView represents a struct, creating a property editor of the fields -- constructs Children widgets to show the field names and editor fields for each field, within an overall frame.

func (*StructView) Config added in v0.0.8

func (sv *StructView) Config()

Config configures the view

func (*StructView) ConfigStructGrid

func (sv *StructView) ConfigStructGrid() bool

ConfigStructGrid configures the StructGrid for the current struct. returns true if any fields changed.

func (*StructView) FieldTags

func (sv *StructView) FieldTags(fld reflect.StructField) reflect.StructTag

FieldTags returns the integrated tags for this field

func (*StructView) IsConfiged

func (sv *StructView) IsConfiged() bool

IsConfiged returns true if the widget is fully configured

func (*StructView) KiType

func (t *StructView) KiType() *gti.Type

KiType returns the *gti.Type of StructView

func (*StructView) New

func (t *StructView) New() ki.Ki

New returns a new *StructView value

func (*StructView) OnInit

func (sv *StructView) OnInit()

func (*StructView) SetStackTop

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

SetStackTop sets the [StructView.StackTop]

func (*StructView) SetStruct

func (sv *StructView) SetStruct(st any) *StructView

SetStruct sets the source struct that we are viewing -- rebuilds the children to represent this struct

func (*StructView) SetStyles

func (sv *StructView) SetStyles()

func (*StructView) SetTooltip

func (t *StructView) SetTooltip(v string) *StructView

SetTooltip sets the [StructView.Tooltip]

func (*StructView) SetViewPath

func (t *StructView) SetViewPath(v string) *StructView

SetViewPath sets the [StructView.ViewPath]: a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows

func (*StructView) StructGrid

func (sv *StructView) StructGrid() *gi.Frame

StructGrid returns the grid layout widget, which contains all the fields and values

func (*StructView) UpdateField

func (sv *StructView) UpdateField(field string)

UpdateField updates the value-view widget for the named field

func (*StructView) UpdateFieldAction

func (sv *StructView) UpdateFieldAction()

func (*StructView) UpdateFields

func (sv *StructView) UpdateFields()

UpdateFields updates each of the value-view widgets for the fields -- called by the ViewSig update

type StructViewInline

type StructViewInline struct {
	gi.Layout

	// the struct that we are a view onto
	Struct any `set:"-"`

	// Value for the struct itself, if this was created within value view framework -- otherwise nil
	StructValue Value `set:"-"`

	// if true, add an edit button at the end
	AddButton bool

	// Value representations of the fields
	FieldViews []Value `json:"-" xml:"-"`

	// a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows
	ViewPath string

	// IsShouldShower is whether the struct implements [gi.ShouldShower], which results
	// in additional updating being done at certain points.
	IsShouldShower bool `set:"-" json:"-" xml:"-" edit:"-"`
}

StructViewInline represents a struct as a single line widget, for smaller structs and those explicitly marked inline.

func NewStructViewInline

func NewStructViewInline(par ki.Ki, name ...string) *StructViewInline

NewStructViewInline adds a new StructViewInline with the given name to the given parent: StructViewInline represents a struct as a single line widget, for smaller structs and those explicitly marked inline.

func (*StructViewInline) Config added in v0.0.8

func (sv *StructViewInline) Config()

func (*StructViewInline) KiType

func (t *StructViewInline) KiType() *gti.Type

KiType returns the *gti.Type of StructViewInline

func (*StructViewInline) New

func (t *StructViewInline) New() ki.Ki

New returns a new *StructViewInline value

func (*StructViewInline) OnInit

func (sv *StructViewInline) OnInit()

func (*StructViewInline) SetAddButton

func (t *StructViewInline) SetAddButton(v bool) *StructViewInline

SetAddButton sets the [StructViewInline.AddButton]: if true, add an edit button at the end

func (*StructViewInline) SetFieldViews

func (t *StructViewInline) SetFieldViews(v ...Value) *StructViewInline

SetFieldViews sets the [StructViewInline.FieldViews]: Value representations of the fields

func (*StructViewInline) SetStackTop

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

SetStackTop sets the [StructViewInline.StackTop]

func (*StructViewInline) SetStruct

func (sv *StructViewInline) SetStruct(st any) *StructViewInline

SetStruct sets the source struct that we are viewing -- rebuilds the children to represent this struct

func (*StructViewInline) SetStyles

func (sv *StructViewInline) SetStyles()

func (*StructViewInline) SetTooltip

func (t *StructViewInline) SetTooltip(v string) *StructViewInline

SetTooltip sets the [StructViewInline.Tooltip]

func (*StructViewInline) SetViewPath

func (t *StructViewInline) SetViewPath(v string) *StructViewInline

SetViewPath sets the [StructViewInline.ViewPath]: a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows

func (*StructViewInline) UpdateFieldAction

func (sv *StructViewInline) UpdateFieldAction()

func (*StructViewInline) UpdateFields

func (sv *StructViewInline) UpdateFields()

type TableView

type TableView struct {
	SliceViewBase

	// optional styling function
	StyleFunc TableViewStyleFunc `copier:"-" view:"-" json:"-" xml:"-"`

	// current selection field -- initially select value in this field
	SelectedField string `copier:"-" view:"-" json:"-" xml:"-"`

	// current sort index
	SortIndex int

	// whether current sort order is descending
	SortDesc bool

	// struct type for each row
	StruType reflect.Type `set:"-" copier:"-" view:"-" json:"-" xml:"-"`

	// the visible fields
	VisFields []reflect.StructField `set:"-" copier:"-" view:"-" json:"-" xml:"-"`

	// number of visible fields
	NVisFields int `set:"-" copier:"-" view:"-" json:"-" xml:"-"`

	// HeaderWidths has number of characters in each header, per visfields
	HeaderWidths []int `set:"-" copier:"-" json:"-" xml:"-"`

	// ColMaxWidths records maximum width in chars of string type fields
	ColMaxWidths []int `set:"-" copier:"-" json:"-" xml:"-"`
}

TableView represents a slice-of-structs as a table, where the fields are the columns, within an overall frame. It is a full-featured editor with multiple-selection, cut-and-paste, and drag-and-drop. If ReadOnly, it functions as a mutually-exclusive item selector, highlighting the selected row and emitting a Selected action.

func NewTableView

func NewTableView(par ki.Ki, name ...string) *TableView

NewTableView adds a new TableView with the given name to the given parent: TableView represents a slice-of-structs as a table, where the fields are the columns, within an overall frame. It is a full-featured editor with multiple-selection, cut-and-paste, and drag-and-drop. If ReadOnly, it functions as a mutually-exclusive item selector, highlighting the selected row and emitting a Selected action.

func (*TableView) CacheVisFields

func (tv *TableView) CacheVisFields()

CacheVisFields computes the number of visible fields in nVisFields and caches those to skip in fieldSkip

func (*TableView) Config added in v0.0.8

func (tv *TableView) Config()

Config configures the view

func (*TableView) ConfigFrame

func (tv *TableView) ConfigFrame()

func (*TableView) ConfigHeader

func (tv *TableView) ConfigHeader()

func (*TableView) ConfigRows

func (tv *TableView) ConfigRows()

ConfigRows configures VisRows worth of widgets to display slice data. It should only be called when NeedsConfigRows is true: when VisRows changes.

func (*TableView) ConfigTableView

func (tv *TableView) ConfigTableView()

func (*TableView) ContextMenu

func (tv *TableView) ContextMenu(m *gi.Scene)

func (*TableView) EditIdx

func (tv *TableView) EditIdx(idx int)

func (*TableView) HasStyleFunc added in v0.0.5

func (tv *TableView) HasStyleFunc() bool

func (*TableView) KiType

func (t *TableView) KiType() *gti.Type

KiType returns the *gti.Type of TableView

func (*TableView) New

func (t *TableView) New() ki.Ki

New returns a new *TableView value

func (*TableView) OnInit

func (tv *TableView) OnInit()

func (*TableView) RowFirstVisWidget

func (tv *TableView) RowFirstVisWidget(row int) (*gi.WidgetBase, bool)

RowFirstVisWidget returns the first visible widget for given row (could be index or not) -- false if out of range

func (*TableView) RowGrabFocus

func (tv *TableView) RowGrabFocus(row int) *gi.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 (*TableView) RowWidgetNs

func (tv *TableView) RowWidgetNs() (nWidgPerRow, idxOff int)

RowWidgetNs returns number of widgets per row and offset for index label

func (*TableView) SelectFieldVal

func (tv *TableView) SelectFieldVal(fld, val string) bool

SelectFieldVal sets SelField and SelVal and attempts to find corresponding row, setting SelectedIdx and selecting row if found -- returns true if found, false otherwise

func (*TableView) SetInitSelectedIndex added in v0.0.8

func (t *TableView) SetInitSelectedIndex(v int) *TableView

SetInitSelectedIndex sets the [TableView.InitSelectedIndex]

func (*TableView) SetMinRows

func (t *TableView) SetMinRows(v int) *TableView

SetMinRows sets the [TableView.MinRows]

func (*TableView) SetSelVal

func (t *TableView) SetSelVal(v any) *TableView

SetSelVal sets the [TableView.SelVal]

func (*TableView) SetSelectedField added in v0.0.8

func (t *TableView) SetSelectedField(v string) *TableView

SetSelectedField sets the [TableView.SelectedField]: current selection field -- initially select value in this field

func (*TableView) SetSelectedIndex added in v0.0.8

func (t *TableView) SetSelectedIndex(v int) *TableView

SetSelectedIndex sets the [TableView.SelectedIndex]

func (*TableView) SetSlice

func (tv *TableView) SetSlice(sl any) *TableView

SetSlice sets the source slice that we are viewing -- rebuilds the children to represent this slice (does Update if already viewing).

func (*TableView) SetSortDesc

func (t *TableView) SetSortDesc(v bool) *TableView

SetSortDesc sets the [TableView.SortDesc]: whether current sort order is descending

func (*TableView) SetSortFieldName

func (tv *TableView) SetSortFieldName(nm string)

SetSortFieldName sets sorting to happen on given field and direction -- see SortFieldName for details

func (*TableView) SetSortIndex added in v0.0.8

func (t *TableView) SetSortIndex(v int) *TableView

SetSortIndex sets the [TableView.SortIndex]: current sort index

func (*TableView) SetStackTop

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

SetStackTop sets the [TableView.StackTop]

func (*TableView) SetStyleFunc

func (t *TableView) SetStyleFunc(v TableViewStyleFunc) *TableView

SetStyleFunc sets the [TableView.StyleFunc]: optional styling function

func (*TableView) SetStyles

func (tv *TableView) SetStyles()

func (*TableView) SetTooltip

func (t *TableView) SetTooltip(v string) *TableView

SetTooltip sets the [TableView.Tooltip]

func (*TableView) SetViewMu

func (t *TableView) SetViewMu(v *sync.Mutex) *TableView

SetViewMu sets the [TableView.ViewMu]

func (*TableView) SetViewPath

func (t *TableView) SetViewPath(v string) *TableView

SetViewPath sets the [TableView.ViewPath]

func (*TableView) SizeFinal

func (tv *TableView) SizeFinal()

func (*TableView) SliceDeleteAt

func (tv *TableView) SliceDeleteAt(idx int)

SliceDeleteAt deletes element at given index from slice

func (*TableView) SliceHeader

func (tv *TableView) SliceHeader() *gi.Frame

SliceHeader returns the Frame header for slice grid

func (*TableView) SliceNewAt

func (tv *TableView) SliceNewAt(idx int)

SliceNewAt inserts a new blank element at given index in the slice -- -1 means the end

func (*TableView) SortFieldName

func (tv *TableView) SortFieldName() string

SortFieldName returns the name of the field being sorted, along with :up or :down depending on descending

func (*TableView) SortSlice

func (tv *TableView) SortSlice()

SortSlice sorts the slice according to current settings

func (*TableView) SortSliceAction

func (tv *TableView) SortSliceAction(fldIdx int)

SortSliceAction sorts the slice for given field index -- toggles ascending vs. descending if already sorting on this dimension

func (*TableView) StructType

func (tv *TableView) StructType() reflect.Type

StructType sets the StruType and returns the type of the struct within the slice -- this is a non-ptr type even if slice has pointers to structs

func (*TableView) StyleRow

func (tv *TableView) StyleRow(w gi.Widget, idx, fidx int)

func (*TableView) StyleValueWidget added in v0.0.4

func (tv *TableView) StyleValueWidget(w gi.Widget, s *styles.Style, row, col int)

StyleValueWidget performs additional value widget styling

func (*TableView) UpdateWidgets

func (tv *TableView) UpdateWidgets()

UpdateWidgets updates the row widget display to represent the current state of the slice data, including which range of data is being displayed. This is called for scrolling, navigation etc.

type TableViewStyleFunc

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

TableViewStyleFunc is a styling function for custom styling and configuration of elements in the table view.

type TimeValue

type TimeValue struct {
	ValueBase[*gi.Layout]
}

TimeValue presents two text fields for editing a date and time, both of which can pull up corresponding picker view dialogs.

func (*TimeValue) Config added in v0.0.8

func (v *TimeValue) Config()

func (*TimeValue) TimeValue added in v0.0.8

func (v *TimeValue) TimeValue() *time.Time

TimeValue decodes the value into a *time.Time value, also handling the fi.FileTime case.

func (*TimeValue) Update added in v0.0.8

func (v *TimeValue) Update()

type TimeView

type TimeView struct {
	gi.Frame

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

	// the raw input hour
	Hour int `set:"-"`

	// whether we are in PM mode (so we have to add 12h to everything)
	PM bool `set:"-"`
}

TimeView is a view for selecting a time

func NewTimeView

func NewTimeView(par ki.Ki, name ...string) *TimeView

NewTimeView adds a new TimeView with the given name to the given parent: TimeView is a view for selecting a time

func (*TimeView) Config added in v0.0.8

func (tv *TimeView) Config()

func (*TimeView) KiType

func (t *TimeView) KiType() *gti.Type

KiType returns the *gti.Type of TimeView

func (*TimeView) New

func (t *TimeView) New() ki.Ki

New returns a new *TimeView value

func (*TimeView) SetStackTop

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

SetStackTop sets the [TimeView.StackTop]

func (*TimeView) SetTime

func (tv *TimeView) SetTime(tim time.Time) *TimeView

SetTime sets the source time and updates the view

func (*TimeView) SetTooltip

func (t *TimeView) SetTooltip(v string) *TimeView

SetTooltip sets the [TimeView.Tooltip]

type TreeTableView added in v0.0.4

type TreeTableView struct {
	gi.Frame

	// Tree is the tree view component of the tree table view.
	Tree *TreeView `set:"-"`

	// Table is the table view component of the tree table view.
	Table *TableView `set:"-"`
}

TreeTableView combines a TreeView and TableView.

func NewTreeTableView added in v0.0.4

func NewTreeTableView(par ki.Ki, name ...string) *TreeTableView

NewTreeTableView adds a new TreeTableView with the given name to the given parent: TreeTableView combines a TreeView and TableView.

func (*TreeTableView) Config added in v0.0.8

func (tt *TreeTableView) Config()

func (*TreeTableView) KiType added in v0.0.4

func (t *TreeTableView) KiType() *gti.Type

KiType returns the *gti.Type of TreeTableView

func (*TreeTableView) New added in v0.0.4

func (t *TreeTableView) New() ki.Ki

New returns a new *TreeTableView value

func (*TreeTableView) SetStackTop added in v0.0.4

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

SetStackTop sets the [TreeTableView.StackTop]

func (*TreeTableView) SetTooltip added in v0.0.4

func (t *TreeTableView) SetTooltip(v string) *TreeTableView

SetTooltip sets the [TreeTableView.Tooltip]

type TreeView

type TreeView struct {
	gi.WidgetBase

	// If non-nil, the Ki Node that this widget is viewing in the tree (the source)
	SyncNode ki.Ki `set:"-" copier:"-" json:"-" xml:"-"`

	// The text to display for the tree view item label, which automatically
	// defaults to the [ki.Node.Name] of the tree view node. It has no effect
	// if [TreeView.SyncNode] is non-nil.
	Text string

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

	// icon to use for an open (expanded) branch; defaults to [icons.KeyboardArrowDown]
	IconOpen icons.Icon `view:"show-name"`

	// icon to use for a closed (collapsed) branch; defaults to [icons.KeyboardArrowRight]
	IconClosed icons.Icon `view:"show-name"`

	// icon to use for a terminal node branch that has no children; defaults to [icons.Blank]
	IconLeaf icons.Icon `view:"show-name"`

	// amount to indent children relative to this node
	Indent units.Value `copier:"-" json:"-" xml:"-"`

	// depth for nodes be initialized as open (default 4).
	// Nodes beyond this depth will be initialized as closed.
	OpenDepth int `copier:"-" json:"-" xml:"-"`

	// linear index of this node within the entire tree.
	// updated on full rebuilds and may sometimes be off,
	// but close enough for expected uses
	ViewIdx int `copier:"-" json:"-" xml:"-" edit:"-"`

	// size of just this node widget.
	// our alloc includes all of our children, but we only draw us.
	WidgetSize mat32.Vec2 `copier:"-" json:"-" xml:"-" edit:"-"`

	// The cached root of the view. It is automatically set and does not need to be
	// set by the end user.
	RootView *TreeView `copier:"-" json:"-" xml:"-" edit:"-"`

	// SelectedNodes holds the currently-selected nodes, on the
	// RootView node only.
	SelectedNodes []TreeViewer `copier:"-" json:"-" xml:"-" edit:"-"`
	// contains filtered or unexported fields
}

TreeView provides a graphical representation of a tree structure, providing full navigation and manipulation abilities.

It does not handle layout by itself, so if you want it to scroll separately from the rest of the surrounding context, use NewTreeViewFrame.

If the SyncNode field is non-nil, typically via SyncRootNode method, then the TreeView mirrors another Ki tree structure, and tree editing functions apply to the source tree first, and then to the TreeView by sync.

Otherwise, data can be directly encoded in a TreeView derived type, to represent any kind of tree structure and associated data.

Standard events.Event are sent to any listeners, including Select, Change, and DoubleClick. The selected nodes are in the root SelectedNodes list.

func AsTreeView

func AsTreeView(k ki.Ki) *TreeView

AsTreeView returns the given value as a value of type TreeView if the type of the given value embeds TreeView, or nil otherwise

func NewTreeView

func NewTreeView(par ki.Ki, name ...string) *TreeView

NewTreeView adds a new TreeView with the given name to the given parent: TreeView provides a graphical representation of a tree structure, providing full navigation and manipulation abilities.

It does not handle layout by itself, so if you want it to scroll separately from the rest of the surrounding context, use NewTreeViewFrame.

If the SyncNode field is non-nil, typically via SyncRootNode method, then the TreeView mirrors another Ki tree structure, and tree editing functions apply to the source tree first, and then to the TreeView by sync.

Otherwise, data can be directly encoded in a TreeView derived type, to represent any kind of tree structure and associated data.

Standard events.Event are sent to any listeners, including Select, Change, and DoubleClick. The selected nodes are in the root SelectedNodes list.

func NewTreeViewFrame added in v0.0.8

func NewTreeViewFrame(par ki.Ki, name ...string) *TreeView

NewTreeViewFrame adds a new TreeView with the given name to a new frame in the given parent that ensures that the tree view scrolls separately from the surrounding context. If a name is provided, it sets the name of the tree view to that and the name of the frame to that plus "-frame".

func (*TreeView) AddChildNode

func (tv *TreeView) 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 (*TreeView) AddSyncNodes

func (tv *TreeView) AddSyncNodes(rel, myidx int, typ *gti.Type, n int)

func (*TreeView) AddTreeNodes

func (tv *TreeView) AddTreeNodes(rel, myidx int, typ *gti.Type, n int)

func (*TreeView) ApplyStyle

func (tv *TreeView) ApplyStyle()

func (*TreeView) AsTreeView

func (tv *TreeView) AsTreeView() *TreeView

AsTreeView satisfies the [TreeViewEmbedder] interface

func (*TreeView) BaseType

func (tv *TreeView) BaseType() *gti.Type

func (*TreeView) BranchPart

func (tv *TreeView) BranchPart() (*gi.Switch, bool)

BranchPart returns the branch in parts, if it exists

func (*TreeView) CanOpen

func (tv *TreeView) 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 (*TreeView) Close

func (tv *TreeView) Close()

Close closes the given node and updates the view accordingly (if it is not already closed). Calls OnClose in TreeViewer interface for extensible actions.

func (*TreeView) CloseAll

func (tv *TreeView) CloseAll()

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

func (*TreeView) Config added in v0.0.8

func (tv *TreeView) Config()

func (*TreeView) ContextMenu

func (tv *TreeView) ContextMenu(m *gi.Scene)

func (*TreeView) ContextMenuPos

func (tv *TreeView) ContextMenuPos(e events.Event) (pos image.Point)

func (*TreeView) ContextMenuReadOnly

func (tv *TreeView) ContextMenuReadOnly(m *gi.Scene)

func (*TreeView) Copy

func (tv *TreeView) Copy(reset bool)

Copy copies to goosi.Clipboard, optionally resetting the selection.

func (*TreeView) Cut

func (tv *TreeView) Cut()

Cut copies to goosi.Clipboard and deletes selected items.

func (*TreeView) CutSync

func (tv *TreeView) CutSync()

CutSync copies to goosi.Clipboard and deletes selected items.

func (*TreeView) DeleteNode

func (tv *TreeView) 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 (*TreeView) DragClearStates added in v0.0.6

func (tv *TreeView) DragClearStates()

DragClearStates clears the drag-drop related states for this widget

func (*TreeView) DragDrop

func (tv *TreeView) DragDrop(e events.Event)

DragDrop handles drag drop event

func (*TreeView) DragStart

func (tv *TreeView) DragStart(e events.Event)

DragStart starts a drag-n-drop on this node -- it includes any other selected nodes as well, each as additional records in mimedata.

func (*TreeView) DropDeleteSource

func (tv *TreeView) DropDeleteSource(e events.Event)

DropDeleteSource handles delete source event for DropMove case

func (*TreeView) DropDeleteSourceSync

func (tv *TreeView) DropDeleteSourceSync(de *events.DragDrop)

DropDeleteSourceSync handles delete source event for DropMove case, for Sync

func (*TreeView) DropExternal

func (tv *TreeView) DropExternal(md mimedata.Mimes, mod events.DropMods)

DropExternal is not handled by base case but could be in derived

func (*TreeView) DropFinalize

func (tv *TreeView) DropFinalize(de *events.DragDrop)

DropFinalize is called to finalize Drop actions on the Source node. Only relevant for DropMod == DropMove.

func (*TreeView) Duplicate

func (tv *TreeView) 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 (*TreeView) DuplicateSync

func (tv *TreeView) DuplicateSync()

func (*TreeView) EditNode

func (tv *TreeView) EditNode()

EditNode pulls up a StructViewDialog window on the node. If SyncNode is set, operates on Sync Tree.

func (*TreeView) FindSyncNode

func (tv *TreeView) FindSyncNode(kn ki.Ki) *TreeView

FindSyncNode finds TreeView node for given source node, or nil if not found

func (*TreeView) FlagType

func (tv *TreeView) FlagType() enums.BitFlagSetter

func (*TreeView) HandleEvents

func (tv *TreeView) HandleEvents()

func (*TreeView) HandleKeys

func (tv *TreeView) HandleKeys()

func (*TreeView) HandleMouse

func (tv *TreeView) HandleMouse()

func (*TreeView) HasSelection

func (tv *TreeView) HasSelection() bool

HasSelection returns true if there are currently selected items

func (*TreeView) IconPart

func (tv *TreeView) IconPart() (*gi.Icon, bool)

IconPart returns the icon in parts, if it exists

func (*TreeView) InsertAfter

func (tv *TreeView) 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 (*TreeView) InsertAt

func (tv *TreeView) InsertAt(rel int, actNm string)

InsertAt inserts a new node in the tree at given relative offset from this node, at the same (sibling) level, prompting for the type of node to insert If SyncNode is set, operates on Sync Tree.

func (*TreeView) InsertBefore

func (tv *TreeView) 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 (*TreeView) InspectNode

func (tv *TreeView) InspectNode()

InspectNode pulls up a new Inspector window on the node. If SyncNode is set, operates on Sync Tree.

func (*TreeView) IsClosed

func (tv *TreeView) IsClosed() bool

IsClosed returns whether this node itself closed?

func (*TreeView) IsRoot

func (tv *TreeView) IsRoot(op string) bool

IsRoot returns true if given node is the root of the tree.

func (*TreeView) KiType

func (t *TreeView) KiType() *gti.Type

KiType returns the *gti.Type of TreeView

func (*TreeView) Label

func (tv *TreeView) Label() string

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

func (*TreeView) LabelPart

func (tv *TreeView) LabelPart() (*gi.Label, bool)

LabelPart returns the label in parts, if it exists

func (*TreeView) MakePasteMenu

func (tv *TreeView) MakePasteMenu(m *gi.Scene, md mimedata.Mimes, fun func())

MakePasteMenu makes the menu of options for paste events optional function is typically the DropFinalize but could also be other actions to take after each optional action.

func (*TreeView) MimeData

func (tv *TreeView) MimeData(md *mimedata.Mimes)

MimeData adds mimedata for this node: a text/plain of the Path.

func (*TreeView) MimeDataSync

func (tv *TreeView) MimeDataSync(md *mimedata.Mimes)

MimeDataSync adds mimedata for this node: a text/plain of the Path, and an application/json of the sync node.

func (*TreeView) MoveDown

func (tv *TreeView) MoveDown(selMode events.SelectModes) *TreeView

MoveDown moves the selection down to next element in the tree, using given select mode (from keyboard modifiers). Returns newly selected node.

func (*TreeView) MoveDownAction

func (tv *TreeView) MoveDownAction(selMode events.SelectModes) *TreeView

MoveDownAction moves the selection down to next element in the tree, using given select mode (from keyboard modifiers). Sends select event for newly selected item.

func (*TreeView) MoveDownSibling

func (tv *TreeView) MoveDownSibling(selMode events.SelectModes) *TreeView

MoveDownSibling moves down only to siblings, not down into children, using given select mode (from keyboard modifiers)

func (*TreeView) MoveEndAction

func (tv *TreeView) MoveEndAction(selMode events.SelectModes) *TreeView

MoveEndAction moves the selection to the very last node in the tree, using given select mode (from keyboard modifiers) Sends select event for newly selected item.

func (*TreeView) MoveHomeAction

func (tv *TreeView) MoveHomeAction(selMode events.SelectModes) *TreeView

MoveHomeAction moves the selection up to top of the tree, using given select mode (from keyboard modifiers) and emits select event for newly selected item

func (*TreeView) MovePageDownAction

func (tv *TreeView) MovePageDownAction(selMode events.SelectModes) *TreeView

MovePageDownAction moves the selection up to previous TreeViewPageSteps elements in the tree, using given select mode (from keyboard modifiers). Sends select event for newly selected item.

func (*TreeView) MovePageUpAction

func (tv *TreeView) MovePageUpAction(selMode events.SelectModes) *TreeView

MovePageUpAction moves the selection up to previous TreeViewPageSteps elements in the tree, using given select mode (from keyboard modifiers). Sends select event for newly selected item.

func (*TreeView) MoveToLastChild

func (tv *TreeView) MoveToLastChild(selMode events.SelectModes) *TreeView

MoveToLastChild moves to the last child under me, using given select mode (from keyboard modifiers)

func (*TreeView) MoveUp

func (tv *TreeView) MoveUp(selMode events.SelectModes) *TreeView

MoveUp moves selection up to previous element in the tree, using given select mode (from keyboard modifiers). Returns newly selected node

func (*TreeView) MoveUpAction

func (tv *TreeView) MoveUpAction(selMode events.SelectModes) *TreeView

MoveUpAction moves the selection up to previous element in the tree, using given select mode (from keyboard modifiers). Sends select event for newly selected item.

func (*TreeView) New

func (t *TreeView) New() ki.Ki

New returns a new *TreeView value

func (*TreeView) NodesFromMimeData

func (tv *TreeView) NodesFromMimeData(md mimedata.Mimes) (ki.Slice, []string)

NodesFromMimeData returns a slice of Ki nodes for the TreeView nodes and paths from mime data.

func (*TreeView) OnAdd

func (tv *TreeView) OnAdd()

func (*TreeView) OnClose

func (tv *TreeView) OnClose()

OnClose is called when a node is closed. The base version does nothing.

func (*TreeView) OnDoubleClick

func (tv *TreeView) OnDoubleClick(e events.Event)

func (*TreeView) OnInit

func (tv *TreeView) OnInit()

func (*TreeView) OnOpen

func (tv *TreeView) OnOpen()

OnOpen is called when a node is opened. The base version does nothing.

func (*TreeView) Open

func (tv *TreeView) Open()

Open opens the given node and updates the view accordingly (if it is not already opened) Calls OnOpen in TreeViewer interface for extensible actions.

func (*TreeView) OpenAll

func (tv *TreeView) OpenAll()

OpenAll opens the given node and all of its sub-nodes

func (*TreeView) OpenParents

func (tv *TreeView) OpenParents()

OpenParents opens all the parents of this node, so that it will be visible.

func (*TreeView) Paste

func (tv *TreeView) Paste()

Paste pastes clipboard at given node.

func (*TreeView) PasteAfter

func (tv *TreeView) PasteAfter(md mimedata.Mimes, mod events.DropMods)

PasteAfter inserts object(s) from mime data after this node. If another item with the same name already exists, it will append _Copy on the name of the inserted objects

func (*TreeView) PasteAssign

func (tv *TreeView) PasteAssign(md mimedata.Mimes)

PasteAssign assigns mime data (only the first one!) to this node

func (*TreeView) PasteAssignSync

func (tv *TreeView) PasteAssignSync(md mimedata.Mimes)

PasteAssignSync assigns mime data (only the first one!) to this node

func (*TreeView) PasteAt

func (tv *TreeView) PasteAt(md mimedata.Mimes, mod events.DropMods, rel int, actNm string)

PasteAt inserts object(s) from mime data at rel position to this node. If another item with the same name already exists, it will append _Copy on the name of the inserted objects

func (*TreeView) PasteAtSync

func (tv *TreeView) PasteAtSync(md mimedata.Mimes, mod events.DropMods, rel int, actNm string)

PasteAtSync inserts object(s) from mime data at rel position to this node. If another item with the same name already exists, it will append _Copy on the name of the inserted objects

func (*TreeView) PasteBefore

func (tv *TreeView) PasteBefore(md mimedata.Mimes, mod events.DropMods)

PasteBefore inserts object(s) from mime data before this node. If another item with the same name already exists, it will append _Copy on the name of the inserted objects

func (*TreeView) PasteChildren

func (tv *TreeView) PasteChildren(md mimedata.Mimes, mod events.DropMods)

PasteChildren inserts object(s) from mime data at end of children of this node

func (*TreeView) PasteChildrenSync

func (tv *TreeView) PasteChildrenSync(md mimedata.Mimes, mod events.DropMods)

PasteChildrenSync inserts object(s) from mime data at end of children of this node

func (*TreeView) PasteMenu

func (tv *TreeView) PasteMenu(md mimedata.Mimes)

PasteMenu performs a paste from the clipboard using given data, by popping up a menu to determine what specifically to do.

func (*TreeView) Position

func (tv *TreeView) Position()

func (*TreeView) ReSync

func (tv *TreeView) ReSync()

ReSync resynchronizes the view relative to the underlying nodes and forces a full rerender

func (*TreeView) Render

func (tv *TreeView) Render()

func (*TreeView) RenderNode

func (tv *TreeView) RenderNode()

func (*TreeView) RootIsReadOnly

func (tv *TreeView) RootIsReadOnly() bool

RootIsReadOnly returns the ReadOnly status of the root node, which is what controls the functional inactivity of the tree if individual nodes are ReadOnly that only affects display typically.

func (*TreeView) RootSetViewIdx

func (tv *TreeView) RootSetViewIdx() int

RootSetViewIdx sets the RootView and ViewIdx for all nodes. This must be called from the root node after construction or any modification to the tree. Returns the total number of leaves in the tree.

func (*TreeView) ScenePos

func (tv *TreeView) ScenePos()

func (*TreeView) Select

func (tv *TreeView) Select()

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

func (*TreeView) SelectAction

func (tv *TreeView) SelectAction(mode events.SelectModes) bool

SelectAction updates selection to include this node, using selectmode from mouse event (ExtendContinuous, ExtendOne), and Root sends selection event. Returns true if signal emitted.

func (*TreeView) SelectAll

func (tv *TreeView) SelectAll()

SelectAll all items in view

func (*TreeView) SelectMode

func (tv *TreeView) SelectMode() bool

SelectMode returns true if keyboard movements should automatically select nodes

func (*TreeView) SelectModeToggle

func (tv *TreeView) SelectModeToggle()

SelectModeToggle toggles the SelectMode

func (*TreeView) SelectUpdate

func (tv *TreeView) SelectUpdate(mode events.SelectModes) bool

SelectUpdate updates selection to include this node, using selectmode from mouse event (ExtendContinuous, ExtendOne). Returns true if this node selected

func (*TreeView) SelectedSyncNodes

func (tv *TreeView) SelectedSyncNodes() ki.Slice

SelectedSyncNodes returns a slice of the currently-selected sync source nodes in the entire tree view

func (*TreeView) SelectedViews

func (tv *TreeView) SelectedViews() []TreeViewer

SelectedViews returns a slice of the currently-selected TreeViews within the entire tree, using a list maintained by the root node

func (*TreeView) SendChangeEvent

func (tv *TreeView) SendChangeEvent(ctx events.Event)

SendChangeEvent sends the events.Change event on the RootView node, using context event if avail (else nil).

func (*TreeView) SendChangeEventReSync

func (tv *TreeView) SendChangeEventReSync(ctx events.Event)

SendChangeEventReSync sends the events.Change event on the RootView node, using context event if avail (else nil). If SyncNode != nil, also does a re-sync from root.

func (*TreeView) SendSelectEvent

func (tv *TreeView) SendSelectEvent(ctx events.Event)

SendSelectEvent sends the events.Select event on the RootView node, using context event if avail (else nil).

func (*TreeView) SetBranchState

func (tv *TreeView) SetBranchState()

func (*TreeView) SetClosed

func (tv *TreeView) SetClosed(closed bool)

SetClosed sets the closed flag for this node. Call Close() method to close a node and update view.

func (*TreeView) SetIcon

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

SetIcon sets the [TreeView.Icon]: optional icon, displayed to the the left of the text label

func (*TreeView) SetIconClosed added in v0.0.3

func (t *TreeView) SetIconClosed(v icons.Icon) *TreeView

SetIconClosed sets the [TreeView.IconClosed]: icon to use for a closed (collapsed) branch; defaults to icons.KeyboardArrowRight

func (*TreeView) SetIconLeaf added in v0.0.3

func (t *TreeView) SetIconLeaf(v icons.Icon) *TreeView

SetIconLeaf sets the [TreeView.IconLeaf]: icon to use for a terminal node branch that has no children; defaults to icons.Blank

func (*TreeView) SetIconOpen added in v0.0.3

func (t *TreeView) SetIconOpen(v icons.Icon) *TreeView

SetIconOpen sets the [TreeView.IconOpen]: icon to use for an open (expanded) branch; defaults to icons.KeyboardArrowDown

func (*TreeView) SetIndent

func (t *TreeView) SetIndent(v units.Value) *TreeView

SetIndent sets the [TreeView.Indent]: amount to indent children relative to this node

func (*TreeView) SetKidsVisibility

func (tv *TreeView) SetKidsVisibility(parentClosed bool)

func (*TreeView) SetOpenDepth

func (t *TreeView) SetOpenDepth(v int) *TreeView

SetOpenDepth sets the [TreeView.OpenDepth]: depth for nodes be initialized as open (default 4). Nodes beyond this depth will be initialized as closed.

func (*TreeView) SetRootView

func (t *TreeView) SetRootView(v *TreeView) *TreeView

SetRootView sets the [TreeView.RootView]: The cached root of the view. It is automatically set and does not need to be set by the end user.

func (*TreeView) SetSelectMode

func (tv *TreeView) SetSelectMode(selMode bool)

SetSelectMode updates the select mode

func (*TreeView) SetSelectedNodes

func (t *TreeView) SetSelectedNodes(v ...TreeViewer) *TreeView

SetSelectedNodes sets the [TreeView.SelectedNodes]: SelectedNodes holds the currently-selected nodes, on the RootView node only.

func (*TreeView) SetSelectedViews

func (tv *TreeView) SetSelectedViews(sl []TreeViewer)

SetSelectedViews updates the selected views to given list

func (*TreeView) SetStyles

func (tv *TreeView) SetStyles()

func (*TreeView) SetSyncNode

func (tv *TreeView) SetSyncNode(sk ki.Ki, tvIdx *int, init bool, depth int)

SetSyncNode sets the sync source node that we are viewing, and syncs the view of its tree. It is called routinely via SyncToSrc during tree updating. It uses ki Config mechanism to perform minimal updates to remain in sync.

func (*TreeView) SetText

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

SetText sets the [TreeView.Text]: The text to display for the tree view item label, which automatically defaults to the ki.Node.Name of the tree view node. It has no effect if [TreeView.SyncNode] is non-nil.

func (*TreeView) SetTooltip

func (t *TreeView) SetTooltip(v string) *TreeView

SetTooltip sets the [TreeView.Tooltip]

func (*TreeView) SetViewIdx

func (t *TreeView) SetViewIdx(v int) *TreeView

SetViewIdx sets the [TreeView.ViewIdx]: linear index of this node within the entire tree. updated on full rebuilds and may sometimes be off, but close enough for expected uses

func (*TreeView) SetWidgetSize

func (t *TreeView) SetWidgetSize(v mat32.Vec2) *TreeView

SetWidgetSize sets the [TreeView.WidgetSize]: size of just this node widget. our alloc includes all of our children, but we only draw us.

func (*TreeView) SizeDown

func (tv *TreeView) SizeDown(iter int) bool

func (*TreeView) SizeUp

func (tv *TreeView) SizeUp()

func (*TreeView) SyncNodesFromMimeData

func (tv *TreeView) SyncNodesFromMimeData(md mimedata.Mimes) (ki.Slice, []string)

SyncNodesFromMimeData creates a slice of Ki node(s) from given mime data and also a corresponding slice of original paths.

func (*TreeView) SyncRootNode

func (tv *TreeView) SyncRootNode(sk ki.Ki) *TreeView

SyncRootNode sets the root view to the root of the sync source node for this TreeView, and syncs the rest of the tree to match. Calls ki.UniquifyNamesAll on source tree to ensure that node names are unique which is essential for proper viewing!

func (*TreeView) SyncToSrc

func (tv *TreeView) SyncToSrc(tvIdx *int, init bool, depth int)

SyncToSrc updates the view tree to match the sync tree, using ConfigChildren to maximally preserve existing tree elements. init means we are doing initial build, and depth tracks depth (only during init).

func (*TreeView) ToggleClose

func (tv *TreeView) ToggleClose()

ToggleClose toggles the close / open status: if closed, opens, and vice-versa

func (*TreeView) TreeViewChanged

func (tv *TreeView) TreeViewChanged(ctx events.Event)

TreeViewChanged must be called after any structural change to the TreeView (adding or deleting nodes). It calls: RootSetViewIdx() to update indexes and SendChangeEvent to notify of changes.

func (*TreeView) TreeViewParent

func (tv *TreeView) TreeViewParent() *TreeView

func (*TreeView) Unselect

func (tv *TreeView) Unselect()

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

func (*TreeView) UnselectAction

func (tv *TreeView) UnselectAction()

UnselectAction unselects this node (if selected), and Root sends a selection event.

func (*TreeView) UnselectAll

func (tv *TreeView) UnselectAll()

UnselectAll unselects all selected items in the view

func (*TreeView) UpdateBranchIcons

func (tv *TreeView) UpdateBranchIcons()

func (*TreeView) UpdateReadOnly

func (tv *TreeView) UpdateReadOnly() bool

UpdateReadOnly updates the ReadOnly state based on SyncNode. Returns true if ReadOnly. The inactivity of individual nodes only affects display properties typically, and not overall functional behavior, which is controlled by inactivity of the root node (i.e, make the root ReadOnly to make entire tree read-only and non-modifiable)

type TreeViewFlags

type TreeViewFlags gi.WidgetFlags //enums:bitflag -trim-prefix TreeViewFlag

TreeViewFlags extend WidgetFlags to hold TreeView state

const (
	// TreeViewFlagClosed means node is toggled closed
	// (children not visible)  Otherwise Open.
	TreeViewFlagClosed TreeViewFlags = TreeViewFlags(gi.WidgetFlagsN) + iota

	// TreeViewFlagSelectMode, when set on the Root node, determines whether keyboard movements
	// update selection or not.
	TreeViewFlagSelectMode

	// TreeViewInOpen is set in the Open method to prevent recursive opening for lazy-open nodes
	TreeViewInOpen
)
const TreeViewFlagsN TreeViewFlags = 5

TreeViewFlagsN is the highest valid value for type TreeViewFlags, plus one.

func TreeViewFlagsValues

func TreeViewFlagsValues() []TreeViewFlags

TreeViewFlagsValues returns all possible values for the type TreeViewFlags.

func (TreeViewFlags) BitIndexString

func (i TreeViewFlags) BitIndexString() string

BitIndexString returns the string representation of this TreeViewFlags value if it is a bit index value (typically an enum constant), and not an actual bit flag value.

func (TreeViewFlags) Desc

func (i TreeViewFlags) Desc() string

Desc returns the description of the TreeViewFlags value.

func (TreeViewFlags) HasFlag

func (i TreeViewFlags) HasFlag(f enums.BitFlag) bool

HasFlag returns whether these bit flags have the given bit flag set.

func (TreeViewFlags) Int64

func (i TreeViewFlags) Int64() int64

Int64 returns the TreeViewFlags value as an int64.

func (TreeViewFlags) MarshalText

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

MarshalText implements the encoding.TextMarshaler interface.

func (*TreeViewFlags) SetFlag

func (i *TreeViewFlags) SetFlag(on bool, f ...enums.BitFlag)

SetFlag sets the value of the given flags in these flags to the given value.

func (*TreeViewFlags) SetInt64

func (i *TreeViewFlags) SetInt64(in int64)

SetInt64 sets the TreeViewFlags value from an int64.

func (*TreeViewFlags) SetString

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

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

func (*TreeViewFlags) SetStringOr

func (i *TreeViewFlags) SetStringOr(s string) error

SetStringOr sets the TreeViewFlags value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.

func (TreeViewFlags) String

func (i TreeViewFlags) String() string

String returns the string representation of this TreeViewFlags value.

func (*TreeViewFlags) UnmarshalText

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

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (TreeViewFlags) Values

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

Values returns all possible values for the type TreeViewFlags.

type TreeViewer

type TreeViewer interface {
	gi.Widget

	// AsTreeView returns the base *TreeView for this node
	AsTreeView() *TreeView

	// CanOpen returns true if the node is able to open.
	// By default it checks HasChildren(), but could check other properties
	// to perform lazy building of the tree.
	CanOpen() bool

	// OnOpen is called when a node is opened.
	// The base version does nothing.
	OnOpen()

	// OnClose is called when a node is closed
	// The base version does nothing.
	OnClose()

	// OnDoubleClick is called when a node is double-clicked
	// The base version does ToggleClose
	OnDoubleClick(e events.Event)

	// UpdateBranchIcons is called during DoLayout to update branch icons
	// when everything should be configured, prior to rendering.
	UpdateBranchIcons()

	// Following are all tree editing functions:
	DeleteNode()
	Duplicate()
	AddChildNode()
	InsertBefore()
	InsertAfter()
	MimeData(md *mimedata.Mimes)
	Cut()
	Copy(reset bool)
	Paste()
	DragStart(e events.Event)
	DragDrop(e events.Event)
	DropFinalize(de *events.DragDrop)
	DropDeleteSource(e events.Event)
	MakePasteMenu(m *gi.Scene, md mimedata.Mimes, fun func())
}

TreeViewer is an interface for TreeView types providing access to the base TreeView and overridable method hooks for actions taken on the TreeView, including OnOpen, OnClose, etc.

type TypeValue

type TypeValue struct {
	ValueBase[*gi.Chooser]
}

TypeValue represents a gti.Type value with a chooser.

func (*TypeValue) Config added in v0.0.8

func (v *TypeValue) Config()

func (*TypeValue) Update added in v0.0.8

func (v *TypeValue) Update()

type Value

type Value interface {
	fmt.Stringer

	// AsValueData gives access to the basic data fields so that the
	// interface doesn't need to provide accessors for them.
	AsValueData() *ValueData

	// AsWidget returns the widget associated with the value.
	AsWidget() gi.Widget

	// AsWidgetBase returns the widget base associated with the value.
	AsWidgetBase() *gi.WidgetBase

	// WidgetType returns the type of widget associated with this value.
	WidgetType() *gti.Type

	// SetWidget sets the widget used to represent the value.
	// It is typically only used internally in [Config].
	SetWidget(w gi.Widget)

	// Config configures the widget to represent the value, including setting up
	// the OnChange event listener to set the value when the user edits it
	// (values are always set immediately when the widget is updated).
	// You should typically call the global [Config] function instead of this;
	// this is the method that values implement, which is called in the global
	// Config helper function.
	Config()

	// Update updates the widget representation to reflect the current value.
	Update()

	// Name returns the name of the value
	Name() string

	// SetName sets the name of the value
	SetName(name string)

	// Label returns the label for the value
	Label() string

	// SetLabel sets the label for the value
	SetLabel(label string) *ValueData

	// Doc returns the documentation for the value
	Doc() string

	// SetDoc sets the documentation for the value
	SetDoc(doc string) *ValueData

	// Is checks if flag is set, using atomic, safe for concurrent access
	Is(f enums.BitFlag) bool

	// SetFlag sets the given flag(s) to given state
	// using atomic, safe for concurrent access
	SetFlag(on bool, f ...enums.BitFlag)

	// SetStructValue sets the value, owner and field information for a struct field.
	SetStructValue(val reflect.Value, owner any, field *reflect.StructField, viewPath string)

	// SetMapKey sets the key value and owner for a map key.
	SetMapKey(val reflect.Value, owner any)

	// SetMapValue sets the value, owner and map key information for a map
	// element -- needs pointer to Value representation of key to track
	// current key value.
	SetMapValue(val reflect.Value, owner any, key any, keyView Value, viewPath string)

	// SetSliceValue sets the value, owner and index information for a slice element.
	SetSliceValue(val reflect.Value, owner any, idx int, viewPath string)

	// SetSoloValue sets the value for a singleton standalone value
	// (e.g., for arg values).
	SetSoloValue(val reflect.Value)

	// OwnerKind returns the reflect.Kind of the owner: Struct, Map, or Slice
	// (or Invalid for standalone values such as args).
	OwnerKind() reflect.Kind

	// IsReadOnly returns whether the value is ReadOnly, which prevents modification
	// of the underlying Value.  Can be flagged by container views, or
	// Map owners have ReadOnly values, and fields can be marked
	// as ReadOnly using a struct tag.
	IsReadOnly() bool

	// SetReadOnly marks this value as ReadOnly or not
	SetReadOnly(ro bool)

	// Val returns the reflect.Value representation for this item.
	Val() reflect.Value

	// SetValue assigns given value to this item (if not ReadOnly), using
	// Ki.SetField for Ki types and laser.SetRobust otherwise -- emits a ViewSig
	// signal when set.
	SetValue(val any) bool

	// SendChange sends events.Change event to all listeners registered on this view.
	// This is the primary notification event for all Value elements.
	// It takes an optional original event to base the event on.
	SendChange(orig ...events.Event)

	// OnChange registers given listener function for Change events on Value.
	// This is the primary notification event for all Value elements.
	OnChange(fun func(e events.Event))

	// SetTags sets tags for this valueview, for non-struct values, to
	// influence interface for this value -- see
	// https://cogentcore.org/core/wiki/Tags for valid options.  Adds to
	// existing tags if some are already set.
	SetTags(tags map[string]string)

	// SetTag sets given tag to given value for this valueview, for non-struct
	// values, to influence interface for this value -- see
	// https://cogentcore.org/core/wiki/Tags for valid options.
	SetTag(tag, value string)

	// Tag returns value for given tag -- looks first at tags set by
	// SetTag(s) methods, and then at field tags if this is a field in a
	// struct -- returns false if tag was not set.
	Tag(tag string) (string, bool)

	// AllTags returns all the tags for this value view, from structfield or set
	// specifically using SetTag* methods
	AllTags() map[string]string
}

A Value is a bridge between Go values like strings, integers, and structs and GUI widgets. It allows you to represent simple and complicated values of any kind with automatic, editable, and user-friendly widgets. The most common pathway for making [Value]s is NewValue.

func FieldToValue

func FieldToValue(str any, field string, val any) Value

FieldToValue converts the given value into its appropriate Value representation, using its type, tags, value, field name, and parent struct. It checks FieldValuer before falling back on ToValue, which you should use for values that are not struct fields.

func NewValue

func NewValue(par ki.Ki, val any, tags ...string) Value

NewValue makes and returns a new Value from the given value and creates the widget for it with the given parent and optional tags (only the first argument is used). It is the main way that end-user code should interact with [Value]s. The given value needs to be a pointer for it to be modified.

NewValue is not appropriate for internal code configuring non-solo values (for example, in StructView), but it should be fine for end-user code.

func ToValue

func ToValue(val any, tags string) Value

ToValue converts the given value into its appropriate Value representation, using its type, tags, and value. It checks the Valuer interface and the ValueMap before falling back on checks for standard primitive and compound types. If it can not find any good representation for the value, it falls back on StringValue. The tags are optional tags in reflect.StructTag format that can affect what Value is returned; see the Tags page in the Cogent Core Docs to learn more. You should use FieldToValue when making a value in the context of a broader struct owner.

type ValueBase

type ValueBase[W gi.Widget] struct {
	ValueData

	// Widget is the GUI widget used to display and edit the value in the GUI.
	Widget W
}

ValueBase is the base type that all Value objects extend. It contains both ValueData and a generically parameterized gi.Widget.

func (*ValueBase[W]) AsWidget

func (v *ValueBase[W]) AsWidget() gi.Widget

func (*ValueBase[W]) AsWidgetBase

func (v *ValueBase[W]) AsWidgetBase() *gi.WidgetBase

func (*ValueBase[W]) SetValue

func (v *ValueBase[W]) SetValue(val any) bool

func (*ValueBase[W]) SetValueMap

func (v *ValueBase[W]) SetValueMap(val any) (bool, error)

func (*ValueBase[W]) SetWidget added in v0.0.8

func (v *ValueBase[W]) SetWidget(w gi.Widget)

func (*ValueBase[W]) WidgetType

func (v *ValueBase[W]) WidgetType() *gti.Type

type ValueData added in v0.0.8

type ValueData struct {

	// Nm is locally-unique name of Value
	Nm string

	// SavedLabel is the label for the Value
	SavedLabel string

	// SavedDoc is the saved documentation for the Value, if any
	// (only valid if [ValueHasSaveDoc] is true)
	SavedDoc string

	// Flags are atomic bit flags for Value state
	Flags ValueFlags

	// the reflect.Value representation of the value
	Value reflect.Value `set:"-"`

	// kind of owner that we have -- reflect.Struct, .Map, .Slice are supported
	OwnKind reflect.Kind

	// a record of parent View names that have led up to this view -- displayed as extra contextual information in view dialog windows
	ViewPath string

	// the object that owns this value, either a struct, slice, or map, if non-nil -- if a Ki Node, then SetField is used to set value, to provide proper updating
	Owner any

	// if Owner is a struct, this is the reflect.StructField associated with the value
	Field *reflect.StructField

	// set of tags that can be set to customize interface for different types of values -- only source for non-structfield values
	Tags map[string]string `set:"-"`

	// if Owner is a map, and this is a value, this is the key for this value in the map
	Key any `set:"-" edit:"-"`

	// if Owner is a map, and this is a value, this is the value view representing the key -- its value has the *current* value of the key, which can be edited
	KeyView Value `set:"-" edit:"-"`

	// if Owner is a slice, this is the index for the value in the slice
	Idx int `set:"-" edit:"-"`

	// Listeners are event listener functions for processing events on this widget.
	// type specific Listeners are added in OnInit when the widget is initialized.
	Listeners events.Listeners `set:"-" view:"-"`
}

ValueData contains the base data common to all Value objects. Value objects should extend ValueBase, not ValueData.

func (*ValueData) AllTags added in v0.0.8

func (v *ValueData) AllTags() map[string]string

func (*ValueData) AsValueData added in v0.0.8

func (v *ValueData) AsValueData() *ValueData

func (*ValueData) Doc added in v0.0.8

func (v *ValueData) Doc() string

func (*ValueData) GetTitle added in v0.0.8

func (v *ValueData) GetTitle() (label, newPath string, isZero bool)

GetTitle returns a title for this item suitable for a window title etc, based on the underlying value type name, owner label, and ViewPath. newPath returns just what should be added to a ViewPath also includes zero value check reported in the isZero bool, which can be used for not proceeding in case of non-value-based types.

func (*ValueData) HandleEvent added in v0.0.8

func (v *ValueData) HandleEvent(ev events.Event)

HandleEvent sends the given event to all Listeners for that event type. It also checks if the State has changed and calls ApplyStyle if so. If more significant Config level changes are needed due to an event, the event handler must do this itself.

func (*ValueData) Is added in v0.0.8

func (v *ValueData) Is(f enums.BitFlag) bool

Is checks if flag is set, using atomic, safe for concurrent access

func (*ValueData) IsReadOnly added in v0.0.8

func (v *ValueData) IsReadOnly() bool

func (*ValueData) Label added in v0.0.8

func (v *ValueData) Label() string

func (*ValueData) Name added in v0.0.8

func (v *ValueData) Name() string

func (*ValueData) On added in v0.0.8

func (v *ValueData) On(etype events.Types, fun func(e events.Event))

On adds an event listener function for the given event type

func (*ValueData) OnChange added in v0.0.8

func (v *ValueData) OnChange(fun func(e events.Event))

OnChange registers given listener function for Change events on Value. This is the primary notification event for all Value elements.

func (*ValueData) OwnerKind added in v0.0.8

func (v *ValueData) OwnerKind() reflect.Kind

OwnerKind we have this one accessor b/c it is more useful for outside consumers vs. internal usage

func (*ValueData) OwnerLabel added in v0.0.8

func (v *ValueData) OwnerLabel() string

OwnerLabel returns some extra info about the owner of this value view which is useful to put in title of our object

func (*ValueData) Send added in v0.0.8

func (v *ValueData) Send(typ events.Types, orig ...events.Event)

Send sends an NEW event of given type to this widget, optionally starting from values in the given original event (recommended to include where possible). Do NOT send an existing event using this method if you want the Handled state to persist throughout the call chain; call HandleEvent directly for any existing events.

func (*ValueData) SendChange added in v0.0.8

func (v *ValueData) SendChange(orig ...events.Event)

SendChange sends events.Change event to all listeners registered on this view. This is the primary notification event for all Value elements. It takes an optional original event to base the event on.

func (*ValueData) SetDoc added in v0.0.8

func (v *ValueData) SetDoc(doc string) *ValueData

func (*ValueData) SetFlag added in v0.0.8

func (v *ValueData) SetFlag(on bool, f ...enums.BitFlag)

SetFlag sets the given flag(s) to given state using atomic, safe for concurrent access

func (*ValueData) SetLabel added in v0.0.8

func (v *ValueData) SetLabel(label string) *ValueData

func (*ValueData) SetMapKey added in v0.0.8

func (v *ValueData) SetMapKey(key reflect.Value, owner any)

func (*ValueData) SetMapValue added in v0.0.8

func (v *ValueData) SetMapValue(val reflect.Value, owner any, key any, keyView Value, viewPath string)

func (*ValueData) SetName added in v0.0.8

func (v *ValueData) SetName(name string)

func (*ValueData) SetReadOnly added in v0.0.8

func (v *ValueData) SetReadOnly(ro bool)

func (*ValueData) SetSliceValue added in v0.0.8

func (v *ValueData) SetSliceValue(val reflect.Value, owner any, idx int, viewPath string)

func (*ValueData) SetSoloValue added in v0.0.8

func (v *ValueData) SetSoloValue(val reflect.Value)

SetSoloValue sets the value for a singleton standalone value (e.g., for arg values).

func (*ValueData) SetStructValue added in v0.0.8

func (v *ValueData) SetStructValue(val reflect.Value, owner any, field *reflect.StructField, viewPath string)

func (*ValueData) SetTag added in v0.0.8

func (v *ValueData) SetTag(tag, value string)

func (*ValueData) SetTags added in v0.0.8

func (v *ValueData) SetTags(tags map[string]string)

func (*ValueData) String added in v0.0.8

func (v *ValueData) String() string

func (*ValueData) Tag added in v0.0.8

func (v *ValueData) Tag(tag string) (string, bool)

func (*ValueData) Val added in v0.0.8

func (v *ValueData) Val() reflect.Value

type ValueFlags

type ValueFlags int64 //enums:bitflag -trim-prefix Value

ValueFlags for Value bool state

const (
	// ValueReadOnly flagged after first configuration
	ValueReadOnly ValueFlags = iota

	// ValueMapKey for OwnKind = Map, this value represents the Key -- otherwise the Value
	ValueMapKey

	// ValueHasSavedLabel is whether the value has a saved version of its
	// label, which can be set either automatically or explicitly
	ValueHasSavedLabel

	// ValueHasSavedDoc is whether the value has a saved version of its
	// documentation, which can be set either automatically or explicitly
	ValueHasSavedDoc

	// ValueDialogNewWindow indicates that the dialog should be opened with
	// in a new window, instead of a typical FullWindow in same current window.
	// this is triggered by holding down any modifier key while clicking on a
	// button that opens the window.
	ValueDialogNewWindow
)
const ValueFlagsN ValueFlags = 5

ValueFlagsN is the highest valid value for type ValueFlags, plus one.

func ValueFlagsValues

func ValueFlagsValues() []ValueFlags

ValueFlagsValues returns all possible values for the type ValueFlags.

func (ValueFlags) BitIndexString

func (i ValueFlags) BitIndexString() string

BitIndexString returns the string representation of this ValueFlags value if it is a bit index value (typically an enum constant), and not an actual bit flag value.

func (ValueFlags) Desc

func (i ValueFlags) Desc() string

Desc returns the description of the ValueFlags value.

func (ValueFlags) HasFlag

func (i ValueFlags) HasFlag(f enums.BitFlag) bool

HasFlag returns whether these bit flags have the given bit flag set.

func (ValueFlags) Int64

func (i ValueFlags) Int64() int64

Int64 returns the ValueFlags value as an int64.

func (ValueFlags) MarshalText

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

MarshalText implements the encoding.TextMarshaler interface.

func (*ValueFlags) SetFlag

func (i *ValueFlags) SetFlag(on bool, f ...enums.BitFlag)

SetFlag sets the value of the given flags in these flags to the given value.

func (*ValueFlags) SetInt64

func (i *ValueFlags) SetInt64(in int64)

SetInt64 sets the ValueFlags value from an int64.

func (*ValueFlags) SetString

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

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

func (*ValueFlags) SetStringOr

func (i *ValueFlags) SetStringOr(s string) error

SetStringOr sets the ValueFlags value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.

func (ValueFlags) String

func (i ValueFlags) String() string

String returns the string representation of this ValueFlags value.

func (*ValueFlags) UnmarshalText

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

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (ValueFlags) Values

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

Values returns all possible values for the type ValueFlags.

type Valuer

type Valuer interface {
	Value() Value
}

Valuer is an interface that types can implement to specify the Value that should be used to represent them in the GUI. If the return value is nil, then the default Value for the value will be used. For example:

func (m *MyType) Value() giv.Value {
	return &MyValue{}
}

Jump to

Keyboard shortcuts

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