giv

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: BSD-3-Clause Imports: 48 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: "Title", Doc: "title / prompt to show above the editor fields"}, {Name: "Args", Doc: "the args that we are a view onto"}, {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"}}, 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"}, {Name: "TmpSave", Doc: "value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent"}, {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"}}, 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: "TmpSave", Doc: "value view that needs to have SaveTmp called on it whenever a change\nis made to one of the underlying values.\npass this down to any sub-views created from a parent"}, {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"}, {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 FontChooserSize = units.Pt(18)

show fonts in a bigger size so you can actually see the differences

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."}}, 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 KeyChordEditType = gti.AddType(&gti.Type{Name: "cogentcore.org/core/giv.KeyChordEdit", IDName: "key-chord-edit", Doc: "KeyChordEdit is a label widget that shows a key chord string, and, when in\nfocus (after being clicked) will update to whatever key chord is typed --\nused for representing and editing key chords.", Embeds: []gti.Field{{Name: "Label"}}, Fields: []gti.Field{{Name: "FocusActive", Doc: "true if the keyboard focus is active or not -- when we lose active focus we apply changes"}}, Instance: &KeyChordEdit{}})

KeyChordEditType is the gti.Type for KeyChordEdit

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: "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 fields"}, {Name: "TmpSave", Doc: "value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent"}, {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"}}, 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; generally only access internally"}, {Name: "TmpSave", Doc: "value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent"}, {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"}}, 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: "SelIdx", Doc: "index of currently selected item"}, {Name: "InitSelIdx", Doc: "index of row to select at start"}, {Name: "SelIdxs", 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: "SliceNPVal", Doc: "non-ptr reflect.Value of the slice"}, {Name: "SliceValView", 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: "DraggedIdxs", Doc: "list of currently-dragged indexes"}, {Name: "TmpSave", Doc: "value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent"}, {Name: "VisRows", Doc: "total number of rows visible in allocated display size"}, {Name: "StartIdx", 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: "TmpIdx", 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: "TmpSave", Doc: "value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent"}, {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"}}, 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: "StructValView", Doc: "Value for the struct itself, if this was created within value view framework -- otherwise nil"}, {Name: "AddButton", Doc: "if true add an edit action button at the end -- other users of this widget can then configure that -- it is called 'edit-action'"}, {Name: "FieldViews", Doc: "Value representations of the fields"}, {Name: "TmpSave", Doc: "value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent"}, {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: "StructValView", Doc: "Value for the struct itself, if this was created within value view framework -- otherwise 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: "TmpSave", Doc: "value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent"}, {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: "SelField", Doc: "current selection field -- initially select value in this field"}, {Name: "SortIdx", 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: "TmpSave", Doc: "value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent"}, {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: "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 tructure\nproviding full navigation and manipulation abilities.\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]ValueFunc

The ValueMap is used to connect type names with corresponding Value representations of those types -- this can be used when it is not possible to use the Valuer interface (e.g., interface methods can only be defined within the package that defines the type -- so we need this for all types in gi which don't know about giv). You must use laser.LongTypeName (full package name + "." . type name) for the type name, as that is how it will be looked up.

Functions

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 ConfigDialogWidget

func ConfigDialogWidget(vv Value, w gi.Widget, allowReadOnly bool)

ConfigDialogWidget configures the given widget 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 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 OpenValueDialog

func OpenValueDialog(vv Value, ctx gi.Widget, fun func(), title ...string)

OpenValueDialog is a helper for OpenDialog for cases that use [ConfigDialog] method to configure the dialog contents. If a title is specified, it is used as the title for the dialog instead of the default one.

func SetSoloValueIface

func SetSoloValueIface(vv *ValueBase, 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 StructTagVal

func StructTagVal(key, tags string) string

StructTagVal returns the value for given key in given struct tag string uses reflect.StructTag Lookup method -- just a wrapper for external use (e.g., in Python code)

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 ValueMapAdd

func ValueMapAdd(val any, fun ValueFunc)

ValueMapAdd adds a ValueFunc for the type of the given value.

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

	// title / prompt to show above the editor fields
	Title string

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

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

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

func (av *ArgView) ConfigArgsGrid()

ConfigArgsGrid configures the ArgsGrid for the current struct

func (*ArgView) ConfigWidget

func (av *ArgView) ConfigWidget()

ConfigWidget configures the view

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]: 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) SetTitle

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

SetTitle sets the [ArgView.Title]: title / prompt to show above the editor fields

func (*ArgView) SetTooltip

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

SetTooltip sets the [ArgView.Tooltip]

func (*ArgView) SetViewPath

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

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

func (*ArgView) TitleWidget

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

TitleWidget returns the title label widget

func (*ArgView) UpdateArgs

func (av *ArgView) UpdateArgs()

UpdateArgs updates each of the value-view widgets for the args

type BitFlagValue

type BitFlagValue struct {
	ValueBase
}

BitFlagValue presents chip gi.Switches for editing bitflags

func (*BitFlagValue) ConfigWidget

func (vv *BitFlagValue) ConfigWidget(w gi.Widget)

func (*BitFlagValue) EnumValue

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

func (*BitFlagValue) SetEnumValueFromInt

func (vv *BitFlagValue) SetEnumValueFromInt(ival int64) bool

func (*BitFlagValue) UpdateWidget

func (vv *BitFlagValue) UpdateWidget()

func (*BitFlagValue) WidgetType

func (vv *BitFlagValue) WidgetType() *gti.Type

type BoolValue

type BoolValue struct {
	ValueBase
}

BoolValue presents a checkbox for a boolean

func (*BoolValue) ConfigWidget

func (vv *BoolValue) ConfigWidget(w gi.Widget)

func (*BoolValue) UpdateWidget

func (vv *BoolValue) UpdateWidget()

func (*BoolValue) WidgetType

func (vv *BoolValue) WidgetType() *gti.Type

type ByteSliceValue

type ByteSliceValue struct {
	ValueBase
}

ByteSliceValue presents a textfield of the bytes

func (*ByteSliceValue) ConfigWidget

func (vv *ByteSliceValue) ConfigWidget(w gi.Widget)

func (*ByteSliceValue) UpdateWidget

func (vv *ByteSliceValue) UpdateWidget()

func (*ByteSliceValue) WidgetType

func (vv *ByteSliceValue) WidgetType() *gti.Type

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
}

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

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

func (*ColorMapValue) ConfigWidget

func (vv *ColorMapValue) ConfigWidget(w gi.Widget)

func (*ColorMapValue) HasDialog

func (vv *ColorMapValue) HasDialog() bool

func (*ColorMapValue) OpenDialog

func (vv *ColorMapValue) OpenDialog(ctx gi.Widget, fun func())

func (*ColorMapValue) UpdateWidget

func (vv *ColorMapValue) UpdateWidget()

func (*ColorMapValue) WidgetType

func (vv *ColorMapValue) WidgetType() *gti.Type

type ColorNameValue

type ColorNameValue struct {
	ValueBase
}

ColorNameValue presents an button for displaying a ColorNameName and selecting meshes from a ChooserDialog

func (*ColorNameValue) ConfigDialog

func (vv *ColorNameValue) ConfigDialog(d *gi.Body) (bool, func())

func (*ColorNameValue) ConfigWidget

func (vv *ColorNameValue) ConfigWidget(w gi.Widget)

func (*ColorNameValue) HasDialog

func (vv *ColorNameValue) HasDialog() bool

func (*ColorNameValue) OpenDialog

func (vv *ColorNameValue) OpenDialog(ctx gi.Widget, fun func())

func (*ColorNameValue) UpdateWidget

func (vv *ColorNameValue) UpdateWidget()

func (*ColorNameValue) WidgetType

func (vv *ColorNameValue) WidgetType() *gti.Type

type ColorValue

type ColorValue struct {
	ValueBase
	TmpColor color.RGBA
}

ColorValue presents a StructViewInline for a struct plus a ColorView button..

func (*ColorValue) Color

func (vv *ColorValue) Color() (*color.RGBA, bool)

Color returns a standardized color value from whatever value is represented internally

func (*ColorValue) ConfigDialog

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

func (*ColorValue) ConfigWidget

func (vv *ColorValue) ConfigWidget(w gi.Widget)

func (*ColorValue) HasDialog

func (vv *ColorValue) HasDialog() bool

func (*ColorValue) OpenDialog

func (vv *ColorValue) OpenDialog(ctx gi.Widget, fun func())

func (*ColorValue) SetColor

func (vv *ColorValue) SetColor(clr color.RGBA)

SetColor sets color value from a standard color value -- more robust than plain SetValue

func (*ColorValue) UpdateWidget

func (vv *ColorValue) UpdateWidget()

func (*ColorValue) WidgetType

func (vv *ColorValue) WidgetType() *gti.Type

type ColorView

type ColorView struct {
	gi.Frame

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

	// value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent
	TmpSave 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
}

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

func (cv *ColorView) ConfigWidget()

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

func (t *ColorView) SetTmpSave(v Value) *ColorView

SetTmpSave sets the [ColorView.TmpSave]: value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent

func (*ColorView) SetTooltip

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

SetTooltip sets the [ColorView.Tooltip]

func (*ColorView) SetViewPath

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

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

type DateView

type DateView struct {
	gi.Frame

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

	// value view that needs to have SaveTmp called on it whenever a change
	// is made to one of the underlying values.
	// pass this down to any sub-views created from a parent
	TmpSave 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

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

func (dv *DateView) ConfigDateGrid()

func (*DateView) ConfigWidget

func (dv *DateView) ConfigWidget()

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

func (t *DateView) SetTmpSave(v Value) *DateView

SetTmpSave sets the [DateView.TmpSave]: value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values. pass this down to any sub-views created from a parent

func (*DateView) SetTooltip

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

SetTooltip sets the [DateView.Tooltip]

func (*DateView) SetViewPath

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

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

type DurationValue

type DurationValue struct {
	ValueBase
}

DurationValue presents a spinner and unit chooser for a time.Duration

func (*DurationValue) ConfigWidget

func (vv *DurationValue) ConfigWidget(w gi.Widget)

func (*DurationValue) UpdateWidget

func (vv *DurationValue) UpdateWidget()

func (*DurationValue) WidgetType

func (vv *DurationValue) WidgetType() *gti.Type

type EnumValue

type EnumValue struct {
	ValueBase
}

EnumValue presents a chooser for choosing enums

func (*EnumValue) ConfigWidget

func (vv *EnumValue) ConfigWidget(w gi.Widget)

func (*EnumValue) EnumValue

func (vv *EnumValue) EnumValue() enums.Enum

func (*EnumValue) UpdateWidget

func (vv *EnumValue) UpdateWidget()

func (*EnumValue) WidgetType

func (vv *EnumValue) WidgetType() *gti.Type

type FieldValuer

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

FieldValuer interface supplies the appropriate type of Value for a given field name and current field value on the receiver parent struct -- called on a given receiver struct if defined for that receiver type (tries both pointer and non-pointer receivers) -- if a struct implements this interface, then it is used first for structs -- return nil to fall back on the default ToValue result

type FileValue

type FileValue struct {
	ValueBase
}

FileValue presents an action for displaying a Filename and selecting icons from FileChooserDialog

func (*FileValue) ConfigDialog

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

func (*FileValue) ConfigWidget

func (vv *FileValue) ConfigWidget(w gi.Widget)

func (*FileValue) HasDialog

func (vv *FileValue) HasDialog() bool

func (*FileValue) OpenDialog

func (vv *FileValue) OpenDialog(ctx gi.Widget, fun func())

func (*FileValue) UpdateWidget

func (vv *FileValue) UpdateWidget()

func (*FileValue) WidgetType

func (vv *FileValue) WidgetType() *gti.Type

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

func (fv *FileView) ConfigWidget()

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 FloatValue

type FloatValue struct {
	ValueBase
}

FloatValue presents a spinner

func (*FloatValue) ConfigWidget

func (vv *FloatValue) ConfigWidget(w gi.Widget)

func (*FloatValue) UpdateWidget

func (vv *FloatValue) UpdateWidget()

func (*FloatValue) WidgetType

func (vv *FloatValue) WidgetType() *gti.Type

type FontValue

type FontValue struct {
	ValueBase
}

FontValue presents an action for displaying a FontName and selecting fonts from FontChooserDialog

func (*FontValue) ConfigDialog

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

func (*FontValue) ConfigWidget

func (vv *FontValue) ConfigWidget(w gi.Widget)

func (*FontValue) HasDialog

func (vv *FontValue) HasDialog() bool

func (*FontValue) OpenDialog

func (vv *FontValue) OpenDialog(ctx gi.Widget, fun func())

func (*FontValue) UpdateWidget

func (vv *FontValue) UpdateWidget()

func (*FontValue) WidgetType

func (vv *FontValue) WidgetType() *gti.Type

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
}

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

FuncValue presents a FuncButton for viewing the information of and calling a function

func (*FuncValue) ConfigWidget

func (vv *FuncValue) ConfigWidget(w gi.Widget)

func (*FuncValue) UpdateWidget

func (vv *FuncValue) UpdateWidget()

func (*FuncValue) WidgetType

func (vv *FuncValue) WidgetType() *gti.Type

type IconValue

type IconValue struct {
	ValueBase
}

IconValue presents an action for displaying an IconName and selecting icons from IconChooserDialog

func (*IconValue) ConfigDialog

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

func (*IconValue) ConfigWidget

func (vv *IconValue) ConfigWidget(w gi.Widget)

func (*IconValue) HasDialog

func (vv *IconValue) HasDialog() bool

func (*IconValue) OpenDialog

func (vv *IconValue) OpenDialog(ctx gi.Widget, fun func())

func (*IconValue) UpdateWidget

func (vv *IconValue) UpdateWidget()

func (*IconValue) WidgetType

func (vv *IconValue) WidgetType() *gti.Type

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

func (is *Inspector) ConfigSplits()

ConfigSplits configures the Splits.

func (*Inspector) ConfigToolbar

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

func (*Inspector) ConfigWidget

func (is *Inspector) ConfigWidget()

ConfigWidget configures the widget

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 IntValue

type IntValue struct {
	ValueBase
}

IntValue presents a spinner

func (*IntValue) ConfigWidget

func (vv *IntValue) ConfigWidget(w gi.Widget)

func (*IntValue) UpdateWidget

func (vv *IntValue) UpdateWidget()

func (*IntValue) WidgetType

func (vv *IntValue) WidgetType() *gti.Type

type KeyChordEdit

type KeyChordEdit struct {
	gi.Label

	// true if the keyboard focus is active or not -- when we lose active focus we apply changes
	FocusActive bool `json:"-" xml:"-"`
}

KeyChordEdit is a label widget that shows a key chord string, and, when in focus (after being clicked) will update to whatever key chord is typed -- used for representing and editing key chords.

func NewKeyChordEdit

func NewKeyChordEdit(par ki.Ki, name ...string) *KeyChordEdit

NewKeyChordEdit adds a new KeyChordEdit with the given name to the given parent: KeyChordEdit is a label widget that shows a key chord string, and, when in focus (after being clicked) will update to whatever key chord is typed -- used for representing and editing key chords.

func (*KeyChordEdit) ContextMenu

func (kc *KeyChordEdit) ContextMenu(m *gi.Scene)

func (*KeyChordEdit) HandleEvents

func (kc *KeyChordEdit) HandleEvents()

func (*KeyChordEdit) HandleKeys

func (kc *KeyChordEdit) HandleKeys()

func (*KeyChordEdit) KiType

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

KiType returns the *gti.Type of KeyChordEdit

func (*KeyChordEdit) New

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

New returns a new *KeyChordEdit value

func (*KeyChordEdit) OnInit

func (kc *KeyChordEdit) OnInit()

func (*KeyChordEdit) SetFocusActive

func (t *KeyChordEdit) SetFocusActive(v bool) *KeyChordEdit

SetFocusActive sets the [KeyChordEdit.FocusActive]: true if the keyboard focus is active or not -- when we lose active focus we apply changes

func (*KeyChordEdit) SetStyles

func (kc *KeyChordEdit) SetStyles()

func (*KeyChordEdit) SetText

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

SetText sets the [KeyChordEdit.Text]

func (*KeyChordEdit) SetTooltip

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

SetTooltip sets the [KeyChordEdit.Tooltip]

func (*KeyChordEdit) SetType

func (t *KeyChordEdit) SetType(v gi.LabelTypes) *KeyChordEdit

SetType sets the [KeyChordEdit.Type]

type KeyChordValue

type KeyChordValue struct {
	ValueBase
}

KeyChordValue presents an KeyChordEdit for key.Chord

func (*KeyChordValue) ConfigWidget

func (vv *KeyChordValue) ConfigWidget(w gi.Widget)

func (*KeyChordValue) HasDialog

func (vv *KeyChordValue) HasDialog() bool

func (*KeyChordValue) UpdateWidget

func (vv *KeyChordValue) UpdateWidget()

func (*KeyChordValue) WidgetType

func (vv *KeyChordValue) WidgetType() *gti.Type

type KeyMapValue

type KeyMapValue struct {
	ValueBase
}

KeyMapValue presents an action for displaying a KeyMapName and selecting from chooser

func (*KeyMapValue) ConfigDialog

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

func (*KeyMapValue) ConfigWidget

func (vv *KeyMapValue) ConfigWidget(w gi.Widget)

func (*KeyMapValue) HasDialog

func (vv *KeyMapValue) HasDialog() bool

func (*KeyMapValue) OpenDialog

func (vv *KeyMapValue) OpenDialog(ctx gi.Widget, fun func())

func (*KeyMapValue) UpdateWidget

func (vv *KeyMapValue) UpdateWidget()

func (*KeyMapValue) WidgetType

func (vv *KeyMapValue) WidgetType() *gti.Type

type KiPtrValue

type KiPtrValue struct {
	ValueBase
}

KiPtrValue provides a chooser for pointers to Ki objects

func (*KiPtrValue) ConfigDialog

func (vv *KiPtrValue) ConfigDialog(d *gi.Body) (bool, func())

func (*KiPtrValue) ConfigWidget

func (vv *KiPtrValue) ConfigWidget(w gi.Widget)

func (*KiPtrValue) HasDialog

func (vv *KiPtrValue) HasDialog() bool

func (*KiPtrValue) KiStruct

func (vv *KiPtrValue) KiStruct() ki.Ki

get the Ki struct itself (or nil)

func (*KiPtrValue) OpenDialog

func (vv *KiPtrValue) OpenDialog(ctx gi.Widget, fun func())

func (*KiPtrValue) UpdateWidget

func (vv *KiPtrValue) UpdateWidget()

func (*KiPtrValue) WidgetType

func (vv *KiPtrValue) WidgetType() *gti.Type

type MapInlineValue

type MapInlineValue struct {
	ValueBase
}

MapInlineValue presents a MapViewInline for a map

func (*MapInlineValue) ConfigWidget

func (vv *MapInlineValue) ConfigWidget(w gi.Widget)

func (*MapInlineValue) UpdateWidget

func (vv *MapInlineValue) UpdateWidget()

func (*MapInlineValue) WidgetType

func (vv *MapInlineValue) WidgetType() *gti.Type

type MapValue

type MapValue struct {
	ValueBase
}

MapValue presents a button to edit maps

func (*MapValue) ConfigDialog

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

func (*MapValue) ConfigWidget

func (vv *MapValue) ConfigWidget(w gi.Widget)

func (*MapValue) HasDialog

func (vv *MapValue) HasDialog() bool

func (*MapValue) OpenDialog

func (vv *MapValue) OpenDialog(ctx gi.Widget, fun func())

func (*MapValue) UpdateWidget

func (vv *MapValue) UpdateWidget()

func (*MapValue) WidgetType

func (vv *MapValue) WidgetType() *gti.Type

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

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

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

	// value view that needs to have SaveTmp called on it whenever a change
	// is made to one of the underlying values.
	// Pass this down to any sub-views created from a parent
	TmpSave 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
}

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

func (mv *MapView) ConfigWidget()

ConfigWidget configures the 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) SetKeys

func (t *MapView) SetKeys(v ...Value) *MapView

SetKeys sets the [MapView.Keys]: Value representations of the map keys

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) SetNCols added in v0.0.5

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

SetNCols sets the [MapView.NCols]: the number of columns in the map; do not set externally; generally only access internally

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

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

SetTmpSave sets the [MapView.TmpSave]: value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent

func (*MapView) SetTooltip

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

SetTooltip sets the [MapView.Tooltip]

func (*MapView) SetValues

func (t *MapView) SetValues(v ...Value) *MapView

SetValues sets the [MapView.Values]: Value representations of the map values

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

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

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

	// value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent
	TmpSave Value `view:"-" 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
}

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

func (mv *MapViewInline) ConfigMap() bool

ConfigMap configures children for map view

func (*MapViewInline) ConfigWidget

func (mv *MapViewInline) ConfigWidget()

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

func (t *MapViewInline) SetKeys(v ...Value) *MapViewInline

SetKeys sets the [MapViewInline.Keys]: Value representations of the map keys

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

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

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

func (*MapViewInline) SetStackTop

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

SetStackTop sets the [MapViewInline.StackTop]

func (*MapViewInline) SetStyles

func (mv *MapViewInline) SetStyles()

func (*MapViewInline) SetTmpSave

func (t *MapViewInline) SetTmpSave(v Value) *MapViewInline

SetTmpSave sets the [MapViewInline.TmpSave]: value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent

func (*MapViewInline) SetTooltip

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

SetTooltip sets the [MapViewInline.Tooltip]

func (*MapViewInline) SetValues

func (t *MapViewInline) SetValues(v ...Value) *MapViewInline

SetValues sets the [MapViewInline.Values]: Value representations of the fields

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

func (mv *MapViewInline) UpdateValues()

type NilValue

type NilValue struct {
	ValueBase
}

NilValue presents a label saying 'nil' -- for any nil or otherwise unrepresentable items

func (*NilValue) ConfigWidget

func (vv *NilValue) ConfigWidget(w gi.Widget)

func (*NilValue) UpdateWidget

func (vv *NilValue) UpdateWidget()

func (*NilValue) WidgetType

func (vv *NilValue) WidgetType() *gti.Type

type OptionValue

type OptionValue struct {
	ValueBase
}

OptionValue presents an [option.Option]

func (*OptionValue) ConfigWidget

func (vv *OptionValue) ConfigWidget(w gi.Widget)

func (*OptionValue) UpdateWidget

func (vv *OptionValue) UpdateWidget()

func (*OptionValue) WidgetType

func (vv *OptionValue) WidgetType() *gti.Type

type RuneSliceValue

type RuneSliceValue struct {
	ValueBase
}

RuneSliceValue presents a textfield of the bytes

func (*RuneSliceValue) ConfigWidget

func (vv *RuneSliceValue) ConfigWidget(w gi.Widget)

func (*RuneSliceValue) UpdateWidget

func (vv *RuneSliceValue) UpdateWidget()

func (*RuneSliceValue) WidgetType

func (vv *RuneSliceValue) WidgetType() *gti.Type

type SliceInlineValue

type SliceInlineValue struct {
	ValueBase
}

SliceInlineValue presents a SliceViewInline for a map

func (*SliceInlineValue) ConfigWidget

func (vv *SliceInlineValue) ConfigWidget(w gi.Widget)

func (*SliceInlineValue) UpdateWidget

func (vv *SliceInlineValue) UpdateWidget()

func (*SliceInlineValue) WidgetType

func (vv *SliceInlineValue) WidgetType() *gti.Type

type SliceValue

type SliceValue struct {
	ValueBase
	IsArray    bool         // is an array, not a slice
	ElType     reflect.Type // type of element in the slice -- has pointer if slice has pointers
	ElIsStruct bool         // whether non-pointer element type is a struct or not
}

SliceValue presents a button to edit slices

func (*SliceValue) ConfigDialog

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

func (*SliceValue) ConfigWidget

func (vv *SliceValue) ConfigWidget(w gi.Widget)

func (*SliceValue) GetTypeInfo

func (vv *SliceValue) GetTypeInfo()

func (*SliceValue) HasDialog

func (vv *SliceValue) HasDialog() bool

func (*SliceValue) OpenDialog

func (vv *SliceValue) OpenDialog(ctx gi.Widget, fun func())

func (*SliceValue) UpdateWidget

func (vv *SliceValue) UpdateWidget()

func (*SliceValue) WidgetType

func (vv *SliceValue) WidgetType() *gti.Type

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

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

SetInitSelIdx sets the [SliceView.InitSelIdx]

func (*SliceView) SetMinRows

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

SetMinRows sets the [SliceView.MinRows]

func (*SliceView) SetSelIdx

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

SetSelIdx sets the [SliceView.SelIdx]

func (*SliceView) SetSelVal

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

SetSelVal sets the [SliceView.SelVal]

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

func (t *SliceView) SetTmpSave(v Value) *SliceView

SetTmpSave sets the [SliceView.TmpSave]

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
	SelIdx int `copier:"-" json:"-" xml:"-"`

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

	// list of currently-selected slice indexes
	SelIdxs 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
	SliceValView 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
	DraggedIdxs []int `set:"-" view:"-" copier:"-" json:"-" xml:"-"`

	// value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent
	TmpSave Value `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
	StartIdx 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
	TmpIdx 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) 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) ConfigWidget

func (sv *SliceViewBase) ConfigWidget()

ConfigWidget configures a standard setup of the overall Frame

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

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

SetInitSelIdx sets the [SliceViewBase.InitSelIdx]: 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) SetSelIdx

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

SetSelIdx sets the [SliceViewBase.SelIdx]: index of currently selected item

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

func (t *SliceViewBase) SetTmpSave(v Value) *SliceViewBase

SetTmpSave sets the [SliceViewBase.TmpSave]: value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent

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 = 16

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

func (i SliceViewFlags) IsValid() bool

IsValid returns whether the value is a valid option for type SliceViewFlags.

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)

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

	// whether the slice is actually an array -- no modifications
	IsArray bool

	// whether the slice has a fixed-len flag on it
	IsFixedLen bool

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

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

	// value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent
	TmpSave Value `view:"-" 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
}

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

func (sv *SliceViewInline) ConfigSlice() bool

ConfigSlice configures children for slice view

func (*SliceViewInline) ConfigWidget

func (sv *SliceViewInline) ConfigWidget()

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

func (t *SliceViewInline) SetIsArray(v bool) *SliceViewInline

SetIsArray sets the [SliceViewInline.IsArray]: whether the slice is actually an array -- no modifications

func (*SliceViewInline) SetIsFixedLen

func (t *SliceViewInline) SetIsFixedLen(v bool) *SliceViewInline

SetIsFixedLen sets the [SliceViewInline.IsFixedLen]: whether the slice has a fixed-len flag on it

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) SetSliceValue added in v0.0.4

func (t *SliceViewInline) SetSliceValue(v Value) *SliceViewInline

SetSliceValue sets the [SliceViewInline.SliceValue]: SliceValue is the Value for the slice itself if this was created within the Value framework. Otherwise, it is nil.

func (*SliceViewInline) SetStackTop

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

SetStackTop sets the [SliceViewInline.StackTop]

func (*SliceViewInline) SetStyles

func (sv *SliceViewInline) SetStyles()

func (*SliceViewInline) SetTmpSave

func (t *SliceViewInline) SetTmpSave(v Value) *SliceViewInline

SetTmpSave sets the [SliceViewInline.TmpSave]: value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent

func (*SliceViewInline) SetTooltip

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

SetTooltip sets the [SliceViewInline.Tooltip]

func (*SliceViewInline) SetValues

func (t *SliceViewInline) SetValues(v ...Value) *SliceViewInline

SetValues sets the [SliceViewInline.Values]: Value representations of the fields

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

SliderValue presents a slider

func (*SliderValue) ConfigWidget

func (vv *SliderValue) ConfigWidget(w gi.Widget)

func (*SliderValue) UpdateWidget

func (vv *SliderValue) UpdateWidget()

func (*SliderValue) WidgetType

func (vv *SliderValue) WidgetType() *gti.Type

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
}

StructInlineValue presents a StructViewInline for a struct

func (*StructInlineValue) ConfigWidget

func (vv *StructInlineValue) ConfigWidget(w gi.Widget)

func (*StructInlineValue) UpdateWidget

func (vv *StructInlineValue) UpdateWidget()

func (*StructInlineValue) WidgetType

func (vv *StructInlineValue) WidgetType() *gti.Type

type StructValue

type StructValue struct {
	ValueBase
}

StructValue presents a button to edit the struct

func (*StructValue) ConfigDialog

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

func (*StructValue) ConfigWidget

func (vv *StructValue) ConfigWidget(w gi.Widget)

func (*StructValue) HasDialog

func (vv *StructValue) HasDialog() bool

func (*StructValue) OpenDialog

func (vv *StructValue) OpenDialog(ctx gi.Widget, fun func())

func (*StructValue) UpdateWidget

func (vv *StructValue) UpdateWidget()

func (*StructValue) WidgetType

func (vv *StructValue) WidgetType() *gti.Type

type StructView

type StructView struct {
	gi.Frame

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

	// value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent
	TmpSave 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:"-"`

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

func (sv *StructView) ConfigStructGrid() bool

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

func (*StructView) ConfigWidget

func (sv *StructView) ConfigWidget()

ConfigWidget configures the view

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

func (t *StructView) SetTmpSave(v Value) *StructView

SetTmpSave sets the [StructView.TmpSave]: value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent

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
	StructValView Value

	// if true add an edit action button at the end -- other users of this widget can then configure that -- it is called 'edit-action'
	AddButton bool

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

	// value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent
	TmpSave Value `json:"-" xml:"-" view:"-"`

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

func (sv *StructViewInline) ConfigStruct() bool

ConfigStruct configures the children for the current struct

func (*StructViewInline) ConfigWidget

func (sv *StructViewInline) ConfigWidget()

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 action button at the end -- other users of this widget can then configure that -- it is called 'edit-action'

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

func (t *StructViewInline) SetStructValView(v Value) *StructViewInline

SetStructValView sets the [StructViewInline.StructValView]: Value for the struct itself, if this was created within value view framework -- otherwise nil

func (*StructViewInline) SetStyles

func (sv *StructViewInline) SetStyles()

func (*StructViewInline) SetTmpSave

func (t *StructViewInline) SetTmpSave(v Value) *StructViewInline

SetTmpSave sets the [StructViewInline.TmpSave]: value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent

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
	SelField string `copier:"-" view:"-" json:"-" xml:"-"`

	// current sort index
	SortIdx 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) 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) ConfigWidget

func (tv *TableView) ConfigWidget()

ConfigWidget configures the view

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

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

SetInitSelIdx sets the [TableView.InitSelIdx]

func (*TableView) SetMinRows

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

SetMinRows sets the [TableView.MinRows]

func (*TableView) SetSelField

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

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

func (*TableView) SetSelIdx

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

SetSelIdx sets the [TableView.SelIdx]

func (*TableView) SetSelVal

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

SetSelVal sets the [TableView.SelVal]

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

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

SetSortIdx sets the [TableView.SortIdx]: 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) SetTmpSave

func (t *TableView) SetTmpSave(v Value) *TableView

SetTmpSave sets the [TableView.TmpSave]

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
}

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

func (*TimeValue) ConfigWidget

func (vv *TimeValue) ConfigWidget(w gi.Widget)

func (*TimeValue) TimeVal

func (vv *TimeValue) TimeVal() *time.Time

TimeVal decodes Value into a *time.Time value -- also handles FileTime case

func (*TimeValue) UpdateWidget

func (vv *TimeValue) UpdateWidget()

func (*TimeValue) WidgetType

func (vv *TimeValue) WidgetType() *gti.Type

type TimeView

type TimeView struct {
	gi.Frame

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

	// value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent
	TmpSave 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

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

func (tv *TimeView) ConfigWidget()

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

func (t *TimeView) SetTmpSave(v Value) *TimeView

SetTmpSave sets the [TimeView.TmpSave]: value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent

func (*TimeView) SetTooltip

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

SetTooltip sets the [TimeView.Tooltip]

func (*TimeView) SetViewPath

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

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

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) ConfigWidget added in v0.0.4

func (tt *TreeTableView) ConfigWidget()

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 tructure providing full navigation and manipulation abilities.

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 tructure providing full navigation and manipulation abilities.

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

func (tv *TreeView) ConfigWidget()

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

func (tv *TreeView) StyleTreeView()

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 = 11

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

func (i TreeViewFlags) IsValid() bool

IsValid returns whether the value is a valid option for type TreeViewFlags.

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
}

TypeValue presents a chooser for choosing types

func (*TypeValue) ConfigWidget

func (vv *TypeValue) ConfigWidget(w gi.Widget)

func (*TypeValue) UpdateWidget

func (vv *TypeValue) UpdateWidget()

func (*TypeValue) WidgetType

func (vv *TypeValue) WidgetType() *gti.Type

type Value

type Value interface {
	fmt.Stringer

	// AsValueBase gives access to the basic data fields so that the
	// interface doesn't need to provide accessors for them.
	AsValueBase() *ValueBase

	// AsWidget returns the widget associated with the value
	AsWidget() gi.Widget

	// AsWidgetBase returns the widget base associated with the value
	AsWidgetBase() *gi.WidgetBase

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

	// Doc returns the documentation for the value
	Doc() string

	// SetDoc sets the documentation for the value
	SetDoc(doc string)

	// 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, tmpSave Value, viewPath string)

	// SetMapKey sets the key value and owner for a map key.
	SetMapKey(val reflect.Value, owner any, tmpSave Value)

	// 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, tmpSave Value, viewPath string)

	// SetSliceValue sets the value, owner and index information for a slice element.
	SetSliceValue(val reflect.Value, owner any, idx int, tmpSave Value, 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)

	// WidgetType returns an appropriate type of widget to represent the
	// current value.
	WidgetType() *gti.Type

	// UpdateWidget updates the widget representation to reflect the current
	// value.  Must first check for a nil widget -- can be called in a
	// no-widget context (e.g., for single-argument values with actions).
	UpdateWidget()

	// ConfigWidget configures a widget of WidgetType for representing 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).  Note: use OnFinal(events.Change, ...) to ensure that
	// any other change modifiers have had a chance to intervene first.
	ConfigWidget(w gi.Widget)

	// HasDialog returns true if this value has an associated Dialog,
	// e.g., for Filename, StructView, SliceView, etc.
	// The OpenDialog method will open the dialog.
	HasDialog() bool

	// OpenDialog opens the dialog for this Value, if [HasDialog] is true.
	// 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())

	// ConfigDialog adds content to given dialog body for this value,
	// for Values with [HasDialog] == true, that use full dialog scenes.
	// The bool return is false if the value does not use this method
	// (e.g., for simple menu choosers).
	// The [OpenValueDialog] function is used to construct and run the dialog.
	// 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())

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

	// SaveTmp saves a temporary copy of a struct to a map -- map values must
	// be explicitly re-saved and cannot be directly written to by the value
	// elements -- each Value has a pointer to any parent Value that
	// might need to be saved after SetValue -- SaveTmp called automatically
	// in SetValue but other cases that use something different need to call
	// it explicitly.
	SaveTmp()
}

Value is an interface for managing the GUI representation of values (e.g., fields, map values, slice values) in Views (StructView, MapView, etc). It is a GUI version of the reflect.Value, and uses that for representing the underlying Value being represented graphically. The different types of Value are for different Kinds of values (bool, float, etc) -- which can have different Kinds of owners. The ValueBase class supports all the basic fields for managing the owner kinds.

func FieldToValue

func FieldToValue(it any, field string, fval any) Value

FieldToValue returns the appropriate Value for given field on a struct -- attempts to get the FieldValuer interface, and falls back on ToValue otherwise, using field value (fval) gopy:interface=handle

func NewSoloValue

func NewSoloValue(val any) Value

NewSoloValue makes and returns a new Value from the given value. It does not configure the widget, so most end-user code should call NewValue instead. It is intended for use in internal code that needs standalone solo values (for example, for a custom TmpSave).

func NewValue

func NewValue(par ki.Ki, val any, name ...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 name. It is the main way that end-user code should interact with giv. The given value needs to be a pointer for it to be settable.

NewValue is not appropriate for internal code configuring non-solo values (for example, in StructView), but it should be fine for most end-user code.

func ToValue

func ToValue(it any, tags string) Value

ToValue returns the appropriate Value for given item, based only on its type -- attempts to get the Valuer interface and failing that, falls back on default Kind-based options. tags are optional tags, e.g., from the field in a struct, that control the view properties -- see the gi wiki for details on supported tags -- these are NOT set for the view element, only used for options that affect what kind of view to create. See FieldToValue for version that takes into account the properties of the owner.

type ValueBase

type ValueBase 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:"-"`

	// type of widget to create -- cached during WidgetType method -- chosen based on the Value type and reflect.Value type -- see Valuer interface
	WidgetTyp *gti.Type `set:"-" edit:"-"`

	// the widget used to display and edit the value in the interface -- this is created for us externally and we cache it during ConfigWidget
	Widget gi.Widget `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:"-"`

	// value view that needs to have SaveTmp called on it whenever a change is made to one of the underlying values -- pass this down to any sub-views created from a parent
	TmpSave Value `set:"-" view:"-"`
}

ValueBase provides the basis for implementations of the Value interface, representing values in the interface -- it implements a generic TextField representation of the string value, and provides the generic fallback for everything that doesn't provide a specific Valuer type.

func (*ValueBase) AllTags

func (vv *ValueBase) AllTags() map[string]string

func (*ValueBase) AsValueBase

func (vv *ValueBase) AsValueBase() *ValueBase

func (*ValueBase) AsWidget

func (vv *ValueBase) AsWidget() gi.Widget

func (*ValueBase) AsWidgetBase

func (vv *ValueBase) AsWidgetBase() *gi.WidgetBase

func (*ValueBase) ConfigDialog

func (vv *ValueBase) ConfigDialog(d *gi.Body) (bool, func())

func (*ValueBase) ConfigWidget

func (vv *ValueBase) ConfigWidget(w gi.Widget)

func (*ValueBase) CreateTempIfNotPtr

func (vv *ValueBase) CreateTempIfNotPtr() bool

func (*ValueBase) Doc

func (vv *ValueBase) Doc() string

func (*ValueBase) GetTitle

func (vv *ValueBase) 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 (*ValueBase) HandleEvent

func (vv *ValueBase) 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 (*ValueBase) HasDialog

func (vv *ValueBase) HasDialog() bool

func (*ValueBase) Is

func (vv *ValueBase) Is(f enums.BitFlag) bool

Is checks if flag is set, using atomic, safe for concurrent access

func (*ValueBase) IsReadOnly

func (vv *ValueBase) IsReadOnly() bool

func (*ValueBase) Label

func (vv *ValueBase) Label() string

func (*ValueBase) Name

func (vv *ValueBase) Name() string

func (*ValueBase) On

func (vv *ValueBase) On(etype events.Types, fun func(e events.Event))

On adds an event listener function for the given event type

func (*ValueBase) OnChange

func (vv *ValueBase) 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 (*ValueBase) OpenDialog

func (vv *ValueBase) OpenDialog(ctx gi.Widget, fun func())

func (*ValueBase) OwnerKind

func (vv *ValueBase) OwnerKind() reflect.Kind

OwnerKind we have this one accessor b/c it is more useful for outside consumers vs. internal usage

func (*ValueBase) OwnerLabel

func (vv *ValueBase) 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 (*ValueBase) SaveTmp

func (vv *ValueBase) SaveTmp()

func (*ValueBase) Send

func (vv *ValueBase) 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 (*ValueBase) SendChange

func (vv *ValueBase) 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 (*ValueBase) SetDoc

func (vv *ValueBase) SetDoc(doc string)

func (*ValueBase) SetFlag

func (vv *ValueBase) SetFlag(on bool, f ...enums.BitFlag)

SetFlag sets the given flag(s) to given state using atomic, safe for concurrent access

func (*ValueBase) SetLabel

func (vv *ValueBase) SetLabel(label string)

func (*ValueBase) SetMapKey

func (vv *ValueBase) SetMapKey(key reflect.Value, owner any, tmpSave Value)

func (*ValueBase) SetMapValue

func (vv *ValueBase) SetMapValue(val reflect.Value, owner any, key any, keyView Value, tmpSave Value, viewPath string)

func (*ValueBase) SetName

func (vv *ValueBase) SetName(name string)

func (*ValueBase) SetReadOnly

func (vv *ValueBase) SetReadOnly(ro bool)

func (*ValueBase) SetSliceValue

func (vv *ValueBase) SetSliceValue(val reflect.Value, owner any, idx int, tmpSave Value, viewPath string)

func (*ValueBase) SetSoloValue

func (vv *ValueBase) SetSoloValue(val reflect.Value)

SetSoloValue sets the value for a singleton standalone value (e.g., for arg values).

func (*ValueBase) SetStructValue

func (vv *ValueBase) SetStructValue(val reflect.Value, owner any, field *reflect.StructField, tmpSave Value, viewPath string)

func (*ValueBase) SetTag

func (vv *ValueBase) SetTag(tag, value string)

func (*ValueBase) SetTags

func (vv *ValueBase) SetTags(tags map[string]string)

func (*ValueBase) SetValue

func (vv *ValueBase) SetValue(val any) bool

func (*ValueBase) SetValueMap

func (vv *ValueBase) SetValueMap(val any) (bool, error)

func (*ValueBase) StdConfigWidget

func (vv *ValueBase) StdConfigWidget(w gi.Widget)

StdConfigWidget does all of the standard widget configuration tag options

func (*ValueBase) String

func (vv *ValueBase) String() string

func (*ValueBase) Tag

func (vv *ValueBase) Tag(tag string) (string, bool)

func (*ValueBase) UpdateWidget

func (vv *ValueBase) UpdateWidget()

func (*ValueBase) Val

func (vv *ValueBase) Val() reflect.Value

func (*ValueBase) WidgetType

func (vv *ValueBase) WidgetType() *gti.Type

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

func (i ValueFlags) IsValid() bool

IsValid returns whether the value is a valid option for type ValueFlags.

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 ValueFunc

type ValueFunc func() Value

ValueFunc is a function that returns a new initialized Value of an appropriate type as registered in the ValueMap

type Valuer

type Valuer interface {
	Value() Value
}

Valuer interface supplies the appropriate type of Value -- called on a given receiver item if defined for that receiver type (tries both pointer and non-pointer receivers) -- can use this for custom types to provide alternative custom interfaces -- must call Init on Value before returning it

Jump to

Keyboard shortcuts

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