Documentation ¶
Overview ¶
Package core provides the core GUI functionality of Cogent Core.
Index ¶
- Constants
- Variables
- func ActivateExistingDialogWindow(data any) bool
- func ActivateExistingMainWindow(data any) bool
- func AddButtonItems(items *[]ChooserItem, parent tree.Node, path string)
- func AsWidget(n tree.Node) (Widget, *WidgetBase)
- func ChildByLabelCanFocus(ly *Layout, name string, after tree.Node) tree.Node
- func CompleteEditText(text string, cp int, completion string, seed string) (ed complete.Edit)
- func ConcealDots(n int) []rune
- func CurrentWindowAppBar(tb *Toolbar)
- func EndCPUMemProfile()
- func EndTargProfile()
- func ErrorDialog(ctx Widget, err error, title ...string)
- func ErrorSnackbar(ctx Widget, err error, label ...string)
- func GrabRenderFrom(w Widget) *image.RGBA
- func HandleRecover(r any)
- func IsWordBreak(r1, r2 rune) bool
- func LoadAllSettings() error
- func LoadSettings(se Settings) error
- func MenuSceneConfigStyles(msc *Scene)
- func MessageDialog(ctx Widget, msg string, title ...string)
- func MessageSnackbar(ctx Widget, msg string)
- func OpenRecentPaths()
- func OpenSettings(se Settings) error
- func ProfileToggle()
- func Quit()
- func RecycleDialog(data any) bool
- func ResetAllSettings() error
- func ResetSettings(se Settings) error
- func SaveAllSettings() error
- func SaveRecentPaths()
- func SaveSettings(se Settings) error
- func SetUnitContext(st *styles.Style, sc *Scene, el, parent math32.Vector2)
- func StandardAppBarConfig(parent Widget)
- func StandardAppBarStart(tb *Toolbar)
- func StandardOverflowMenu(tb *Toolbar)
- func StartCPUMemProfile()
- func StartTargProfile()
- func StringsInsertFirstUnique(strs *[]string, str string, max int)
- func TextWrapSizeEstimate(csz math32.Vector2, nChars int, fs *styles.Font) math32.Vector2
- func ToLabel(it any) string
- func ToLabeler(it any) (string, bool)
- func ToolbarStyles(ly Layouter)
- func UpdateAll()
- func Wait()
- type App
- type AppearanceSettingsData
- func (as *AppearanceSettingsData) Apply()
- func (as *AppearanceSettingsData) ApplyDPI()
- func (as *AppearanceSettingsData) DeleteSavedWindowGeoms()
- func (as *AppearanceSettingsData) SaveScreenZoom()
- func (as *AppearanceSettingsData) ShouldShow(field string) bool
- func (as *AppearanceSettingsData) ZebraStripesWeight() float32
- type BarFuncs
- type BasicBar
- type Blinker
- type Body
- func (bd *Body) AddAppBar(fun func(tb *Toolbar))
- func (bd *Body) AddBottomBar(fun func(parent Widget))
- func (bd *Body) AddCancel(parent Widget, name ...string) *Button
- func (bd *Body) AddLeftBar(fun func(parent Widget))
- func (bd *Body) AddOK(parent Widget, name ...string) *Button
- func (bd *Body) AddOKOnly() *Body
- func (bd *Body) AddRightBar(fun func(parent Widget))
- func (bd *Body) AddSnackbarButton(text string, onClick ...func(e events.Event)) *Body
- func (bd *Body) AddSnackbarIcon(icon icons.Icon, onClick ...func(e events.Event)) *Body
- func (bd *Body) AddSnackbarText(text string) *Body
- func (bd *Body) AddText(text string) *Body
- func (bd *Body) AddTitle(title string) *Body
- func (bd *Body) AddTopBar(fun func(parent Widget))
- func (b *Body) AssertRender(t imagex.TestingT, filename string, fun ...func())
- func (b *Body) AssertScreenRender(t imagex.TestingT, filename string, fun ...func())
- func (bd *Body) Close()
- func (bd *Body) DialogStyles()
- func (bd *Body) GetTopAppBar() *Toolbar
- func (t *Body) New() tree.Node
- func (bd *Body) NewDialog(ctx Widget) *Stage
- func (bd *Body) NewFullDialog(ctx Widget) *Stage
- func (bd *Body) NewSnackbar(ctx Widget) *Stage
- func (bd *Body) NewWindow() *Stage
- func (t *Body) NodeType() *types.Type
- func (bd *Body) OnInit()
- func (b *Body) RunAndShowNewWindow()
- func (bd *Body) RunMainWindow()
- func (bd *Body) SetData(data any) *Body
- func (bd *Body) SetStyles()
- func (bd *Body) SetTitle(title string) *Body
- func (t *Body) SetTooltip(v string) *Body
- func (bd *Body) SnackbarStyles()
- func (b *Body) WaitNoEvents()
- type Box
- type Button
- func (t *Button) AsButton() *Button
- func (bt *Button) Config()
- func (bt *Button) HandleClickDismissMenu()
- func (bt *Button) HandleEvents()
- func (bt *Button) HasMenu() bool
- func (bt *Button) IconWidget() *Icon
- func (bt *Button) Label() string
- func (bt *Button) LabelWidget() *Label
- func (t *Button) New() tree.Node
- func (t *Button) NodeType() *types.Type
- func (bt *Button) OnInit()
- func (bt *Button) OpenMenu(e events.Event) bool
- func (t *Button) SetIcon(v icons.Icon) *Button
- func (t *Button) SetIndicator(v icons.Icon) *Button
- func (bt *Button) SetKey(kf keymap.Functions) *Button
- func (t *Button) SetMenu(v func(m *Scene)) *Button
- func (t *Button) SetShortcut(v key.Chord) *Button
- func (bt *Button) SetStyles()
- func (bt *Button) SetText(v string) *Button
- func (t *Button) SetTooltip(v string) *Button
- func (t *Button) SetType(v ButtonTypes) *Button
- func (bt *Button) WidgetTooltip() string
- type ButtonEmbedder
- type ButtonTypes
- func (i ButtonTypes) Desc() string
- func (i ButtonTypes) Int64() int64
- func (i ButtonTypes) MarshalText() ([]byte, error)
- func (i *ButtonTypes) SetInt64(in int64)
- func (i *ButtonTypes) SetString(s string) error
- func (i ButtonTypes) String() string
- func (i *ButtonTypes) UnmarshalText(text []byte) error
- func (i ButtonTypes) Values() []enums.Enum
- type Canvas
- type Chooser
- func (ch *Chooser) AddItemsFunc(f func()) *Chooser
- func (ch *Chooser) CallItemsFuncs()
- func (ch *Chooser) CompleteEdit(data any, text string, cursorPos int, completion complete.Completion, ...) (ed complete.Edit)
- func (ch *Chooser) CompleteMatch(data any, text string, posLn, posCh int) (md complete.Matches)
- func (ch *Chooser) Config()
- func (ch *Chooser) FindItem(it any) int
- func (ch *Chooser) HandleChooserTextFieldEvents(tf *TextField)
- func (ch *Chooser) HandleEvents()
- func (ch *Chooser) LabelWidget() *Label
- func (ch *Chooser) MakeItemsMenu(m *Scene)
- func (t *Chooser) New() tree.Node
- func (t *Chooser) NodeType() *types.Type
- func (ch *Chooser) OnInit()
- func (ch *Chooser) OpenMenu(e events.Event) bool
- func (ch *Chooser) SelectItem(idx int) *Chooser
- func (ch *Chooser) SelectItemAction(idx int) *Chooser
- func (t *Chooser) SetAllowNew(v bool) *Chooser
- func (ch *Chooser) SetCurrentIndex(idx int) *Chooser
- func (ch *Chooser) SetCurrentText(text string) error
- func (ch *Chooser) SetCurrentValue(v any) *Chooser
- func (t *Chooser) SetDefaultNew(v bool) *Chooser
- func (t *Chooser) SetEditable(v bool) *Chooser
- func (ch *Chooser) SetEnum(enum enums.Enum) *Chooser
- func (ch *Chooser) SetEnums(es ...enums.Enum) *Chooser
- func (t *Chooser) SetIcon(v icons.Icon) *Chooser
- func (t *Chooser) SetIndicator(v icons.Icon) *Chooser
- func (t *Chooser) SetItems(v ...ChooserItem) *Chooser
- func (ch *Chooser) SetPlaceholder(text string) *Chooser
- func (ch *Chooser) SetStrings(ss ...string) *Chooser
- func (ch *Chooser) SetStyles()
- func (t *Chooser) SetTooltip(v string) *Chooser
- func (t *Chooser) SetType(v ChooserTypes) *Chooser
- func (ch *Chooser) SetTypes(ts ...*types.Type) *Chooser
- func (ch *Chooser) ShowCurrentItem() *Chooser
- func (ch *Chooser) TextField() *TextField
- type ChooserItem
- type ChooserTypes
- func (i ChooserTypes) Desc() string
- func (i ChooserTypes) Int64() int64
- func (i ChooserTypes) MarshalText() ([]byte, error)
- func (i *ChooserTypes) SetInt64(in int64)
- func (i *ChooserTypes) SetString(s string) error
- func (i ChooserTypes) String() string
- func (i *ChooserTypes) UnmarshalText(text []byte) error
- func (i ChooserTypes) Values() []enums.Enum
- type Complete
- func (c *Complete) Abort() bool
- func (c *Complete) Cancel() bool
- func (c *Complete) CancelAsync() bool
- func (c *Complete) Complete(s string)
- func (c *Complete) GetCompletion(s string) complete.Completion
- func (c *Complete) IsAboutToShow() bool
- func (c *Complete) Lookup(text string, posLn, posCh int, sc *Scene, pt image.Point)
- func (c *Complete) On(etype events.Types, fun func(e events.Event))
- func (c *Complete) OnSelect(fun func(e events.Event))
- func (t *Complete) SetCompletion(v string) *Complete
- func (t *Complete) SetCompletions(v complete.Completions) *Complete
- func (t *Complete) SetContext(v any) *Complete
- func (t *Complete) SetEditFunc(v complete.EditFunc) *Complete
- func (t *Complete) SetLookupFunc(v complete.LookupFunc) *Complete
- func (t *Complete) SetMatchFunc(v complete.MatchFunc) *Complete
- func (t *Complete) SetSeed(v string) *Complete
- func (t *Complete) SetSrcCh(v int) *Complete
- func (t *Complete) SetSrcLn(v int) *Complete
- func (t *Complete) SetStage(v *Stage) *Complete
- func (c *Complete) Show(ctx Widget, pos image.Point, text string)
- func (c *Complete) ShowNow(ctx Widget, pos image.Point, text string)
- func (c *Complete) ShowNowAsync(ctx Widget, pos image.Point, text string)
- func (c *Complete) ShowNowImpl(ctx Widget, pos image.Point, text string) bool
- type CompleteSignals
- func (i CompleteSignals) Desc() string
- func (i CompleteSignals) Int64() int64
- func (i CompleteSignals) MarshalText() ([]byte, error)
- func (i *CompleteSignals) SetInt64(in int64)
- func (i *CompleteSignals) SetString(s string) error
- func (i CompleteSignals) String() string
- func (i *CompleteSignals) UnmarshalText(text []byte) error
- func (i CompleteSignals) Values() []enums.Enum
- type Completer
- type DebugSettingsData
- type DeviceSettingsData
- type EditorSettings
- type EventMgr
- func (em *EventMgr) ActivateStartFocus() bool
- func (em *EventMgr) AddShortcut(chord key.Chord, bt *Button)
- func (em *EventMgr) CancelLongPress()
- func (em *EventMgr) CancelRepeatClick()
- func (em *EventMgr) ClearNonFocus(foc Widget)
- func (em *EventMgr) Clipboard() system.Clipboard
- func (em *EventMgr) DeleteShortcut(chord key.Chord, bt *Button)
- func (em *EventMgr) DragClearSprite()
- func (em *EventMgr) DragDrop(drag Widget, e events.Event)
- func (em *EventMgr) DragMenuAddModLabel(m *Scene, mod events.DropMods)
- func (em *EventMgr) DragMove(e events.Event)
- func (em *EventMgr) DragStart(w Widget, data any, e events.Event)
- func (em *EventMgr) DragStartCheck(e events.Event, dur time.Duration, dist int) bool
- func (em *EventMgr) DropFinalize(de *events.DragDrop)
- func (em *EventMgr) FocusClear() bool
- func (em *EventMgr) FocusFirst() bool
- func (em *EventMgr) FocusLast() bool
- func (em *EventMgr) FocusLastFrom(from Widget) bool
- func (em *EventMgr) FocusNext() bool
- func (em *EventMgr) FocusNextFrom(from Widget) bool
- func (em *EventMgr) FocusOnOrNext(foc Widget) bool
- func (em *EventMgr) FocusOnOrPrev(foc Widget) bool
- func (em *EventMgr) FocusPrev() bool
- func (em *EventMgr) FocusPrevFrom(from Widget) bool
- func (em *EventMgr) GetMouseInBBox(w Widget, pos image.Point)
- func (em *EventMgr) GetShortcuts()
- func (em *EventMgr) GetShortcutsIn(parent Widget)
- func (em *EventMgr) HandleEvent(e events.Event)
- func (em *EventMgr) HandleFocusEvent(e events.Event)
- func (em *EventMgr) HandleLong(e events.Event, deep Widget, w *Widget, pos *image.Point, t **time.Timer, ...)
- func (em *EventMgr) HandleLongHover(e events.Event)
- func (em *EventMgr) HandleLongPress(e events.Event)
- func (em *EventMgr) HandleOtherEvent(e events.Event)
- func (em *EventMgr) HandlePosEvent(e events.Event)
- func (em *EventMgr) MainStageMgr() *StageMgr
- func (em *EventMgr) ManagerKeyChordEvents(e events.Event)
- func (em *EventMgr) RenderWin() *RenderWindow
- func (em *EventMgr) ResetOnMouseDown()
- func (em *EventMgr) SetCursor(cur cursors.Cursor)
- func (em *EventMgr) SetFocus(w Widget) bool
- func (em *EventMgr) SetFocusEvent(w Widget) bool
- func (em *EventMgr) SetFocusImpl(w Widget, sendEvent bool) bool
- func (em *EventMgr) SetStartFocus(k Widget)
- func (em *EventMgr) StartRepeatClickTimer()
- func (em *EventMgr) TopLongHover() Widget
- func (em *EventMgr) TriggerShortcut(chord key.Chord) bool
- func (em *EventMgr) UpdateHovers(hov, prev []Widget, e events.Event, enter, leave events.Types) []Widget
- type FavPathItem
- type FavPaths
- type FieldValidator
- type FilePaths
- type Filename
- type FontName
- type Frame
- type GeomCT
- type GeomSize
- type GeomState
- type Handle
- func (hl *Handle) HandleEvents()
- func (t *Handle) New() tree.Node
- func (t *Handle) NodeType() *types.Type
- func (hl *Handle) OnInit()
- func (t *Handle) SetMax(v float32) *Handle
- func (t *Handle) SetMin(v float32) *Handle
- func (t *Handle) SetPos(v float32) *Handle
- func (hl *Handle) SetStyles()
- func (t *Handle) SetTooltip(v string) *Handle
- func (hl *Handle) Value() float32
- type HiStyleName
- type Icon
- func (t *Icon) New() tree.Node
- func (t *Icon) NodeType() *types.Type
- func (ic *Icon) OnInit()
- func (ic *Icon) Render()
- func (ic *Icon) RenderSVG()
- func (ic *Icon) SetIcon(icon icons.Icon) *Icon
- func (ic *Icon) SetIconTry(icon icons.Icon) (bool, error)
- func (ic *Icon) SetStyles()
- func (t *Icon) SetTooltip(v string) *Icon
- type Image
- func (t *Image) New() tree.Node
- func (t *Image) NodeType() *types.Type
- func (im *Image) OnInit()
- func (im *Image) Open(filename Filename) error
- func (im *Image) OpenFS(fsys fs.FS, filename string) error
- func (im *Image) Render()
- func (im *Image) SetImage(img image.Image) *Image
- func (t *Image) SetTooltip(v string) *Image
- type Label
- func (t *Label) AsLabel() *Label
- func (lb *Label) Config()
- func (lb *Label) ConfigLabelAlloc(sz math32.Vector2) math32.Vector2
- func (lb *Label) ConfigLabelSize(sz math32.Vector2)
- func (lb *Label) Copy(reset bool)
- func (lb *Label) HandleEvents()
- func (lb *Label) HandleLabelClick(openLink func(tl *paint.TextLink))
- func (lb *Label) Label() string
- func (t *Label) New() tree.Node
- func (t *Label) NodeType() *types.Type
- func (lb *Label) OnInit()
- func (lb *Label) Render()
- func (lb *Label) SetStyles()
- func (t *Label) SetText(v string) *Label
- func (t *Label) SetTooltip(v string) *Label
- func (t *Label) SetType(v LabelTypes) *Label
- func (lb *Label) SizeDown(iter int) bool
- func (lb *Label) SizeUp()
- type LabelEmbedder
- type LabelTypes
- func (i LabelTypes) Desc() string
- func (i LabelTypes) Int64() int64
- func (i LabelTypes) MarshalText() ([]byte, error)
- func (i *LabelTypes) SetInt64(in int64)
- func (i *LabelTypes) SetString(s string) error
- func (i LabelTypes) String() string
- func (i *LabelTypes) UnmarshalText(text []byte) error
- func (i LabelTypes) Values() []enums.Enum
- type Labeler
- type LayCell
- type LayCells
- type LayImplState
- func (ls *LayImplState) Cell(d math32.Dims, dIndex, odIndex int) *LayCell
- func (ls *LayImplState) CellsSize() math32.Vector2
- func (ls *LayImplState) ColWidth(row, col int) (float32, error)
- func (ls *LayImplState) InitCells()
- func (ls *LayImplState) RowHeight(row, col int) (float32, error)
- func (ls *LayImplState) ShapeCheck(w Widget, phase string) bool
- func (ls *LayImplState) String() string
- func (ls *LayImplState) WrapIndexToCoord(idx int) image.Point
- type Layout
- func (t *Layout) AsLayout() *Layout
- func (ly *Layout) AutoScroll(pos math32.Vector2) bool
- func (ly *Layout) AutoScrollDim(d math32.Dims, pos float32) bool
- func (ly *Layout) ChildWithFocus() (Widget, int)
- func (ly *Layout) Config()
- func (ly *Layout) ConfigScroll(d math32.Dims)
- func (ly *Layout) ConfigScrolls()
- func (ly *Layout) DeleteScroll(d math32.Dims)
- func (ly *Layout) Destroy()
- func (ly *Layout) FlagType() enums.BitFlagSetter
- func (ly *Layout) FocusNextChild(updn bool) bool
- func (ly *Layout) FocusOnName(e events.Event) bool
- func (ly *Layout) FocusPrevChild(updn bool) bool
- func (ly *Layout) HandleEvents()
- func (ly *Layout) HandleKeys()
- func (ly *Layout) HasAnyScroll() bool
- func (ly *Layout) LaySetContentFitOverflow(nsz math32.Vector2, pass LayoutPasses)
- func (ly *Layout) LaySetGapSizeFromCells()
- func (ly *Layout) LaySetInitCells()
- func (ly *Layout) LaySetInitCellsFlex()
- func (ly *Layout) LaySetInitCellsGrid()
- func (ly *Layout) LaySetInitCellsStacked()
- func (ly *Layout) LaySetInitCellsWrap()
- func (ly *Layout) LaySetWrapIndexes()
- func (ly *Layout) LayoutSpace()
- func (ly *Layout) ManageOverflow(iter int, updtSize bool) bool
- func (t *Layout) New() tree.Node
- func (t *Layout) NodeType() *types.Type
- func (ly *Layout) OnInit()
- func (ly *Layout) Position()
- func (ly *Layout) PositionCells()
- func (ly *Layout) PositionCellsMainX()
- func (ly *Layout) PositionCellsMainY()
- func (ly *Layout) PositionLay()
- func (ly *Layout) PositionScroll(d math32.Dims)
- func (ly *Layout) PositionScrolls()
- func (ly *Layout) PositionStacked()
- func (ly *Layout) PositionWrap()
- func (ly *Layout) Render()
- func (ly *Layout) RenderChildren()
- func (ly *Layout) RenderScrolls()
- func (ly *Layout) ScenePos()
- func (ly *Layout) ScenePosChildren()
- func (ly *Layout) ScenePosLay()
- func (ly *Layout) ScrollActionDelta(d math32.Dims, delta float32)
- func (ly *Layout) ScrollActionPos(d math32.Dims, pos float32)
- func (ly *Layout) ScrollChanged(d math32.Dims, sb *Slider)
- func (ly *Layout) ScrollDelta(e events.Event)
- func (ly *Layout) ScrollDimToCenter(d math32.Dims, posi int) bool
- func (ly *Layout) ScrollDimToContentEnd(d math32.Dims) bool
- func (ly *Layout) ScrollDimToEnd(d math32.Dims, posi int) bool
- func (ly *Layout) ScrollDimToStart(d math32.Dims, posi int) bool
- func (ly *Layout) ScrollGeom(d math32.Dims) (pos, sz math32.Vector2)
- func (ly *Layout) ScrollResetIfNone()
- func (ly *Layout) ScrollToBox(box image.Rectangle) bool
- func (ly *Layout) ScrollToBoxDim(d math32.Dims, tmini, tmaxi int) bool
- func (ly *Layout) ScrollToItem(wi Widget) bool
- func (ly *Layout) ScrollToPos(d math32.Dims, pos float32)
- func (ly *Layout) ScrollValues(d math32.Dims) (maxSize, visSize, visPct float32)
- func (ly *Layout) SetScrollParams(d math32.Dims, sb *Slider)
- func (ly *Layout) SetScrollsOff()
- func (ly *Layout) SetStyles()
- func (t *Layout) SetTooltip(v string) *Layout
- func (ly *Layout) SizeDown(iter int) bool
- func (ly *Layout) SizeDownAllocActual(iter int)
- func (ly *Layout) SizeDownAllocActualCells(iter int)
- func (ly *Layout) SizeDownAllocActualStacked(iter int)
- func (ly *Layout) SizeDownChildren(iter int) bool
- func (ly *Layout) SizeDownGrow(iter int, extra math32.Vector2) bool
- func (ly *Layout) SizeDownGrowCells(iter int, extra math32.Vector2) bool
- func (ly *Layout) SizeDownGrowStacked(iter int, extra math32.Vector2) bool
- func (ly *Layout) SizeDownLay(iter int) bool
- func (ly *Layout) SizeDownSetAllocs(iter int)
- func (ly *Layout) SizeDownWrap(iter int) bool
- func (ly *Layout) SizeFinal()
- func (ly *Layout) SizeFinalChildren()
- func (ly *Layout) SizeFinalLay()
- func (ly *Layout) SizeFinalUpdateChildrenSizes()
- func (ly *Layout) SizeFromChildren(iter int, pass LayoutPasses) math32.Vector2
- func (ly *Layout) SizeFromChildrenCells(iter int, pass LayoutPasses) math32.Vector2
- func (ly *Layout) SizeFromChildrenFit(iter int, pass LayoutPasses)
- func (ly *Layout) SizeFromChildrenStacked() math32.Vector2
- func (ly *Layout) SizeUp()
- func (ly *Layout) SizeUpChildren()
- func (ly *Layout) SizeUpLay()
- func (ly *Layout) StackTopWidget() (Widget, *WidgetBase)
- func (ly *Layout) UpdateStackedVisibility()
- type LayoutFlags
- func (i LayoutFlags) BitIndexString() string
- func (i LayoutFlags) Desc() string
- func (i LayoutFlags) HasFlag(f enums.BitFlag) bool
- func (i LayoutFlags) Int64() int64
- func (i LayoutFlags) MarshalText() ([]byte, error)
- func (i *LayoutFlags) SetFlag(on bool, f ...enums.BitFlag)
- func (i *LayoutFlags) SetInt64(in int64)
- func (i *LayoutFlags) SetString(s string) error
- func (i *LayoutFlags) SetStringOr(s string) error
- func (i LayoutFlags) String() string
- func (i *LayoutFlags) UnmarshalText(text []byte) error
- func (i LayoutFlags) Values() []enums.Enum
- type LayoutPasses
- func (i LayoutPasses) Desc() string
- func (i LayoutPasses) Int64() int64
- func (i LayoutPasses) MarshalText() ([]byte, error)
- func (i *LayoutPasses) SetInt64(in int64)
- func (i *LayoutPasses) SetString(s string) error
- func (i LayoutPasses) String() string
- func (i *LayoutPasses) UnmarshalText(text []byte) error
- func (i LayoutPasses) Values() []enums.Enum
- type Layouter
- type Meter
- func (m *Meter) ApplyStyle()
- func (t *Meter) New() tree.Node
- func (t *Meter) NodeType() *types.Type
- func (m *Meter) OnInit()
- func (m *Meter) Render()
- func (t *Meter) SetMax(v float32) *Meter
- func (t *Meter) SetMin(v float32) *Meter
- func (t *Meter) SetText(v string) *Meter
- func (t *Meter) SetTooltip(v string) *Meter
- func (t *Meter) SetType(v MeterTypes) *Meter
- func (t *Meter) SetValue(v float32) *Meter
- func (t *Meter) SetValueColor(v image.Image) *Meter
- func (t *Meter) SetWidth(v units.Value) *Meter
- func (m *Meter) WidgetTooltip() string
- type MeterTypes
- func (i MeterTypes) Desc() string
- func (i MeterTypes) Int64() int64
- func (i MeterTypes) MarshalText() ([]byte, error)
- func (i *MeterTypes) SetInt64(in int64)
- func (i *MeterTypes) SetString(s string) error
- func (i MeterTypes) String() string
- func (i *MeterTypes) UnmarshalText(text []byte) error
- func (i MeterTypes) Values() []enums.Enum
- type NewItemsData
- type RenderContext
- type RenderContextFlags
- func (i RenderContextFlags) BitIndexString() string
- func (i RenderContextFlags) Desc() string
- func (i RenderContextFlags) HasFlag(f enums.BitFlag) bool
- func (i RenderContextFlags) Int64() int64
- func (i RenderContextFlags) MarshalText() ([]byte, error)
- func (i *RenderContextFlags) SetFlag(on bool, f ...enums.BitFlag)
- func (i *RenderContextFlags) SetInt64(in int64)
- func (i *RenderContextFlags) SetString(s string) error
- func (i *RenderContextFlags) SetStringOr(s string) error
- func (i RenderContextFlags) String() string
- func (i *RenderContextFlags) UnmarshalText(text []byte) error
- func (i RenderContextFlags) Values() []enums.Enum
- type RenderParams
- type RenderScenes
- type RenderWindow
- func (w *RenderWindow) CloseReq()
- func (w *RenderWindow) Closed()
- func (w *RenderWindow) DrawScenes()
- func (w *RenderWindow) EventLoop()
- func (w *RenderWindow) FillInsets()
- func (w *RenderWindow) GatherScenes() bool
- func (w *RenderWindow) GoStartEventLoop()
- func (w *RenderWindow) HandleEvent(e events.Event)
- func (w *RenderWindow) HandleWindowEvents(e events.Event)
- func (w *RenderWindow) HasFlag(flag enums.BitFlag) bool
- func (w *RenderWindow) Is(flag enums.BitFlag) bool
- func (w *RenderWindow) IsClosed() bool
- func (w *RenderWindow) IsVisible() bool
- func (w *RenderWindow) LogicalDPI() float32
- func (w *RenderWindow) MainScene() *Scene
- func (w *RenderWindow) Minimize()
- func (w *RenderWindow) Raise()
- func (w *RenderWindow) RenderContext() *RenderContext
- func (w *RenderWindow) RenderWindow()
- func (w *RenderWindow) Resized()
- func (w *RenderWindow) SendCustomEvent(data any)
- func (w *RenderWindow) SendShowEvents()
- func (w *RenderWindow) SendWinFocusEvent(act events.WinActions)
- func (w *RenderWindow) SetCloseCleanFunc(fun func(win *RenderWindow))
- func (w *RenderWindow) SetCloseReqFunc(fun func(win *RenderWindow))
- func (w *RenderWindow) SetFlag(on bool, flag ...enums.BitFlag)
- func (w *RenderWindow) SetName(name string)
- func (w *RenderWindow) SetSize(sz image.Point)
- func (w *RenderWindow) SetStageTitle(title string)
- func (w *RenderWindow) SetTitle(title string)
- func (w *RenderWindow) SetWinSize(sz image.Point)
- func (w *RenderWindow) SetZoom(zoom float32)
- func (w *RenderWindow) StepZoom(steps float32)
- func (w *RenderWindow) StopEventLoop()
- type RenderWindowList
- func (wl *RenderWindowList) Add(w *RenderWindow)
- func (wl *RenderWindowList) Delete(w *RenderWindow)
- func (wl *RenderWindowList) FindData(data any) (*RenderWindow, bool)
- func (wl *RenderWindowList) FindName(name string) (*RenderWindow, bool)
- func (wl *RenderWindowList) FindRenderWin(osw system.Window) (*RenderWindow, bool)
- func (wl *RenderWindowList) FocusNext() (*RenderWindow, int)
- func (wl *RenderWindowList) Focused() (*RenderWindow, int)
- func (wl *RenderWindowList) Len() int
- func (wl *RenderWindowList) Win(idx int) *RenderWindow
- type SVG
- func (sv *SVG) HandleEvents()
- func (t *SVG) New() tree.Node
- func (t *SVG) NodeType() *types.Type
- func (sv *SVG) OnInit()
- func (sv *SVG) Open(filename Filename) error
- func (sv *SVG) OpenFS(fsys fs.FS, filename string) error
- func (sv *SVG) Read(r io.Reader) error
- func (sv *SVG) ReadBytes(b []byte) error
- func (sv *SVG) ReadString(s string) error
- func (sv *SVG) Render()
- func (sv *SVG) SavePNG(filename Filename) error
- func (sv *SVG) SaveSVG(filename Filename) error
- func (sv *SVG) SetStyles()
- func (t *SVG) SetTooltip(v string) *SVG
- func (sv *SVG) SizeFinal()
- type ScFlags
- func (i ScFlags) BitIndexString() string
- func (i ScFlags) Desc() string
- func (i ScFlags) HasFlag(f enums.BitFlag) bool
- func (i ScFlags) Int64() int64
- func (i ScFlags) MarshalText() ([]byte, error)
- func (i *ScFlags) SetFlag(on bool, f ...enums.BitFlag)
- func (i *ScFlags) SetInt64(in int64)
- func (i *ScFlags) SetString(s string) error
- func (i *ScFlags) SetStringOr(s string) error
- func (i ScFlags) String() string
- func (i *ScFlags) UnmarshalText(text []byte) error
- func (i ScFlags) Values() []enums.Enum
- type Scene
- func AsScene(k tree.Node) *Scene
- func NewBodyScene(body *Body, name ...string) *Scene
- func NewMenuFromStrings(strs []string, sel string, fun func(idx int)) *Scene
- func NewMenuScene(menu func(m *Scene), name ...string) *Scene
- func NewScene(name ...string) *Scene
- func NewTooltipScene(w Widget, tooltip string, pos, sz image.Point) *Scene
- func (sc *Scene) AddAppBar(fun func(tb *Toolbar))
- func (sc *Scene) AddDirectRender(w Widget)
- func (sc *Scene) AddReRender(w Widget)
- func (sc *Scene) ApplyStyleScene()
- func (t *Scene) AsScene() *Scene
- func (sc *Scene) AssertPixels(t imagex.TestingT, filename string)
- func (sc *Scene) BenchmarkFullRender()
- func (sc *Scene) BenchmarkReRender()
- func (sc *Scene) Close() bool
- func (sc *Scene) ConfigSceneBars()
- func (sc *Scene) ConfigSceneWidgets()
- func (sc *Scene) Delete()
- func (sc *Scene) DeleteDirectRender(w Widget)
- func (sc *Scene) DeleteImpl()
- func (sc *Scene) DirectRenderDraw(drw system.Drawer, idx int, flipY bool)
- func (sc *Scene) DirectRenderImage(drw system.Drawer, idx int)
- func (sc *Scene) DoRebuild()
- func (sc *Scene) DoUpdate() bool
- func (sc *Scene) FitInWindow(winGeom math32.Geom2DInt)
- func (sc *Scene) FlagType() enums.BitFlagSetter
- func (sc *Scene) GetBar(side styles.SideIndexes) *Layout
- func (sc *Scene) GetTopAppBar() *Toolbar
- func (sc *Scene) HandleEvents()
- func (sc *Scene) InheritBars(osc *Scene)
- func (sc *Scene) InheritBarsWidget(wi Widget)
- func (sc *Scene) LayoutRenderScene()
- func (sc *Scene) LayoutScene()
- func (sc *Scene) MainStageMgr() *StageMgr
- func (t *Scene) New() tree.Node
- func (t *Scene) NodeType() *types.Type
- func (sc *Scene) OnInit()
- func (sc *Scene) PrefSize(initSz image.Point) image.Point
- func (sc *Scene) RenderContext() *RenderContext
- func (sc *Scene) RenderWin() *RenderWindow
- func (sc *Scene) ReportWinNodes()
- func (sc *Scene) Resize(geom math32.Geom2DInt)
- func (sc *Scene) ScIsVisible() bool
- func (sc *Scene) ScenePos()
- func (t *Scene) SetAppBars(v ToolbarFuncs) *Scene
- func (t *Scene) SetBars(v styles.Sides[BarFuncs]) *Scene
- func (t *Scene) SetBarsInherit(v styles.Sides[bool]) *Scene
- func (t *Scene) SetBody(v *Body) *Scene
- func (t *Scene) SetData(v any) *Scene
- func (t *Scene) SetDirectRenders(v ...Widget) *Scene
- func (t *Scene) SetReRender(v ...Widget) *Scene
- func (t *Scene) SetSelectedWidget(v Widget) *Scene
- func (t *Scene) SetSelectedWidgetChan(v chan Widget) *Scene
- func (sc *Scene) SetStyles()
- func (t *Scene) SetTooltip(v string) *Scene
- func (sc *Scene) UpdateTitle(title string)
- type SceneEmbedder
- type ScreenSettings
- type Scrim
- type Separator
- type Settings
- type SettingsBase
- type SettingsOpener
- type SettingsSaver
- type Shortcuts
- type ShouldShower
- type SizeClasses
- func (i SizeClasses) Desc() string
- func (i SizeClasses) Int64() int64
- func (i SizeClasses) MarshalText() ([]byte, error)
- func (i *SizeClasses) SetInt64(in int64)
- func (i *SizeClasses) SetString(s string) error
- func (i SizeClasses) String() string
- func (i *SizeClasses) UnmarshalText(text []byte) error
- func (i SizeClasses) Values() []enums.Enum
- type SliceLabeler
- type Slider
- func (t *Slider) AsSlider() *Slider
- func (sr *Slider) Config()
- func (sr *Slider) EffectiveMax() float32
- func (sr *Slider) HandleEvents()
- func (sr *Slider) HandleKeys()
- func (sr *Slider) HandleMouse()
- func (t *Slider) New() tree.Node
- func (t *Slider) NodeType() *types.Type
- func (sr *Slider) OnInit()
- func (sr *Slider) PointToRelPos(pt image.Point) float32
- func (sr *Slider) Render()
- func (sr *Slider) ScenePos()
- func (sr *Slider) ScrollScale(del float32) float32
- func (sr *Slider) ScrollThumbValue() float32
- func (sr *Slider) SendChanged(e ...events.Event) bool
- func (t *Slider) SetEnforceStep(v bool) *Slider
- func (t *Slider) SetIcon(v icons.Icon) *Slider
- func (t *Slider) SetInputThreshold(v float32) *Slider
- func (t *Slider) SetMax(v float32) *Slider
- func (t *Slider) SetMin(v float32) *Slider
- func (t *Slider) SetPageStep(v float32) *Slider
- func (sr *Slider) SetPosFromValue(val float32)
- func (t *Slider) SetPrec(v int) *Slider
- func (sr *Slider) SetSliderPos(pos float32)
- func (sr *Slider) SetSliderPosAction(pos float32)
- func (t *Slider) SetStayInView(v bool) *Slider
- func (t *Slider) SetStep(v float32) *Slider
- func (sr *Slider) SetStyles()
- func (t *Slider) SetThumbColor(v image.Image) *Slider
- func (t *Slider) SetThumbSize(v math32.Vector2) *Slider
- func (t *Slider) SetTooltip(v string) *Slider
- func (t *Slider) SetTrackSize(v float32) *Slider
- func (t *Slider) SetType(v SliderTypes) *Slider
- func (sr *Slider) SetValue(val float32) *Slider
- func (sr *Slider) SetValueAction(val float32)
- func (t *Slider) SetValueColor(v image.Image) *Slider
- func (sr *Slider) SetVisiblePct(val float32) *Slider
- func (sr *Slider) SlideThumbSize() float32
- func (sr *Slider) SliderSize() float32
- func (sr *Slider) SliderThickness() float32
- func (sr *Slider) SnapValue()
- func (sr *Slider) ThumbSizeDots() math32.Vector2
- func (sr *Slider) WidgetTooltip() string
- type SliderEmbedder
- type SliderTypes
- func (i SliderTypes) Desc() string
- func (i SliderTypes) Int64() int64
- func (i SliderTypes) MarshalText() ([]byte, error)
- func (i *SliderTypes) SetInt64(in int64)
- func (i *SliderTypes) SetString(s string) error
- func (i SliderTypes) String() string
- func (i *SliderTypes) UnmarshalText(text []byte) error
- func (i SliderTypes) Values() []enums.Enum
- type Space
- type Spinner
- func (t *Spinner) AsSpinner() *Spinner
- func (sp *Spinner) FormatIsInt() bool
- func (sp *Spinner) HandleEvents()
- func (sp *Spinner) IncrementValue(steps float32) *Spinner
- func (t *Spinner) New() tree.Node
- func (t *Spinner) NodeType() *types.Type
- func (sp *Spinner) OnInit()
- func (sp *Spinner) PageIncrementValue(steps float32) *Spinner
- func (t *Spinner) SetCursorColor(v image.Image) *Spinner
- func (t *Spinner) SetCursorWidth(v units.Value) *Spinner
- func (t *Spinner) SetEnforceStep(v bool) *Spinner
- func (t *Spinner) SetFormat(v string) *Spinner
- func (t *Spinner) SetLeadingIconOnClick(v func(e events.Event)) *Spinner
- func (sp *Spinner) SetMax(max float32) *Spinner
- func (sp *Spinner) SetMin(min float32) *Spinner
- func (t *Spinner) SetNoEcho(v bool) *Spinner
- func (t *Spinner) SetPageStep(v float32) *Spinner
- func (t *Spinner) SetPlaceholder(v string) *Spinner
- func (t *Spinner) SetPlaceholderColor(v image.Image) *Spinner
- func (t *Spinner) SetPrec(v int) *Spinner
- func (t *Spinner) SetSelectColor(v image.Image) *Spinner
- func (t *Spinner) SetSelectMode(v bool) *Spinner
- func (t *Spinner) SetStep(v float32) *Spinner
- func (sp *Spinner) SetStyles()
- func (sp *Spinner) SetTextToValue()
- func (t *Spinner) SetTooltip(v string) *Spinner
- func (t *Spinner) SetTrailingIconOnClick(v func(e events.Event)) *Spinner
- func (t *Spinner) SetType(v TextFieldTypes) *Spinner
- func (t *Spinner) SetUndoMgr(v TextFieldUndoMgr) *Spinner
- func (t *Spinner) SetValidator(v func() error) *Spinner
- func (sp *Spinner) SetValue(val float32) *Spinner
- func (sp *Spinner) SetValueAction(val float32) *Spinner
- func (sp *Spinner) SizeUp()
- func (sp *Spinner) StringToValue(str string) (float32, error)
- func (sp *Spinner) ValueToString(val float32) string
- func (sp *Spinner) WidgetTooltip() string
- func (sp *Spinner) WrapAround(val float32) float32
- type SpinnerEmbedder
- type Splits
- func (sl *Splits) ApplyStyle()
- func (t *Splits) AsSplits() *Splits
- func (sl *Splits) CollapseChild(save bool, idxs ...int)
- func (sl *Splits) Config()
- func (sl *Splits) ConfigSplitters()
- func (sl *Splits) EvenSplits()
- func (sl *Splits) HandleEvents()
- func (sl *Splits) IsCollapsed(idx int) bool
- func (t *Splits) New() tree.Node
- func (t *Splits) NodeType() *types.Type
- func (sl *Splits) OnInit()
- func (sl *Splits) Position()
- func (sl *Splits) PositionSplits()
- func (sl *Splits) RenderWidget()
- func (sl *Splits) RestoreChild(idxs ...int)
- func (sl *Splits) RestoreSplits()
- func (sl *Splits) SaveSplits()
- func (sl *Splits) SetSplitAction(idx int, nwval float32)
- func (t *Splits) SetSplits(v ...float32) *Splits
- func (sl *Splits) SetStyles()
- func (t *Splits) SetTooltip(v string) *Splits
- func (sl *Splits) SizeDownSetAllocs(iter int)
- func (sl *Splits) UpdateSplits() *Splits
- type SplitsEmbedder
- type Sprite
- type Sprites
- func (ss *Sprites) ActivateSprite(name string)
- func (ss *Sprites) Add(sp *Sprite)
- func (ss *Sprites) AllocSizes()
- func (ss *Sprites) ConfigSprites(drw system.Drawer)
- func (ss *Sprites) Delete(sp *Sprite)
- func (ss *Sprites) DrawSprites(drw system.Drawer)
- func (ss *Sprites) HasSizeChanged() bool
- func (ss *Sprites) InactivateAllSprites()
- func (ss *Sprites) InactivateSprite(name string)
- func (ss *Sprites) Init()
- func (ss *Sprites) Reset()
- func (ss *Sprites) SpriteByName(name string) (*Sprite, bool)
- type Stage
- func NewCompleter(sc *Scene, ctx Widget) *Stage
- func NewMainStage(typ StageTypes, sc *Scene) *Stage
- func NewMenu(menu func(m *Scene), ctx Widget, pos image.Point) *Stage
- func NewMenuStage(sc *Scene, ctx Widget, pos image.Point) *Stage
- func NewPopupStage(typ StageTypes, sc *Scene, ctx Widget) *Stage
- func NewTooltip(w Widget) *Stage
- func NewTooltipFromScene(sc *Scene, ctx Widget) *Stage
- func NewTooltipText(w Widget, tooltip string) *Stage
- func NewTooltipTextAt(w Widget, tooltip string, pos, sz image.Point) *Stage
- func (st *Stage) AddDialogDecor() *Stage
- func (st *Stage) AddWindowDecor() *Stage
- func (st *Stage) ClosePopup() bool
- func (st *Stage) ClosePopupAndBelow() bool
- func (st *Stage) ClosePopupAndBelowAsync() bool
- func (st *Stage) ClosePopupAsync()
- func (st *Stage) ConfigMainStage()
- func (st *Stage) Delete()
- func (st *Stage) DoUpdate() (stageMods, sceneMods bool)
- func (st *Stage) FirstWinManager() *StageMgr
- func (st *Stage) GetValidContext() bool
- func (st *Stage) InheritBars()
- func (st *Stage) MainHandleEvent(e events.Event)
- func (st *Stage) NewRenderWin() *RenderWindow
- func (st *Stage) PopupHandleEvent(e events.Event)
- func (st *Stage) Raise()
- func (st *Stage) Run() *Stage
- func (st *Stage) RunDialog() *Stage
- func (st *Stage) RunImpl() *Stage
- func (st *Stage) RunPopup() *Stage
- func (st *Stage) RunPopupAsync() *Stage
- func (st *Stage) RunWindow() *Stage
- func (t *Stage) SetClickOff(v bool) *Stage
- func (t *Stage) SetCloseOnBack(v bool) *Stage
- func (t *Stage) SetCloseable(v bool) *Stage
- func (t *Stage) SetContext(v Widget) *Stage
- func (t *Stage) SetData(v any) *Stage
- func (t *Stage) SetFullWindow(v bool) *Stage
- func (t *Stage) SetIgnoreEvents(v bool) *Stage
- func (t *Stage) SetMain(v *Stage) *Stage
- func (st *Stage) SetMainMgr(sm *StageMgr) *Stage
- func (st *Stage) SetModal(modal bool) *Stage
- func (t *Stage) SetMovable(v bool) *Stage
- func (t *Stage) SetName(v string) *Stage
- func (st *Stage) SetNameFromScene() *Stage
- func (t *Stage) SetNewWindow(v bool) *Stage
- func (st *Stage) SetPopupMgr(mainSt *Stage) *Stage
- func (t *Stage) SetPos(v image.Point) *Stage
- func (t *Stage) SetRenderContext(v *RenderContext) *Stage
- func (t *Stage) SetResizable(v bool) *Stage
- func (st *Stage) SetScene(sc *Scene) *Stage
- func (t *Stage) SetScrim(v bool) *Stage
- func (t *Stage) SetSpriteDragging(v string) *Stage
- func (t *Stage) SetSprites(v Sprites) *Stage
- func (t *Stage) SetTimeout(v time.Duration) *Stage
- func (t *Stage) SetTitle(v string) *Stage
- func (st *Stage) SetType(typ StageTypes) *Stage
- func (st *Stage) String() string
- func (st *Stage) Wait()
- type StageMgr
- func (sm *StageMgr) DeleteAll()
- func (sm *StageMgr) DeleteStage(st *Stage) bool
- func (sm *StageMgr) DeleteStageAndBelow(st *Stage) bool
- func (sm *StageMgr) MainHandleEvent(e events.Event)
- func (sm *StageMgr) MoveToTop(st *Stage) bool
- func (sm *StageMgr) Pop() *Stage
- func (sm *StageMgr) PopDelete()
- func (sm *StageMgr) PopDeleteType(typ StageTypes)
- func (sm *StageMgr) PopType(typ StageTypes) *Stage
- func (pm *StageMgr) PopupHandleEvent(e events.Event)
- func (sm *StageMgr) Push(st *Stage)
- func (sm *StageMgr) Resize(rg math32.Geom2DInt)
- func (sm *StageMgr) SendShowEvents()
- func (sm *StageMgr) Top() *Stage
- func (pm *StageMgr) TopIsModal() bool
- func (sm *StageMgr) TopNotType(typ StageTypes) *Stage
- func (sm *StageMgr) TopOfType(typ StageTypes) *Stage
- func (sm *StageMgr) UniqueName(nm string) string
- func (sm *StageMgr) UpdateAll() (stageMods, sceneMods bool)
- type StageTypes
- func (i StageTypes) Desc() string
- func (i StageTypes) Int64() int64
- func (st StageTypes) IsMain() bool
- func (st StageTypes) IsPopup() bool
- func (i StageTypes) MarshalText() ([]byte, error)
- func (i *StageTypes) SetInt64(in int64)
- func (i *StageTypes) SetString(s string) error
- func (i StageTypes) String() string
- func (i *StageTypes) UnmarshalText(text []byte) error
- func (i StageTypes) Values() []enums.Enum
- type Stretch
- type Switch
- func (sw *Switch) ClearIcons() *Switch
- func (sw *Switch) Config()
- func (sw *Switch) HandleEvents()
- func (sw *Switch) IsChecked() bool
- func (sw *Switch) LabelWidget() *Label
- func (t *Switch) New() tree.Node
- func (t *Switch) NodeType() *types.Type
- func (sw *Switch) OnInit()
- func (sw *Switch) Render()
- func (sw *Switch) SetChecked(on bool) *Switch
- func (sw *Switch) SetIconFromState()
- func (t *Switch) SetIconIndeterminate(v icons.Icon) *Switch
- func (t *Switch) SetIconOff(v icons.Icon) *Switch
- func (t *Switch) SetIconOn(v icons.Icon) *Switch
- func (sw *Switch) SetIcons(on, off, unk icons.Icon) *Switch
- func (sw *Switch) SetStyles()
- func (t *Switch) SetText(v string) *Switch
- func (t *Switch) SetTooltip(v string) *Switch
- func (sw *Switch) SetType(typ SwitchTypes) *Switch
- type SwitchItem
- type SwitchTypes
- func (i SwitchTypes) Desc() string
- func (i SwitchTypes) Int64() int64
- func (i SwitchTypes) MarshalText() ([]byte, error)
- func (i *SwitchTypes) SetInt64(in int64)
- func (i *SwitchTypes) SetString(s string) error
- func (i SwitchTypes) String() string
- func (i *SwitchTypes) UnmarshalText(text []byte) error
- func (i SwitchTypes) Values() []enums.Enum
- type Switches
- func (t *Switches) AsSwitches() *Switches
- func (sw *Switches) Config()
- func (sw *Switches) HandleSwitchEvents(swi *Switch)
- func (t *Switches) New() tree.Node
- func (t *Switches) NodeType() *types.Type
- func (sw *Switches) OnInit()
- func (sw *Switches) SelectItem(idx int) error
- func (sw *Switches) SelectItemAction(idx int) error
- func (sw *Switches) SelectedItem() string
- func (sw *Switches) SelectedItems() []string
- func (sw *Switches) SetEnum(enum enums.Enum) *Switches
- func (sw *Switches) SetEnums(es ...enums.Enum) *Switches
- func (t *Switches) SetItems(v ...SwitchItem) *Switches
- func (t *Switches) SetMutex(v bool) *Switches
- func (sw *Switches) SetStrings(ss ...string) *Switches
- func (sw *Switches) SetStyles()
- func (t *Switches) SetTooltip(v string) *Switches
- func (t *Switches) SetType(v SwitchTypes) *Switches
- func (sw *Switches) UnCheckAll()
- func (sw *Switches) UnCheckAllBut(idx int)
- func (sw *Switches) UpdateBitFlag(bitflag enums.BitFlagSetter)
- func (sw *Switches) UpdateFromBitFlag(bitflag enums.BitFlag)
- type SwitchesEmbedder
- type SystemSettingsData
- type Tab
- func (tb *Tab) Config()
- func (t *Tab) New() tree.Node
- func (t *Tab) NodeType() *types.Type
- func (tb *Tab) OnInit()
- func (t *Tab) SetCloseIcon(v icons.Icon) *Tab
- func (t *Tab) SetIcon(v icons.Icon) *Tab
- func (t *Tab) SetMaxChars(v int) *Tab
- func (tb *Tab) SetStyles()
- func (t *Tab) SetText(v string) *Tab
- func (t *Tab) SetTooltip(v string) *Tab
- func (t *Tab) SetType(v TabTypes) *Tab
- func (tb *Tab) Tabs() *Tabs
- type TabTypes
- func (i TabTypes) Desc() string
- func (tt TabTypes) Effective(w Widget) TabTypes
- func (i TabTypes) Int64() int64
- func (tt TabTypes) IsColumn() bool
- func (i TabTypes) MarshalText() ([]byte, error)
- func (i *TabTypes) SetInt64(in int64)
- func (i *TabTypes) SetString(s string) error
- func (i TabTypes) String() string
- func (i *TabTypes) UnmarshalText(text []byte) error
- func (i TabTypes) Values() []enums.Enum
- type Tabs
- func (ts *Tabs) AddTab(frame *Frame, label string) int
- func (t *Tabs) AsTabs() *Tabs
- func (ts *Tabs) Config()
- func (ts *Tabs) ConfigNewTabButton() bool
- func (ts *Tabs) CurTab() (Widget, int, bool)
- func (ts *Tabs) DeleteTabIndex(idx int) bool
- func (ts *Tabs) Frame() *Frame
- func (ts *Tabs) InsertNewTab(label string, idx int, icon ...icons.Icon) *Frame
- func (ts *Tabs) InsertTab(frame *Frame, label string, idx int, icon ...icons.Icon)
- func (ts *Tabs) InsertTabOnlyAt(frame *Frame, label string, idx int, icon ...icons.Icon)
- func (ts *Tabs) NTabs() int
- func (t *Tabs) New() tree.Node
- func (ts *Tabs) NewTab(label string, icon ...icons.Icon) *Frame
- func (t *Tabs) NodeType() *types.Type
- func (ts *Tabs) OnInit()
- func (ts *Tabs) RecycleTab(name string, sel bool) *Frame
- func (ts *Tabs) RecycleTabWidget(name string, sel bool, typ *types.Type) Widget
- func (ts *Tabs) SelectTabByName(name string) *Frame
- func (ts *Tabs) SelectTabIndex(idx int) (*Frame, bool)
- func (t *Tabs) SetCloseIcon(v icons.Icon) *Tabs
- func (t *Tabs) SetMaxChars(v int) *Tabs
- func (t *Tabs) SetNewTabButton(v bool) *Tabs
- func (ts *Tabs) SetStyles()
- func (t *Tabs) SetTooltip(v string) *Tabs
- func (t *Tabs) SetType(v TabTypes) *Tabs
- func (ts *Tabs) TabAtIndex(idx int) (*Frame, *Tab, bool)
- func (ts *Tabs) TabByName(name string) *Frame
- func (ts *Tabs) TabIndexByName(name string) int
- func (ts *Tabs) TabLabel(idx int) string
- func (ts *Tabs) Tabs() *Frame
- func (ts *Tabs) UnselectOtherTabs(idx int)
- type TabsEmbedder
- type TextField
- func (tf *TextField) AddClearButton() *TextField
- func (tf *TextField) ApplyStyle()
- func (t *TextField) AsTextField() *TextField
- func (tf *TextField) AutoScroll()
- func (tf *TextField) CancelComplete()
- func (tf *TextField) CharPos(idx int) math32.Vector2
- func (tf *TextField) CharRenderPos(charidx int, wincoords bool) math32.Vector2
- func (tf *TextField) Clear()
- func (tf *TextField) ClearCursor()
- func (tf *TextField) ClearSelected()
- func (tf *TextField) CompleteText(s string)
- func (tf *TextField) Config()
- func (tf *TextField) ConfigTextSize(sz math32.Vector2) math32.Vector2
- func (tf *TextField) ContextMenu(m *Scene)
- func (tf *TextField) Copy(reset bool)
- func (tf *TextField) CursorBackspace(steps int)
- func (tf *TextField) CursorBackspaceWord(steps int)
- func (tf *TextField) CursorBackward(steps int)
- func (tf *TextField) CursorBackwardWord(steps int)
- func (tf *TextField) CursorDelete(steps int)
- func (tf *TextField) CursorDeleteWord(steps int)
- func (tf *TextField) CursorDown(steps int)
- func (tf *TextField) CursorEnd()
- func (tf *TextField) CursorForward(steps int)
- func (tf *TextField) CursorForwardWord(steps int)
- func (tf *TextField) CursorKill()
- func (tf *TextField) CursorSprite(on bool) *Sprite
- func (tf *TextField) CursorStart()
- func (tf *TextField) CursorUp(steps int)
- func (tf *TextField) Cut()
- func (tf *TextField) DeleteSelection() string
- func (tf *TextField) Destroy()
- func (tf *TextField) EditDone()
- func (tf *TextField) HandleEvents()
- func (tf *TextField) HandleKeyEvents()
- func (tf *TextField) HasSelection() bool
- func (tf *TextField) HasWordWrap() bool
- func (tf *TextField) IconsSize() math32.Vector2
- func (tf *TextField) InsertAtCursor(str string)
- func (tf *TextField) IsWordBreak(r rune) bool
- func (tf *TextField) LeadingIconButton() *Button
- func (t *TextField) New() tree.Node
- func (t *TextField) NodeType() *types.Type
- func (tf *TextField) OfferComplete()
- func (tf *TextField) OnAdd()
- func (tf *TextField) OnInit()
- func (tf *TextField) Paste()
- func (tf *TextField) PixelToCursor(pt image.Point) int
- func (tf *TextField) Redo()
- func (tf *TextField) RelCharPos(st, ed int) math32.Vector2
- func (tf *TextField) Render()
- func (tf *TextField) RenderCursor(on bool)
- func (tf *TextField) RenderSelect()
- func (tf *TextField) Revert()
- func (tf *TextField) SaveUndo()
- func (tf *TextField) ScenePos()
- func (tf *TextField) ScrollLayoutToCursor() bool
- func (tf *TextField) SelectAll()
- func (tf *TextField) SelectModeToggle()
- func (tf *TextField) SelectRegUpdate(pos int)
- func (tf *TextField) SelectReset()
- func (tf *TextField) SelectUpdate()
- func (tf *TextField) SelectWord()
- func (tf *TextField) Selection() string
- func (tf *TextField) SetCompleter(data any, matchFun complete.MatchFunc, editFun complete.EditFunc)
- func (t *TextField) SetCursorColor(v image.Image) *TextField
- func (tf *TextField) SetCursorFromPixel(pt image.Point, selMode events.SelectModes)
- func (t *TextField) SetCursorWidth(v units.Value) *TextField
- func (tf *TextField) SetEffPosAndSize()
- func (tf *TextField) SetLeadingIcon(icon icons.Icon, onClick ...func(e events.Event)) *TextField
- func (t *TextField) SetLeadingIconOnClick(v func(e events.Event)) *TextField
- func (t *TextField) SetNoEcho(v bool) *TextField
- func (t *TextField) SetPlaceholder(v string) *TextField
- func (t *TextField) SetPlaceholderColor(v image.Image) *TextField
- func (t *TextField) SetSelectColor(v image.Image) *TextField
- func (t *TextField) SetSelectMode(v bool) *TextField
- func (tf *TextField) SetStyles()
- func (tf *TextField) SetText(txt string) *TextField
- func (t *TextField) SetTooltip(v string) *TextField
- func (tf *TextField) SetTrailingIcon(icon icons.Icon, onClick ...func(e events.Event)) *TextField
- func (t *TextField) SetTrailingIconOnClick(v func(e events.Event)) *TextField
- func (t *TextField) SetType(v TextFieldTypes) *TextField
- func (tf *TextField) SetTypePassword() *TextField
- func (t *TextField) SetUndoMgr(v TextFieldUndoMgr) *TextField
- func (t *TextField) SetValidator(v func() error) *TextField
- func (tf *TextField) ShiftSelect(e events.Event)
- func (tf *TextField) SizeDown(iter int) bool
- func (tf *TextField) SizeUp()
- func (tf *TextField) StartCursor()
- func (tf *TextField) StopCursor()
- func (tf *TextField) Text() string
- func (tf *TextField) TrailingIconButton() *Button
- func (tf *TextField) Undo()
- func (tf *TextField) Validate()
- func (tf *TextField) WidgetTooltip() string
- type TextFieldEmbedder
- type TextFieldTypes
- func (i TextFieldTypes) Desc() string
- func (i TextFieldTypes) Int64() int64
- func (i TextFieldTypes) MarshalText() ([]byte, error)
- func (i *TextFieldTypes) SetInt64(in int64)
- func (i *TextFieldTypes) SetString(s string) error
- func (i TextFieldTypes) String() string
- func (i *TextFieldTypes) UnmarshalText(text []byte) error
- func (i TextFieldTypes) Values() []enums.Enum
- type TextFieldUndoMgr
- type TextFieldUndoRec
- type Themes
- func (i Themes) Desc() string
- func (i Themes) Int64() int64
- func (i Themes) MarshalText() ([]byte, error)
- func (i *Themes) SetInt64(in int64)
- func (i *Themes) SetString(s string) error
- func (i Themes) String() string
- func (i *Themes) UnmarshalText(text []byte) error
- func (i Themes) Values() []enums.Enum
- type Toolbar
- func (tb *Toolbar) AddOverflowMenu(fun func(m *Scene))
- func (tb *Toolbar) AllItemsToChildren()
- func (tb *Toolbar) AppChooser() *Chooser
- func (t *Toolbar) AsToolbar() *Toolbar
- func (tb *Toolbar) Config()
- func (tb *Toolbar) DeleteShortcuts()
- func (tb *Toolbar) Destroy()
- func (tb *Toolbar) IsVisible() bool
- func (tb *Toolbar) MoveToOverflow()
- func (t *Toolbar) New() tree.Node
- func (t *Toolbar) NodeType() *types.Type
- func (tb *Toolbar) OnInit()
- func (tb *Toolbar) OverflowMenu(m *Scene)
- func (tb *Toolbar) ParentSize() float32
- func (t *Toolbar) SetOverflowButton(v *Button) *Toolbar
- func (tb *Toolbar) SetShortcuts()
- func (t *Toolbar) SetToolbarFuncs(v ToolbarFuncs) *Toolbar
- func (t *Toolbar) SetTooltip(v string) *Toolbar
- func (tb *Toolbar) SizeDown(iter int) bool
- func (tb *Toolbar) SizeFromChildren(iter int, pass LayoutPasses) math32.Vector2
- func (tb *Toolbar) SizeUp()
- func (tb *Toolbar) StandardOverflowMenu(m *Scene)
- func (tb *Toolbar) UpdateBar()
- type ToolbarEmbedder
- type ToolbarFuncs
- type Toolbarer
- type Updater
- type User
- type Validator
- type Widget
- func NonNilContext(ctx Widget) Widget
- func WidgetLastChild(wi Widget) Widget
- func WidgetLastChildParts(wi Widget) Widget
- func WidgetNext(wi Widget) Widget
- func WidgetNextFunc(wi Widget, fun func(w Widget) bool) Widget
- func WidgetNextSibling(wi Widget) Widget
- func WidgetPrev(wi Widget) Widget
- func WidgetPrevFunc(wi Widget, fun func(w Widget) bool) Widget
- type WidgetBase
- func (wb *WidgetBase) AbilityIs(able abilities.Abilities) bool
- func (wb *WidgetBase) AddCloseDialog(config func(d *Body) bool) *WidgetBase
- func (wb *WidgetBase) AddContextMenu(menu func(m *Scene)) *WidgetBase
- func (wb *WidgetBase) ApplyContextMenus(m *Scene)
- func (wb *WidgetBase) ApplyStyle()
- func (wb *WidgetBase) ApplyStyleParts()
- func (wb *WidgetBase) ApplyStyleSettings()
- func (wb *WidgetBase) ApplyStyleTree()
- func (wb *WidgetBase) ApplyStyleUpdate()
- func (wb *WidgetBase) ApplyStyleWidget()
- func (wb *WidgetBase) AsWidget() *WidgetBase
- func (wb *WidgetBase) AsyncLock()
- func (wb *WidgetBase) AsyncUnlock()
- func (wb *WidgetBase) BaseType() *types.Type
- func (wb *WidgetBase) BoxSpace() styles.SideFloats
- func (wb *WidgetBase) CanFocus() bool
- func (wb *WidgetBase) ChildBackground(child Widget) image.Image
- func (wb *WidgetBase) Clipboard() system.Clipboard
- func (wb *WidgetBase) Config()
- func (wb *WidgetBase) ConfigParts(config tree.Config, after ...func())
- func (wb *WidgetBase) ConfigTree()
- func (wb *WidgetBase) ContainsFocus() bool
- func (wb *WidgetBase) ContextMenuPos(e events.Event) image.Point
- func (wb *WidgetBase) CopyFieldsFrom(from tree.Node)
- func (wb *WidgetBase) DeleteParts()
- func (wb *WidgetBase) Destroy()
- func (wb *WidgetBase) DirectRenderDraw(drw system.Drawer, idx int, flipY bool)
- func (wb *WidgetBase) DirectRenderImage(drw system.Drawer, idx int)
- func (wb *WidgetBase) DoNeedsRender()
- func (wb *WidgetBase) EventMgr() *EventMgr
- func (wb *WidgetBase) FieldByName(field string) (tree.Node, error)
- func (wb *WidgetBase) FinalHandleEvent(ev events.Event)
- func (wb *WidgetBase) FirstHandleEvent(ev events.Event)
- func (wb *WidgetBase) FlagType() enums.BitFlagSetter
- func (wb *WidgetBase) FocusClear()
- func (wb *WidgetBase) FocusNext()
- func (wb *WidgetBase) FocusPrev()
- func (wb *WidgetBase) FocusableInMe() Widget
- func (wb *WidgetBase) GrowToAlloc() bool
- func (wb *WidgetBase) GrowToAllocSize(act, alloc math32.Vector2) (math32.Vector2, bool)
- func (wb *WidgetBase) HandleClickOnEnterSpace()
- func (wb *WidgetBase) HandleEvent(ev events.Event)
- func (wb *WidgetBase) HandleEvents()
- func (wb *WidgetBase) HandleLongHoverTooltip()
- func (wb *WidgetBase) HandleSelectToggle()
- func (wb *WidgetBase) HandleWidgetClick()
- func (wb *WidgetBase) HandleWidgetContextMenu()
- func (wb *WidgetBase) HandleWidgetMagnify()
- func (wb *WidgetBase) HandleWidgetStateFromFocus()
- func (wb *WidgetBase) HandleWidgetStateFromMouse()
- func (wb *WidgetBase) HasFlagWithin(flag enums.BitFlag) bool
- func (wb *WidgetBase) HasSc() bool
- func (wb *WidgetBase) HasStateWithin(state states.States) bool
- func (wb *WidgetBase) IsDisabled() bool
- func (wb *WidgetBase) IsFirstChild() bool
- func (wb *WidgetBase) IsLastChild() bool
- func (wb *WidgetBase) IsNthChild(n int) bool
- func (wb *WidgetBase) IsOnlyChild() bool
- func (wb *WidgetBase) IsReadOnly() bool
- func (wb *WidgetBase) IsVisible() bool
- func (wb *WidgetBase) NeedsLayout()
- func (wb *WidgetBase) NeedsRebuild() bool
- func (wb *WidgetBase) NeedsRender()
- func (t *WidgetBase) New() tree.Node
- func (wb *WidgetBase) NewParts() *Layout
- func (t *WidgetBase) NodeType() *types.Type
- func (wb *WidgetBase) NodeWalkDown(fun func(tree.Node) bool)
- func (wb *WidgetBase) On(etype events.Types, fun func(e events.Event)) *WidgetBase
- func (wb *WidgetBase) OnAdd()
- func (wb *WidgetBase) OnChange(fun func(e events.Event)) *WidgetBase
- func (wb *WidgetBase) OnChildAdded(child tree.Node)
- func (wb *WidgetBase) OnClick(fun func(e events.Event)) *WidgetBase
- func (wb *WidgetBase) OnClose(fun func(e events.Event)) *WidgetBase
- func (wb *WidgetBase) OnDoubleClick(fun func(e events.Event)) *WidgetBase
- func (wb *WidgetBase) OnFinal(etype events.Types, fun func(e events.Event)) Widget
- func (wb *WidgetBase) OnFirst(etype events.Types, fun func(e events.Event)) Widget
- func (wb *WidgetBase) OnFocus(fun func(e events.Event)) *WidgetBase
- func (wb *WidgetBase) OnFocusLost(fun func(e events.Event)) *WidgetBase
- func (wb *WidgetBase) OnInit()
- func (wb *WidgetBase) OnInput(fun func(e events.Event)) *WidgetBase
- func (wb *WidgetBase) OnKeyChord(fun func(e events.Event)) *WidgetBase
- func (wb *WidgetBase) OnSelect(fun func(e events.Event)) *WidgetBase
- func (wb *WidgetBase) OnShow(fun func(e events.Event)) *WidgetBase
- func (wb *WidgetBase) OnWidgetAdded(fun func(w Widget)) *WidgetBase
- func (wb *WidgetBase) ParentActualBackground() image.Image
- func (wb *WidgetBase) ParentLayout() *Layout
- func (wb *WidgetBase) ParentScrollLayout() *Layout
- func (wb *WidgetBase) ParentWidget() *WidgetBase
- func (wb *WidgetBase) ParentWidgetIf(fun func(p *WidgetBase) bool) *WidgetBase
- func (wb *WidgetBase) PointToRelPos(pt image.Point) image.Point
- func (wb *WidgetBase) PopBounds()
- func (wb *WidgetBase) PosInScBBox(pos image.Point) bool
- func (wb *WidgetBase) Position()
- func (wb *WidgetBase) PositionChildren()
- func (wb *WidgetBase) PositionParts()
- func (wb *WidgetBase) PositionWidget()
- func (wb *WidgetBase) PositionWithinAllocMainX(pos math32.Vector2, parJustify, parAlign styles.Aligns)
- func (wb *WidgetBase) PositionWithinAllocMainY(pos math32.Vector2, parJustify, parAlign styles.Aligns)
- func (wb *WidgetBase) PushBounds() bool
- func (wb *WidgetBase) Render()
- func (wb *WidgetBase) RenderBoxImpl(pos math32.Vector2, sz math32.Vector2, bs styles.Border)
- func (wb *WidgetBase) RenderChildren()
- func (wb *WidgetBase) RenderParts()
- func (wb *WidgetBase) RenderStandardBox()
- func (wb *WidgetBase) RenderWidget()
- func (wb *WidgetBase) ResetStyleSettings()
- func (wb *WidgetBase) ResetStyleWidget()
- func (wb *WidgetBase) RunStylers()
- func (wb *WidgetBase) ScenePos()
- func (wb *WidgetBase) ScenePosChildren()
- func (wb *WidgetBase) ScenePosParts()
- func (wb *WidgetBase) ScenePosWidget()
- func (wb *WidgetBase) ScrollToMe() bool
- func (wb *WidgetBase) Send(typ events.Types, orig ...events.Event)
- func (wb *WidgetBase) SendChange(orig ...events.Event)
- func (wb *WidgetBase) SendKey(kf keymap.Functions, orig ...events.Event)
- func (wb *WidgetBase) SendKeyChord(kc key.Chord, orig ...events.Event)
- func (wb *WidgetBase) SendKeyChordRune(r rune, code key.Codes, mods key.Modifiers, orig ...events.Event)
- func (wb *WidgetBase) SetAbilities(on bool, able ...abilities.Abilities) *WidgetBase
- func (wb *WidgetBase) SetBBoxes()
- func (wb *WidgetBase) SetBBoxesFromAllocs()
- func (wb *WidgetBase) SetContentPosFromPos()
- func (wb *WidgetBase) SetEnabled(enabled bool) *WidgetBase
- func (wb *WidgetBase) SetFocus()
- func (wb *WidgetBase) SetFocusEvent()
- func (wb *WidgetBase) SetPosFromParent()
- func (wb *WidgetBase) SetReadOnly(ro bool) *WidgetBase
- func (wb *WidgetBase) SetScene(sc *Scene)
- func (wb *WidgetBase) SetSelected(sel bool)
- func (wb *WidgetBase) SetState(on bool, state ...states.States) *WidgetBase
- func (wb *WidgetBase) SetStyles()
- func (t *WidgetBase) SetTooltip(v string) *WidgetBase
- func (wb *WidgetBase) ShowContextMenu(e events.Event)
- func (wb *WidgetBase) SizeClass() SizeClasses
- func (wb *WidgetBase) SizeDown(iter int) bool
- func (wb *WidgetBase) SizeDownChildren(iter int) bool
- func (wb *WidgetBase) SizeDownParts(iter int) bool
- func (wb *WidgetBase) SizeDownWidget(iter int) bool
- func (wb *WidgetBase) SizeFinal()
- func (wb *WidgetBase) SizeFinalChildren()
- func (wb *WidgetBase) SizeFinalParts()
- func (wb *WidgetBase) SizeFinalWidget()
- func (wb *WidgetBase) SizeFromStyle()
- func (wb *WidgetBase) SizeUp()
- func (wb *WidgetBase) SizeUpChildren()
- func (wb *WidgetBase) SizeUpParts()
- func (wb *WidgetBase) SizeUpWidget()
- func (wb *WidgetBase) SpaceFromStyle()
- func (wb *WidgetBase) StartFocus()
- func (wb *WidgetBase) StateIs(state states.States) bool
- func (wb *WidgetBase) Style(s func(s *styles.Style)) *WidgetBase
- func (wb *WidgetBase) StyleFinal(s func(s *styles.Style)) *WidgetBase
- func (wb *WidgetBase) StyleFirst(s func(s *styles.Style)) *WidgetBase
- func (wb *WidgetBase) StyleSizeUpdate() bool
- func (wb *WidgetBase) SystemEventMgr() *events.Mgr
- func (wb *WidgetBase) Update()
- func (wb *WidgetBase) VisibleKidsIter(fun func(i int, kwi Widget, kwb *WidgetBase) bool)
- func (wb *WidgetBase) WidgetKidsIter(fun func(i int, kwi Widget, kwb *WidgetBase) bool)
- func (wb *WidgetBase) WidgetTooltip() string
- func (wb *WidgetBase) WidgetWalkPre(fun func(kwi Widget, kwb *WidgetBase) bool)
- func (wb *WidgetBase) WinBBox() image.Rectangle
- func (wb *WidgetBase) WinPos(x, y float32) image.Point
- type WidgetFlags
- func (i WidgetFlags) BitIndexString() string
- func (i WidgetFlags) Desc() string
- func (i WidgetFlags) HasFlag(f enums.BitFlag) bool
- func (i WidgetFlags) Int64() int64
- func (i WidgetFlags) MarshalText() ([]byte, error)
- func (i *WidgetFlags) SetFlag(on bool, f ...enums.BitFlag)
- func (i *WidgetFlags) SetInt64(in int64)
- func (i *WidgetFlags) SetString(s string) error
- func (i *WidgetFlags) SetStringOr(s string) error
- func (i WidgetFlags) String() string
- func (i *WidgetFlags) UnmarshalText(text []byte) error
- func (i WidgetFlags) Values() []enums.Enum
- type WindowFlags
- func (i WindowFlags) BitIndexString() string
- func (i WindowFlags) Desc() string
- func (i WindowFlags) HasFlag(f enums.BitFlag) bool
- func (i WindowFlags) Int64() int64
- func (i WindowFlags) MarshalText() ([]byte, error)
- func (i *WindowFlags) SetFlag(on bool, f ...enums.BitFlag)
- func (i *WindowFlags) SetInt64(in int64)
- func (i *WindowFlags) SetString(s string) error
- func (i *WindowFlags) SetStringOr(s string) error
- func (i WindowFlags) String() string
- func (i *WindowFlags) UnmarshalText(text []byte) error
- func (i WindowFlags) Values() []enums.Enum
- type WindowGeometries
- type WindowGeometry
- type WindowGeometrySaver
- func (mgr *WindowGeometrySaver) AbortSave()
- func (mgr *WindowGeometrySaver) DeleteAll()
- func (mgr *WindowGeometrySaver) Init()
- func (mgr *WindowGeometrySaver) LockFile() error
- func (mgr *WindowGeometrySaver) NeedToReload() bool
- func (mgr *WindowGeometrySaver) Open() error
- func (mgr *WindowGeometrySaver) Pref(winName string, scrn *system.Screen) *WindowGeometry
- func (mgr *WindowGeometrySaver) RecordPref(win *RenderWindow)
- func (mgr *WindowGeometrySaver) ResetCache()
- func (mgr *WindowGeometrySaver) RestoreAll()
- func (mgr *WindowGeometrySaver) Save() error
- func (mgr *WindowGeometrySaver) SaveCached()
- func (mgr *WindowGeometrySaver) SaveLastSave()
- func (mgr *WindowGeometrySaver) SettingEnd()
- func (mgr *WindowGeometrySaver) SettingStart()
- func (mgr *WindowGeometrySaver) UnlockFile()
- func (mgr *WindowGeometrySaver) WinName(winName string) string
Examples ¶
Constants ¶
const ( // Sprites are stored as arrays of same-sized textures, // allocated by size in Set 2, starting at 32 SpriteStart = system.MaxTexturesPerSet * 2 // Full set of sprite textures in set = 2 MaxSpriteTextures = system.MaxTexturesPerSet // Allocate 128 layers within each sprite size MaxSpritesPerTexture = 128 )
const (
DragSpriteName = "__DragSprite__"
)
Variables ¶
var ( // LayoutPrefMaxRows is maximum number of rows to use in a grid layout // when computing the preferred size (ScPrefSizing) LayoutPrefMaxRows = 20 // LayoutPrefMaxCols is maximum number of columns to use in a grid layout // when computing the preferred size (ScPrefSizing) LayoutPrefMaxCols = 20 // AutoScrollRate determines the rate of auto-scrolling of layouts AutoScrollRate = float32(1.0) )
var ( // TextFieldBlinker manages cursor blinking TextFieldBlinker = Blinker{} // TextFieldSpriteName is the name of the window sprite used for the cursor TextFieldSpriteName = "core.TextField.Cursor" )
var AllSettings = []Settings{AppearanceSettings, SystemSettings, DeviceSettings, DebugSettings}
AllSettings is a global slice containing all of the user Settings that the user will see in the settings window. It contains the base Cogent Core settings by default and should be modified by other apps to add their app settings.
var AppColor = color.RGBA{66, 133, 244, 255}
AppColor is the default primary color used to generate the color scheme. The user can still change the primary color used to generate the color scheme through [AppearanceSettingsData.Color] unless ForceAppColor is set to true, but this value will always take effect if the settings color is the default value. It defaults to Google Blue (#4285f4).
var AppearanceSettings = &AppearanceSettingsData{ SettingsBase: SettingsBase{ Name: "Appearance", File: filepath.Join(TheApp.CogentCoreDataDir(), "appearance-settings.toml"), }, }
AppearanceSettings are the currently active global Cogent Core appearance settings.
var BasicBarType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.BasicBar", IDName: "basic-bar", Doc: "BasicBar is just a styled Frame layout for holding buttons\nand other widgets. Use this when the more advanced features\nof the Toolbar are not needed.", Embeds: []types.Field{{Name: "Frame"}}, Instance: &BasicBar{}})
BasicBarType is the types.Type for BasicBar
var BodyType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Body", IDName: "body", Doc: "Body holds the primary content of a Scene", Directives: []types.Directive{{Tool: "core", Directive: "no-new"}}, Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Title", Doc: "title of the Body, also used for window title where relevant"}}, Instance: &Body{}})
BodyType is the types.Type for Body
var BoxType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Box", IDName: "box", Doc: "Box is a simple base [Widget] that renders the standard box model.", Embeds: []types.Field{{Name: "WidgetBase"}}, Instance: &Box{}})
BoxType is the types.Type for Box
var ButtonType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Button", IDName: "button", Doc: "Button is an interactive button with text, an icon, an indicator, a shortcut,\nand/or a menu. The standard behavior is to register a click event handler with\nOnClick.", Directives: []types.Directive{{Tool: "core", Directive: "embedder"}}, Embeds: []types.Field{{Name: "Box"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the type of button."}, {Name: "Text", Doc: "Text is the label text for the button.\nIf it is blank, no label is shown."}, {Name: "Icon", Doc: "Icon is the icon for the button.\nIf it is \"\" or [icons.None], no icon is shown."}, {Name: "Indicator", Doc: "Indicator is the menu indicator icon to present.\nIf it is \"\" or [icons.None],, no indicator is shown.\nIt is automatically set to [icons.KeyboardArrowDown]\nwhen there is a Menu elements present unless it is\nset to [icons.None]."}, {Name: "Shortcut", Doc: "Shortcut is an optional shortcut keyboard chord to trigger this button,\nactive in window-wide scope. Avoid conflicts with other shortcuts\n(a log message will be emitted if so). Shortcuts are processed after\nall other processing of keyboard input. Use Command for\nControl / Meta (Mac Command key) per platform."}, {Name: "Menu", Doc: "Menu is a menu constructor function used to build and display\na menu whenever the button is clicked. There will be no menu\nif it is nil. The constructor function should add buttons\nto the Scene that it is passed."}}, Instance: &Button{}})
ButtonType is the types.Type for Button
var CanvasType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Canvas", IDName: "canvas", Doc: "Canvas is a widget that can be arbitrarily drawn to by setting\nits Draw function using [Canvas.SetDraw].", Embeds: []types.Field{{Name: "Box"}}, Fields: []types.Field{{Name: "Draw", Doc: "Draw is the function used to draw the content of the\ncanvas every time that it is rendered. The paint context\nis automatically normalized to the size of the canvas,\nso you should specify points on a 0-1 scale."}, {Name: "Context", Doc: "Context is the paint context used for drawing."}}, Instance: &Canvas{}})
CanvasType is the types.Type for Canvas
var ChooserType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Chooser", IDName: "chooser", Doc: "Chooser is for selecting items from a dropdown list, with an optional\nedit TextField for typing directly.\nThe items can be of any type, including enum values -- they are converted\nto strings for the display. If the items are of type [icons.Icon], then they\nare displayed using icons instead.", Embeds: []types.Field{{Name: "Box"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the styling type of the chooser."}, {Name: "Items", Doc: "Items are the chooser items available for selection."}, {Name: "Icon", Doc: "Icon is an optional icon displayed on the left side of the chooser."}, {Name: "Indicator", Doc: "Indicator is the icon to use for the indicator displayed on the\nright side of the chooser."}, {Name: "Editable", Doc: "Editable is whether provide a text field for editing the value,\nor just a button for selecting items."}, {Name: "AllowNew", Doc: "AllowNew is whether to allow the user to add new items to the\nchooser through the editable textfield (if Editable is set to\ntrue) and a button at the end of the chooser menu. See also [DefaultNew]."}, {Name: "DefaultNew", Doc: "DefaultNew configures the chooser to accept new items, as in\n[AllowNew], and also turns off completion popups and always\nadds new items to the list of items, without prompting.\nUse this for cases where the typical use-case is to enter new values,\nbut the history of prior values can also be useful."}, {Name: "Placeholder", Doc: "Placeholder, if Editable is set to true, is the text that is\ndisplayed in the text field when it is empty. It must be set\nusing [Chooser.SetPlaceholder]."}, {Name: "ItemsFuncs", Doc: "ItemsFuncs is a slice of functions to call before showing the items\nof the chooser, which is typically used to configure them\n(eg: if they are based on dynamic data). The functions are called\nin ascending order such that the items added in the first function\nwill appear before those added in the last function. Use\n[Chooser.AddItemsFunc] to add a new items function. If at least\none ItemsFunc is specified, the items of the chooser will be\ncleared before calling the functions."}, {Name: "CurrentItem", Doc: "CurrentItem is the currently selected item."}, {Name: "CurrentIndex", Doc: "CurrentIndex is the index of the currently selected item\nin [Chooser.Items]."}}, Instance: &Chooser{}})
ChooserType is the types.Type for Chooser
var CustomConfigStyles func(w Widget)
CustomConfigStyles is the custom, global style configuration function that is called on all widgets to configure their style functions. By default, it is nil. If you set it, you should mostly call AddStyleFunc within it. For reference on how you should structure your CustomStyleFunc, you should look at https://cogentcore.org/core/docs/gi/styling.
var DebugSettings = &DebugSettingsData{ SettingsBase: SettingsBase{ Name: "Debug", File: filepath.Join(TheApp.CogentCoreDataDir(), "debug-settings.toml"), }, }
DebugSettings are the currently active debugging settings
var DefaultPaths = FavPaths{ {icons.Home, "home", "~"}, {icons.DesktopMac, "Desktop", "~/Desktop"}, {icons.Document, "Documents", "~/Documents"}, {icons.Download, "Downloads", "~/Downloads"}, {icons.Computer, "root", "/"}, }
DefaultPaths are default favorite paths
var DeviceSettings = &DeviceSettingsData{ SettingsBase: SettingsBase{ Name: "Device", File: filepath.Join(TheApp.CogentCoreDataDir(), "device-settings.toml"), }, }
DeviceSettings are the global device settings.
var ForceAppColor bool
ForceAppColor is whether to prevent the user from changing the color scheme and make it always based on AppColor.
var FrameType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Frame", IDName: "frame", Doc: "Frame is a Layout that renders a background according to the\nbackground-color style setting, and optional striping for grid layouts", Embeds: []types.Field{{Name: "Layout"}}, Instance: &Frame{}})
FrameType is the types.Type for Frame
var HandleType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Handle", IDName: "handle", Doc: "Handle represents a draggable handle that can be used to\ncontrol the size of an element. The [Handle.Styles.Direction]\ncontrols the direction in which the handle moves.", Embeds: []types.Field{{Name: "Box"}}, Fields: []types.Field{{Name: "Min", Doc: "Min is the minimum value that the handle can go to\n(typically the lower bound of the dialog/splits)"}, {Name: "Max", Doc: "Max is the maximum value that the handle can go to\n(typically the upper bound of the dialog/splits)"}, {Name: "Pos", Doc: "Pos is the current position of the handle on the\nscale of [Handle.Min] to [Handle.Max]"}}, Instance: &Handle{}})
HandleType is the types.Type for Handle
var IconType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Icon", IDName: "icon", Doc: "Icon contains a svg.SVG element.\nThe rendered version is cached for a given size.\nIcons do not render a background or border independent of their SVG object.\nThe size of on Icon is determined by the [styles.Font.Size] property.", Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "Icon", Doc: "icon name that has been set."}, {Name: "Filename", Doc: "file name for the loaded icon, if loaded"}, {Name: "SVG", Doc: "SVG drawing of the icon"}}, Instance: &Icon{}})
IconType is the types.Type for Icon
var ImageType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Image", IDName: "image", Doc: "Image is a widget that renders a static bitmap image.\nSee [styles.ObjectFits] for how to control the image rendering within\nthe allocated size. The default minimum requested size is the pixel\nsize in [units.Dp] units (1/160th of an inch). See [views.ConfigImageToolbar]\nfor a toolbar with I/O buttons.", Methods: []types.Method{{Name: "Open", Doc: "Open sets the image to the image located at the given filename.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"filename"}, Returns: []string{"error"}}}, Embeds: []types.Field{{Name: "Box"}}, Fields: []types.Field{{Name: "Image", Doc: "Image is the bitmap image."}, {Name: "prevPixels", Doc: "prevPixels is the cached last rendered image."}, {Name: "prevObjectFit", Doc: "prevObjectFit is the cached [styles.Style.ObjectFit] of the last rendered image."}, {Name: "prevSize", Doc: "prevSize is the cached allocated size for the last rendered image."}}, Instance: &Image{}})
ImageType is the types.Type for Image
var InspectorWindow func(obj tree.Node)
InspectorWindow opens an interactive editor of the given Ki tree at its root. It is set to [views.InspectorWindow] if views is imported; otherwise; it is nil.
var LabelType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Label", IDName: "label", Doc: "Label is a widget for rendering text labels. It supports full HTML styling,\nincluding links. By default, labels wrap and collapse whitespace, although\nyou can change this by changing [styles.Text.WhiteSpace].", Directives: []types.Directive{{Tool: "core", Directive: "embedder"}}, Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "Text", Doc: "label to display"}, {Name: "Type", Doc: "the type of label"}, {Name: "TextRender", Doc: "render data for text label"}, {Name: "NormalCursor", Doc: "NormalCursor is the cached cursor to display when there\nis no link being hovered."}}, Instance: &Label{}})
LabelType is the types.Type for Label
var LayoutLastAutoScroll time.Time
var LayoutType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Layout", IDName: "layout", Doc: "Layout is the primary node type responsible for organizing the sizes\nand positions of child widgets. It does not render, only organize,\nso properties like background and border will have no effect.\nAll arbitrary collections of widgets should generally be contained\nwithin a layout or a [Frame]; otherwise, the parent widget must take over\nresponsibility for positioning. Layouts automatically can add scrollbars\ndepending on the [styles.Style.Overflow].\n\nFor a [styles.Grid] layout, the [styles.Style.Columns] property should\ngenerally be set to the desired number of columns, from which the number of rows\nis computed; otherwise, it uses the square root of number of\nelements.", Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "StackTop", Doc: "StackTop, for a [styles.Stacked] layout, is the index of the node to use as the top of the stack.\nOnly the node at this index is rendered; if not a valid index, nothing is rendered."}, {Name: "LayImpl", Doc: "LayImpl contains implementation state info for doing layout"}, {Name: "HasScroll", Doc: "whether scrollbar is used for given dim"}, {Name: "Scrolls", Doc: "scroll bars -- we fully manage them as needed"}, {Name: "FocusName", Doc: "accumulated name to search for when keys are typed"}, {Name: "FocusNameTime", Doc: "time of last focus name event -- for timeout"}, {Name: "FocusNameLast", Doc: "last element focused on -- used as a starting point if name is the same"}}, Instance: &Layout{}})
LayoutType is the types.Type for Layout
var MeterType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Meter", IDName: "meter", Doc: "Meter is a widget that renders a current value on as a filled\nbar/semicircle relative to a minimum and maximum potential value.", Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the styling type of the meter."}, {Name: "Value", Doc: "Value is the current value of the meter.\nIt defaults to 0.5."}, {Name: "Min", Doc: "Min is the minimum possible value of the meter.\nIt defaults to 0."}, {Name: "Max", Doc: "Max is the maximum possible value of the meter.\nIt defaults to 1."}, {Name: "Text", Doc: "Text, for [MeterCircle] and [MeterSemicircle], is the\ntext to render inside of the circle/semicircle."}, {Name: "ValueColor", Doc: "ValueColor is the image color that will be used to\nrender the filled value bar. It should be set in Style."}, {Name: "Width", Doc: "Width, for [MeterCircle] and [MeterSemicircle], is the\nwidth of the circle/semicircle. It should be set in Style."}}, Instance: &Meter{}})
MeterType is the types.Type for Meter
var RenderWindowGlobalMu sync.Mutex
RenderWindowGlobalMu is a mutex for any global state associated with windows
var SVGType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.SVG", IDName: "svg", Doc: "SVG is a Widget that renders an [svg.SVG] object.\nIf it is not [states.ReadOnly], the user can pan and zoom the display.\nBy default, it is [states.ReadOnly]. See [views.ConfigSVGToolbar] for a\ntoolbar with panning, selecting, and I/O buttons.", Methods: []types.Method{{Name: "Open", Doc: "Open opens an XML-formatted SVG file", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"filename"}, Returns: []string{"error"}}, {Name: "SaveSVG", Doc: "SaveSVG saves the current SVG to an XML-encoded standard SVG file.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"filename"}, Returns: []string{"error"}}, {Name: "SavePNG", Doc: "SavePNG saves the current rendered SVG image to an PNG image file.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"filename"}, Returns: []string{"error"}}}, Embeds: []types.Field{{Name: "Box"}}, Fields: []types.Field{{Name: "SVG", Doc: "SVG is the SVG object associated with the element."}}, Instance: &SVG{}})
SVGType is the types.Type for SVG
var SavedPathsFilename = "saved-paths.json"
SavedPathsFilename is the name of the saved file paths file in the Cogent Core data directory.
var SceneShowIters = 2
var SceneType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Scene", IDName: "scene", Doc: "Scene contains a Widget tree, rooted in an embedded Frame layout,\nwhich renders into its Pixels image.\nThe Scene is set in a Stage (pointer retained in Scene).\nStage has a StageMgr manager for controlling things like Popups\n(Menus and Dialogs, etc).\n\nEach Scene and Widget tree contains state specific to its particular usage\nwithin a given Stage and overall rendering context, representing the unit\nof rendering in the Cogent Core framework.", Directives: []types.Directive{{Tool: "core", Directive: "no-new"}, {Tool: "core", Directive: "embedder"}}, Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Bars", Doc: "Bars contains functions for constructing the control bars for this Scene,\nattached to different sides of a Scene (e.g., TopAppBar at Top,\nNavBar at Bottom, etc). Functions are called in forward order\nso first added are called first."}, {Name: "BarsInherit", Doc: "BarsInherit determines which of the Bars side functions are inherited\nfrom the context widget, for FullWindow Dialogs"}, {Name: "AppBars", Doc: "AppBars contains functions for configuring a top-level App toolbar,\n(e.g., TopAppBar) for elements contained within this Scene,\nthat should be represented in any app-level toolbar constructed\nfor this Scene."}, {Name: "Body", Doc: "Body provides the main contents of scenes that use control Bars\nto allow the main window contents to be specified separately\nfrom that dynamic control content. When constructing scenes using\na Body, you can operate directly on the [Body], which has wrappers\nfor most major Scene functions."}, {Name: "Data", Doc: "Data is the optional data value being represented by this scene.\nUsed e.g., for recycling views of a given item instead of creating new one."}, {Name: "SceneGeom", Doc: "Size and position relative to overall rendering context."}, {Name: "PaintContext", Doc: "paint context for rendering"}, {Name: "Pixels", Doc: "live pixels that we render into"}, {Name: "EventMgr", Doc: "event manager for this scene"}, {Name: "Stage", Doc: "current stage in which this Scene is set"}, {Name: "RenderBBoxHue", Doc: "RenderBBoxHue is current hue for rendering bounding box in ScRenderBBoxes mode"}, {Name: "SelectedWidget", Doc: "the currently selected/hovered widget through the inspect editor selection mode\nthat should be highlighted with a background color"}, {Name: "SelectedWidgetChan", Doc: "the channel on which the selected widget through the inspect editor\nselection mode is transmitted to the inspect editor after the user is done selecting"}, {Name: "LastRender", Doc: "LastRender captures key params from last render.\nIf different then a new ApplyStyleScene is needed."}, {Name: "StyleMu", Doc: "StyleMu is RW mutex protecting access to Style-related global vars"}, {Name: "ShowIter", Doc: "ShowIter counts up at start of showing a Scene\nto trigger Show event and other steps at start of first show"}, {Name: "ReRender", Doc: "ReRender items are re-rendered after the current pass"}, {Name: "hasShown", Doc: "hasShown is whether this scene has already been shown.\nThis is used to ensure that [events.Show] is only sent once."}, {Name: "DirectRenders", Doc: "DirectRenders are widgets that render directly to the RenderWin\ninstead of rendering into the Scene Pixels image."}}, Instance: &Scene{}})
SceneType is the types.Type for Scene
var ScrimType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Scrim", IDName: "scrim", Doc: "A Scrim is just a dummy Widget used for rendering a Scrim.\nOnly used for its type. Everything else managed by RenderWin.", Embeds: []types.Field{{Name: "WidgetBase"}}, Instance: &Scrim{}})
ScrimType is the types.Type for Scrim
var SeparatorType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Separator", IDName: "separator", Doc: "Separator draws a separator line. It goes in the direction\nspecified by [style.Style.Direction].", Embeds: []types.Field{{Name: "Box"}}, Instance: &Separator{}})
SeparatorType is the types.Type for Separator
var SettingsWindow func()
SettingsWindow opens a window for editing the user settings. It is set to [views.SettingsWindow] if views is imported; otherwise; it is nil.
var SliderType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Slider", IDName: "slider", Doc: "Slider is a slideable widget that provides slider functionality for two Types:\nSlider type provides a movable thumb that represents Value as the center of thumb\nPos position, with room reserved at ends for 1/2 of the thumb size.\nScrollbar has a VisiblePct factor that specifies the percent of the content\ncurrently visible, which determines the size of the thumb, and thus the range of motion\nremaining for the thumb Value (VisiblePct = 1 means thumb is full size, and no remaining\nrange of motion).\nThe Content size (inside the margin and padding) determines the outer bounds of\nthe rendered area.\nThe [styles.Style.Direction] determines the direction in which the slider slides.", Directives: []types.Directive{{Tool: "core", Directive: "embedder"}}, Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the type of the slider, which determines its visual\nand functional properties. The default type, [SliderSlider],\nshould work for most end-user use cases."}, {Name: "Value", Doc: "Value is the current value, represented by the position of the thumb.\nIt defaults to 0.5."}, {Name: "Min", Doc: "Min is the minimum possible value.\nIt defaults to 0."}, {Name: "Max", Doc: "Max is the maximum value supported.\nIt defaults to 1."}, {Name: "Step", Doc: "Step is the amount that the arrow keys increment/decrement the value by.\nIt defaults to 0.1."}, {Name: "EnforceStep", Doc: "EnforceStep is whether to ensure that the value is always\na multiple of [Slider.Step]."}, {Name: "PageStep", Doc: "PageStep is the amount that the PageUp and PageDown keys\nincrement/decrement the value by.\nIt defaults to 0.2, and will be at least as big as [Slider.Step]."}, {Name: "Icon", Doc: "Icon is an optional icon to use for the dragging knob."}, {Name: "VisiblePct", Doc: "For Scrollbar type only: proportion (1 max) of the full range of scrolled data\nthat is currently visible. This determines the thumb size and range of motion:\nif 1, full slider is the thumb and no motion is possible."}, {Name: "ThumbSize", Doc: "Size of the thumb as a proportion of the slider thickness, which is\nContent size (inside the padding). This is for actual X,Y dimensions,\nso must be sensitive to Dim dimension alignment."}, {Name: "TrackSize", Doc: "TrackSize is the proportion of slider thickness for the visible track\nfor the Slider type. It is often thinner than the thumb, achieved by\nvalues < 1 (.5 default)"}, {Name: "InputThreshold", Doc: "threshold for amount of change in scroll value before emitting an input event"}, {Name: "Prec", Doc: "specifies the precision of decimal places (total, not after the decimal point)\nto use in representing the number. This helps to truncate small weird floating\npoint values in the nether regions."}, {Name: "ValueColor", Doc: "The background color that is used for styling the selected value section of the slider.\nIt should be set in the StyleFuncs, just like the main style object is.\nIf it is set to transparent, no value is rendered, so the value section of the slider\njust looks like the rest of the slider."}, {Name: "ThumbColor", Doc: "The background color that is used for styling the thumb (handle) of the slider.\nIt should be set in the StyleFuncs, just like the main style object is.\nIf it is set to transparent, no thumb is rendered, so the thumb section of the slider\njust looks like the rest of the slider."}, {Name: "StayInView", Doc: "If true, keep the slider (typically a Scrollbar) within the parent Scene\nbounding box, if the parent is in view. This is the default behavior\nfor Layout scrollbars, and setting this flag replicates that behavior\nin other scrollbars."}, {Name: "Pos", Doc: "logical position of the slider relative to Size"}, {Name: "LastValue", Doc: "previous Change event emitted value - don't re-emit Change if it is the same"}, {Name: "PrevSlide", Doc: "previous sliding value - for computing the Input change"}, {Name: "Size", Doc: "Computed size of the slide box in the relevant dimension\nrange of motion, exclusive of spacing, based on layout allocation."}, {Name: "SlideStartPos", Doc: "underlying drag position of slider -- not subject to snapping"}}, Instance: &Slider{}})
SliderType is the types.Type for Slider
var SpaceType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Space", IDName: "space", Doc: "Space is a fixed size blank space, with\na default width of 1ch and a height of 1em.\nYou can set [styles.Style.Min] to change its size.", Embeds: []types.Field{{Name: "WidgetBase"}}, Instance: &Space{}})
SpaceType is the types.Type for Space
var SpinnerType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Spinner", IDName: "spinner", Doc: "Spinner combines a TextField with up / down buttons for incrementing /\ndecrementing values -- all configured within the Parts of the widget", Directives: []types.Directive{{Tool: "core", Directive: "embedder"}}, Embeds: []types.Field{{Name: "TextField"}}, Fields: []types.Field{{Name: "Value", Doc: "Value is the current value."}, {Name: "HasMin", Doc: "HasMin is whether there is a minimum value to enforce."}, {Name: "Min", Doc: "Min, if HasMin is true, is the the minimum value in range."}, {Name: "HasMax", Doc: "HaxMax is whether there is a maximum value to enforce."}, {Name: "Max", Doc: "Max, if HasMax is true, is the maximum value in range."}, {Name: "Step", Doc: "Step is the amount that the up and down buttons and arrow keys\nincrement/decrement the value by. It defaults to 0.1."}, {Name: "EnforceStep", Doc: "EnforceStep is whether to ensure that the value of the spinner\nis always a multiple of [Spinner.Step]."}, {Name: "PageStep", Doc: "PageStep is the amount that the PageUp and PageDown keys\nincrement/decrement the value by.\nIt defaults to 0.2, and will be at least as big as [Spinner.Step]."}, {Name: "Prec", Doc: "Prec specifies the precision of decimal places\n(total, not after the decimal point) to use in\nrepresenting the number. This helps to truncate\nsmall weird floating point values."}, {Name: "Format", Doc: "Format is the format string to use for printing the value.\nIf it unset, %g is used. If it is decimal based\n(ends in d, b, c, o, O, q, x, X, or U) then the value is\nconverted to decimal prior to printing."}}, Instance: &Spinner{}})
SpinnerType is the types.Type for Spinner
var SplitsType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Splits", IDName: "splits", Doc: "Splits allocates a certain proportion of its space to each of its children\nalong [styles.Style.Direction]. It adds [Handle] widgets to its parts that\nallow the user to customize the amount of space allocated to each child.", Directives: []types.Directive{{Tool: "core", Directive: "embedder"}}, Embeds: []types.Field{{Name: "Layout"}}, Fields: []types.Field{{Name: "Splits", Doc: "Splits is the proportion (0-1 normalized, enforced) of space\nallocated to each element. 0 indicates that an element should\nbe completely collapsed. By default, each element gets the\nsame amount of space."}, {Name: "SavedSplits", Doc: "SavedSplits is a saved version of the splits that can be restored\nfor dynamic collapse/expand operations."}}, Instance: &Splits{}})
SplitsType is the types.Type for Splits
var StretchType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Stretch", IDName: "stretch", Doc: "Stretch adds a stretchy element that grows to fill all\navailable space. You can set [styles.Style.Grow] to change\nhow much it grows relative to other growing elements.", Embeds: []types.Field{{Name: "WidgetBase"}}, Instance: &Stretch{}})
StretchType is the types.Type for Stretch
var SwitchType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Switch", IDName: "switch", Doc: "Switch is a widget that can toggle between an on and off state.\nIt can be displayed as a switch, checkbox, or radio button.", Embeds: []types.Field{{Name: "Box"}}, Fields: []types.Field{{Name: "Type", Doc: "the type of switch that this is"}, {Name: "Text", Doc: "the label text for the switch"}, {Name: "IconOn", Doc: "icon to use for the on, checked state of the switch"}, {Name: "IconOff", Doc: "icon to use for the off, unchecked state of the switch"}, {Name: "IconIndeterminate", Doc: "icon to use for the indeterminate (unknown) state"}}, Instance: &Switch{}})
SwitchType is the types.Type for Switch
var SwitchesType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Switches", IDName: "switches", Doc: "Switches is a widget for containing a set of switches.\nIt can optionally enforce mutual exclusivity (i.e., Radio Buttons).\nThe buttons are all in the Parts of the widget and the Parts layout\ndetermines how they are displayed.", Directives: []types.Directive{{Tool: "core", Directive: "embedder"}}, Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "Type", Doc: "the type of switches that will be made"}, {Name: "Items", Doc: "Items are the items displayed to the user."}, {Name: "Mutex", Doc: "whether to make the items mutually exclusive (checking one turns off all the others)"}}, Instance: &Switches{}})
SwitchesType is the types.Type for Switches
var SystemSettings = &SystemSettingsData{ SettingsBase: SettingsBase{ Name: "System", File: filepath.Join(TheApp.CogentCoreDataDir(), "system-settings.toml"), }, }
SystemSettings are the currently active Cogent Core system settings.
var TabType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Tab", IDName: "tab", Doc: "Tab is a tab button that contains any, all, or none of a label, an icon,\nand a close icon. Tabs should be made using the [Tabs.NewTab] function.", Directives: []types.Directive{{Tool: "core", Directive: "no-new"}}, Embeds: []types.Field{{Name: "Box"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the styling type of the tab. This property\nmust be set on the parent [Tabs] for it to work correctly."}, {Name: "Text", Doc: "Text is the label text for the tab.\nIf it is nil, no label is shown.\nLabels are never shown for [NavigationRail] tabs."}, {Name: "Icon", Doc: "Icon is the icon for the tab.\nIf it is \"\" or [icons.None], no icon is shown."}, {Name: "CloseIcon", Doc: "CloseIcon is the icon used as a close button for the tab.\nIf it is \"\" or [icons.None], the tab is not closeable.\nThe default value is [icons.Close].\nOnly [FunctionalTabs] can be closed; all other types of\ntabs will not render a close button and can not be closed."}, {Name: "MaxChars", Doc: "Maximum number of characters to include in tab label.\nElides labels that are longer than that"}}, Instance: &Tab{}})
TabType is the types.Type for Tab
var TabsType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Tabs", IDName: "tabs", Doc: "Tabs switches among child widgets via tabs. The selected widget gets\nthe full allocated space avail after the tabs are accounted for. The\nTabs is just a Vertical layout that manages two child widgets: a\nHorizFlow Layout for the tabs (which can flow across multiple rows as\nneeded) and a Stacked Frame that actually contains all the children, and\nprovides scrollbars as needed to any content within. Typically should have\nmax stretch and a set preferred size, so it expands.", Directives: []types.Directive{{Tool: "core", Directive: "embedder"}}, Embeds: []types.Field{{Name: "Layout"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the styling type of the tabs. If it is changed after\nthe tabs are first configured, Update needs to be called on\nthe tabs."}, {Name: "NewTabButton", Doc: "NewTabButton is whether to show a new tab button at the end of the list of tabs."}, {Name: "MaxChars", Doc: "MaxChars is the maximum number of characters to include in the tab label.\nIt elides labels that are longer than that."}, {Name: "CloseIcon", Doc: "CloseIcon is the icon used for tab close buttons.\nIf it is \"\" or [icons.None], the tab is not closeable.\nThe default value is [icons.Close].\nOnly [FunctionalTabs] can be closed; all other types of\ntabs will not render a close button and can not be closed."}, {Name: "PrevEffectiveType", Doc: "PrevEffectiveType is the previous effective type of the tabs\nas computed by [TabTypes.Effective]."}, {Name: "Mu", Doc: "Mu is a mutex protecting updates to tabs. Tabs can be driven\nprogrammatically and via user input so need extra protection."}}, Instance: &Tabs{}})
TabsType is the types.Type for Tabs
var TextFieldType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.TextField", IDName: "text-field", Doc: "TextField is a widget for editing a line of text.\nWith the default WhiteSpaceNormal style setting,\ntext will wrap onto multiple lines as needed.\nSet to WhiteSpaceNowrap (e.g., Styles.SetTextWrap(false)) to\nforce everything to be on a single line.\nWith multi-line wrapped text, the text is still treated as a contiguous\nwrapped text.", Directives: []types.Directive{{Tool: "core", Directive: "embedder"}}, Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "Type", Doc: "Type is the styling type of the text field."}, {Name: "Placeholder", Doc: "Placeholder is the text that is displayed\nwhen the text field is empty."}, {Name: "Validator", Doc: "Validator is a function used to validate the input\nof the text field. If it returns a non-nil error,\nthen an error color, icon, and tooltip will be displayed."}, {Name: "LeadingIcon", Doc: "LeadingIcon, if specified, indicates to add a button\nat the start of the text field with this icon."}, {Name: "LeadingIconOnClick", Doc: "LeadingIconOnClick, if specified, is the function to call when\nthe LeadingIcon is clicked. If this is nil, the leading icon\nwill not be interactive."}, {Name: "TrailingIcon", Doc: "TrailingIcon, if specified, indicates to add a button\nat the end of the text field with this icon."}, {Name: "TrailingIconOnClick", Doc: "TrailingIconOnClick, if specified, is the function to call when\nthe TrailingIcon is clicked. If this is nil, the trailing icon\nwill not be interactive."}, {Name: "NoEcho", Doc: "NoEcho is whether replace displayed characters with bullets to conceal text\n(for example, for a password input)."}, {Name: "CursorWidth", Doc: "CursorWidth is the width of the text field cursor.\nIt should be set in Style like all other style properties.\nBy default, it is 1dp."}, {Name: "CursorColor", Doc: "CursorColor is the color used for the text field cursor (caret).\nIt should be set in Style like all other style properties.\nBy default, it is [colors.Scheme.Primary.Base]."}, {Name: "PlaceholderColor", Doc: "PlaceholderColor is the color used for the Placeholder text.\nIt should be set in Style like all other style properties.\nBy default, it is [colors.Scheme.OnSurfaceVariant]."}, {Name: "SelectColor", Doc: "SelectColor is the color used for the text selection background color.\nIt should be set in Style like all other style properties.\nBy default, it is [colors.Scheme.Select.Container]"}, {Name: "Complete", Doc: "Complete contains functions and data for text field completion.\nIt must be set using [TextField.SetCompleter]."}, {Name: "Txt", Doc: "Txt is the last saved value of the text string being edited."}, {Name: "Edited", Doc: "Edited is whether the text has been edited relative to the original."}, {Name: "EditTxt", Doc: "EditTxt is the live text string being edited, with the latest modifications."}, {Name: "Error", Doc: "Error is the current validation error of the text field."}, {Name: "EffPos", Doc: "EffPos is the effective position with any leading icon space added."}, {Name: "EffSize", Doc: "EffSize is the effective size, subtracting any leading and trailing icon space."}, {Name: "StartPos", Doc: "StartPos is the starting display position in the string."}, {Name: "EndPos", Doc: "EndPos is the ending display position in the string."}, {Name: "CursorPos", Doc: "CursorPos is the current cursor position."}, {Name: "CursorLine", Doc: "CursorLine is the current cursor line position."}, {Name: "CharWidth", Doc: "CharWidth is the approximate number of chars that can be\ndisplayed at any time, which is computed from the font size."}, {Name: "SelectStart", Doc: "SelectStart is the starting position of selection in the string."}, {Name: "SelectEnd", Doc: "SelectEnd is the ending position of selection in the string."}, {Name: "SelectInit", Doc: "SelectInit is the initial selection position (where it started)."}, {Name: "SelectMode", Doc: "SelectMode is whether to select text as the cursor moves."}, {Name: "RenderAll", Doc: "RenderAll is the render version of entire text, for sizing."}, {Name: "RenderVis", Doc: "RenderVis is the render version of just the visible text."}, {Name: "NLines", Doc: "number of lines from last render update, for word-wrap version"}, {Name: "FontHeight", Doc: "FontHeight is the font height cached during styling."}, {Name: "BlinkOn", Doc: "BlinkOn oscillates between on and off for blinking."}, {Name: "CursorMu", Doc: "CursorMu is the mutex for updating the cursor between blinker and field."}, {Name: "UndoMgr", Doc: "the undo manager"}}, Instance: &TextField{}})
TextFieldType is the types.Type for TextField
var TheApp = &App{App: system.TheApp}
TheApp is the current App; only one is ever in effect.
var TheWindowGeometrySaver = WindowGeometrySaver{}
TheWindowGeometrySaver is the manager of window geometry settings
var ToolbarType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.Toolbar", IDName: "toolbar", Doc: "Toolbar is a [Frame] that is useful for holding [Button]s that do things.\nIt automatically moves items that do not fit into an overflow menu, and\nmanages additional items that are always placed onto this overflow menu.\nIn general it should be possible to use a single toolbar + overflow to\nmanage all an app's functionality, in a way that is portable across\nmobile and desktop environments.\nSee [Widget.ConfigToolbar] for the standard toolbar config method for\nany given widget, and [Scene.AppBars] for [ToolbarFuncs] for [Scene]\nelements who should be represented in the main AppBar (e.g., TopAppBar).", Directives: []types.Directive{{Tool: "core", Directive: "embedder"}}, Methods: []types.Method{{Name: "StandardOverflowMenu", Doc: "StandardOverflowMenu adds standard overflow menu items.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Args: []string{"m"}}}, Embeds: []types.Field{{Name: "Frame"}}, Fields: []types.Field{{Name: "OverflowItems", Doc: "items moved from the main toolbar, will be shown in the overflow menu"}, {Name: "OverflowMenus", Doc: "functions for overflow menu: use AddOverflowMenu to add.\nThese are processed in _reverse_ order (last in, first called)\nso that the default items are added last."}, {Name: "ToolbarFuncs", Doc: "ToolbarFuncs contains functions for configuring this toolbar,\ncalled on Config"}, {Name: "OverflowButton", Doc: "This is the overflow button"}}, Instance: &Toolbar{}})
ToolbarType is the types.Type for Toolbar
var WidgetBaseType = types.AddType(&types.Type{Name: "cogentcore.org/core/core.WidgetBase", IDName: "widget-base", Doc: "WidgetBase is the base type for all Widget Widget elements, which are\nmanaged by a containing Layout, and use all 5 rendering passes. All\nelemental widgets must support the ReadOnly and Selected states in a\nreasonable way (Selected only essential when also ReadOnly), so they can\nfunction appropriately in a chooser (e.g., SliceView or TableView) -- this\nincludes toggling selection on left mouse press.", Directives: []types.Directive{{Tool: "core", Directive: "no-new"}}, Methods: []types.Method{{Name: "Update", Doc: "Update does a general purpose update of the widget and everything\nbelow it by reconfiguring it, applying its styles, and indicating\nthat it needs a new layout pass. It is the main way that end users\nshould update widgets, and it should be called after making any\nchanges to the core properties of a widget (for example, the text\nof a label, the icon of a button, or the slice of a table view).\n\nIf you are calling this in a separate goroutine outside of the main\nconfiguration, rendering, and event handling structure, you need to\ncall [WidgetBase.AsyncLock] and [WidgetBase.AsyncUnlock] before and\nafter this, respectively.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}}, Embeds: []types.Field{{Name: "NodeBase"}}, Fields: []types.Field{{Name: "Tooltip", Doc: "Tooltip is the text for the tooltip for this widget,\nwhich can use HTML formatting."}, {Name: "Parts", Doc: "Parts are a separate tree of sub-widgets that implement discrete parts\nof a widget. Positions are relative to the parent widget.\nThese are fully managed by the parent widget"}, {Name: "Geom", Doc: "Geom has the full layout geometry for size and position of this Widget"}, {Name: "OverrideStyle", Doc: "If true, Override the computed styles and allow directly editing Style"}, {Name: "Styles", Doc: "Styles are styling settings for this widget.\nThese are set in SetApplyStyle which should be called after any Config\nchange (e.g., as done by the Update method). See Stylers for functions\nthat set all of the styles, ordered from initial base defaults to later\nadded overrides."}, {Name: "Stylers", Doc: "Stylers are a slice of functions that are called in sequential\nascending order (so the last added styler is called last and\nthus overrides all other functions) to style the element.\nThese should be set using Style function. FirstStylers and\nFinalStylers are called before and after these stylers, respectively."}, {Name: "FirstStylers", Doc: "FirstStylers are a slice of functions that are called in sequential\nascending order (so the last added styler is called last and\nthus overrides all other functions) to style the element.\nThese should be set using StyleFirst function. These stylers\nare called before Stylers and FinalStylers."}, {Name: "FinalStylers", Doc: "FinalStylers are a slice of functions that are called in sequential\nascending order (so the last added styler is called last and\nthus overrides all other functions) to style the element.\nThese should be set using StyleFinal function. These stylers\nare called after FirstStylers and Stylers."}, {Name: "Listeners", Doc: "Listeners are event listener functions for processing events on this widget.\nThey are called in sequential descending order (so the last added listener\nis called first). They should be added using the On function. FirstListeners\nand FinalListeners are called before and after these listeners, respectively."}, {Name: "FirstListeners", Doc: "FirstListeners are event listener functions for processing events on this widget.\nThey are called in sequential descending order (so the last added listener\nis called first). They should be added using the OnFirst function. These listeners\nare called before Listeners and FinalListeners."}, {Name: "FinalListeners", Doc: "FinalListeners are event listener functions for processing events on this widget.\nThey are called in sequential descending order (so the last added listener\nis called first). They should be added using the OnFinal function. These listeners\nare called after FirstListeners and Listeners."}, {Name: "OnWidgetAdders", Doc: "A slice of functions to call on all widgets that are added as children\nto this widget or its children. These functions are called in sequential\nascending order, so the last added one is called last and thus can\noverride anything set by the other ones. These should be set using\nOnWidgetAdded, which can be called by both end-user and internal code."}, {Name: "ContextMenus", Doc: "ContextMenus is a slice of menu functions to call to construct\nthe widget's context menu on an [events.ContextMenu]. The\nfunctions are called in reverse order such that the elements\nadded in the last function are the first in the menu.\nContext menus should be added through [Widget.AddContextMenu].\nSeparators will be added between each context menu function."}, {Name: "Scene", Doc: "Scene is the overall Scene to which we belong. It is automatically\nby widgets whenever they are added to another widget parent."}}, Instance: &WidgetBase{}})
WidgetBaseType is the types.Type for WidgetBase
var WindowWait sync.WaitGroup
WindowWait is a wait group for waiting for all the open window event loops to finish. It is incremented by RenderWindow.GoStartEventLoop and decremented when the event loop terminates.
Functions ¶
func ActivateExistingDialogWindow ¶
ActivateExistingDialogWindow looks for existing dialog window with given Data. If found brings that to the front, returns true for bool, else false.
func ActivateExistingMainWindow ¶
ActivateExistingMainWindow looks for existing window with given Data. If found brings that to the front, returns true for bool, else false.
func AddButtonItems ¶
func AddButtonItems(items *[]ChooserItem, parent tree.Node, path string)
AddButtonItems adds to the given items all of the buttons under the given parent. It navigates through button menus to find other buttons using a recursive approach that updates path with context about the original button menu. Consumers of this function should typically set path to "".
func AsWidget ¶
func AsWidget(n tree.Node) (Widget, *WidgetBase)
AsWidget returns the given tree node as a Widget interface and a WidgetBase.
func ChildByLabelCanFocus ¶
ChildByLabelCanFocus uses breadth-first search to find the first focusable element within the layout whose Label (using ToLabel) matches the given name using complete.IsSeedMatching. If after is non-nil, it only finds after that element.
func CompleteEditText ¶
CompleteEditText is a chance to modify the completion selection before it is inserted
func ConcealDots ¶
ConcealDots creates an n-length []rune of bullet characters.
func CurrentWindowAppBar ¶
func CurrentWindowAppBar(tb *Toolbar)
CurrentWindowAppBar calls ConfigToolbar functions registered on the Scene to which the given toolbar belongs.
func EndCPUMemProfile ¶
func EndCPUMemProfile()
EndCPUMemProfile ends the standard Go cpu and memory profiling.
func EndTargProfile ¶
func EndTargProfile()
EndTargProfile ends targeted profiling and prints report.
func ErrorDialog ¶
ErrorDialog opens a new Dialog displaying the given error in the context of the given widget. An optional title can be provided; if it is not, the title will default to "There was an error". If the given error is nil, no dialog is created.
func ErrorSnackbar ¶
ErrorSnackbar opens a [Snackbar] displaying the given error in the context of the given widget. Optional label text can be provided; if it is not, the label text will default to "Error". If the given error is nil, no snackbar. is created.
func GrabRenderFrom ¶
GrabRenderFrom grabs the rendered image from the given widget. If it returns nil, then the image could not be fetched.
func HandleRecover ¶
func HandleRecover(r any)
HandleRecover is the core value of system.HandleRecover. If r is not nil, it makes a window displaying information about the panic. system.HandleRecover is initialized to this in init.
func IsWordBreak ¶
IsWordBreak defines what counts as a word break for the purposes of selecting words. r1 is the rune in question, r2 is the rune past r1 in the direction you are moving. Pass -1 for r2 if there is no rune past r1.
func LoadAllSettings ¶
func LoadAllSettings() error
LoadAllSettings sets the defaults of, opens, and applies AllSettings.
func LoadSettings ¶
LoadSettings sets the defaults of, opens, and applies the given settings. If they are not already saved, it saves them. It process their `default:` struct tags in addition to calling their [Settings.Default] method.
func MenuSceneConfigStyles ¶
func MenuSceneConfigStyles(msc *Scene)
MenuSceneConfigStyles configures the default styles for the given pop-up menu frame with the given parent. It should be called on menu frames when they are created.
func MessageDialog ¶
MessageDialog opens a new Dialog displaying the given message in the context of the given widget. An optional title can be provided.
func MessageSnackbar ¶
MessageSnackbar opens a [Snackbar] displaying the given message in the context of the given widget.
func OpenRecentPaths ¶
func OpenRecentPaths()
OpenRecentPaths loads the active RecentPaths from data dir
func OpenSettings ¶
OpenSettings opens the given settings from their [Settings.Filename]. The settings are assumed to be in TOML unless they have a .json file extension. If they satisfy the SettingsOpener interface, [SettingsOpener.Open] will be used instead.
func ProfileToggle ¶
func ProfileToggle()
ProfileToggle turns profiling on or off, which does both targeted and global CPU and Memory profiling.
func RecycleDialog ¶
RecycleDialog looks for a dialog with the given data. If it finds it, it shows it and returns true. Otherwise, it returns false.
func ResetAllSettings ¶
func ResetAllSettings() error
ResetAllSettings resets all of the settings to their default values.
func ResetSettings ¶
ResetSettings resets the given settings to their default values.
func SaveRecentPaths ¶
func SaveRecentPaths()
SaveRecentPaths saves the active RecentPaths to data dir
func SaveSettings ¶
SaveSettings saves the given settings to their [Settings.Filename]. The settings will be encoded in TOML unless they have a .json file extension. If they satisfy the SettingsSaver interface, [SettingsSaver.Save] will be used instead. Any non default fields are not saved, following reflectx.NonDefaultFields.
func SetUnitContext ¶
SetUnitContext sets the unit context based on size of scene, element, and parent element (from bbox) and then caches everything out in terms of raw pixel dots for rendering. Zero values for element and parent size are ignored.
func StandardAppBarConfig ¶
func StandardAppBarConfig(parent Widget)
StandardAppBarConfig is the standard impl for a [App.AppBarConfig]. It adds a Back navigation buttons and the AppChooser, followed by the [Widget.ConfigToolbar] for the current FullWindow Scene being viewed, along with StandardOverflowMenu items. and calls AddDefaultOverflowMenu to provide default menu items, which will appear below any other OverflowMenu items added.
func StandardAppBarStart ¶
func StandardAppBarStart(tb *Toolbar)
StandardAppBarStart adds standard items to start of an AppBar: StandardAppBarBack and StandardAppBarChooser
func StandardOverflowMenu ¶
func StandardOverflowMenu(tb *Toolbar)
StandardOverflowMenu adds the standard overflow menu function.
func StartCPUMemProfile ¶
func StartCPUMemProfile()
StartCPUMemProfile starts the standard Go cpu and memory profiling.
func StartTargProfile ¶
func StartTargProfile()
StartTargProfile starts targeted profiling using the prof package.
func StringsInsertFirstUnique ¶
StringsInsertFirstUnique inserts the given string at the start of the given string slice while keeping the overall length to the given max value. If the item is already on the list, then it is moved to the top and not re-added (unique items only). This is useful for a list of recent items.
func TextWrapSizeEstimate ¶
TextWrapSizeEstimate is the size to use for layout during the SizeUp pass, for word wrap case, where the sizing actually matters, based on trying to fit the given number of characters into the given content size with given font height.
func ToLabel ¶
ToLabel returns the gui-appropriate label for an item, using the Labeler interface if it is defined, and falling back on reflectx.ToString converter otherwise -- also contains label impls for basic interface types for which we cannot easily define the Labeler interface
func ToolbarStyles ¶
func ToolbarStyles(ly Layouter)
ToolbarStyles can be applied to any layout (e.g., Frame) to achieve standard toolbar styling.
func UpdateAll ¶
func UpdateAll()
UpdateAll updates all windows and triggers a full render rebuild. It is typically called when user settings are changed.
func Wait ¶
func Wait()
Wait waits for all windows to close and runs the main app loop. This should be put at the end of the main function, and is typically called through Stage.Wait.
Types ¶
type App ¶
type App struct { system.App `set:"-"` // Icon specifies the app icon, which is passed to [system.Window.SetIcon]. // It should typically be set using [App.SetIconSVG]. Icon []image.Image // AppBarConfig is the function that configures the AppBar, // typically put in the [Scene.Bars.Top] (i.e., a TopAppBar). // It is set to StdAppBarConfig by default, which makes the // standard AppBar behavior. If this is nil, then no AppBar // will be created by default. AppBarConfig func(parent Widget) // SceneConfig is the function called on every newly created [core.Scene] // to configure it, if it is non-nil. This can be used to set global // configuration and styling for all widgets using the OnWidgetAdded // method. SceneConfig func(sc *Scene) }
App represents a Cogent Core app. It extends system.App to provide both system-level and high-level data and functions to do with the currently running application. The single instance of it is TheApp, which embeds system.TheApp.
func (*App) SetAppBarConfig ¶
SetAppBarConfig sets the [App.AppBarConfig]: AppBarConfig is the function that configures the AppBar, typically put in the [Scene.Bars.Top] (i.e., a TopAppBar). It is set to StdAppBarConfig by default, which makes the standard AppBar behavior. If this is nil, then no AppBar will be created by default.
func (*App) SetIcon ¶
SetIcon sets the [App.Icon]: Icon specifies the app icon, which is passed to system.Window.SetIcon. It should typically be set using App.SetIconSVG.
func (*App) SetIconBytes ¶
SetIconBytes sets the icon of the app to the given SVG icon bytes. It automatically logs any errors.
func (*App) SetIconSVG ¶
SetIconSVG sets the icon of the app to the given SVG icon. It automatically logs any errors.
func (*App) SetSceneConfig ¶
SetSceneConfig sets the [App.SceneConfig]: SceneConfig is the function called on every newly created core.Scene to configure it, if it is non-nil. This can be used to set global configuration and styling for all widgets using the OnWidgetAdded method.
type AppearanceSettingsData ¶
type AppearanceSettingsData struct { SettingsBase // the color theme Theme Themes `default:"Auto"` // the primary color used to generate the color scheme Color color.RGBA `default:"#4285f4"` // overall zoom factor as a percentage of the default zoom Zoom float32 `default:"100" min:"10" max:"500" step:"10" format:"%g%%"` // the overall spacing factor as a percentage of the default amount of spacing // (higher numbers lead to more space and lower numbers lead to higher density) Spacing float32 `default:"100" min:"10" max:"500" step:"10" format:"%g%%"` // the overall font size factor applied to all text as a percentage // of the default font size (higher numbers lead to larger text) FontSize float32 `default:"100" min:"10" max:"500" step:"10" format:"%g%%"` // the amount that alternating rows are highlighted when showing tabular data (set to 0 to disable zebra striping) ZebraStripes float32 `default:"0" min:"0" max:"100" step:"10" format:"%g%%"` // screen-specific settings, which will override overall defaults if set Screens map[string]ScreenSettings // text highlighting style / theme HiStyle HiStyleName `default:"emacs"` // default font family when otherwise not specified FontFamily FontName `default:"Roboto"` // default mono-spaced font family MonoFont FontName `default:"Roboto Mono"` }
AppearanceSettingsData is the data type for the global Cogent Core appearance settings.
func (*AppearanceSettingsData) Apply ¶
func (as *AppearanceSettingsData) Apply()
func (*AppearanceSettingsData) ApplyDPI ¶
func (as *AppearanceSettingsData) ApplyDPI()
ApplyDPI updates the screen LogicalDPI values according to current settings and zoom factor, and then updates all open windows as well.
func (*AppearanceSettingsData) DeleteSavedWindowGeoms ¶
func (as *AppearanceSettingsData) DeleteSavedWindowGeoms()
DeleteSavedWindowGeoms deletes the file that saves the position and size of each window, by screen, and clear current in-memory cache. You shouldn't generally need to do this, but sometimes it is useful for testing or windows that are showing up in bad places that you can't recover from.
func (*AppearanceSettingsData) SaveScreenZoom ¶
func (as *AppearanceSettingsData) SaveScreenZoom()
SaveScreenZoom saves the current zoom factor for current screen.
func (*AppearanceSettingsData) ShouldShow ¶
func (as *AppearanceSettingsData) ShouldShow(field string) bool
func (*AppearanceSettingsData) ZebraStripesWeight ¶
func (as *AppearanceSettingsData) ZebraStripesWeight() float32
ZebraStripesWeight returns a 0 to 0.2 alpha opacity factor to use in computing a zebra stripe color.
type BarFuncs ¶
type BarFuncs []func(parent Widget)
BarFuncs are functions for creating control bars, attached to different sides of a Scene (e.g., TopAppBar at Top, NavBar at Bottom, etc). Functions are called in forward order so first added are called first.
type BasicBar ¶
type BasicBar struct {
Frame
}
BasicBar is just a styled Frame layout for holding buttons and other widgets. Use this when the more advanced features of the Toolbar are not needed.
func NewBasicBar ¶
NewBasicBar adds a new BasicBar with the given name to the given parent: BasicBar is just a styled Frame layout for holding buttons and other widgets. Use this when the more advanced features of the Toolbar are not needed.
func (*BasicBar) NodeType ¶
NodeType returns the *types.Type of BasicBar
func (*BasicBar) SetTooltip ¶
SetTooltip sets the [BasicBar.Tooltip]
type Blinker ¶
type Blinker struct { // Ticker is the time.Ticker Ticker *time.Ticker // Widget is the current widget subject to blinking Widget Widget // Func is the function called every tick -- under Mu mutex protection Func func(w Widget) Quit chan struct{} Mu sync.Mutex }
Blinker manages the logistics of blinking things, such as cursors
func (*Blinker) BlinkLoop ¶
func (bl *Blinker) BlinkLoop()
BlinkLoop is the blinker's main control loop
func (*Blinker) QuitClean ¶
func (bl *Blinker) QuitClean()
QuitClean is a cleanup function to call during Quit that breaks out of the ticker loop
func (*Blinker) ResetWidget ¶
ResetWidget sets Widget = nil if it is currently set to given one
type Body ¶
type Body struct { Frame // title of the Body, also used for window title where relevant Title string `set:"-"` }
Body holds the primary content of a Scene
func NewBody ¶
NewBody creates a new Body that will serve as the content of a Scene (e.g., a Window, Dialog, etc). Body forms the central region of a Scene, and has OverflowAuto scrollbars by default. It will create its own parent Scene at this point, and has wrapper functions to transparently manage everything that the Scene typically manages during configuration, so you can usually avoid having to access the Scene directly. If a name is given and the name of TheApp is unset, it sets it to the given name.
func (*Body) AddBottomBar ¶
AddBottomBar adds the given function for configuring a control bar at the bottom of the window
func (*Body) AddCancel ¶
AddCancel adds Cancel button to given parent Widget (typically in Bottom Bar function), connecting to Close method and the Esc keychord event. Close sends a Change event to the Scene for listeners there. Should add an OnClick listener to this button to perform additional specific actions needed beyond Close. Name should be passed when there are multiple effective Cancel buttons (rare).
func (*Body) AddLeftBar ¶
AddLeftBar adds the given function for configuring a control bar on the left of the window
func (*Body) AddOK ¶
AddOK adds an OK button to given parent Widget (typically in Bottom Bar function), connecting to Close method the Ctrl+Enter keychord event. Close sends a Change event to the Scene for listeners there. Should add an OnClick listener to this button to perform additional specific actions needed beyond Close. Name should be passed when there are multiple effective OK buttons.
func (*Body) AddOKOnly ¶
AddOKOnly just adds an OK button in the BottomBar for simple popup dialogs that just need that one button
func (*Body) AddRightBar ¶
AddRightBar adds the given function for configuring a control bar on the right of the window
func (*Body) AddSnackbarButton ¶
AddSnackbarButton adds a snackbar button with the given text and optional OnClick event handler. Only the first of the given event handlers is used, and the snackbar is automatically closed when the button is clicked regardless of whether there is an event handler passed.
func (*Body) AddSnackbarIcon ¶
AddSnackbarIcon adds a snackbar icon button with the given icon and optional OnClick event handler. Only the first of the given event handlers is used, and the snackbar is automatically closed when the button is clicked regardless of whether there is an event handler passed.
func (*Body) AddSnackbarText ¶
AddSnackbarText adds a snackbar label with the given text
func (*Body) AddTitle ¶
AddTitle adds a Label with given title, and sets the Title text which will be used by the Scene etc.
func (*Body) AddTopBar ¶
AddTopBar adds the given function for configuring a control bar at the top of the window
func (*Body) AssertRender ¶
AssertRender makes a new window from the body, waits until it is shown and all events have been handled, does any necessary re-rendering, asserts that its rendered image is the same as that stored at the given filename, saving the image to that filename if it does not already exist, and then closes the window. It does not return until all of those steps are completed. If a function is passed for the final argument, it is called after the scene is shown. A testdata directory and png file extension are automatically added to the the filename, and forward slashes are automatically replaced with backslashes on Windows. See Body.AssertScreenRender for a version that asserts the rendered image of the entire screen, not just this body.
func (*Body) AssertScreenRender ¶
AssertScreenRender is the same as Body.AssertRender except that it asserts the rendered image of the entire screen, not just this body. It should be used for multi-scene tests like those of snackbars and dialogs.
func (*Body) Close ¶
func (bd *Body) Close()
Close closes the stage associated with this Body (typically for dialogs)
func (*Body) DialogStyles ¶
func (bd *Body) DialogStyles()
DialogStyles sets default stylers for dialog bodies. It is automatically called in Body.NewDialog.
func (*Body) GetTopAppBar ¶
GetTopAppBar returns the TopAppBar Toolbar if it exists, nil otherwise.
func (*Body) NewDialog ¶
NewDialog returns a new DialogStage that does not take up the full window it is created in, in the context of the given widget. See Body.NewFullDialog for a full-window dialog.
func (*Body) NewFullDialog ¶
NewFullDialog returns a new DialogStage that takes up the full window it is created in, in the context of the given widget, optionally with the given name. See Body.NewDialog for a non-full-window dialog.
func (*Body) NewSnackbar ¶
NewSnackbar returns a new SnackbarStage in the context of the given widget.
func (*Body) NewWindow ¶
NewWindow returns a new Window stage with the body contents. Make further configuration choices using Set* methods, which can be chained directly after the New call. Use an appropriate Run call at the end to start the Stage running.
func (*Body) NodeType ¶
NodeType returns the *types.Type of Body
func (*Body) RunAndShowNewWindow ¶
func (b *Body) RunAndShowNewWindow()
RunAndShowNewWindow runs a new window and waits for it to be shown. It it used internally in test infrastructure, and it should typically not be used by end users.
func (*Body) RunMainWindow ¶
func (bd *Body) RunMainWindow()
RunMainWindow creates a new main window from the body, runs it, starts the app's main loop, and waits for all windows to close. It should typically be called once by every app at the end of their main function. It can not be called more than once for one app. For more specific configuration and for secondary windows, see Body.NewWindow.
func (*Body) SetTitle ¶
SetTitle sets the title in the Body, Scene, and Stage, RenderWin, and title widget. This is the one place to change the title for everything.
func (*Body) SetTooltip ¶
SetTooltip sets the [Body.Tooltip]
func (*Body) SnackbarStyles ¶
func (bd *Body) SnackbarStyles()
SnackbarStyles sets default stylers for snackbar bodies. It is automatically called in Body.NewSnackbar.
func (*Body) WaitNoEvents ¶
func (b *Body) WaitNoEvents()
WaitNoEvents waits for all events to be handled and does any rendering of the body necessary. It it used internally in test infrastructure, and it should typically not be used by end users.
type Box ¶
type Box struct {
WidgetBase
}
Box is a simple base Widget that renders the standard box model.
type Button ¶
type Button struct { Box // Type is the type of button. Type ButtonTypes // Text is the label text for the button. // If it is blank, no label is shown. Text string `set:"-"` // Icon is the icon for the button. // If it is "" or [icons.None], no icon is shown. Icon icons.Icon `xml:"icon" view:"show-name"` // Indicator is the menu indicator icon to present. // If it is "" or [icons.None],, no indicator is shown. // It is automatically set to [icons.KeyboardArrowDown] // when there is a Menu elements present unless it is // set to [icons.None]. Indicator icons.Icon `xml:"indicator" view:"show-name"` // Shortcut is an optional shortcut keyboard chord to trigger this button, // active in window-wide scope. Avoid conflicts with other shortcuts // (a log message will be emitted if so). Shortcuts are processed after // all other processing of keyboard input. Use Command for // Control / Meta (Mac Command key) per platform. Shortcut key.Chord `xml:"shortcut"` // Menu is a menu constructor function used to build and display // a menu whenever the button is clicked. There will be no menu // if it is nil. The constructor function should add buttons // to the Scene that it is passed. Menu func(m *Scene) `json:"-" xml:"-"` }
Button is an interactive button with text, an icon, an indicator, a shortcut, and/or a menu. The standard behavior is to register a click event handler with OnClick.
func AsButton ¶
AsButton returns the given value as a value of type Button if the type of the given value embeds Button, or nil otherwise
func NewButton ¶
NewButton adds a new Button with the given name to the given parent: Button is an interactive button with text, an icon, an indicator, a shortcut, and/or a menu. The standard behavior is to register a click event handler with OnClick.
func StandardAppBarBack ¶
StandardAppBarBack adds a back button
func (*Button) AsButton ¶
AsButton satisfies the ButtonEmbedder interface
func (*Button) HandleClickDismissMenu ¶
func (bt *Button) HandleClickDismissMenu()
func (*Button) HandleEvents ¶
func (bt *Button) HandleEvents()
func (*Button) HasMenu ¶
HasMenu returns true if the button has a menu that pops up when it is clicked (not that it is in a menu itself; see ButtonMenu)
func (*Button) IconWidget ¶
IconWidget returns the icon widget if present
func (*Button) LabelWidget ¶
LabelWidget returns the label widget if present
func (*Button) NodeType ¶
NodeType returns the *types.Type of Button
func (*Button) OpenMenu ¶
OpenMenu will open any menu associated with this element. Returns true if menu opened, false if not.
func (*Button) SetIcon ¶
SetIcon sets the [Button.Icon]: Icon is the icon for the button. If it is "" or icons.None, no icon is shown.
func (*Button) SetIndicator ¶
SetIndicator sets the [Button.Indicator]: Indicator is the menu indicator icon to present. If it is "" or icons.None,, no indicator is shown. It is automatically set to icons.KeyboardArrowDown when there is a Menu elements present unless it is set to icons.None.
func (*Button) SetKey ¶
SetKey sets the shortcut of the button from the given keymap.Functions
func (*Button) SetMenu ¶
SetMenu sets the [Button.Menu]: Menu is a menu constructor function used to build and display a menu whenever the button is clicked. There will be no menu if it is nil. The constructor function should add buttons to the Scene that it is passed.
func (*Button) SetShortcut ¶
SetShortcut sets the [Button.Shortcut]: Shortcut is an optional shortcut keyboard chord to trigger this button, active in window-wide scope. Avoid conflicts with other shortcuts (a log message will be emitted if so). Shortcuts are processed after all other processing of keyboard input. Use Command for Control / Meta (Mac Command key) per platform.
func (*Button) SetText ¶
SetText sets the [Button.Text]: Text is the label text for the button. If it is blank, no label is shown.
func (*Button) SetTooltip ¶
SetTooltip sets the [Button.Tooltip]
func (*Button) SetType ¶
func (t *Button) SetType(v ButtonTypes) *Button
SetType sets the [Button.Type]: Type is the type of button.
func (*Button) WidgetTooltip ¶
type ButtonEmbedder ¶
type ButtonEmbedder interface {
AsButton() *Button
}
ButtonEmbedder is an interface that all types that embed Button satisfy
type ButtonTypes ¶
type ButtonTypes int32 //enums:enum -trim-prefix Button
ButtonTypes is an enum containing the different possible types of buttons.
const ( // ButtonFilled is a filled button with a // contrasting background color. It should be // used for prominent actions, typically those // that are the final in a sequence. It is equivalent // to Material Design's filled button. ButtonFilled ButtonTypes = iota // ButtonTonal is a filled button, similar // to [ButtonFilled]. It is used for the same purposes, // but it has a lighter background color and less emphasis. // It is equivalent to Material Design's filled tonal button. ButtonTonal // ButtonElevated is an elevated button with // a light background color and a shadow. // It is equivalent to Material Design's elevated button. ButtonElevated // ButtonOutlined is an outlined button that is // used for secondary actions that are still important. // It is equivalent to Material Design's outlined button. ButtonOutlined // ButtonText is a low-importance button with no border, // background color, or shadow when not being interacted with. // It renders primary-colored text, and it renders a background // color and shadow when hovered/focused/active. // It should only be used for low emphasis // actions, and you must ensure it stands out from the // surrounding context sufficiently. It is equivalent // to Material Design's text button, but it can also // contain icons and other things. ButtonText // ButtonAction is a simple button that typically serves // as a simple action among a series of other buttons // (eg: in a toolbar), or as a part of another widget, // like a spinner or snackbar. It has no border, background color, // or shadow when not being interacted with. It inherits the text // color of its parent, and it renders a background when // hovered/focused/active. you must ensure it stands out from the // surrounding context sufficiently. It is equivalent to Material Design's // icon button, but it can also contain text and other things (and frequently does). ButtonAction // ButtonMenu is similar to [ButtonAction], but it is only // for buttons located in popup menus. ButtonMenu )
const ButtonTypesN ButtonTypes = 7
ButtonTypesN is the highest valid value for type ButtonTypes, plus one.
func ButtonTypesValues ¶
func ButtonTypesValues() []ButtonTypes
ButtonTypesValues returns all possible values for the type ButtonTypes.
func (ButtonTypes) Desc ¶
func (i ButtonTypes) Desc() string
Desc returns the description of the ButtonTypes value.
func (ButtonTypes) Int64 ¶
func (i ButtonTypes) Int64() int64
Int64 returns the ButtonTypes value as an int64.
func (ButtonTypes) MarshalText ¶
func (i ButtonTypes) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*ButtonTypes) SetInt64 ¶
func (i *ButtonTypes) SetInt64(in int64)
SetInt64 sets the ButtonTypes value from an int64.
func (*ButtonTypes) SetString ¶
func (i *ButtonTypes) SetString(s string) error
SetString sets the ButtonTypes value from its string representation, and returns an error if the string is invalid.
func (ButtonTypes) String ¶
func (i ButtonTypes) String() string
String returns the string representation of this ButtonTypes value.
func (*ButtonTypes) UnmarshalText ¶
func (i *ButtonTypes) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (ButtonTypes) Values ¶
func (i ButtonTypes) Values() []enums.Enum
Values returns all possible values for the type ButtonTypes.
type Canvas ¶
type Canvas struct { Box // Draw is the function used to draw the content of the // canvas every time that it is rendered. The paint context // is automatically normalized to the size of the canvas, // so you should specify points on a 0-1 scale. Draw func(pc *paint.Context) // Context is the paint context used for drawing. Context *paint.Context `set:"-"` }
Canvas is a widget that can be arbitrarily drawn to by setting its Draw function using Canvas.SetDraw.
func NewCanvas ¶
NewCanvas adds a new Canvas with the given name to the given parent: Canvas is a widget that can be arbitrarily drawn to by setting its Draw function using Canvas.SetDraw.
func (*Canvas) NodeType ¶
NodeType returns the *types.Type of Canvas
func (*Canvas) SetDraw ¶
SetDraw sets the [Canvas.Draw]: Draw is the function used to draw the content of the canvas every time that it is rendered. The paint context is automatically normalized to the size of the canvas, so you should specify points on a 0-1 scale.
func (*Canvas) SetTooltip ¶
SetTooltip sets the [Canvas.Tooltip]
type Chooser ¶
type Chooser struct { Box // Type is the styling type of the chooser. Type ChooserTypes // Items are the chooser items available for selection. Items []ChooserItem // Icon is an optional icon displayed on the left side of the chooser. Icon icons.Icon `view:"show-name"` // Indicator is the icon to use for the indicator displayed on the // right side of the chooser. Indicator icons.Icon `view:"show-name"` // Editable is whether provide a text field for editing the value, // or just a button for selecting items. Editable bool // AllowNew is whether to allow the user to add new items to the // chooser through the editable textfield (if Editable is set to // true) and a button at the end of the chooser menu. See also [DefaultNew]. AllowNew bool // DefaultNew configures the chooser to accept new items, as in // [AllowNew], and also turns off completion popups and always // adds new items to the list of items, without prompting. // Use this for cases where the typical use-case is to enter new values, // but the history of prior values can also be useful. DefaultNew bool // Placeholder, if Editable is set to true, is the text that is // displayed in the text field when it is empty. It must be set // using [Chooser.SetPlaceholder]. Placeholder string `set:"-"` // ItemsFuncs is a slice of functions to call before showing the items // of the chooser, which is typically used to configure them // (eg: if they are based on dynamic data). The functions are called // in ascending order such that the items added in the first function // will appear before those added in the last function. Use // [Chooser.AddItemsFunc] to add a new items function. If at least // one ItemsFunc is specified, the items of the chooser will be // cleared before calling the functions. ItemsFuncs []func() `copier:"-" json:"-" xml:"-" set:"-"` // CurrentItem is the currently selected item. CurrentItem ChooserItem `json:"-" xml:"-" set:"-"` // CurrentIndex is the index of the currently selected item // in [Chooser.Items]. CurrentIndex int `json:"-" xml:"-" set:"-"` }
Chooser is for selecting items from a dropdown list, with an optional edit TextField for typing directly. The items can be of any type, including enum values -- they are converted to strings for the display. If the items are of type icons.Icon, then they are displayed using icons instead.
func ConfigAppChooser ¶
ConfigAppChooser configures the given Chooser to give access to all app resources, such as open scenes and buttons in the given toolbar. This chooser is typically placed at the start of the AppBar. You can extend the resources available for access in the app chooser using Chooser.AddItemsFunc and [ChooserItem.Func].
func NewChooser ¶
NewChooser adds a new Chooser with the given name to the given parent: Chooser is for selecting items from a dropdown list, with an optional edit TextField for typing directly. The items can be of any type, including enum values -- they are converted to strings for the display. If the items are of type icons.Icon, then they are displayed using icons instead.
func StandardAppBarChooser ¶
StandardAppBarChooser adds an AppChooser
func (*Chooser) AddItemsFunc ¶
AddItemsFunc adds the given function to [Chooser.ItemsFuncs]. These functions are called before showing the items of the chooser, and they are typically used to configure them (eg: if they are based on dynamic data). The functions are called in ascending order such that the items added in the first function will appear before those added in the last function. If at least one ItemsFunc is specified, the items, labels, icons, and tooltips of the chooser will be cleared before calling the functions.
func (*Chooser) CallItemsFuncs ¶
func (ch *Chooser) CallItemsFuncs()
CallItemsFuncs calls [Chooser.ItemsFuncs].
func (*Chooser) CompleteEdit ¶
func (ch *Chooser) CompleteEdit(data any, text string, cursorPos int, completion complete.Completion, seed string) (ed complete.Edit)
CompleteEdit is the complete.EditFunc used for the editable textfield part of the Chooser (if it exists).
func (*Chooser) CompleteMatch ¶
CompleteMatch is the complete.MatchFunc used for the editable text field part of the Chooser (if it exists).
func (*Chooser) FindItem ¶
FindItem finds the given item value on the list of items and returns its index
func (*Chooser) HandleChooserTextFieldEvents ¶
func (*Chooser) HandleEvents ¶
func (ch *Chooser) HandleEvents()
func (*Chooser) LabelWidget ¶
LabelWidget returns the label widget if present.
func (*Chooser) MakeItemsMenu ¶
MakeItemsMenu constructs a menu of all the items. It is used when the chooser is clicked.
func (*Chooser) NodeType ¶
NodeType returns the *types.Type of Chooser
func (*Chooser) OpenMenu ¶
OpenMenu opens the chooser menu that displays all of the items. It returns false if there are no items.
func (*Chooser) SelectItem ¶
SelectItem selects the item at the given index and updates the chooser to display it.
func (*Chooser) SelectItemAction ¶
SelectItemAction selects the item at the given index and updates the chooser to display it. It also sends an events.Change event to indicate that the value has changed.
func (*Chooser) SetAllowNew ¶
SetAllowNew sets the [Chooser.AllowNew]: AllowNew is whether to allow the user to add new items to the chooser through the editable textfield (if Editable is set to true) and a button at the end of the chooser menu. See also [DefaultNew].
func (*Chooser) SetCurrentIndex ¶
SetCurrentIndex sets the current index and the item associated with it.
func (*Chooser) SetCurrentText ¶
SetCurrentText sets the current index and item based on the given text string. It can only be used for editable choosers.
func (*Chooser) SetCurrentValue ¶
SetCurrentValue sets the current item and index to those associated with the given value. If the given item is not found, it adds it to the items list. It also sets the text of the chooser to the label of the item.
func (*Chooser) SetDefaultNew ¶
SetDefaultNew sets the [Chooser.DefaultNew]: DefaultNew configures the chooser to accept new items, as in [AllowNew], and also turns off completion popups and always adds new items to the list of items, without prompting. Use this for cases where the typical use-case is to enter new values, but the history of prior values can also be useful.
func (*Chooser) SetEditable ¶
SetEditable sets the [Chooser.Editable]: Editable is whether provide a text field for editing the value, or just a button for selecting items.
func (*Chooser) SetEnum ¶
SetEnum sets the [Chooser.Items] from the enums.Enum.Values of the given enum.
func (*Chooser) SetIcon ¶
SetIcon sets the [Chooser.Icon]: Icon is an optional icon displayed on the left side of the chooser.
func (*Chooser) SetIndicator ¶
SetIndicator sets the [Chooser.Indicator]: Indicator is the icon to use for the indicator displayed on the right side of the chooser.
func (*Chooser) SetItems ¶
func (t *Chooser) SetItems(v ...ChooserItem) *Chooser
SetItems sets the [Chooser.Items]: Items are the chooser items available for selection.
func (*Chooser) SetPlaceholder ¶
SetPlaceholder sets the given placeholder text and indicates that nothing has been selected.
func (*Chooser) SetStrings ¶
SetStrings sets the [Chooser.Items] from the given strings.
func (*Chooser) SetTooltip ¶
SetTooltip sets the [Chooser.Tooltip]
func (*Chooser) SetType ¶
func (t *Chooser) SetType(v ChooserTypes) *Chooser
SetType sets the [Chooser.Type]: Type is the styling type of the chooser.
func (*Chooser) ShowCurrentItem ¶
ShowCurrentItem updates the display to present the current item.
type ChooserItem ¶
type ChooserItem struct { // Value is the underlying value of the chooser item. Value any // Label is the label displayed to the user for this item. // If it is empty, then [ToLabel] of [ChooserItem.Value] is // used instead. Label string // Icon is the icon displayed to the user for this item. Icon icons.Icon // Tooltip is the tooltip displayed to the user for this item. Tooltip string // Func, if non-nil, is a function to call whenever this // item is selected as the current value of the chooser. Func func() `json:"-" xml:"-"` // SeparatorBefore is whether to add a separator before // this item in the chooser menu. SeparatorBefore bool }
ChooserItem is an item that can be used in a Chooser.
func (*ChooserItem) GetLabel ¶
func (ci *ChooserItem) GetLabel() string
GetLabel returns the effective label of this chooser item. If [ChooserItem.Label] is set, it returns that. Otherwise, it uses ToLabel of [ChooserItem.Value]
type ChooserTypes ¶
type ChooserTypes int32 //enums:enum -trim-prefix Chooser
ChooserTypes is an enum containing the different possible types of combo boxes
const ( // ChooserFilled represents a filled // Chooser with a background color // and a bottom border ChooserFilled ChooserTypes = iota // ChooserOutlined represents an outlined // Chooser with a border on all sides // and no background color ChooserOutlined )
const ChooserTypesN ChooserTypes = 2
ChooserTypesN is the highest valid value for type ChooserTypes, plus one.
func ChooserTypesValues ¶
func ChooserTypesValues() []ChooserTypes
ChooserTypesValues returns all possible values for the type ChooserTypes.
func (ChooserTypes) Desc ¶
func (i ChooserTypes) Desc() string
Desc returns the description of the ChooserTypes value.
func (ChooserTypes) Int64 ¶
func (i ChooserTypes) Int64() int64
Int64 returns the ChooserTypes value as an int64.
func (ChooserTypes) MarshalText ¶
func (i ChooserTypes) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*ChooserTypes) SetInt64 ¶
func (i *ChooserTypes) SetInt64(in int64)
SetInt64 sets the ChooserTypes value from an int64.
func (*ChooserTypes) SetString ¶
func (i *ChooserTypes) SetString(s string) error
SetString sets the ChooserTypes value from its string representation, and returns an error if the string is invalid.
func (ChooserTypes) String ¶
func (i ChooserTypes) String() string
String returns the string representation of this ChooserTypes value.
func (*ChooserTypes) UnmarshalText ¶
func (i *ChooserTypes) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (ChooserTypes) Values ¶
func (i ChooserTypes) Values() []enums.Enum
Values returns all possible values for the type ChooserTypes.
type Complete ¶
type Complete struct { // function to get the list of possible completions MatchFunc complete.MatchFunc // function to get the text to show for lookup LookupFunc complete.LookupFunc // function to edit text using the selected completion EditFunc complete.EditFunc // the object that implements complete.Func Context any // line number in source that completion is operating on, if relevant SrcLn int // character position in source that completion is operating on SrcCh int // the list of potential completions Completions complete.Completions // current completion seed Seed string // the user's completion selection Completion string // the event listeners for the completer (it sends Select events) Listeners events.Listeners `set:"-" view:"-"` // Stage is the [PopupStage] associated with the [Complete] Stage *Stage DelayTimer *time.Timer `set:"-"` DelayMu sync.Mutex `set:"-"` ShowMu sync.Mutex `set:"-"` }
Complete holds the current completion data and functions to call for building the list of possible completions and for editing text after a completion is selected. It also holds the [PopupStage] associated with it.
func NewComplete ¶
func NewComplete() *Complete
NewComplete returns a new Complete object. It does not show it; see Complete.Show.
func (*Complete) Abort ¶
Abort aborts *only* pending completions, but does not close existing window. Returns true if aborted.
func (*Complete) Cancel ¶
Cancel cancels any existing *or* pending completion. Call when new events nullify prior completions. Returns true if canceled.
func (*Complete) CancelAsync ¶
CancelAsync cancels any existing *or* pending completion, inside a delayed callback function (Async) Call when new events nullify prior completions. Returns true if canceled.
func (*Complete) Complete ¶
Complete sends Select event to listeners, indicating that the user has made a selection from the list of possible completions. This is called inside the main event loop.
func (*Complete) GetCompletion ¶
func (c *Complete) GetCompletion(s string) complete.Completion
func (*Complete) IsAboutToShow ¶
IsAboutToShow returns true if the DelayTimer is started for preparing to show a completion. note: don't really need to lock
func (*Complete) OnSelect ¶
OnSelect registers given listener function for Select events on Value. This is the primary notification event for all Complete elements.
func (*Complete) SetCompletion ¶
SetCompletion sets the [Complete.Completion]: the user's completion selection
func (*Complete) SetCompletions ¶
func (t *Complete) SetCompletions(v complete.Completions) *Complete
SetCompletions sets the [Complete.Completions]: the list of potential completions
func (*Complete) SetContext ¶
SetContext sets the [Complete.Context]: the object that implements complete.Func
func (*Complete) SetEditFunc ¶
SetEditFunc sets the [Complete.EditFunc]: function to edit text using the selected completion
func (*Complete) SetLookupFunc ¶
func (t *Complete) SetLookupFunc(v complete.LookupFunc) *Complete
SetLookupFunc sets the [Complete.LookupFunc]: function to get the text to show for lookup
func (*Complete) SetMatchFunc ¶
SetMatchFunc sets the [Complete.MatchFunc]: function to get the list of possible completions
func (*Complete) SetSrcCh ¶
SetSrcCh sets the [Complete.SrcCh]: character position in source that completion is operating on
func (*Complete) SetSrcLn ¶
SetSrcLn sets the [Complete.SrcLn]: line number in source that completion is operating on, if relevant
func (*Complete) SetStage ¶
SetStage sets the [Complete.Stage]: Stage is the [PopupStage] associated with the Complete
func (*Complete) Show ¶
Show is the main call for listing completions. Has a builtin delay timer so completions are only shown after a delay, which resets every time it is called. After delay, Calls ShowNow, which calls MatchFunc to get a list of completions and builds the completion popup menu
func (*Complete) ShowNow ¶
ShowNow actually calls MatchFunc to get a list of completions and builds the completion popup menu. This is the sync version called from
func (*Complete) ShowNowAsync ¶
ShowNowAsync actually calls MatchFunc to get a list of completions and builds the completion popup menu. This is the Async version for delayed AfterFunc call.
type CompleteSignals ¶
type CompleteSignals int32 //enums:enum -trim-prefix Complete
CompleteSignals are signals that are sent by Complete
const ( // CompleteSelect means the user chose one of the possible completions CompleteSelect CompleteSignals = iota // CompleteExtend means user has requested that the seed extend if all // completions have a common prefix longer than current seed CompleteExtend )
const CompleteSignalsN CompleteSignals = 2
CompleteSignalsN is the highest valid value for type CompleteSignals, plus one.
func CompleteSignalsValues ¶
func CompleteSignalsValues() []CompleteSignals
CompleteSignalsValues returns all possible values for the type CompleteSignals.
func (CompleteSignals) Desc ¶
func (i CompleteSignals) Desc() string
Desc returns the description of the CompleteSignals value.
func (CompleteSignals) Int64 ¶
func (i CompleteSignals) Int64() int64
Int64 returns the CompleteSignals value as an int64.
func (CompleteSignals) MarshalText ¶
func (i CompleteSignals) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*CompleteSignals) SetInt64 ¶
func (i *CompleteSignals) SetInt64(in int64)
SetInt64 sets the CompleteSignals value from an int64.
func (*CompleteSignals) SetString ¶
func (i *CompleteSignals) SetString(s string) error
SetString sets the CompleteSignals value from its string representation, and returns an error if the string is invalid.
func (CompleteSignals) String ¶
func (i CompleteSignals) String() string
String returns the string representation of this CompleteSignals value.
func (*CompleteSignals) UnmarshalText ¶
func (i *CompleteSignals) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (CompleteSignals) Values ¶
func (i CompleteSignals) Values() []enums.Enum
Values returns all possible values for the type CompleteSignals.
type Completer ¶
type Completer interface { // SetCompleter sets completion functions so that completions will // automatically be offered as the user types. data provides context where being used. SetCompleter(data any, matchFun complete.MatchFunc, editFun complete.EditFunc) }
Completer interface supports the SetCompleter method for setting completer parameters This is defined e.g., on TextField and texteditor.Buf
type DebugSettingsData ¶
type DebugSettingsData struct { SettingsBase // Print a trace of updates that trigger re-rendering UpdateTrace bool // Print a trace of the nodes rendering RenderTrace bool // Print a trace of all layouts LayoutTrace bool // Print more detailed info about the underlying layout computations LayoutTraceDetail bool // Print a trace of window events WinEventTrace bool // Print the stack trace leading up to win publish events // which are expensive WinRenderTrace bool // Print a trace of window geometry saving / loading functions WinGeomTrace bool // Print a trace of keyboard events KeyEventTrace bool // Print a trace of event handling EventTrace bool // Print a trace of focus changes FocusTrace bool // Print a trace of DND event handling DNDTrace bool // Print a trace of Go language completion and lookup process GoCompleteTrace bool // Print a trace of Go language type parsing and inference process GoTypeTrace bool }
DebugSettingsData is the data type for debugging settings.
func (*DebugSettingsData) Apply ¶
func (db *DebugSettingsData) Apply()
func (*DebugSettingsData) Defaults ¶
func (db *DebugSettingsData) Defaults()
type DeviceSettingsData ¶
type DeviceSettingsData struct { SettingsBase // The keyboard shortcut map to use KeyMap keymap.MapName // The keyboard shortcut maps available as options for Key map. // If you do not want to have custom key maps, you should leave // this unset so that you always have the latest standard key maps. KeyMaps option.Option[keymap.Maps] // The maximum time interval between button press events to count as a double-click DoubleClickInterval time.Duration `default:"500ms" min:"100ms" step:"50ms"` // How fast the scroll wheel moves, which is typically pixels per wheel step // but units can be arbitrary. It is generally impossible to standardize speed // and variable across devices, and we don't have access to the system settings, // so unfortunately you have to set it here. ScrollWheelSpeed float32 `default:"1" min:"0.01" step:"1"` // The amount of time to wait before initiating a slide event // (as opposed to a basic press event) SlideStartTime time.Duration `default:"50ms" min:"5ms" max:"1s" step:"5ms"` // The amount of time to wait before initiating a drag (drag and drop) event // (as opposed to a basic press or slide event) DragStartTime time.Duration `default:"250ms" min:"5ms" max:"1s" step:"5ms"` // The amount of time to wait between each repeat click event, // when the mouse is pressed down. The first click is 8x this. RepeatClickTime time.Duration `default:"100ms" min:"5ms" max:"1s" step:"5ms"` // The number of pixels that must be moved before initiating a slide/drag // event (as opposed to a basic press event) DragStartDistance int `default:"4" min:"0" max:"100" step:"1"` // The amount of time to wait before initiating a long hover event (e.g., for opening a tooltip) LongHoverTime time.Duration `default:"500ms" min:"10ms" max:"10s" step:"10ms"` // The maximum number of pixels that mouse can move and still register a long hover event LongHoverStopDistance int `default:"5" min:"0" max:"1000" step:"1"` // The amount of time to wait before initiating a long press event (e.g., for opening a tooltip) LongPressTime time.Duration `default:"500ms" min:"10ms" max:"10s" step:"10ms"` // The maximum number of pixels that mouse/finger can move and still register a long press event LongPressStopDistance int `default:"50" min:"0" max:"1000" step:"1"` }
DeviceSettingsData is the data type for the device settings.
func (*DeviceSettingsData) Apply ¶
func (ds *DeviceSettingsData) Apply()
func (*DeviceSettingsData) Defaults ¶
func (ds *DeviceSettingsData) Defaults()
type EditorSettings ¶
type EditorSettings struct { // size of a tab, in chars -- also determines indent level for space indent TabSize int `default:"4" xml:"tab-size"` // use spaces for indentation, otherwise tabs SpaceIndent bool `xml:"space-indent"` // wrap lines at word boundaries -- otherwise long lines scroll off the end WordWrap bool `default:"true" xml:"word-wrap"` // show line numbers LineNos bool `default:"true" xml:"line-nos"` // use the completion system to suggest options while typing Completion bool `default:"true" xml:"completion"` // suggest corrections for unknown words while typing SpellCorrect bool `default:"true" xml:"spell-correct"` // automatically indent lines when enter, tab, }, etc pressed AutoIndent bool `default:"true" xml:"auto-indent"` // use emacs-style undo, where after a non-undo command, all the current undo actions are added to the undo stack, such that a subsequent undo is actually a redo EmacsUndo bool `xml:"emacs-undo"` // colorize the background according to nesting depth DepthColor bool `default:"true" xml:"depth-color"` }
EditorSettings contains text editor settings.
type EventMgr ¶
type EventMgr struct { // Scene is the scene that we manage events for Scene *Scene // mutex that protects timer variable updates (e.g., hover AfterFunc's) TimerMu sync.Mutex // stack of widgets with mouse pointer in BBox, and are not Disabled. // Last item in the stack is the deepest nested widget (smallest BBox). MouseInBBox []Widget // stack of hovered widgets: have mouse pointer in BBox and have Hoverable flag Hovers []Widget // LastClickWidget is the last widget that has been clicked on LastClickWidget Widget // LastDoubleClickWidget is the last widget that has been clicked on LastDoubleClickWidget Widget // LastClickTime is the time the last widget was clicked on LastClickTime time.Time // the current candidate for a long hover event LongHoverWidget Widget // the position of the mouse at the start of LongHoverTimer LongHoverPos image.Point // the timer for the LongHover event, started with time.AfterFunc LongHoverTimer *time.Timer // the current candidate for a long press event LongPressWidget Widget // the position of the mouse at the start of LongPressTimer LongPressPos image.Point // the timer for the LongPress event, started with time.AfterFunc LongPressTimer *time.Timer // stack of drag-hovered widgets: have mouse pointer in BBox and have Droppable flag DragHovers []Widget // the deepest widget that was just pressed Press Widget // widget receiving mouse dragging events -- for drag-n-drop Drag Widget // the deepest draggable widget that was just pressed DragPress Widget // widget receiving mouse sliding events Slide Widget // the deepest slideable widget that was just pressed SlidePress Widget // widget receiving mouse scrolling events Scroll Widget // widget being held down with RepeatClickable ability RepeatClick Widget // the timer for RepeatClickable items RepeatClickTimer *time.Timer // widget receiving keyboard events -- use SetFocus, CurFocus Focus Widget // widget to focus on at start when no other focus has been set yet -- use SetStartFocus StartFocus Widget // if StartFocus not set, activate starting focus on first element StartFocusFirst bool // previously-focused widget -- what was in Focus when FocusClear is called PrevFocus Widget // Last Select Mode from most recent Mouse, Keyboard events LastSelMode events.SelectModes // Currently active shortcuts for this window (shortcuts are always window-wide. // Use widget key event processing for more local key functions) Shortcuts Shortcuts // source data from DragStart event DragData any }
EventMgr is an event manager that handles incoming events for a Scene. It creates all the derived event types (Hover, Sliding, Dragging) and Focus management for keyboard events.
func (*EventMgr) ActivateStartFocus ¶
ActivateStartFocus activates start focus if there is no current focus and StartFocus is set -- returns true if activated
func (*EventMgr) AddShortcut ¶
AddShortcut adds given shortcut to given button.
func (*EventMgr) CancelLongPress ¶
func (em *EventMgr) CancelLongPress()
func (*EventMgr) CancelRepeatClick ¶
func (em *EventMgr) CancelRepeatClick()
func (*EventMgr) ClearNonFocus ¶
ClearNonFocus clears the focus of any non-w.Focus item.
func (*EventMgr) Clipboard ¶
Clipboard returns the system system.Clipboard, supplying the window context if available.
func (*EventMgr) DeleteShortcut ¶
DeleteShortcut deletes given shortcut
func (*EventMgr) DragClearSprite ¶
func (em *EventMgr) DragClearSprite()
func (*EventMgr) DragDrop ¶
DragDrop sends the events.Drop event to the top of the DragHovers stack. clearing the current dragging sprite before doing anything. It is up to the target to call
func (*EventMgr) DragMenuAddModLabel ¶
func (*EventMgr) DragStart ¶
DragStart starts a drag event, capturing a sprite image of the given widget and storing the data for later use during Drop. A drag does not officially start until this is called.
func (*EventMgr) DragStartCheck ¶
func (*EventMgr) DropFinalize ¶
DropFinalize should be called as the last step in the Drop event processing, to send the DropDeleteSource event to the source in case of DropMod == DropMove. Otherwise, nothing actually happens.
func (*EventMgr) FocusClear ¶
FocusClear saves current focus to FocusPrev
func (*EventMgr) FocusFirst ¶
FocusFirst sets the focus on the first focusable item in the tree. returns true if a focusable item was found.
func (*EventMgr) FocusLast ¶
FocusLast sets the focus on the last focusable item in the tree. returns true if a focusable item was found.
func (*EventMgr) FocusLastFrom ¶
FocusLastFrom sets the focus on the last focusable item in the given tree. returns true if a focusable item was found.
func (*EventMgr) FocusNext ¶
FocusNext sets the focus on the next item that can accept focus after the current Focus item. returns true if a focus item found.
func (*EventMgr) FocusNextFrom ¶
FocusNextFrom sets the focus on the next item that can accept focus after the given item. returns true if a focus item found.
func (*EventMgr) FocusOnOrNext ¶
FocusOnOrNext sets the focus on the given item, or the next one that can accept focus -- returns true if a new focus item found.
func (*EventMgr) FocusOnOrPrev ¶
FocusOnOrPrev sets the focus on the given item, or the previous one that can accept focus -- returns true if a new focus item found.
func (*EventMgr) FocusPrev ¶
FocusPrev sets the focus on the previous item before the current focus item.
func (*EventMgr) FocusPrevFrom ¶
FocusPrevFrom sets the focus on the previous item before the given item (can be nil).
func (*EventMgr) GetShortcuts ¶
func (em *EventMgr) GetShortcuts()
GetShortcuts gathers all [Button]s in the Scene with a shortcut specified. It recursively navigates [Button.Menu]s.
func (*EventMgr) GetShortcutsIn ¶
GetShortcutsIn gathers all [Button]s in the given parent widget with a shortcut specified. It recursively navigates [Button.Menu]s.
func (*EventMgr) HandleEvent ¶
func (*EventMgr) HandleFocusEvent ¶
func (*EventMgr) HandleLong ¶
func (em *EventMgr) HandleLong(e events.Event, deep Widget, w *Widget, pos *image.Point, t **time.Timer, styp, etyp events.Types, stime time.Duration, sdist int)
HandleLong is the implementation of EventMgr.HandleLongHover and [EventManger.HandleLongPress]. It handles the logic to do with tracking long events using the given pointers to event manager fields and constant type, time, and distance properties. It should not need to be called by anything except for the aforementioned functions.
func (*EventMgr) HandleLongHover ¶
HandleLongHover handles long hover events
func (*EventMgr) HandleLongPress ¶
HandleLongPress handles long press events
func (*EventMgr) HandleOtherEvent ¶
func (*EventMgr) HandlePosEvent ¶
func (*EventMgr) MainStageMgr ¶
MainStageMgr returns the MainStageMgr for our Main Stage
func (*EventMgr) ManagerKeyChordEvents ¶
MangerKeyChordEvents handles lower-priority manager-level key events. Mainly tab, shift-tab, and Inspector and Settings. event will be marked as processed if handled here.
func (*EventMgr) RenderWin ¶
func (em *EventMgr) RenderWin() *RenderWindow
RenderWin returns the overall render window, which could be nil
func (*EventMgr) ResetOnMouseDown ¶
func (em *EventMgr) ResetOnMouseDown()
func (*EventMgr) SetFocus ¶
SetFocus sets focus to given item, and returns true if focus changed. If item is nil, then nothing has focus. This does NOT send the events.Focus event to the widget. See [SetFocusEvent] for version that does send event.
func (*EventMgr) SetFocusEvent ¶
SetFocusEvent sets focus to given item, and returns true if focus changed. If item is nil, then nothing has focus. This sends the events.Focus event to the widget. See [SetFocus] for a version that does not.
func (*EventMgr) SetFocusImpl ¶
SetFocusImpl sets focus to given item -- returns true if focus changed. If item is nil, then nothing has focus. sendEvent determines whether the events.Focus event is sent to the focused item.
func (*EventMgr) SetStartFocus ¶
SetStartFocus sets the given item to be first focus when window opens.
func (*EventMgr) StartRepeatClickTimer ¶
func (em *EventMgr) StartRepeatClickTimer()
func (*EventMgr) TopLongHover ¶
TopLongHover returns the top-most LongHoverable widget among the Hovers
func (*EventMgr) TriggerShortcut ¶
TriggerShortcut attempts to trigger a shortcut, returning true if one was triggered, and false otherwise. Also eliminates any shortcuts with deleted buttons, and does not trigger for Disabled buttons.
type FavPathItem ¶
type FavPathItem struct { // icon for item Ic icons.Icon // name of the favorite item Name string `width:"20"` // the path of the favorite item Path string `tableview:"-select"` }
FavPathItem represents one item in a favorite path list, for display of favorites. Is an ordered list instead of a map because user can organize in order
func (FavPathItem) Label ¶
func (fi FavPathItem) Label() string
Label satisfies the Labeler interface
type FavPaths ¶
type FavPaths []FavPathItem
FavPaths is a list (slice) of favorite path items
func (*FavPaths) SetToDefaults ¶
func (pf *FavPaths) SetToDefaults()
SetToDefaults sets the paths to default values
type FieldValidator ¶
type FieldValidator interface { // ValidateField returns an error if the value of the given named field is invalid. ValidateField(field string) error }
FieldValidator is an interface for types to provide a ValidateField method that is used in views to validate string field Values using [TextField.Validator].
type FilePaths ¶
type FilePaths []string
FilePaths represents a set of file paths.
var RecentPaths FilePaths
RecentPaths are the recently opened paths in the file view.
func (*FilePaths) AddPath ¶
AddPath inserts a path to the file paths (at the start), subject to max length -- if path is already on the list then it is moved to the start.
type Filename ¶
type Filename string
Filename is used to specify an filename (including path). Automatically opens the FileView dialog using Value system. Use this for any method args that are filenames to trigger use of FileViewDialog under FuncButton automatic method calling.
type FontName ¶
type FontName string
FontName is used to specify a font, as the unique name of the font family. This automatically provides a chooser menu for fonts using [views.Value].
type Frame ¶
type Frame struct {
Layout
}
Frame is a Layout that renders a background according to the background-color style setting, and optional striping for grid layouts
func NewFrame ¶
NewFrame adds a new Frame with the given name to the given parent: Frame is a Layout that renders a background according to the background-color style setting, and optional striping for grid layouts
func (*Frame) NodeType ¶
NodeType returns the *types.Type of Frame
func (*Frame) RenderWidget ¶
func (fr *Frame) RenderWidget()
func (*Frame) SetTooltip ¶
SetTooltip sets the [Frame.Tooltip]
type GeomCT ¶
type GeomCT struct { // Content is for the contents (children, parts) of the widget, // excluding the Space (margin, padding, scrollbars). // This content includes the InnerSpace factor (Gaps in Layout) // which must therefore be subtracted when allocating down to children. Content math32.Vector2 // Total is for the total exterior of the widget: Content + Space Total math32.Vector2 }
GeomCT has core layout elements: Content and Total
type GeomSize ¶
type GeomSize struct { // Actual is the actual size for the purposes of rendering, representing // the "external" demands of the widget for space from its parent. // This is initially the bottom-up constraint computed by SizeUp, // and only changes during SizeDown when wrapping elements are reshaped // based on allocated size, or when scrollbars are added. // For elements with scrollbars (OverflowAuto), the Actual size remains // at the initial style minimums, "absorbing" is internal size, // while Internal records the true size of the contents. // For SizeFinal, Actual size can Grow up to the final Alloc size, // while Internal records the actual bottom-up contents size. Actual GeomCT `view:"inline"` // Alloc is the top-down allocated size, based on available visible space, // starting from the Scene geometry and working downward, attempting to // accommodate the Actual contents, and allocating extra space based on // Grow factors. When Actual < Alloc, alignment factors determine positioning // within the allocated space. Alloc GeomCT `view:"inline"` // Internal is the internal size representing the true size of all contents // of the widget. This can be less than Actual.Content if widget has Grow // factors but its internal contents did not grow accordingly, or it can // be more than Actual.Content if it has scrollbars (OverflowAuto). // Note that this includes InnerSpace (Gap). Internal math32.Vector2 // Space is the padding, total effective margin (border, shadow, etc), // and scrollbars that subtracts from Total size to get Content size. Space math32.Vector2 // InnerSpace is total extra space that is included within the Content Size region // and must be subtracted from Content when passing sizes down to children. InnerSpace math32.Vector2 // Min is the Styles.Min.Dots() (Ceil int) that constrains the Actual.Content size Min math32.Vector2 // Max is the Styles.Max.Dots() (Ceil int) that constrains the Actual.Content size Max math32.Vector2 }
GeomSize has all of the relevant Layout sizes
func (*GeomSize) FitSizeMax ¶
FitSizeMax increases given size to fit given fm value, subject to Max constraints
func (*GeomSize) SetContentFromTotal ¶
SetContentFromTotal sets the Content from Total size, subtracting Space
func (*GeomSize) SetInitContentMin ¶
SetInitContentMin sets initial Actual.Content size from given Styles.Min, further subject to the current Max constraint.
func (*GeomSize) SetTotalFromContent ¶
SetTotalFromContent sets the Total size as Content plus Space
type GeomState ¶
type GeomState struct { // Size has sizing data for the widget: use Actual for rendering. // Alloc shows the potentially larger space top-down allocated. Size GeomSize `view:"add-fields"` // Pos is position within the overall Scene that we render into, // including effects of scroll offset, for both Total outer dimension // and inner Content dimension. Pos GeomCT `view:"inline" edit:"-" copier:"-" json:"-" xml:"-" set:"-"` // Cell is the logical X, Y index coordinates (col, row) of element // within its parent layout Cell image.Point // RelPos is top, left position relative to parent Content size space RelPos math32.Vector2 // Scroll is additional scrolling offset within our parent layout Scroll math32.Vector2 // 2D bounding box for Actual.Total size occupied within parent Scene // that we render onto, starting at Pos.Total and ending at Pos.Total + Size.Total. // These are the pixels we can draw into, intersected with parent bounding boxes // (empty for invisible). Used for render Bounds clipping. // This includes all space (margin, padding etc). TotalBBox image.Rectangle `edit:"-" copier:"-" json:"-" xml:"-" set:"-"` // 2D bounding box for our Content, which excludes our padding, margin, etc. // starting at Pos.Content and ending at Pos.Content + Size.Content. // It is intersected with parent bounding boxes. ContentBBox image.Rectangle `edit:"-" copier:"-" json:"-" xml:"-" set:"-"` }
GeomState contains the the layout geometry state for each widget. Set by the parent Layout during the Layout process.
func (*GeomState) ContentRangeDim ¶
ContentRangeDim returns the Content bounding box min, max along given dimension
func (*GeomState) ContentRect ¶
ContentRect returns Pos.Content, Size.Actual.Content as an image.Rectangle, e.g., for bounding box.
func (*GeomState) ScrollOffset ¶
ScrollOffset computes the net scrolling offset as a function of the difference between the allocated position and the actual content position according to the clipped bounding box.
type Handle ¶
type Handle struct { Box // Min is the minimum value that the handle can go to // (typically the lower bound of the dialog/splits) Min float32 // Max is the maximum value that the handle can go to // (typically the upper bound of the dialog/splits) Max float32 // Pos is the current position of the handle on the // scale of [Handle.Min] to [Handle.Max] Pos float32 }
Handle represents a draggable handle that can be used to control the size of an element. The [Handle.Styles.Direction] controls the direction in which the handle moves.
func NewHandle ¶
NewHandle adds a new Handle with the given name to the given parent: Handle represents a draggable handle that can be used to control the size of an element. The [Handle.Styles.Direction] controls the direction in which the handle moves.
func (*Handle) HandleEvents ¶
func (hl *Handle) HandleEvents()
func (*Handle) NodeType ¶
NodeType returns the *types.Type of Handle
func (*Handle) SetMax ¶
SetMax sets the [Handle.Max]: Max is the maximum value that the handle can go to (typically the upper bound of the dialog/splits)
func (*Handle) SetMin ¶
SetMin sets the [Handle.Min]: Min is the minimum value that the handle can go to (typically the lower bound of the dialog/splits)
func (*Handle) SetPos ¶
SetPos sets the [Handle.Pos]: Pos is the current position of the handle on the scale of [Handle.Min] to [Handle.Max]
func (*Handle) SetTooltip ¶
SetTooltip sets the [Handle.Tooltip]
type Icon ¶
type Icon struct { WidgetBase // icon name that has been set. Icon icons.Icon `set:"-"` // file name for the loaded icon, if loaded Filename string `set:"-"` // SVG drawing of the icon SVG svg.SVG `set:"-" copier:"-"` }
Icon contains a svg.SVG element. The rendered version is cached for a given size. Icons do not render a background or border independent of their SVG object. The size of on Icon is determined by the styles.Font.Size property.
func NewIcon ¶
NewIcon adds a new Icon with the given name to the given parent: Icon contains a svg.SVG element. The rendered version is cached for a given size. Icons do not render a background or border independent of their SVG object. The size of on Icon is determined by the styles.Font.Size property.
func (*Icon) NodeType ¶
NodeType returns the *types.Type of Icon
func (*Icon) RenderSVG ¶
func (ic *Icon) RenderSVG()
RenderSVG renders the [Icon.SVG] to the [Icon.Pixels] if they need to be updated.
func (*Icon) SetIcon ¶
SetIcon sets the icon, logging error if not found. Does nothing if IconName is already == icon name.
func (*Icon) SetIconTry ¶
SetIconTry sets the icon, returning error message if not found etc, and returning true if a new icon was actually set. Does nothing and returns false if IconName is already == icon name.
func (*Icon) SetTooltip ¶
SetTooltip sets the [Icon.Tooltip]
type Image ¶
type Image struct { Box // Image is the bitmap image. Image *image.RGBA `xml:"-" json:"-" set:"-"` // contains filtered or unexported fields }
Image is a widget that renders a static bitmap image. See styles.ObjectFits for how to control the image rendering within the allocated size. The default minimum requested size is the pixel size in units.Dp units (1/160th of an inch). See [views.ConfigImageToolbar] for a toolbar with I/O buttons.
func NewImage ¶
NewImage adds a new Image with the given name to the given parent: Image is a widget that renders a static bitmap image. See styles.ObjectFits for how to control the image rendering within the allocated size. The default minimum requested size is the pixel size in units.Dp units (1/160th of an inch). See [views.ConfigImageToolbar] for a toolbar with I/O buttons.
func (*Image) NodeType ¶
NodeType returns the *types.Type of Image
func (*Image) OpenFS ¶
OpenFS sets the image to the image located at the given filename in the given fs.
func (*Image) SetImage ¶
SetImage sets the image to the given image. It copies from the given image into an internal image.
func (*Image) SetTooltip ¶
SetTooltip sets the [Image.Tooltip]
type Label ¶
type Label struct { WidgetBase // label to display Text string // the type of label Type LabelTypes // render data for text label TextRender paint.Text `copier:"-" xml:"-" json:"-" set:"-"` // NormalCursor is the cached cursor to display when there // is no link being hovered. NormalCursor cursors.Cursor `copier:"-" xml:"-" json:"-" set:"-"` }
Label is a widget for rendering text labels. It supports full HTML styling, including links. By default, labels wrap and collapse whitespace, although you can change this by changing styles.Text.WhiteSpace.
func AsLabel ¶
AsLabel returns the given value as a value of type Label if the type of the given value embeds Label, or nil otherwise
func NewLabel ¶
NewLabel adds a new Label with the given name to the given parent: Label is a widget for rendering text labels. It supports full HTML styling, including links. By default, labels wrap and collapse whitespace, although you can change this by changing styles.Text.WhiteSpace.
func (*Label) AsLabel ¶
AsLabel satisfies the LabelEmbedder interface
func (*Label) Config ¶
func (lb *Label) Config()
ConfigLabel does the HTML and Layout in TextRender for label text, using actual content size to constrain layout.
func (*Label) ConfigLabelAlloc ¶
ConfigLabelAlloc is used for determining how much space the label takes, using given size (typically Alloc). In this case, alignment factors are turned off, because they otherwise can absorb much more space, which should instead be controlled by the base Align X,Y factors.
func (*Label) ConfigLabelSize ¶
ConfigLabel does the HTML and Layout in TextRender for label text, using given size to constrain layout.
func (*Label) HandleEvents ¶
func (lb *Label) HandleEvents()
func (*Label) HandleLabelClick ¶
HandleLabelClick handles click events such that the given function will be called on any links that are clicked on.
func (*Label) NodeType ¶
NodeType returns the *types.Type of Label
func (*Label) SetTooltip ¶
SetTooltip sets the [Label.Tooltip]
func (*Label) SetType ¶
func (t *Label) SetType(v LabelTypes) *Label
SetType sets the [Label.Type]: the type of label
type LabelEmbedder ¶
type LabelEmbedder interface {
AsLabel() *Label
}
LabelEmbedder is an interface that all types that embed Label satisfy
type LabelTypes ¶
type LabelTypes int32 //enums:enum -trim-prefix Label
LabelTypes is an enum containing the different possible types of labels
const ( // LabelDisplayLarge is a large, short, and important // display label with a default font size of 57dp. LabelDisplayLarge LabelTypes = iota // LabelDisplayMedium is a medium-sized, short, and important // display label with a default font size of 45dp. LabelDisplayMedium // LabelDisplaySmall is a small, short, and important // display label with a default font size of 36dp. LabelDisplaySmall // LabelHeadlineLarge is a large, high-emphasis // headline label with a default font size of 32dp. LabelHeadlineLarge // LabelHeadlineMedium is a medium-sized, high-emphasis // headline label with a default font size of 28dp. LabelHeadlineMedium // LabelHeadlineSmall is a small, high-emphasis // headline label with a default font size of 24dp. LabelHeadlineSmall // LabelTitleLarge is a large, medium-emphasis // title label with a default font size of 22dp. LabelTitleLarge // LabelTitleMedium is a medium-sized, medium-emphasis // title label with a default font size of 16dp. LabelTitleMedium // LabelTitleSmall is a small, medium-emphasis // title label with a default font size of 14dp. LabelTitleSmall // LabelBodyLarge is a large body label used for longer // passages of text with a default font size of 16dp. LabelBodyLarge // LabelBodyMedium is a medium-sized body label used for longer // passages of text with a default font size of 14dp. LabelBodyMedium // LabelBodySmall is a small body label used for longer // passages of text with a default font size of 12dp. LabelBodySmall // LabelLabelLarge is a large label used for label text (like a caption // or the text inside a button) with a default font size of 14dp. LabelLabelLarge // LabelLabelMedium is a medium-sized label used for label text (like a caption // or the text inside a button) with a default font size of 12dp. LabelLabelMedium // LabelLabelSmall is a small label used for label text (like a caption // or the text inside a button) with a default font size of 11dp. LabelLabelSmall )
const LabelTypesN LabelTypes = 15
LabelTypesN is the highest valid value for type LabelTypes, plus one.
func LabelTypesValues ¶
func LabelTypesValues() []LabelTypes
LabelTypesValues returns all possible values for the type LabelTypes.
func (LabelTypes) Desc ¶
func (i LabelTypes) Desc() string
Desc returns the description of the LabelTypes value.
func (LabelTypes) Int64 ¶
func (i LabelTypes) Int64() int64
Int64 returns the LabelTypes value as an int64.
func (LabelTypes) MarshalText ¶
func (i LabelTypes) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*LabelTypes) SetInt64 ¶
func (i *LabelTypes) SetInt64(in int64)
SetInt64 sets the LabelTypes value from an int64.
func (*LabelTypes) SetString ¶
func (i *LabelTypes) SetString(s string) error
SetString sets the LabelTypes value from its string representation, and returns an error if the string is invalid.
func (LabelTypes) String ¶
func (i LabelTypes) String() string
String returns the string representation of this LabelTypes value.
func (*LabelTypes) UnmarshalText ¶
func (i *LabelTypes) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (LabelTypes) Values ¶
func (i LabelTypes) Values() []enums.Enum
Values returns all possible values for the type LabelTypes.
type Labeler ¶
type Labeler interface { // Label returns a GUI-appropriate label for item Label() string }
Labeler interface provides a GUI-appropriate label for an item, via a Label() string method. Use ToLabel converter to attempt to use this interface and then fall back on Stringer via kit.ToString conversion function.
type LayCell ¶
type LayCell struct { // Size has the Actual size of elements (not Alloc) Size math32.Vector2 // Grow has the Grow factors Grow math32.Vector2 }
LayCell holds the layout implementation data for col, row Cells
type LayCells ¶
type LayCells struct { // Shape is number of cells along each dimension for our ColRow cells, Shape image.Point `edit:"-"` // ColRow has the data for the columns in [0] and rows in [1]: // col Size.X = max(X over rows) (cross axis), .Y = sum(Y over rows) (main axis for col) // row Size.X = sum(X over cols) (main axis for row), .Y = max(Y over cols) (cross axis) // see: https://docs.google.com/spreadsheets/d/1eimUOIJLyj60so94qUr4Buzruj2ulpG5o6QwG2nyxRw/edit?usp=sharing ColRow [2][]LayCell `edit:"-"` }
LayCells holds one set of LayCell cell elements for rows, cols. There can be multiple of these for Wrap case.
func (*LayCells) Cell ¶
Cell returns the cell for given dimension and index along that dimension (X = Cols, idx = col, Y = Rows, idx = row)
func (*LayCells) CellsSize ¶
CellsSize returns the total Size represented by the current Cells, which is the Sum of the Max values along each dimension.
func (*LayCells) GapSizeDim ¶
GapSizeDim returns the gap size for given dimension, based on Shape and given gap size
type LayImplState ¶
type LayImplState struct { // Shape is number of cells along each dimension, // computed for each layout type: // For Grid: Max Col, Row. // For Flex no Wrap: Cols,1 (X) or 1,Rows (Y). // For Flex Wrap: Cols,Max(Rows) or Max(Cols),Rows // For Stacked: 1,1 Shape image.Point `edit:"-"` // MainAxis cached here from Styles, to enable Wrap-based access. MainAxis math32.Dims // Wraps is the number of actual items in each Wrap for Wrap case: // MainAxis X: Len = Rows, Val = Cols; MainAxis Y: Len = Cols, Val = Rows. // This should be nil for non-Wrap case. Wraps []int // Cells has the Actual size and Grow factor data for each of the child elements, // organized according to the Shape and Display type. // For non-Wrap, has one element in slice, with cells based on Shape. // For Wrap, slice is number of CrossAxis wraps allocated: // MainAxis X = Rows; MainAxis Y = Cols, and Cells are MainAxis layout x 1 CrossAxis. Cells []LayCells `edit:"-"` // ScrollSize has the scrollbar sizes (widths) for each dim, which adds to Space. // If there is a vertical scrollbar, X has width; if horizontal, Y has "width" = height ScrollSize math32.Vector2 // Gap is the Styles.Gap size Gap math32.Vector2 // GapSize has the total extra gap sizing between elements, which adds to Space. // This depends on cell layout so it can vary for Wrap case. // For SizeUp / Down Gap contributes to Space like other cases, // but for BoundingBox rendering and Alignment, it does NOT, and must be // subtracted. This happens in the Position phase. GapSize math32.Vector2 }
LayImplState has internal state for implementing layout
func (*LayImplState) Cell ¶
func (ls *LayImplState) Cell(d math32.Dims, dIndex, odIndex int) *LayCell
Cell returns the cell for given dimension and index along that dimension, and given other-dimension axis which is ignored for non-Wrap cases. Does no range checking and will crash if out of bounds.
func (*LayImplState) CellsSize ¶
func (ls *LayImplState) CellsSize() math32.Vector2
CellsSize returns the total Size represented by the current Cells, which is the Sum of the Max values along each dimension within each Cell, Maxed over cross-axis dimension for Wrap case, plus GapSize.
func (*LayImplState) ColWidth ¶
func (ls *LayImplState) ColWidth(row, col int) (float32, error)
ColWidth returns the width of given column for given row index (ignored for non-Wrap), with full bounds checking. Returns error if out of range.
func (*LayImplState) InitCells ¶
func (ls *LayImplState) InitCells()
InitCells initializes the Cells based on Shape, MainAxis, and Wraps which must be set before calling.
func (*LayImplState) RowHeight ¶
func (ls *LayImplState) RowHeight(row, col int) (float32, error)
RowHeight returns the height of given row for given column (ignored for non-Wrap), with full bounds checking. Returns error if out of range.
func (*LayImplState) ShapeCheck ¶
func (ls *LayImplState) ShapeCheck(w Widget, phase string) bool
func (*LayImplState) String ¶
func (ls *LayImplState) String() string
func (*LayImplState) WrapIndexToCoord ¶
func (ls *LayImplState) WrapIndexToCoord(idx int) image.Point
WrapIndexToCoord returns the X,Y coordinates in Wrap case for given sequential idx
type Layout ¶
type Layout struct { WidgetBase // StackTop, for a [styles.Stacked] layout, is the index of the node to use as the top of the stack. // Only the node at this index is rendered; if not a valid index, nothing is rendered. StackTop int `set:"-"` // LayImpl contains implementation state info for doing layout LayImpl LayImplState `edit:"-" copier:"-" json:"-" xml:"-" set:"-"` // whether scrollbar is used for given dim HasScroll [2]bool `edit:"-" copier:"-" json:"-" xml:"-" set:"-"` // scroll bars -- we fully manage them as needed Scrolls [2]*Slider `edit:"-" copier:"-" json:"-" xml:"-" set:"-"` // accumulated name to search for when keys are typed FocusName string `edit:"-" copier:"-" json:"-" xml:"-" set:"-"` // time of last focus name event -- for timeout FocusNameTime time.Time `edit:"-" copier:"-" json:"-" xml:"-" set:"-"` // last element focused on -- used as a starting point if name is the same FocusNameLast tree.Node `edit:"-" copier:"-" json:"-" xml:"-" set:"-"` }
Layout is the primary node type responsible for organizing the sizes and positions of child widgets. It does not render, only organize, so properties like background and border will have no effect. All arbitrary collections of widgets should generally be contained within a layout or a Frame; otherwise, the parent widget must take over responsibility for positioning. Layouts automatically can add scrollbars depending on the styles.Style.Overflow.
For a styles.Grid layout, the styles.Style.Columns property should generally be set to the desired number of columns, from which the number of rows is computed; otherwise, it uses the square root of number of elements.
func AsLayout ¶
AsLayout returns the given value as a value of type Layout if the type of the given value embeds Layout, or nil otherwise
func NewLayout ¶
NewLayout adds a new Layout with the given name to the given parent: Layout is the primary node type responsible for organizing the sizes and positions of child widgets. It does not render, only organize, so properties like background and border will have no effect. All arbitrary collections of widgets should generally be contained within a layout or a Frame; otherwise, the parent widget must take over responsibility for positioning. Layouts automatically can add scrollbars depending on the styles.Style.Overflow.
For a styles.Grid layout, the styles.Style.Columns property should generally be set to the desired number of columns, from which the number of rows is computed; otherwise, it uses the square root of number of elements.
func (*Layout) AutoScroll ¶
AutoScroll scrolls the layout based on given position in scroll coordinates (i.e., already subtracing the BBox Min for a mouse event).
func (*Layout) AutoScrollDim ¶
AutoScrollDim auto-scrolls along one dimension, based on the current position value, which is in the current scroll value range.
func (*Layout) ChildWithFocus ¶
ChildWithFocus returns a direct child of this layout that either is the current window focus item, or contains that focus item (along with its index) -- nil, -1 if none.
func (*Layout) ConfigScroll ¶
ConfigScroll configures scroll for given dimension
func (*Layout) ConfigScrolls ¶
func (ly *Layout) ConfigScrolls()
ConfigScrolls configures any scrollbars that have been enabled during the Layout process. This is called during Position, once the sizing and need for scrollbars has been established. The final position of the scrollbars is set during ScenePos in PositionScrolls. Scrolls are kept around in general.
func (*Layout) DeleteScroll ¶
DeleteScroll deletes scrollbar along given dimesion.
func (*Layout) FlagType ¶
func (ly *Layout) FlagType() enums.BitFlagSetter
func (*Layout) FocusNextChild ¶
FocusNextChild attempts to move the focus into the next layout child (with wraparound to start) -- returns true if successful. if updn is true, then for Grid layouts, it moves down to next row instead of just the sequentially next item.
func (*Layout) FocusOnName ¶
FocusOnName processes key events to look for an element starting with given name
func (*Layout) FocusPrevChild ¶
FocusPrevChild attempts to move the focus into the previous layout child (with wraparound to end) -- returns true if successful. If updn is true, then for Grid layouts, it moves up to next row instead of just the sequentially next item.
func (*Layout) HandleEvents ¶
func (ly *Layout) HandleEvents()
func (*Layout) HandleKeys ¶
func (ly *Layout) HandleKeys()
HandleKeys handles all key events for navigating focus within a Layout. Typically this is done by the parent Scene level layout, but can be done by default if FocusWithinable Ability is set.
func (*Layout) HasAnyScroll ¶
HasAnyScroll returns true if layout has
func (*Layout) LaySetContentFitOverflow ¶
func (ly *Layout) LaySetContentFitOverflow(nsz math32.Vector2, pass LayoutPasses)
LaySetContentFitOverflow sets Internal and Actual.Content size to fit given new content size, depending on the Styles Overflow: Auto and Scroll types do NOT expand Actual and remain at their current styled actual values, absorbing the extra content size within their own scrolling zone (full size recorded in Internal).
func (*Layout) LaySetGapSizeFromCells ¶
func (ly *Layout) LaySetGapSizeFromCells()
func (*Layout) LaySetInitCells ¶
func (ly *Layout) LaySetInitCells()
SetInitCells sets the initial default assignment of cell indexes to each widget, based on layout type.
func (*Layout) LaySetInitCellsFlex ¶
func (ly *Layout) LaySetInitCellsFlex()
func (*Layout) LaySetInitCellsGrid ¶
func (ly *Layout) LaySetInitCellsGrid()
func (*Layout) LaySetInitCellsStacked ¶
func (ly *Layout) LaySetInitCellsStacked()
func (*Layout) LaySetInitCellsWrap ¶
func (ly *Layout) LaySetInitCellsWrap()
func (*Layout) LaySetWrapIndexes ¶
func (ly *Layout) LaySetWrapIndexes()
LaySetWrapIndexes sets indexes for Wrap case
func (*Layout) LayoutSpace ¶
func (ly *Layout) LayoutSpace()
LayoutSpace sets our Space based on Styles and Scroll. Other layout types can change this if they want to.
func (*Layout) ManageOverflow ¶
ManageOverflow uses overflow settings to determine if scrollbars are needed (Internal > Alloc). Returns true if size changes as a result. If updtSize is false, then the Actual and Alloc sizes are NOT updated as a result of change from adding scrollbars (generally should be true, but some cases not)
func (*Layout) NodeType ¶
NodeType returns the *types.Type of Layout
func (*Layout) Position ¶
func (ly *Layout) Position()
Position: uses the final sizes to position everything within layouts according to alignment settings.
func (*Layout) PositionCells ¶
func (ly *Layout) PositionCells()
func (*Layout) PositionLay ¶
func (ly *Layout) PositionLay()
func (*Layout) PositionScroll ¶
func (*Layout) PositionScrolls ¶
func (ly *Layout) PositionScrolls()
PositionScrolls arranges scrollbars
func (*Layout) PositionStacked ¶
func (ly *Layout) PositionStacked()
func (*Layout) PositionWrap ¶
func (ly *Layout) PositionWrap()
func (*Layout) RenderChildren ¶
func (ly *Layout) RenderChildren()
func (*Layout) ScenePos ¶
func (ly *Layout) ScenePos()
ScenePos: scene-based position and final BBox is computed based on parents accumulated position and scrollbar position. This step can be performed when scrolling after updating Scroll.
func (*Layout) ScenePosChildren ¶
func (ly *Layout) ScenePosChildren()
ScenePosChildren runs ScenePos on the children
func (*Layout) ScenePosLay ¶
func (ly *Layout) ScenePosLay()
func (*Layout) ScrollActionDelta ¶
ScrollActionDelta moves the scrollbar in given dimension by given delta and emits a ScrollSig signal.
func (*Layout) ScrollActionPos ¶
ScrollActionPos moves the scrollbar in given dimension to given position and emits a ScrollSig signal.
func (*Layout) ScrollChanged ¶
ScrollChanged is called in the OnInput event handler for updating, when the scrollbar value has changed, for given dimension. This is part of the Layouter interface.
func (*Layout) ScrollDelta ¶
ScrollDelta processes a scroll event. If only one dimension is processed, and there is a non-zero in other, then the consumed dimension is reset to 0 and the event is left unprocessed, so a higher level can consume the remainder.
func (*Layout) ScrollDimToCenter ¶
ScrollDimToCenter scrolls to put the given child coordinate position (eg., middle of a view box) at the center of our scroll area, to the extent possible. Returns true if scrolling was needed.
func (*Layout) ScrollDimToContentEnd ¶
ScrollDimToContentEnd is a helper function that scrolls the layout to the end of its content (ie: moves the scrollbar to the very end).
func (*Layout) ScrollDimToEnd ¶
ScrollDimToEnd scrolls to put the given child coordinate position (eg., bottom / right of a view box) at the end (bottom / right) of our scroll area, to the extent possible. Returns true if scrolling was needed.
func (*Layout) ScrollDimToStart ¶
ScrollDimToStart scrolls to put the given child coordinate position (eg., top / left of a view box) at the start (top / left) of our scroll area, to the extent possible. Returns true if scrolling was needed.
func (*Layout) ScrollGeom ¶
ScrollGeom returns the target position and size for scrollbars
func (*Layout) ScrollResetIfNone ¶
func (ly *Layout) ScrollResetIfNone()
ScrollResetIfNone resets the scroll offsets if there are no scrollbars
func (*Layout) ScrollToBox ¶
ScrollToBox scrolls the layout to ensure that given rect box is in view. Returns true if scrolling was needed
func (*Layout) ScrollToBoxDim ¶
ScrollToBoxDim scrolls to ensure that given target [min..max] range along one dimension is in view. Returns true if scrolling was needed
func (*Layout) ScrollToItem ¶
ScrollToItem scrolls the layout to ensure that given item is in view. Returns true if scrolling was needed
func (*Layout) ScrollToPos ¶
ScrollToPos moves the scrollbar in given dimension to given position and DOES NOT emit a ScrollSig signal.
func (*Layout) ScrollValues ¶
ScrollValues returns the maximum size that could be scrolled, the visible size (which could be less than the max size, in which case no scrollbar is needed), and visSize / maxSize as the VisiblePct. This is used in updating the scrollbar and determining whether one is needed in the first place
func (*Layout) SetScrollParams ¶
SetScrollParams sets scrollbar parameters. Must set Step and PageStep, but can also set others as needed. Max and VisiblePct are automatically set based on ScrollValues maxSize, visPct.
func (*Layout) SetScrollsOff ¶
func (ly *Layout) SetScrollsOff()
SetScrollsOff turns off the scrollbars
func (*Layout) SetTooltip ¶
SetTooltip sets the [Layout.Tooltip]
func (*Layout) SizeDownAllocActual ¶
SizeDownAllocActual sets Alloc to Actual for no-extra case.
func (*Layout) SizeDownAllocActualCells ¶
SizeDownAllocActualCells sets Alloc to Actual for no-extra case. Note however that due to max sizing for row / column, this size can actually be different than original actual.
func (*Layout) SizeDownAllocActualStacked ¶
func (*Layout) SizeDownChildren ¶
SizeDownChildren calls SizeDown on the Children. The kids must have their Size.Alloc set prior to this, which is what Layout type does. Other special widget types can do custom layout and call this too.
func (*Layout) SizeDownGrow ¶
SizeDownGrow grows the element sizes based on total extra and Grow
func (*Layout) SizeDownGrowCells ¶
func (*Layout) SizeDownGrowStacked ¶
func (*Layout) SizeDownLay ¶
SizeDownLay is the Layout standard SizeDown pass, returning true if another iteration is required. It allocates sizes to fit given parent-allocated total size.
func (*Layout) SizeDownSetAllocs ¶
SizeDownSetAllocs is the key SizeDown step that sets the allocations in the children, based on our allocation. In the default implementation this calls SizeDownGrow if there is extra space to grow, or SizeDownAllocActual to set the allocations as they currrently are.
func (*Layout) SizeDownWrap ¶
func (*Layout) SizeFinalChildren ¶
func (ly *Layout) SizeFinalChildren()
SizeFinalChildren calls SizeFinal on all the children of this node
func (*Layout) SizeFinalLay ¶
func (ly *Layout) SizeFinalLay()
SizeFinalLay is the Layout standard SizeFinal pass
func (*Layout) SizeFinalUpdateChildrenSizes ¶
func (ly *Layout) SizeFinalUpdateChildrenSizes()
SizeFinalUpdateChildrenSizes can optionally be called for layouts that dynamically create child elements based on final layout size. It ensures that the children are properly sized.
func (*Layout) SizeFromChildren ¶
func (ly *Layout) SizeFromChildren(iter int, pass LayoutPasses) math32.Vector2
SizeFromChildren gathers Actual size from kids. Different Layout types can alter this to present different Content sizes for the layout process, e.g., if Content is sized to fit allocation, as in the TopAppBar and Sliceview types.
func (*Layout) SizeFromChildrenCells ¶
func (ly *Layout) SizeFromChildrenCells(iter int, pass LayoutPasses) math32.Vector2
SizeFromChildrenCells for Flex, Grid
func (*Layout) SizeFromChildrenFit ¶
func (ly *Layout) SizeFromChildrenFit(iter int, pass LayoutPasses)
SizeFromChildrenFit gathers Actual size from kids, and calls LaySetContentFitOverflow to update Actual and Internal size based on this.
func (*Layout) SizeFromChildrenStacked ¶
SizeFromChildrenStacked for stacked case
func (*Layout) SizeUpChildren ¶
func (ly *Layout) SizeUpChildren()
SizeUpChildren calls SizeUp on all the children of this node
func (*Layout) SizeUpLay ¶
func (ly *Layout) SizeUpLay()
SizeUpLay is the Layout standard SizeUp pass
func (*Layout) StackTopWidget ¶
func (ly *Layout) StackTopWidget() (Widget, *WidgetBase)
StackTopWidget returns the StackTop element as a widget
func (*Layout) UpdateStackedVisibility ¶
func (ly *Layout) UpdateStackedVisibility()
UpdateStackedVisbility updates the visibility for Stacked layouts so the StackTop widget is visible, and others are Invisible.
type LayoutFlags ¶
type LayoutFlags WidgetFlags //enums:bitflag -trim-prefix Layout
Layoutlags has bool flags for Layout
const ( // for stacked layout, only layout the top widget. // this is appropriate for e.g., tab layout, which does a full // redraw on stack changes, but not for e.g., check boxes which don't LayoutStackTopOnly LayoutFlags = LayoutFlags(WidgetFlagsN) + iota // true if this layout got a redo = true on previous iteration -- otherwise it just skips any re-layout on subsequent iteration LayoutNeedsRedo // LayoutNoKeys prevents processing of keyboard events for this layout. // By default, Layout handles focus navigation events, but if an // outer Widget handles these instead, then this should be set. LayoutNoKeys )
const LayoutFlagsN LayoutFlags = 5
LayoutFlagsN is the highest valid value for type LayoutFlags, plus one.
func LayoutFlagsValues ¶
func LayoutFlagsValues() []LayoutFlags
LayoutFlagsValues returns all possible values for the type LayoutFlags.
func (LayoutFlags) BitIndexString ¶
func (i LayoutFlags) BitIndexString() string
BitIndexString returns the string representation of this LayoutFlags value if it is a bit index value (typically an enum constant), and not an actual bit flag value.
func (LayoutFlags) Desc ¶
func (i LayoutFlags) Desc() string
Desc returns the description of the LayoutFlags value.
func (LayoutFlags) HasFlag ¶
func (i LayoutFlags) HasFlag(f enums.BitFlag) bool
HasFlag returns whether these bit flags have the given bit flag set.
func (LayoutFlags) Int64 ¶
func (i LayoutFlags) Int64() int64
Int64 returns the LayoutFlags value as an int64.
func (LayoutFlags) MarshalText ¶
func (i LayoutFlags) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*LayoutFlags) SetFlag ¶
func (i *LayoutFlags) SetFlag(on bool, f ...enums.BitFlag)
SetFlag sets the value of the given flags in these flags to the given value.
func (*LayoutFlags) SetInt64 ¶
func (i *LayoutFlags) SetInt64(in int64)
SetInt64 sets the LayoutFlags value from an int64.
func (*LayoutFlags) SetString ¶
func (i *LayoutFlags) SetString(s string) error
SetString sets the LayoutFlags value from its string representation, and returns an error if the string is invalid.
func (*LayoutFlags) SetStringOr ¶
func (i *LayoutFlags) SetStringOr(s string) error
SetStringOr sets the LayoutFlags value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.
func (LayoutFlags) String ¶
func (i LayoutFlags) String() string
String returns the string representation of this LayoutFlags value.
func (*LayoutFlags) UnmarshalText ¶
func (i *LayoutFlags) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (LayoutFlags) Values ¶
func (i LayoutFlags) Values() []enums.Enum
Values returns all possible values for the type LayoutFlags.
type LayoutPasses ¶
type LayoutPasses int32 //enums:enum
LayoutPasses is used for the SizeFromChildren method, which can potentially compute different sizes for different passes.
const ( SizeUpPass LayoutPasses = iota SizeDownPass SizeFinalPass )
const LayoutPassesN LayoutPasses = 3
LayoutPassesN is the highest valid value for type LayoutPasses, plus one.
func LayoutPassesValues ¶
func LayoutPassesValues() []LayoutPasses
LayoutPassesValues returns all possible values for the type LayoutPasses.
func (LayoutPasses) Desc ¶
func (i LayoutPasses) Desc() string
Desc returns the description of the LayoutPasses value.
func (LayoutPasses) Int64 ¶
func (i LayoutPasses) Int64() int64
Int64 returns the LayoutPasses value as an int64.
func (LayoutPasses) MarshalText ¶
func (i LayoutPasses) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*LayoutPasses) SetInt64 ¶
func (i *LayoutPasses) SetInt64(in int64)
SetInt64 sets the LayoutPasses value from an int64.
func (*LayoutPasses) SetString ¶
func (i *LayoutPasses) SetString(s string) error
SetString sets the LayoutPasses value from its string representation, and returns an error if the string is invalid.
func (LayoutPasses) String ¶
func (i LayoutPasses) String() string
String returns the string representation of this LayoutPasses value.
func (*LayoutPasses) UnmarshalText ¶
func (i *LayoutPasses) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (LayoutPasses) Values ¶
func (i LayoutPasses) Values() []enums.Enum
Values returns all possible values for the type LayoutPasses.
type Layouter ¶
type Layouter interface { Widget // AsLayout returns the base Layout type AsLayout() *Layout // LayoutSpace sets our Space based on Styles, Scroll, and Gap Spacing. // Other layout types can change this if they want to. LayoutSpace() // SizeFromChildren gathers Actual size from kids into our Actual.Content size. // Different Layout types can alter this to present different Content // sizes for the layout process, e.g., if Content is sized to fit allocation, // as in the TopAppBar and Sliceview types. SizeFromChildren(iter int, pass LayoutPasses) math32.Vector2 // SizeDownSetAllocs is the key SizeDown step that sets the allocations // in the children, based on our allocation. In the default implementation // this calls SizeDownGrow if there is extra space to grow, or // SizeDownAllocActual to set the allocations as they currently are. SizeDownSetAllocs(iter int) // ManageOverflow uses overflow settings to determine if scrollbars // are needed, based on difference between ActualOverflow (full actual size) // and Alloc allocation. Returns true if size changes as a result. // If updtSize is false, then the Actual and Alloc sizes are NOT // updated as a result of change from adding scrollbars // (generally should be true, but some cases not) ManageOverflow(iter int, updtSize bool) bool // ScrollChanged is called in the OnInput event handler for updating // when the scrollbar value has changed, for given dimension ScrollChanged(d math32.Dims, sb *Slider) // ScrollValues returns the maximum size that could be scrolled, // the visible size (which could be less than the max size, in which // case no scrollbar is needed), and visSize / maxSize as the VisiblePct. // This is used in updating the scrollbar and determining whether one is // needed in the first place ScrollValues(d math32.Dims) (maxSize, visSize, visPct float32) // ScrollGeom returns the target position and size for scrollbars ScrollGeom(d math32.Dims) (pos, sz math32.Vector2) // SetScrollParams sets scrollbar parameters. Must set Step and PageStep, // but can also set others as needed. // Max and VisiblePct are automatically set based on ScrollValues maxSize, visPct. SetScrollParams(d math32.Dims, sb *Slider) }
Layouter is the interface for layout functions, called by Layout widget type during the various Layout passes.
type Meter ¶
type Meter struct { WidgetBase // Type is the styling type of the meter. Type MeterTypes // Value is the current value of the meter. // It defaults to 0.5. Value float32 // Min is the minimum possible value of the meter. // It defaults to 0. Min float32 // Max is the maximum possible value of the meter. // It defaults to 1. Max float32 // Text, for [MeterCircle] and [MeterSemicircle], is the // text to render inside of the circle/semicircle. Text string // ValueColor is the image color that will be used to // render the filled value bar. It should be set in Style. ValueColor image.Image // Width, for [MeterCircle] and [MeterSemicircle], is the // width of the circle/semicircle. It should be set in Style. Width units.Value }
Meter is a widget that renders a current value on as a filled bar/semicircle relative to a minimum and maximum potential value.
func NewMeter ¶
NewMeter adds a new Meter with the given name to the given parent: Meter is a widget that renders a current value on as a filled bar/semicircle relative to a minimum and maximum potential value.
func (*Meter) ApplyStyle ¶
func (m *Meter) ApplyStyle()
func (*Meter) NodeType ¶
NodeType returns the *types.Type of Meter
func (*Meter) SetMax ¶
SetMax sets the [Meter.Max]: Max is the maximum possible value of the meter. It defaults to 1.
func (*Meter) SetMin ¶
SetMin sets the [Meter.Min]: Min is the minimum possible value of the meter. It defaults to 0.
func (*Meter) SetText ¶
SetText sets the [Meter.Text]: Text, for MeterCircle and MeterSemicircle, is the text to render inside of the circle/semicircle.
func (*Meter) SetTooltip ¶
SetTooltip sets the [Meter.Tooltip]
func (*Meter) SetType ¶
func (t *Meter) SetType(v MeterTypes) *Meter
SetType sets the [Meter.Type]: Type is the styling type of the meter.
func (*Meter) SetValue ¶
SetValue sets the [Meter.Value]: Value is the current value of the meter. It defaults to 0.5.
func (*Meter) SetValueColor ¶
SetValueColor sets the [Meter.ValueColor]: ValueColor is the image color that will be used to render the filled value bar. It should be set in Style.
func (*Meter) SetWidth ¶
SetWidth sets the [Meter.Width]: Width, for MeterCircle and MeterSemicircle, is the width of the circle/semicircle. It should be set in Style.
func (*Meter) WidgetTooltip ¶
type MeterTypes ¶
type MeterTypes int32 //enums:enum -trim-prefix Meter
MeterTypes are the different styling types of [Meter]s.
const ( // MeterLinear indicates to render a meter that goes in a straight, // linear direction, either horizontal or vertical, as specified by // [styles.Style.Direction]. MeterLinear MeterTypes = iota // MeterCircle indicates to render the meter as a circle. MeterCircle // MeterSemicircle indicates to render the meter as a semicircle. MeterSemicircle )
const MeterTypesN MeterTypes = 3
MeterTypesN is the highest valid value for type MeterTypes, plus one.
func MeterTypesValues ¶
func MeterTypesValues() []MeterTypes
MeterTypesValues returns all possible values for the type MeterTypes.
func (MeterTypes) Desc ¶
func (i MeterTypes) Desc() string
Desc returns the description of the MeterTypes value.
func (MeterTypes) Int64 ¶
func (i MeterTypes) Int64() int64
Int64 returns the MeterTypes value as an int64.
func (MeterTypes) MarshalText ¶
func (i MeterTypes) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*MeterTypes) SetInt64 ¶
func (i *MeterTypes) SetInt64(in int64)
SetInt64 sets the MeterTypes value from an int64.
func (*MeterTypes) SetString ¶
func (i *MeterTypes) SetString(s string) error
SetString sets the MeterTypes value from its string representation, and returns an error if the string is invalid.
func (MeterTypes) String ¶
func (i MeterTypes) String() string
String returns the string representation of this MeterTypes value.
func (*MeterTypes) UnmarshalText ¶
func (i *MeterTypes) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (MeterTypes) Values ¶
func (i MeterTypes) Values() []enums.Enum
Values returns all possible values for the type MeterTypes.
type NewItemsData ¶
type NewItemsData struct { // Number is the number of elements to create Number int // Type is the type of elements to create Type *types.Type }
NewItemsData contains the data necessary to make a certain number of items of a certain type, which can be used with a StructView in new item dialogs.
type RenderContext ¶
type RenderContext struct { // Flags hold binary context state Flags RenderContextFlags // LogicalDPI is the current logical dots-per-inch resolution of the // window, which should be used for most conversion of standard units. LogicalDPI float32 // Geometry of the rendering window, in actual "dot" pixels used for rendering. Geom math32.Geom2DInt // Mu is mutex for locking out rendering and any destructive updates. // It is locked at the RenderWin level during rendering and // event processing to provide exclusive blocking of external updates. // Use AsyncLock from any outside routine to grab the lock before // doing modifications. Mu sync.Mutex }
RenderContext provides rendering context from outer RenderWin window to Stage and Scene elements to inform styling, layout and rendering. It also has the master Mutex for any updates to the window contents: use Read lock for anything updating.
func NewRenderContext ¶
func NewRenderContext() *RenderContext
NewRenderContext returns a new RenderContext initialized according to the main Screen size and LogicalDPI as initial defaults. The actual window size is set during Resized method, which is typically called after the window is created by the OS.
func (*RenderContext) HasFlag ¶
func (rc *RenderContext) HasFlag(flag enums.BitFlag) bool
HasFlag returns true if given flag is set
func (*RenderContext) Lock ¶
func (rc *RenderContext) Lock()
Lock is called by RenderWin during RenderWindow and HandleEvent when updating all widgets and rendering the screen. Any outside access to window contents / scene must acquire this lock first. In general, use AsyncLock to do this.
func (*RenderContext) SetFlag ¶
func (rc *RenderContext) SetFlag(on bool, flag ...enums.BitFlag)
SetFlag sets given flag(s) on or off
func (*RenderContext) String ¶
func (rc *RenderContext) String() string
func (*RenderContext) Unlock ¶
func (rc *RenderContext) Unlock()
Unlock must be called for each Lock, when done.
type RenderContextFlags ¶
type RenderContextFlags int64 //enums:bitflag -trim-prefix Render
RenderContextFlags represent RenderContext state
const ( // the window is visible and should be rendered to RenderVisible RenderContextFlags = iota // forces a rebuild of all scene elements RenderRebuild )
const RenderContextFlagsN RenderContextFlags = 2
RenderContextFlagsN is the highest valid value for type RenderContextFlags, plus one.
func RenderContextFlagsValues ¶
func RenderContextFlagsValues() []RenderContextFlags
RenderContextFlagsValues returns all possible values for the type RenderContextFlags.
func (RenderContextFlags) BitIndexString ¶
func (i RenderContextFlags) BitIndexString() string
BitIndexString returns the string representation of this RenderContextFlags value if it is a bit index value (typically an enum constant), and not an actual bit flag value.
func (RenderContextFlags) Desc ¶
func (i RenderContextFlags) Desc() string
Desc returns the description of the RenderContextFlags value.
func (RenderContextFlags) HasFlag ¶
func (i RenderContextFlags) HasFlag(f enums.BitFlag) bool
HasFlag returns whether these bit flags have the given bit flag set.
func (RenderContextFlags) Int64 ¶
func (i RenderContextFlags) Int64() int64
Int64 returns the RenderContextFlags value as an int64.
func (RenderContextFlags) MarshalText ¶
func (i RenderContextFlags) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*RenderContextFlags) SetFlag ¶
func (i *RenderContextFlags) SetFlag(on bool, f ...enums.BitFlag)
SetFlag sets the value of the given flags in these flags to the given value.
func (*RenderContextFlags) SetInt64 ¶
func (i *RenderContextFlags) SetInt64(in int64)
SetInt64 sets the RenderContextFlags value from an int64.
func (*RenderContextFlags) SetString ¶
func (i *RenderContextFlags) SetString(s string) error
SetString sets the RenderContextFlags value from its string representation, and returns an error if the string is invalid.
func (*RenderContextFlags) SetStringOr ¶
func (i *RenderContextFlags) SetStringOr(s string) error
SetStringOr sets the RenderContextFlags value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.
func (RenderContextFlags) String ¶
func (i RenderContextFlags) String() string
String returns the string representation of this RenderContextFlags value.
func (*RenderContextFlags) UnmarshalText ¶
func (i *RenderContextFlags) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (RenderContextFlags) Values ¶
func (i RenderContextFlags) Values() []enums.Enum
Values returns all possible values for the type RenderContextFlags.
type RenderParams ¶
type RenderParams struct { // LogicalDPI is the current logical dots-per-inch resolution of the // window, which should be used for most conversion of standard units. LogicalDPI float32 // Geometry of the rendering window, in actual "dot" pixels used for rendering. Geom math32.Geom2DInt }
RenderParams are the key RenderWin params that determine if a scene needs to be restyled since last render, if these params change.
func (*RenderParams) NeedsRestyle ¶
func (rp *RenderParams) NeedsRestyle(rc *RenderContext) bool
NeedsRestyle returns true if the current render context params differ from those used in last render.
func (*RenderParams) SaveRender ¶
func (rp *RenderParams) SaveRender(rc *RenderContext)
SaveRender grabs current render context params
type RenderScenes ¶
type RenderScenes struct { // starting index for this set of Scenes StartIndex int // max index (exclusive) for this set of Scenes MaxIndex int // set to true to flip Y axis in drawing these images FlipY bool // ordered list of scenes and direct rendering widgets. Index is Drawer image index. Scenes []Widget // SceneIndex holds the index for each scene / direct render widget. // Used to detect changes in index. SceneIndex map[Widget]int }
RenderScenes are a list of Scene and direct rendering widgets, compiled in rendering order, whose Pixels images are composed directly to the RenderWin window.
func (*RenderScenes) Add ¶
func (rs *RenderScenes) Add(w Widget, scIndex map[Widget]int) int
Add adds a new node, returning index
func (*RenderScenes) DrawAll ¶
func (rs *RenderScenes) DrawAll(drw system.Drawer)
DrawAll does drw.Copy drawing call for all Scenes, using proper TextureSet for each of system.MaxTexturesPerSet Scenes.
func (*RenderScenes) SetImages ¶
func (rs *RenderScenes) SetImages(drw system.Drawer)
SetImages calls drw.SetGoImage on all updated Scene images
func (*RenderScenes) SetIndexRange ¶
func (rs *RenderScenes) SetIndexRange(st, n int)
SetIndexRange sets the index range based on starting index and n
type RenderWindow ¶
type RenderWindow struct { // Flags are the flags associated with the window. Flags WindowFlags // Name is the name of the window. Name string // Title is the displayed name of window, for window manager etc. // Window object name is the internal handle and is used for tracking property info etc Title string // SystemWindow is the OS-specific window interface, which handles // all the os-specific functions, including delivering events etc SystemWindow system.Window `json:"-" xml:"-"` // MainStageMgr controlling the Main Stage elements in this window. // The Render Context in this manager is the original source for all Stages. MainStageMgr StageMgr // RenderScenes are the Scene elements that draw directly to the window, // arranged in order, and continuously updated during Render. RenderScenes RenderScenes // NoEventsChan is a channel on which a signal is sent when there are // no events left in the window [events.Deque]. It is used internally // for event handling in tests, and should typically not be used by // end-users. NoEventsChan chan struct{} }
RenderWindow provides an outer "actual" window where everything is rendered, and is the point of entry for all events coming in from user actions.
RenderWindow contents are all managed by the StageMgr that handles Main Stage elements such as WindowStage and DialogStage, which in turn manage their own stack of Popup Stage elements such as Menu, Tooltip, etc. The contents of each Stage is provided by a Scene, containing Widgets, and the Stage Pixels image is drawn to the RenderWindow in the RenderWindow method.
Rendering is handled by the system.Drawer. It is akin to a window manager overlaying Go image bitmaps on top of each other in the proper order, based on the StageMgr stacking order. Sprites are managed by the Main Stage, as layered textures of the same size, to enable unlimited number packed into a few descriptors for standard sizes.
var CurrentRenderWindow *RenderWindow
CurrentRenderWindow is the current RenderWindow. On single window platforms (mobile, web, and offscreen), this is the sonly render window.
func NewRenderWindow ¶
func NewRenderWindow(name, title string, opts *system.NewWindowOptions) *RenderWindow
NewRenderWindow creates a new window with given internal name handle, display name, and options. This is called by Stage.NewRenderWindow which handles setting the opts and other infrastructure.
func (*RenderWindow) CloseReq ¶
func (w *RenderWindow) CloseReq()
CloseReq requests that the window be closed, which could be rejected. It firsts unlocks and then locks the RenderContext to prevent deadlocks. If this is called asynchronously outside of the main event loop, [RenderWindow.SystemWin.CloseReq] should be called directly instead.
func (*RenderWindow) Closed ¶
func (w *RenderWindow) Closed()
Closed frees any resources after the window has been closed.
func (*RenderWindow) DrawScenes ¶
func (w *RenderWindow) DrawScenes()
DrawScenes does the drawing of RenderScenes to the window.
func (*RenderWindow) EventLoop ¶
func (w *RenderWindow) EventLoop()
EventLoop runs the event processing loop for the RenderWin -- grabs system events for the window and dispatches them to receiving nodes, and manages other state etc (popups, etc).
func (*RenderWindow) FillInsets ¶
func (w *RenderWindow) FillInsets()
FillInsets fills the window insets, if any, with colors.Scheme.Background.
func (*RenderWindow) GatherScenes ¶
func (w *RenderWindow) GatherScenes() bool
GatherScenes finds all the Scene elements that drive rendering into the RenderScenes list. Returns false on failure / nothing to render.
func (*RenderWindow) GoStartEventLoop ¶
func (w *RenderWindow) GoStartEventLoop()
GoStartEventLoop starts the event processing loop for this window in a new goroutine, and returns immediately. Adds to WindowWait wait group so a main thread can wait on that for all windows to close.
func (*RenderWindow) HandleEvent ¶
func (w *RenderWindow) HandleEvent(e events.Event)
HandleEvent processes given events.Event. All event processing operates under a RenderContext.Lock so that no rendering update can occur during event-driven updates. Because rendering itself is event driven, this extra level of safety is redundant in this case, but other non-event-driven updates require the lock protection.
func (*RenderWindow) HandleWindowEvents ¶
func (w *RenderWindow) HandleWindowEvents(e events.Event)
func (*RenderWindow) HasFlag ¶
func (w *RenderWindow) HasFlag(flag enums.BitFlag) bool
HasFlag returns true if given flag is set
func (*RenderWindow) Is ¶
func (w *RenderWindow) Is(flag enums.BitFlag) bool
Is returns true if given flag is set
func (*RenderWindow) IsClosed ¶
func (w *RenderWindow) IsClosed() bool
IsClosed reports if the window has been closed
func (*RenderWindow) IsVisible ¶
func (w *RenderWindow) IsVisible() bool
IsVisible is the main visibility check -- don't do any window updates if not visible!
func (*RenderWindow) LogicalDPI ¶
func (w *RenderWindow) LogicalDPI() float32
LogicalDPI returns the current logical dots-per-inch resolution of the window, which should be used for most conversion of standard units -- physical DPI can be found in the Screen
func (*RenderWindow) MainScene ¶
func (w *RenderWindow) MainScene() *Scene
MainScene returns the current MainStageMgr Top Scene, which is the current Window or FullWindow Dialog occupying the RenderWin.
func (*RenderWindow) Minimize ¶
func (w *RenderWindow) Minimize()
Minimize requests that the window be iconified, making it no longer visible or active -- rendering should not occur for minimized windows.
func (*RenderWindow) Raise ¶
func (w *RenderWindow) Raise()
Raise requests that the window be at the top of the stack of windows, and receive focus. If it is iconified, it will be de-iconified. This is the only supported mechanism for de-iconifying. This also sets CurRenderWin to the window.
func (*RenderWindow) RenderContext ¶
func (w *RenderWindow) RenderContext() *RenderContext
func (*RenderWindow) RenderWindow ¶
func (w *RenderWindow) RenderWindow()
RenderWindow performs all rendering based on current StageMgr config. It sets the Write lock on RenderContext Mutex, so nothing else can update during this time. All other updates are done with a Read lock so they won't interfere with each other.
func (*RenderWindow) Resized ¶
func (w *RenderWindow) Resized()
Resized updates internal buffers after a window has been resized.
func (*RenderWindow) SendCustomEvent ¶
func (w *RenderWindow) SendCustomEvent(data any)
SendCustomEvent sends a custom event with given data to this window -- widgets can connect to receive CustomEventTypes events to receive them. Sometimes it is useful to send a custom event just to trigger a pass through the event loop, even if nobody is listening (e.g., if a popup is posted without a surrounding event, as in Complete.ShowCompletions
func (*RenderWindow) SendShowEvents ¶
func (w *RenderWindow) SendShowEvents()
func (*RenderWindow) SendWinFocusEvent ¶
func (w *RenderWindow) SendWinFocusEvent(act events.WinActions)
todo: fix or remove SendWinFocusEvent sends the RenderWinFocusEvent to widgets
func (*RenderWindow) SetCloseCleanFunc ¶
func (w *RenderWindow) SetCloseCleanFunc(fun func(win *RenderWindow))
SetCloseCleanFunc sets the function that is called whenever window is actually about to close (irrevocably) -- can do any necessary last-minute cleanup here.
func (*RenderWindow) SetCloseReqFunc ¶
func (w *RenderWindow) SetCloseReqFunc(fun func(win *RenderWindow))
SetCloseReqFunc sets the function that is called whenever there is a request to close the window (via a OS or a call to CloseReq() method). That function can then adjudicate whether and when to actually call Close.
func (*RenderWindow) SetFlag ¶
func (w *RenderWindow) SetFlag(on bool, flag ...enums.BitFlag)
SetFlag sets given flag(s) on or off
func (*RenderWindow) SetName ¶
func (w *RenderWindow) SetName(name string)
SetName sets name of this window and also the RenderWin, and applies any window geometry settings associated with the new name if it is different from before
func (*RenderWindow) SetSize ¶
func (w *RenderWindow) SetSize(sz image.Point)
SetSize requests that the window be resized to the given size in underlying pixel coordinates, which means that the requested size is divided by the screen's DevicePixelRatio
func (*RenderWindow) SetStageTitle ¶
func (w *RenderWindow) SetStageTitle(title string)
SetStageTitle sets the title of the underlying SystemWin to the given stage title combined with the RenderWin title.
func (*RenderWindow) SetTitle ¶
func (w *RenderWindow) SetTitle(title string)
SetTitle sets title of this window and its underlying SystemWin.
func (*RenderWindow) SetWinSize ¶
func (w *RenderWindow) SetWinSize(sz image.Point)
SetWinSize requests that the window be resized to the given size in OS window manager specific coordinates, which may be different from the underlying pixel-level resolution of the window. This will trigger a resize event and be processed that way when it occurs.
func (*RenderWindow) SetZoom ¶
func (w *RenderWindow) SetZoom(zoom float32)
SetZoom sets [AppearanceSettingsData.Zoom] to the given value and then triggers necessary updating and makes a snackbar.
func (*RenderWindow) StepZoom ¶
func (w *RenderWindow) StepZoom(steps float32)
StepZoom calls [SetZoom] with the current zoom plus 10 times the given number of steps.
func (*RenderWindow) StopEventLoop ¶
func (w *RenderWindow) StopEventLoop()
StopEventLoop tells the event loop to stop running when the next event arrives.
type RenderWindowList ¶
type RenderWindowList []*RenderWindow
RenderWindowList is a list of windows.
var AllRenderWindows RenderWindowList
AllRenderWindows is the list of all windows that have been created (dialogs, main windows, etc).
var DialogRenderWindows RenderWindowList
DialogRenderWindows is the list of only dialog windows that have been created.
var MainRenderWindows RenderWindowList
MainRenderWindows is the list of main windows (non-dialogs) that have been created.
func (*RenderWindowList) Add ¶
func (wl *RenderWindowList) Add(w *RenderWindow)
Add adds a window to the list.
func (*RenderWindowList) Delete ¶
func (wl *RenderWindowList) Delete(w *RenderWindow)
Delete removes a window from the list.
func (*RenderWindowList) FindData ¶
func (wl *RenderWindowList) FindData(data any) (*RenderWindow, bool)
FindData finds window with given Data on list -- returns window and true if found, nil, false otherwise. data of type string works fine -- does equality comparison on string contents.
func (*RenderWindowList) FindName ¶
func (wl *RenderWindowList) FindName(name string) (*RenderWindow, bool)
FindName finds window with given name on list (case sensitive) -- returns window and true if found, nil, false otherwise.
func (*RenderWindowList) FindRenderWin ¶
func (wl *RenderWindowList) FindRenderWin(osw system.Window) (*RenderWindow, bool)
FindRenderWin finds window with given system.RenderWin on list -- returns window and true if found, nil, false otherwise.
func (*RenderWindowList) FocusNext ¶
func (wl *RenderWindowList) FocusNext() (*RenderWindow, int)
FocusNext focuses on the next window in the list, after the current Focused() one skips minimized windows
func (*RenderWindowList) Focused ¶
func (wl *RenderWindowList) Focused() (*RenderWindow, int)
Focused returns the (first) window in this list that has the WinGotFocus flag set and the index in the list (nil, -1 if not present)
func (*RenderWindowList) Len ¶
func (wl *RenderWindowList) Len() int
Len returns the length of the list, concurrent-safe
func (*RenderWindowList) Win ¶
func (wl *RenderWindowList) Win(idx int) *RenderWindow
Win gets window at given index, concurrent-safe
type SVG ¶
type SVG struct { Box // SVG is the SVG object associated with the element. SVG *svg.SVG `set:"-"` }
SVG is a Widget that renders an svg.SVG object. If it is not states.ReadOnly, the user can pan and zoom the display. By default, it is states.ReadOnly. See [views.ConfigSVGToolbar] for a toolbar with panning, selecting, and I/O buttons.
func NewSVG ¶
NewSVG adds a new SVG with the given name to the given parent: SVG is a Widget that renders an svg.SVG object. If it is not states.ReadOnly, the user can pan and zoom the display. By default, it is states.ReadOnly. See [views.ConfigSVGToolbar] for a toolbar with panning, selecting, and I/O buttons.
func (*SVG) HandleEvents ¶
func (sv *SVG) HandleEvents()
func (*SVG) ReadString ¶
ReadString reads an XML-formatted SVG file from the given string.
type ScFlags ¶
type ScFlags WidgetFlags //enums:bitflag
ScFlags has critical state information signaling when rendering, styling etc need to be done
const ( // ScUpdating means scene is in the process of updating: // set for any kind of tree-level update. // skip any further update passes until it goes off. ScUpdating ScFlags = ScFlags(WidgetFlagsN) + iota // ScNeedsRender means nodes have flagged that they need a Render // update. ScNeedsRender // ScNeedsLayout means that this scene needs DoLayout stack: // GetSize, DoLayout, then Render. This is true after any Config. ScNeedsLayout // ScNeedsRebuild means that this scene needs full Rebuild: // Config, Layout, Render with DoRebuild flag set // (e.g., after global style changes, zooming, etc) ScNeedsRebuild // ScImageUpdated indicates that the Scene's image has been updated // e.g., due to a render or a resize. This is reset by the // global RenderWin rendering pass, so it knows whether it needs to // copy the image up to the GPU or not. ScImageUpdated // ScPrefSizing means that this scene is currently doing a // PrefSize computation to compute the size of the scene // (for sizing window for example) -- affects layout size computation // only for Over ScPrefSizing // ScPreserve keeps this scene around instead of deleting // when it is no longer needed. // Set if added to SceneLibrary for example. ScPreserve // ScRenderBBoxes renders the bounding boxes for all objects in scene ScRenderBBoxes )
const ScFlagsN ScFlags = 10
ScFlagsN is the highest valid value for type ScFlags, plus one.
func ScFlagsValues ¶
func ScFlagsValues() []ScFlags
ScFlagsValues returns all possible values for the type ScFlags.
func (ScFlags) BitIndexString ¶
BitIndexString returns the string representation of this ScFlags value if it is a bit index value (typically an enum constant), and not an actual bit flag value.
func (ScFlags) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*ScFlags) SetFlag ¶
SetFlag sets the value of the given flags in these flags to the given value.
func (*ScFlags) SetString ¶
SetString sets the ScFlags value from its string representation, and returns an error if the string is invalid.
func (*ScFlags) SetStringOr ¶
SetStringOr sets the ScFlags value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.
func (*ScFlags) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Scene ¶
type Scene struct { Frame // Bars contains functions for constructing the control bars for this Scene, // attached to different sides of a Scene (e.g., TopAppBar at Top, // NavBar at Bottom, etc). Functions are called in forward order // so first added are called first. Bars styles.Sides[BarFuncs] `json:"-" xml:"-"` // BarsInherit determines which of the Bars side functions are inherited // from the context widget, for FullWindow Dialogs BarsInherit styles.Sides[bool] // AppBars contains functions for configuring a top-level App toolbar, // (e.g., TopAppBar) for elements contained within this Scene, // that should be represented in any app-level toolbar constructed // for this Scene. AppBars ToolbarFuncs `json:"-" xml:"-"` // Body provides the main contents of scenes that use control Bars // to allow the main window contents to be specified separately // from that dynamic control content. When constructing scenes using // a Body, you can operate directly on the [Body], which has wrappers // for most major Scene functions. Body *Body // Data is the optional data value being represented by this scene. // Used e.g., for recycling views of a given item instead of creating new one. Data any // Size and position relative to overall rendering context. SceneGeom math32.Geom2DInt `edit:"-" set:"-"` // paint context for rendering PaintContext paint.Context `copier:"-" json:"-" xml:"-" view:"-" set:"-"` // live pixels that we render into Pixels *image.RGBA `copier:"-" json:"-" xml:"-" view:"-" set:"-"` // event manager for this scene EventMgr EventMgr `copier:"-" json:"-" xml:"-" set:"-"` // current stage in which this Scene is set Stage *Stage `copier:"-" json:"-" xml:"-" set:"-"` // RenderBBoxHue is current hue for rendering bounding box in ScRenderBBoxes mode RenderBBoxHue float32 `copier:"-" json:"-" xml:"-" view:"-" set:"-"` // the currently selected/hovered widget through the inspect editor selection mode // that should be highlighted with a background color SelectedWidget Widget // the channel on which the selected widget through the inspect editor // selection mode is transmitted to the inspect editor after the user is done selecting SelectedWidgetChan chan Widget `json:"-" xml:"-"` // LastRender captures key params from last render. // If different then a new ApplyStyleScene is needed. LastRender RenderParams `edit:"-" set:"-"` // StyleMu is RW mutex protecting access to Style-related global vars StyleMu sync.RWMutex `copier:"-" json:"-" xml:"-" view:"-" set:"-"` // ShowIter counts up at start of showing a Scene // to trigger Show event and other steps at start of first show ShowIter int `copier:"-" json:"-" xml:"-" view:"-" set:"-"` // ReRender items are re-rendered after the current pass ReRender []Widget // DirectRenders are widgets that render directly to the RenderWin // instead of rendering into the Scene Pixels image. DirectRenders []Widget // contains filtered or unexported fields }
Scene contains a Widget tree, rooted in an embedded Frame layout, which renders into its Pixels image. The Scene is set in a Stage (pointer retained in Scene). Stage has a StageMgr manager for controlling things like Popups (Menus and Dialogs, etc).
Each Scene and Widget tree contains state specific to its particular usage within a given Stage and overall rendering context, representing the unit of rendering in the Cogent Core framework.
func AsScene ¶
AsScene returns the given value as a value of type Scene if the type of the given value embeds Scene, or nil otherwise
func NewBodyScene ¶
NewBodyScene creates a new Scene for use with an associated Body that contains the main content of the Scene (e.g., a Window, Dialog, etc). It will be constructed from the Bars-configured control bars on each side, with the given Body as the central content.
func NewMenuFromStrings ¶
NewMenuFromStrings constructs a new menu from given list of strings, calling the given function with the index of the selected string. if string == sel, that menu item is selected initially.
func NewMenuScene ¶
NewMenuScene constructs a Scene for displaying a menu, using the given menu constructor function. If no name is provided, it defaults to "menu". If no menu items added, returns nil.
func NewScene ¶
NewScene creates a new Scene object without a Body, e.g., for use in a Menu, Tooltip or other such simple popups or non-control-bar Scenes.
func NewTooltipScene ¶
NewTooltipScene returns a new tooltip scene for the given widget with the given tooltip based on the given context position and context size.
func (*Scene) AddDirectRender ¶
func (*Scene) AddReRender ¶
AddReRender adds given widget to be re-rendered next pass
func (*Scene) ApplyStyleScene ¶
func (sc *Scene) ApplyStyleScene()
ApplyStyleScene calls ApplyStyle on all widgets in the Scene, This is needed whenever the window geometry, DPI, etc is updated, which affects styling.
func (*Scene) AsScene ¶
AsScene satisfies the SceneEmbedder interface
func (*Scene) AssertPixels ¶
AssertPixels asserts that [Scene.Pixels] is equivalent to the image stored at the given filename in the testdata directory, with ".png" added to the filename if there is no extension (eg: "button" becomes "testdata/button.png"). Forward slashes are automatically replaced with backslashes on Windows. If it is not, it fails the test with an error, but continues its execution. If there is no image at the given filename in the testdata directory, it creates the image.
func (*Scene) BenchmarkFullRender ¶
func (sc *Scene) BenchmarkFullRender()
BenchmarkFullRender runs benchmark of 50 full re-renders (full restyling, layout, and everything), reporting targeted profile results and generating standard Go cpu.prof and mem.prof outputs.
func (*Scene) BenchmarkReRender ¶
func (sc *Scene) BenchmarkReRender()
BenchmarkReRender runs benchmark of 50 re-render-only updates of display (just the raw rendering, no styling or layout), reporting targeted profile results and generating standard Go cpu.prof and mem.prof outputs.
func (*Scene) Close ¶
Close closes the Stage associated with this Scene. This only works for main stages (windows and dialogs). It returns whether the Stage was successfully closed.
func (*Scene) ConfigSceneBars ¶
func (sc *Scene) ConfigSceneBars()
ConfigSceneBars configures the side control bars, for main scenes
func (*Scene) ConfigSceneWidgets ¶
func (sc *Scene) ConfigSceneWidgets()
ConfigSceneWidgets calls Config on all widgets in the Scene, which will set NeedsLayout to drive subsequent layout and render. This is a top-level call, typically only done when the window is first drawn, once the full sizing information is available.
func (*Scene) Delete ¶
func (sc *Scene) Delete()
Delete this Scene if not Flagged for preservation. Removes Decor and Frame Widgets
func (*Scene) DeleteDirectRender ¶
func (*Scene) DeleteImpl ¶
func (sc *Scene) DeleteImpl()
DeleteImpl does the deletion, removing Decor and Frame Widgets.
func (*Scene) DirectRenderDraw ¶
func (*Scene) DoRebuild ¶
func (sc *Scene) DoRebuild()
DoRebuild does the full re-render and RenderContext Rebuild flag should be used by Widgets to rebuild things that are otherwise cached (e.g., Icon, TextCursor).
func (*Scene) DoUpdate ¶
DoUpdate checks scene Needs flags to do whatever updating is required. returns false if already updating. This is the main update call made by the RenderWin at FPS frequency.
func (*Scene) FitInWindow ¶
FitInWindow fits Scene geometry (pos, size) into given window geom. Calls resize for the new size.
func (*Scene) FlagType ¶
func (sc *Scene) FlagType() enums.BitFlagSetter
func (*Scene) GetBar ¶
func (sc *Scene) GetBar(side styles.SideIndexes) *Layout
GetBar returns Bar layout widget at given side, nil if not there.
func (*Scene) GetTopAppBar ¶
GetTopAppBar returns the TopAppBar Toolbar if it exists, nil otherwise.
func (*Scene) HandleEvents ¶
func (sc *Scene) HandleEvents()
func (*Scene) InheritBars ¶
InheritBars inherits Bars functions from given other scene for each side that the other scene marks as inherited.
func (*Scene) InheritBarsWidget ¶
InheritBarsWidget inherits Bar functions based on a source widget (e.g., Context of dialog)
func (*Scene) LayoutRenderScene ¶
func (sc *Scene) LayoutRenderScene()
LayoutRenderScene does a layout and render of the tree: GetSize, DoLayout, Render. Needed after Config.
func (*Scene) LayoutScene ¶
func (sc *Scene) LayoutScene()
LayoutScene does a layout of the scene: Size, Position
func (*Scene) MainStageMgr ¶
MainStageMgr returns the Main StageMgr that typically lives in a RenderWin and manages all of the MainStage elements (Windows, Dialogs etc), which in turn manage their popups. This Scene could be in a popup or in a main stage.
func (*Scene) NodeType ¶
NodeType returns the *types.Type of Scene
func (*Scene) PrefSize ¶
PrefSize computes the preferred size of the scene based on current contents. initSz is the initial size -- e.g., size of screen. Used for auto-sizing windows.
func (*Scene) RenderContext ¶
func (sc *Scene) RenderContext() *RenderContext
RenderContext returns the current render context. This will be nil prior to actual rendering.
func (*Scene) RenderWin ¶
func (sc *Scene) RenderWin() *RenderWindow
RenderWin returns the current render window for this scene. In general it is best to go through RenderContext instead of the window. This will be nil prior to actual rendering.
func (*Scene) ReportWinNodes ¶
func (sc *Scene) ReportWinNodes()
ReportWinNodes reports the number of nodes in this scene
func (*Scene) ScIsVisible ¶
func (*Scene) SetAppBars ¶
func (t *Scene) SetAppBars(v ToolbarFuncs) *Scene
SetAppBars sets the [Scene.AppBars]: AppBars contains functions for configuring a top-level App toolbar, (e.g., TopAppBar) for elements contained within this Scene, that should be represented in any app-level toolbar constructed for this Scene.
func (*Scene) SetBars ¶
SetBars sets the [Scene.Bars]: Bars contains functions for constructing the control bars for this Scene, attached to different sides of a Scene (e.g., TopAppBar at Top, NavBar at Bottom, etc). Functions are called in forward order so first added are called first.
func (*Scene) SetBarsInherit ¶
SetBarsInherit sets the [Scene.BarsInherit]: BarsInherit determines which of the Bars side functions are inherited from the context widget, for FullWindow Dialogs
func (*Scene) SetBody ¶
SetBody sets the [Scene.Body]: Body provides the main contents of scenes that use control Bars to allow the main window contents to be specified separately from that dynamic control content. When constructing scenes using a Body, you can operate directly on the Body, which has wrappers for most major Scene functions.
func (*Scene) SetData ¶
SetData sets the [Scene.Data]: Data is the optional data value being represented by this scene. Used e.g., for recycling views of a given item instead of creating new one.
func (*Scene) SetDirectRenders ¶
SetDirectRenders sets the [Scene.DirectRenders]: DirectRenders are widgets that render directly to the RenderWin instead of rendering into the Scene Pixels image.
func (*Scene) SetReRender ¶
SetReRender sets the [Scene.ReRender]: ReRender items are re-rendered after the current pass
func (*Scene) SetSelectedWidget ¶
SetSelectedWidget sets the [Scene.SelectedWidget]: the currently selected/hovered widget through the inspect editor selection mode that should be highlighted with a background color
func (*Scene) SetSelectedWidgetChan ¶
SetSelectedWidgetChan sets the [Scene.SelectedWidgetChan]: the channel on which the selected widget through the inspect editor selection mode is transmitted to the inspect editor after the user is done selecting
func (*Scene) SetTooltip ¶
SetTooltip sets the [Scene.Tooltip]
func (*Scene) UpdateTitle ¶
UpdateTitle updates the title of the Scene's associated Stage, RenderWindow, and Body, if applicable.
type SceneEmbedder ¶
type SceneEmbedder interface {
AsScene() *Scene
}
SceneEmbedder is an interface that all types that embed Scene satisfy
type ScreenSettings ¶
type ScreenSettings struct { // overall zoom factor as a percentage of the default zoom Zoom float32 `default:"100" min:"10" max:"1000" step:"10"` }
ScreenSettings are the per-screen settings -- see system.App.Screen for info on the different screens -- these prefs are indexed by the Screen.Name -- settings here override those in the global settings.
type Scrim ¶
type Scrim struct {
WidgetBase
}
A Scrim is just a dummy Widget used for rendering a Scrim. Only used for its type. Everything else managed by RenderWin.
func NewScrim ¶
NewScrim adds a new Scrim with the given name to the given parent: A Scrim is just a dummy Widget used for rendering a Scrim. Only used for its type. Everything else managed by RenderWin.
func NewScrimForScene ¶
NewScrimForScene is the proper function to use for creating a new Scrim for use in rendering. Critical to not actually add the Scrim to the Scene -- just set its pointers.
func (*Scrim) DirectRenderDraw ¶
func (*Scrim) NodeType ¶
NodeType returns the *types.Type of Scrim
func (*Scrim) SetTooltip ¶
SetTooltip sets the [Scrim.Tooltip]
type Separator ¶
type Separator struct {
Box
}
Separator draws a separator line. It goes in the direction specified by [style.Style.Direction].
func NewSeparator ¶
NewSeparator adds a new Separator with the given name to the given parent: Separator draws a separator line. It goes in the direction specified by [style.Style.Direction].
func (*Separator) NodeType ¶
NodeType returns the *types.Type of Separator
func (*Separator) SetTooltip ¶
SetTooltip sets the [Separator.Tooltip]
type Settings ¶
type Settings interface { // Label returns the label text for the settings. Label() string // Filename returns the full filename/filepath at which the settings are stored. Filename() string // Defaults sets the default values for all of the settings. Defaults() // Apply does anything necessary to apply the settings to the app. Apply() // ConfigToolbar is an optional method that settings objects can implement in order to // configure the settings view toolbar with settings-related actions that the user can // perform. ConfigToolbar(tb *Toolbar) }
Settings is the interface that describes the functionality common to all settings data types.
type SettingsBase ¶
type SettingsBase struct { // Name is the name of the settings. Name string `view:"-" save:"-"` // File is the full filename/filepath at which the settings are stored. File string `view:"-" save:"-"` }
SettingsBase contains base settings logic that other settings data types can extend.
func (*SettingsBase) Apply ¶
func (sb *SettingsBase) Apply()
Apply does nothing by default and can be extended by other settings data types.
func (*SettingsBase) ConfigToolbar ¶
func (sb *SettingsBase) ConfigToolbar(tb *Toolbar)
ConfigToolbar does nothing by default and can be extended by other settings data types.
func (*SettingsBase) Defaults ¶
func (sb *SettingsBase) Defaults()
Defaults does nothing by default and can be extended by other settings data types.
func (*SettingsBase) Filename ¶
func (sb *SettingsBase) Filename() string
Filename returns the full filename/filepath at which the settings are stored.
func (*SettingsBase) Label ¶
func (sb *SettingsBase) Label() string
Label returns the label text for the settings.
type SettingsOpener ¶
SettingsOpener is an optional additional interface that Settings can satisfy to customize the behavior of OpenSettings.
type SettingsSaver ¶
SettingsSaver is an optional additional interface that Settings can satisfy to customize the behavior of SaveSettings.
type Shortcuts ¶
Shortcuts is a map between a key chord and a specific Button that can be triggered. This mapping must be unique, in that each chord has unique Button, and generally each Button only has a single chord as well, though this is not strictly enforced. Shortcuts are evaluated *after* the standard KeyMap event processing, so any conflicts are resolved in favor of the local widget's key event processing, with the shortcut only operating when no conflicting widgets are in focus. Shortcuts are always window-wide and are intended for global window / toolbar buttons. Widget-specific key functions should be handled directly within widget key event processing.
type ShouldShower ¶
type ShouldShower interface { // ShouldShow returns whether the given named field should be displayed. ShouldShow(field string) bool }
ShouldShower is an interface determining when you should take a shower. Actually, it determines whether a named field should be displayed (in views.StructView and views.StructViewInline).
type SizeClasses ¶
type SizeClasses int32 //enums:enum -trim-prefix Size
SizeClasses are the different size classes that a window can have.
const ( // SizeCompact is the size class for windows with a width less than // 600dp, which typically happens on phones. SizeCompact SizeClasses = iota // SizeMedium is the size class for windows with a width between 600dp // and 840dp inclusive, which typically happens on tablets. SizeMedium // SizeExpanded is the size class for windows with a width greater than // 840dp, which typically happens on desktop and laptop computers. SizeExpanded )
const SizeClassesN SizeClasses = 3
SizeClassesN is the highest valid value for type SizeClasses, plus one.
func SizeClassesValues ¶
func SizeClassesValues() []SizeClasses
SizeClassesValues returns all possible values for the type SizeClasses.
func (SizeClasses) Desc ¶
func (i SizeClasses) Desc() string
Desc returns the description of the SizeClasses value.
func (SizeClasses) Int64 ¶
func (i SizeClasses) Int64() int64
Int64 returns the SizeClasses value as an int64.
func (SizeClasses) MarshalText ¶
func (i SizeClasses) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*SizeClasses) SetInt64 ¶
func (i *SizeClasses) SetInt64(in int64)
SetInt64 sets the SizeClasses value from an int64.
func (*SizeClasses) SetString ¶
func (i *SizeClasses) SetString(s string) error
SetString sets the SizeClasses value from its string representation, and returns an error if the string is invalid.
func (SizeClasses) String ¶
func (i SizeClasses) String() string
String returns the string representation of this SizeClasses value.
func (*SizeClasses) UnmarshalText ¶
func (i *SizeClasses) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (SizeClasses) Values ¶
func (i SizeClasses) Values() []enums.Enum
Values returns all possible values for the type SizeClasses.
type SliceLabeler ¶
type SliceLabeler interface { // ElemLabel returns a GUI-appropriate label for slice element at given index ElemLabel(idx int) string }
SliceLabeler interface provides a GUI-appropriate label for a slice item, given an index into the slice.
type Slider ¶
type Slider struct { WidgetBase // Type is the type of the slider, which determines its visual // and functional properties. The default type, [SliderSlider], // should work for most end-user use cases. Type SliderTypes // Value is the current value, represented by the position of the thumb. // It defaults to 0.5. Value float32 `set:"-"` // Min is the minimum possible value. // It defaults to 0. Min float32 // Max is the maximum value supported. // It defaults to 1. Max float32 // Step is the amount that the arrow keys increment/decrement the value by. // It defaults to 0.1. Step float32 // EnforceStep is whether to ensure that the value is always // a multiple of [Slider.Step]. EnforceStep bool // PageStep is the amount that the PageUp and PageDown keys // increment/decrement the value by. // It defaults to 0.2, and will be at least as big as [Slider.Step]. PageStep float32 // Icon is an optional icon to use for the dragging knob. Icon icons.Icon `view:"show-name"` // For Scrollbar type only: proportion (1 max) of the full range of scrolled data // that is currently visible. This determines the thumb size and range of motion: // if 1, full slider is the thumb and no motion is possible. VisiblePct float32 `set:"-"` // Size of the thumb as a proportion of the slider thickness, which is // Content size (inside the padding). This is for actual X,Y dimensions, // so must be sensitive to Dim dimension alignment. ThumbSize math32.Vector2 // TrackSize is the proportion of slider thickness for the visible track // for the Slider type. It is often thinner than the thumb, achieved by // values < 1 (.5 default) TrackSize float32 // threshold for amount of change in scroll value before emitting an input event InputThreshold float32 // specifies the precision of decimal places (total, not after the decimal point) // to use in representing the number. This helps to truncate small weird floating // point values in the nether regions. Prec int // The background color that is used for styling the selected value section of the slider. // It should be set in the StyleFuncs, just like the main style object is. // If it is set to transparent, no value is rendered, so the value section of the slider // just looks like the rest of the slider. ValueColor image.Image // The background color that is used for styling the thumb (handle) of the slider. // It should be set in the StyleFuncs, just like the main style object is. // If it is set to transparent, no thumb is rendered, so the thumb section of the slider // just looks like the rest of the slider. ThumbColor image.Image // If true, keep the slider (typically a Scrollbar) within the parent Scene // bounding box, if the parent is in view. This is the default behavior // for Layout scrollbars, and setting this flag replicates that behavior // in other scrollbars. StayInView bool // logical position of the slider relative to Size Pos float32 `edit:"-" set:"-"` // previous Change event emitted value - don't re-emit Change if it is the same LastValue float32 `edit:"-" copier:"-" xml:"-" json:"-" set:"-"` // previous sliding value - for computing the Input change PrevSlide float32 `edit:"-" copier:"-" xml:"-" json:"-" set:"-"` // Computed size of the slide box in the relevant dimension // range of motion, exclusive of spacing, based on layout allocation. Size float32 `edit:"-" set:"-"` // underlying drag position of slider -- not subject to snapping SlideStartPos float32 `edit:"-" set:"-"` }
Slider is a slideable widget that provides slider functionality for two Types: Slider type provides a movable thumb that represents Value as the center of thumb Pos position, with room reserved at ends for 1/2 of the thumb size. Scrollbar has a VisiblePct factor that specifies the percent of the content currently visible, which determines the size of the thumb, and thus the range of motion remaining for the thumb Value (VisiblePct = 1 means thumb is full size, and no remaining range of motion). The Content size (inside the margin and padding) determines the outer bounds of the rendered area. The styles.Style.Direction determines the direction in which the slider slides.
func AsSlider ¶
AsSlider returns the given value as a value of type Slider if the type of the given value embeds Slider, or nil otherwise
func NewSlider ¶
NewSlider adds a new Slider with the given name to the given parent: Slider is a slideable widget that provides slider functionality for two Types: Slider type provides a movable thumb that represents Value as the center of thumb Pos position, with room reserved at ends for 1/2 of the thumb size. Scrollbar has a VisiblePct factor that specifies the percent of the content currently visible, which determines the size of the thumb, and thus the range of motion remaining for the thumb Value (VisiblePct = 1 means thumb is full size, and no remaining range of motion). The Content size (inside the margin and padding) determines the outer bounds of the rendered area. The styles.Style.Direction determines the direction in which the slider slides.
func (*Slider) AsSlider ¶
AsSlider satisfies the SliderEmbedder interface
func (*Slider) EffectiveMax ¶
EffectiveMax returns the effective maximum value represented. For the Slider type, it it is just Max. for the Scrollbar type, it is Max - Value of thumb size
func (*Slider) HandleEvents ¶
func (sr *Slider) HandleEvents()
func (*Slider) HandleKeys ¶
func (sr *Slider) HandleKeys()
func (*Slider) HandleMouse ¶
func (sr *Slider) HandleMouse()
func (*Slider) NodeType ¶
NodeType returns the *types.Type of Slider
func (*Slider) PointToRelPos ¶
PointToRelPos translates a point in scene local pixel coords into relative position within the slider content range
func (*Slider) ScrollScale ¶
ScrollScale returns scaled value of scroll delta as a function of the step size.
func (*Slider) ScrollThumbValue ¶
ScrollThumbValue returns the current scroll VisiblePct in terms of the Min - Max range of values.
func (*Slider) SendChanged ¶
SendChanged sends a Changed message if given new value is different from the existing Value.
func (*Slider) SetEnforceStep ¶
SetEnforceStep sets the [Slider.EnforceStep]: EnforceStep is whether to ensure that the value is always a multiple of [Slider.Step].
func (*Slider) SetIcon ¶
SetIcon sets the [Slider.Icon]: Icon is an optional icon to use for the dragging knob.
func (*Slider) SetInputThreshold ¶
SetInputThreshold sets the [Slider.InputThreshold]: threshold for amount of change in scroll value before emitting an input event
func (*Slider) SetMax ¶
SetMax sets the [Slider.Max]: Max is the maximum value supported. It defaults to 1.
func (*Slider) SetMin ¶
SetMin sets the [Slider.Min]: Min is the minimum possible value. It defaults to 0.
func (*Slider) SetPageStep ¶
SetPageStep sets the [Slider.PageStep]: PageStep is the amount that the PageUp and PageDown keys increment/decrement the value by. It defaults to 0.2, and will be at least as big as [Slider.Step].
func (*Slider) SetPosFromValue ¶
SetPosFromValue sets the slider position based on the given value (typically rs.Value)
func (*Slider) SetPrec ¶
SetPrec sets the [Slider.Prec]: specifies the precision of decimal places (total, not after the decimal point) to use in representing the number. This helps to truncate small weird floating point values in the nether regions.
func (*Slider) SetSliderPos ¶
SetSliderPos sets the position of the slider at the given relative position within the usable Content sliding range, in pixels, and updates the corresponding Value based on that position.
func (*Slider) SetSliderPosAction ¶
SetSliderPosAction sets the position of the slider at the given position in pixels, and updates the corresponding Value based on that position. This version sends tracking changes
func (*Slider) SetStayInView ¶
SetStayInView sets the [Slider.StayInView]: If true, keep the slider (typically a Scrollbar) within the parent Scene bounding box, if the parent is in view. This is the default behavior for Layout scrollbars, and setting this flag replicates that behavior in other scrollbars.
func (*Slider) SetStep ¶
SetStep sets the [Slider.Step]: Step is the amount that the arrow keys increment/decrement the value by. It defaults to 0.1.
func (*Slider) SetThumbColor ¶
SetThumbColor sets the [Slider.ThumbColor]: The background color that is used for styling the thumb (handle) of the slider. It should be set in the StyleFuncs, just like the main style object is. If it is set to transparent, no thumb is rendered, so the thumb section of the slider just looks like the rest of the slider.
func (*Slider) SetThumbSize ¶
SetThumbSize sets the [Slider.ThumbSize]: Size of the thumb as a proportion of the slider thickness, which is Content size (inside the padding). This is for actual X,Y dimensions, so must be sensitive to Dim dimension alignment.
func (*Slider) SetTooltip ¶
SetTooltip sets the [Slider.Tooltip]
func (*Slider) SetTrackSize ¶
SetTrackSize sets the [Slider.TrackSize]: TrackSize is the proportion of slider thickness for the visible track for the Slider type. It is often thinner than the thumb, achieved by values < 1 (.5 default)
func (*Slider) SetType ¶
func (t *Slider) SetType(v SliderTypes) *Slider
SetType sets the [Slider.Type]: Type is the type of the slider, which determines its visual and functional properties. The default type, SliderSlider, should work for most end-user use cases.
func (*Slider) SetValue ¶
SetValue sets the value and updates the slider position, but does not send a Change event (see Action version)
func (*Slider) SetValueAction ¶
SetValueAction sets the value and updates the slider representation, and emits an input and change event
func (*Slider) SetValueColor ¶
SetValueColor sets the [Slider.ValueColor]: The background color that is used for styling the selected value section of the slider. It should be set in the StyleFuncs, just like the main style object is. If it is set to transparent, no value is rendered, so the value section of the slider just looks like the rest of the slider.
func (*Slider) SetVisiblePct ¶
SetVisiblePct sets the visible pct value for Scrollbar type.
func (*Slider) SlideThumbSize ¶
SlideThumbSize returns thumb size, based on type
func (*Slider) SliderSize ¶
SliderSize returns the size available for sliding, based on allocation
func (*Slider) SliderThickness ¶
SliderThickness returns the thickness of the slider: Content size in other dim.
func (*Slider) SnapValue ¶
func (sr *Slider) SnapValue()
SnapValue snaps the value to step sizes if [Slider.EnforceStep] is on
func (*Slider) ThumbSizeDots ¶
ThumbSizeDots returns the thumb size in dots, based on ThumbSize and the content thickness
func (*Slider) WidgetTooltip ¶
type SliderEmbedder ¶
type SliderEmbedder interface {
AsSlider() *Slider
}
SliderEmbedder is an interface that all types that embed Slider satisfy
type SliderTypes ¶
type SliderTypes int32 //enums:enum -trim-prefix Slider
SliderTypes are the different types of sliders
const ( // SliderSlider indicates a standard, user-controllable slider // for setting a numeric value SliderSlider SliderTypes = iota // SliderScrollbar indicates a slider acting as a scrollbar for content // This sets the SliderScrollbar )
const SliderTypesN SliderTypes = 2
SliderTypesN is the highest valid value for type SliderTypes, plus one.
func SliderTypesValues ¶
func SliderTypesValues() []SliderTypes
SliderTypesValues returns all possible values for the type SliderTypes.
func (SliderTypes) Desc ¶
func (i SliderTypes) Desc() string
Desc returns the description of the SliderTypes value.
func (SliderTypes) Int64 ¶
func (i SliderTypes) Int64() int64
Int64 returns the SliderTypes value as an int64.
func (SliderTypes) MarshalText ¶
func (i SliderTypes) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*SliderTypes) SetInt64 ¶
func (i *SliderTypes) SetInt64(in int64)
SetInt64 sets the SliderTypes value from an int64.
func (*SliderTypes) SetString ¶
func (i *SliderTypes) SetString(s string) error
SetString sets the SliderTypes value from its string representation, and returns an error if the string is invalid.
func (SliderTypes) String ¶
func (i SliderTypes) String() string
String returns the string representation of this SliderTypes value.
func (*SliderTypes) UnmarshalText ¶
func (i *SliderTypes) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (SliderTypes) Values ¶
func (i SliderTypes) Values() []enums.Enum
Values returns all possible values for the type SliderTypes.
type Space ¶
type Space struct {
WidgetBase
}
Space is a fixed size blank space, with a default width of 1ch and a height of 1em. You can set styles.Style.Min to change its size.
func NewSpace ¶
NewSpace adds a new Space with the given name to the given parent: Space is a fixed size blank space, with a default width of 1ch and a height of 1em. You can set styles.Style.Min to change its size.
func (*Space) NodeType ¶
NodeType returns the *types.Type of Space
func (*Space) SetTooltip ¶
SetTooltip sets the [Space.Tooltip]
type Spinner ¶
type Spinner struct { TextField // Value is the current value. Value float32 `set:"-"` // HasMin is whether there is a minimum value to enforce. HasMin bool `set:"-"` // Min, if HasMin is true, is the the minimum value in range. Min float32 `set:"-"` // HaxMax is whether there is a maximum value to enforce. HasMax bool `set:"-"` // Max, if HasMax is true, is the maximum value in range. Max float32 `set:"-"` // Step is the amount that the up and down buttons and arrow keys // increment/decrement the value by. It defaults to 0.1. Step float32 // EnforceStep is whether to ensure that the value of the spinner // is always a multiple of [Spinner.Step]. EnforceStep bool // PageStep is the amount that the PageUp and PageDown keys // increment/decrement the value by. // It defaults to 0.2, and will be at least as big as [Spinner.Step]. PageStep float32 // Prec specifies the precision of decimal places // (total, not after the decimal point) to use in // representing the number. This helps to truncate // small weird floating point values. Prec int // Format is the format string to use for printing the value. // If it unset, %g is used. If it is decimal based // (ends in d, b, c, o, O, q, x, X, or U) then the value is // converted to decimal prior to printing. Format string }
Spinner combines a TextField with up / down buttons for incrementing / decrementing values -- all configured within the Parts of the widget
func AsSpinner ¶
AsSpinner returns the given value as a value of type Spinner if the type of the given value embeds Spinner, or nil otherwise
func NewSpinner ¶
NewSpinner adds a new Spinner with the given name to the given parent: Spinner combines a TextField with up / down buttons for incrementing / decrementing values -- all configured within the Parts of the widget
func (*Spinner) AsSpinner ¶
AsSpinner satisfies the SpinnerEmbedder interface
func (*Spinner) FormatIsInt ¶
FormatIsInt returns true if the format string requires an integer value
func (*Spinner) HandleEvents ¶
func (sp *Spinner) HandleEvents()
func (*Spinner) IncrementValue ¶
IncrementValue increments the value by given number of steps (+ or -), and enforces it to be an even multiple of the step size (snap-to-value), and emits the signal
func (*Spinner) NodeType ¶
NodeType returns the *types.Type of Spinner
func (*Spinner) PageIncrementValue ¶
PageIncrementValue increments the value by given number of page steps (+ or -), and enforces it to be an even multiple of the step size (snap-to-value), and emits the signal
func (*Spinner) SetCursorColor ¶
SetCursorColor sets the [Spinner.CursorColor]
func (*Spinner) SetCursorWidth ¶
SetCursorWidth sets the [Spinner.CursorWidth]
func (*Spinner) SetEnforceStep ¶
SetEnforceStep sets the [Spinner.EnforceStep]: EnforceStep is whether to ensure that the value of the spinner is always a multiple of [Spinner.Step].
func (*Spinner) SetFormat ¶
SetFormat sets the [Spinner.Format]: Format is the format string to use for printing the value. If it unset, %g is used. If it is decimal based (ends in d, b, c, o, O, q, x, X, or U) then the value is converted to decimal prior to printing.
func (*Spinner) SetLeadingIconOnClick ¶
SetLeadingIconOnClick sets the [Spinner.LeadingIconOnClick]
func (*Spinner) SetPageStep ¶
SetPageStep sets the [Spinner.PageStep]: PageStep is the amount that the PageUp and PageDown keys increment/decrement the value by. It defaults to 0.2, and will be at least as big as [Spinner.Step].
func (*Spinner) SetPlaceholder ¶
SetPlaceholder sets the [Spinner.Placeholder]
func (*Spinner) SetPlaceholderColor ¶
SetPlaceholderColor sets the [Spinner.PlaceholderColor]
func (*Spinner) SetPrec ¶
SetPrec sets the [Spinner.Prec]: Prec specifies the precision of decimal places (total, not after the decimal point) to use in representing the number. This helps to truncate small weird floating point values.
func (*Spinner) SetSelectColor ¶
SetSelectColor sets the [Spinner.SelectColor]
func (*Spinner) SetSelectMode ¶
SetSelectMode sets the [Spinner.SelectMode]
func (*Spinner) SetStep ¶
SetStep sets the [Spinner.Step]: Step is the amount that the up and down buttons and arrow keys increment/decrement the value by. It defaults to 0.1.
func (*Spinner) SetTextToValue ¶
func (sp *Spinner) SetTextToValue()
func (*Spinner) SetTooltip ¶
SetTooltip sets the [Spinner.Tooltip]
func (*Spinner) SetTrailingIconOnClick ¶
SetTrailingIconOnClick sets the [Spinner.TrailingIconOnClick]
func (*Spinner) SetType ¶
func (t *Spinner) SetType(v TextFieldTypes) *Spinner
SetType sets the [Spinner.Type]
func (*Spinner) SetUndoMgr ¶
func (t *Spinner) SetUndoMgr(v TextFieldUndoMgr) *Spinner
SetUndoMgr sets the [Spinner.UndoMgr]
func (*Spinner) SetValidator ¶
SetValidator sets the [Spinner.Validator]
func (*Spinner) SetValueAction ¶
SetValueAction calls SetValue and also emits the signal
func (*Spinner) StringToValue ¶
StringToValue converts the string field back to float value
func (*Spinner) ValueToString ¶
ValueToString converts the value to the string representation thereof
func (*Spinner) WidgetTooltip ¶
func (*Spinner) WrapAround ¶
WrapAround, if the spinner has a min and a max, converts values less than min to max and values greater than max to min.
type SpinnerEmbedder ¶
type SpinnerEmbedder interface {
AsSpinner() *Spinner
}
SpinnerEmbedder is an interface that all types that embed Spinner satisfy
type Splits ¶
type Splits struct { Layout // Splits is the proportion (0-1 normalized, enforced) of space // allocated to each element. 0 indicates that an element should // be completely collapsed. By default, each element gets the // same amount of space. Splits []float32 `set:"-"` // SavedSplits is a saved version of the splits that can be restored // for dynamic collapse/expand operations. SavedSplits []float32 `set:"-"` }
Splits allocates a certain proportion of its space to each of its children along styles.Style.Direction. It adds Handle widgets to its parts that allow the user to customize the amount of space allocated to each child.
func AsSplits ¶
AsSplits returns the given value as a value of type Splits if the type of the given value embeds Splits, or nil otherwise
func NewSplits ¶
NewSplits adds a new Splits with the given name to the given parent: Splits allocates a certain proportion of its space to each of its children along styles.Style.Direction. It adds Handle widgets to its parts that allow the user to customize the amount of space allocated to each child.
func (*Splits) ApplyStyle ¶
func (sl *Splits) ApplyStyle()
func (*Splits) AsSplits ¶
AsSplits satisfies the SplitsEmbedder interface
func (*Splits) CollapseChild ¶
CollapseChild collapses given child(ren) (sets split proportion to 0), optionally saving the prior splits for later Restore function -- does an Update -- triggered by double-click of splitter
func (*Splits) ConfigSplitters ¶
func (sl *Splits) ConfigSplitters()
func (*Splits) EvenSplits ¶
func (sl *Splits) EvenSplits()
EvenSplits splits space evenly across all panels
func (*Splits) HandleEvents ¶
func (sl *Splits) HandleEvents()
func (*Splits) IsCollapsed ¶
IsCollapsed returns true if given split number is collapsed
func (*Splits) NodeType ¶
NodeType returns the *types.Type of Splits
func (*Splits) PositionSplits ¶
func (sl *Splits) PositionSplits()
func (*Splits) RenderWidget ¶
func (sl *Splits) RenderWidget()
func (*Splits) RestoreChild ¶
RestoreChild restores given child(ren) -- does an Update
func (*Splits) RestoreSplits ¶
func (sl *Splits) RestoreSplits()
RestoreSplits restores a previously-saved set of splits (if it exists), does an update
func (*Splits) SaveSplits ¶
func (sl *Splits) SaveSplits()
SaveSplits saves the current set of splits in SavedSplits, for a later RestoreSplits
func (*Splits) SetSplitAction ¶
SetSplitAction sets the new splitter value, for given splitter. New value is 0..1 value of position of that splitter. It is a sum of all the positions up to that point. Splitters are updated to ensure that selected position is achieved, while dividing remainder appropriately.
func (*Splits) SetSplits ¶
SetSplits sets the [Splits.Splits]: Splits is the proportion (0-1 normalized, enforced) of space allocated to each element. 0 indicates that an element should be completely collapsed. By default, each element gets the same amount of space.
func (*Splits) SetTooltip ¶
SetTooltip sets the [Splits.Tooltip]
func (*Splits) SizeDownSetAllocs ¶
func (*Splits) UpdateSplits ¶
UpdateSplits normalizes the splits and ensures that there are as many split proportions as children.
type SplitsEmbedder ¶
type SplitsEmbedder interface {
AsSplits() *Splits
}
SplitsEmbedder is an interface that all types that embed Splits satisfy
type Sprite ¶
type Sprite struct { // whether this sprite is active now or not On bool // unique name of sprite Name string // properties for sprite, which allow for user-extensible data Properties map[string]any // position and size of the image within the overlay window texture Geom math32.Geom2DInt // pixels to render -- should be same size as Geom.Size Pixels *image.RGBA }
A Sprite is just an image (with optional background) that can be drawn onto the OverTex overlay texture of a window. Sprites are used for text cursors/carets and for dynamic editing / interactive GUI elements (e.g., drag-n-drop elements)
func NewSprite ¶
NewSprite returns a new sprite with given name, which must remain invariant and unique among all sprites in use, and is used for all access -- prefix with package and type name to ensure uniqueness. Starts out in inactive state -- must call ActivateSprite. If size is 0, no image is made.
func (*Sprite) GrabRenderFrom ¶
GrabRenderFrom grabs the rendered image from the given widget.
func (*Sprite) SetBottomPos ¶
SetBottomPos sets the sprite's bottom position to given point the Geom.Pos represents its top position
type Sprites ¶
type Sprites struct { // map of uniquely named sprites Names ordmap.Map[string, *Sprite] // allocation of sprites by size for rendering SzAlloc szalloc.SzAlloc // set to true if sprites have been modified since last config Modified bool // number of active sprites Active int }
Sprites manages a collection of sprites organized by size and name
func (*Sprites) ActivateSprite ¶
ActivateSprite flags the sprite as active, setting Modified if wasn't before
func (*Sprites) Add ¶
Add adds sprite to list, and returns the image index and layer index within that for given sprite. If name already exists on list, then it is returned, with size allocation updated as needed.
func (*Sprites) AllocSizes ¶
func (ss *Sprites) AllocSizes()
AllocSizes allocates the sprites by size to fixed set of images and layers
func (*Sprites) ConfigSprites ¶
ConfigSprites updates the Drawer configuration of sprites. Does a new SzAlloc, and sets corresponding images.
func (*Sprites) Delete ¶
Delete deletes sprite by name, returning indexes where it was located. All sprite images must be updated when this occurs, as indexes may have shifted.
func (*Sprites) DrawSprites ¶
DrawSprites draws sprites
func (*Sprites) HasSizeChanged ¶
HasSizeChanged returns true if a sprite's size has changed relative to its last allocated value, in SzAlloc. Returns true and sets Modified flag to true if so.
func (*Sprites) InactivateAllSprites ¶
func (ss *Sprites) InactivateAllSprites()
InactivateAllSprites inactivates all sprites, setting Modified if wasn't before
func (*Sprites) InactivateSprite ¶
InactivateSprite flags the sprite as inactive, setting Modified if wasn't before
type Stage ¶
type Stage struct { // type of Stage: determines behavior and Styling Type StageTypes `set:"-"` // Scene contents of this Stage (what it displays). Scene *Scene `set:"-"` // widget in another scene that requested this stage to be created // and provides context (stage) Context Widget // Name is the name of the Stage, which is generally auto-set // based on the Scene Name. Name string // Title is the title of the Stage, which is generally auto-set // based on the Scene Title. Used for title of WindowStage and // DialogStage types. Title string // Modal, if true, blocks input to all other stages. Modal bool `set:"-"` // Scrim, if true, places a darkening scrim over other stages, // if not a full window. Scrim bool // ClickOff, if true, dismisses the Stage if user clicks anywhere // off the Stage. ClickOff bool // IgnoreEvents is whether to send no events to the stage and // just pass them down to lower stages. IgnoreEvents bool // NewWindow, if true, opens a WindowStage or DialogStage in its own // separate operating system window (RenderWin). This is true by // default for WindowStage on non-mobile platforms, otherwise false. NewWindow bool // FullWindow, if NewWindow is false, makes DialogStages and // WindowStages take up the entire window they are created in. FullWindow bool // CloseOnBack is whether to close the stage when the back button // is pressed in the app bar. Otherwise, it goes back to the next // stage but keeps this one open. This is on by default for // DialogStages and off for WindowStages. CloseOnBack bool // Closeable, if true, includes a close button for closing dialogs. Closeable bool // Movable, if true, adds a handle titlebar Decor for moving dialogs. Movable bool // Resizable, if true, adds a resize handle Decor for resizing dialogs. Resizable bool // Timeout, if greater than 0, results in a popup stages disappearing // after a timeout duration. Timeout time.Duration // Pos is the target position for Scene to be placed within RenderWin. Pos image.Point // Data is item represented by this main stage -- used for recycling windows Data any // If a Popup Stage, this is the Main Stage that owns it (via its PopupMgr) // If a Main Stage, it points to itself. Main *Stage // For Main stages, this is the manager for the popups within it (created // specifically for the main stage). // For Popups, this is the pointer to the PopupMgr within the // Main Stage managing it. PopupMgr *StageMgr `set:"-"` // For all stages, this is the Main stage manager that lives in a RenderWin // and manages the Main Scenes. MainMgr *StageMgr `set:"-"` // rendering context which has info about the RenderWin onto which we render. // This should be used instead of the RenderWin itself for all relevant // rendering information. This is only available once a Stage is Run, // and must always be checked for nil. RenderContext *RenderContext // sprites are named images that are rendered last overlaying everything else. Sprites Sprites `json:"-" xml:"-"` // name of sprite that is being dragged -- sprite event function is responsible for setting this. SpriteDragging string `json:"-" xml:"-"` }
Stage is a container and manager for displaying a Scene in different functional ways, defined by StageTypes, in two categories: Main types (WindowStage and DialogStage) and Popup types (Menu, Tooltip, Snackbar, Chooser).
func NewCompleter ¶
NewCompleter returns a new CompleterStage with given scene contents, in connection with given widget (which provides key context). Make further configuration choices using Set* methods, which can be chained directly after the New call. Use an appropriate Run call at the end to start the Stage running.
func NewMainStage ¶
func NewMainStage(typ StageTypes, sc *Scene) *Stage
NewMainStage returns a new MainStage with given type and scene contents. Make further configuration choices using Set* methods, which can be chained directly after the NewMainStage call. Use an appropriate Run call at the end to start the Stage running.
func NewMenu ¶
NewMenu returns a new menu stage based on the given menu constructor function, in connection with given widget, which provides key context for constructing the menu at given RenderWin position (e.g., use ContextMenuPos or WinPos method on ctx Widget). Make further configuration choices using Set* methods, which can be chained directly after the New call. Use Run call at the end to start the Stage running.
func NewMenuStage ¶
NewMenuStage returns a new Menu stage with given scene contents, in connection with given widget, which provides key context for constructing the menu, at given RenderWin position (e.g., use ContextMenuPos or WinPos method on ctx Widget). Make further configuration choices using Set* methods, which can be chained directly after the New call. Use Run call at the end to start the Stage running.
func NewPopupStage ¶
func NewPopupStage(typ StageTypes, sc *Scene, ctx Widget) *Stage
NewPopupStage returns a new PopupStage with given type and scene contents. The given context widget must be non-nil. Make further configuration choices using Set* methods, which can be chained directly after the NewPopupStage call. Use Run call at the end to start the Stage running.
func NewTooltip ¶
NewTooltip returns a new tooltip stage displaying the tooltip text for the given widget based on the widget's position and size.
func NewTooltipFromScene ¶
NewTooltipFromScene returns a new Tooltip stage with given scene contents, in connection with given widget (which provides key context). Make further configuration choices using Set* methods, which can be chained directly after the New call. Use an appropriate Run call at the end to start the Stage running.
func NewTooltipText ¶
NewTooltipText returns a new tooltip stage displaying the given tooltip text for the given widget based on the widget's position and size.
func NewTooltipTextAt ¶
NewTooltipTextAt returns a new tooltip stage displaying the given tooltip text for the given widget at the given window-level position with the given size.
func (*Stage) AddDialogDecor ¶
func (*Stage) ClosePopup ¶
ClosePopup closes this stage as a popup, returning whether it was closed.
func (*Stage) ClosePopupAndBelow ¶
ClosePopupAndBelow closes this stage as a popup, and all those immediately below it of the same type. It returns whether it successfully closed popups.
func (*Stage) ClosePopupAndBelowAsync ¶
ClosePopupAndBelowAsync closes this stage as a popup, and all those immediately below it of the same type. This version is for Asynchronous usage outside the main event loop, for example in a delayed callback AfterFunc etc. It returns whether it successfully closed popups.
func (*Stage) ClosePopupAsync ¶
func (st *Stage) ClosePopupAsync()
ClosePopupAsync closes this stage as a popup. This version is for Asynchronous usage outside the main event loop, for example in a delayed callback AfterFunc etc.
func (*Stage) ConfigMainStage ¶
func (st *Stage) ConfigMainStage()
ConfigMainStage does main-stage configuration steps
func (*Stage) DoUpdate ¶
DoUpdate calls DoUpdate on our Scene and UpdateAll on our Popups for Main types. returns stageMods = true if any Popup Stages have been modified and sceneMods = true if any Scenes have been modified.
func (*Stage) FirstWinManager ¶
FirstWinManager creates a temporary Main StageMgr for the first window to be able to get sizing information prior to having a RenderWin, based on the system App Screen Size. Only adds a RenderContext.
func (*Stage) GetValidContext ¶
GetValidContext ensures that the Context is non-nil and has a valid Scene pointer, using CurRenderWin if the current Context is not valid. If CurRenderWin is nil (should not happen), then it returns false and the calling function must bail.
func (*Stage) InheritBars ¶
func (st *Stage) InheritBars()
func (*Stage) MainHandleEvent ¶
MainHandleEvent handles main stage events
func (*Stage) NewRenderWin ¶
func (st *Stage) NewRenderWin() *RenderWindow
func (*Stage) PopupHandleEvent ¶
func (*Stage) Raise ¶
func (st *Stage) Raise()
Raise moves the Stage to the top of its main StageMgr and raises the RenderWindow it is in if necessary.
func (*Stage) RunImpl ¶
RunImpl is the implementation of Stage.Run; it should not typically be called by end-users.
func (*Stage) RunPopupAsync ¶
RunPopupAsync runs a popup-style Stage in context widget's popups. This version is for Asynchronous usage outside the main event loop, for example in a delayed callback AfterFunc etc.
func (*Stage) SetClickOff ¶
SetClickOff sets the [Stage.ClickOff]: ClickOff, if true, dismisses the Stage if user clicks anywhere off the Stage.
func (*Stage) SetCloseOnBack ¶
SetCloseOnBack sets the [Stage.CloseOnBack]: CloseOnBack is whether to close the stage when the back button is pressed in the app bar. Otherwise, it goes back to the next stage but keeps this one open. This is on by default for DialogStages and off for WindowStages.
func (*Stage) SetCloseable ¶
SetCloseable sets the [Stage.Closeable]: Closeable, if true, includes a close button for closing dialogs.
func (*Stage) SetContext ¶
SetContext sets the [Stage.Context]: widget in another scene that requested this stage to be created and provides context (stage)
func (*Stage) SetData ¶
SetData sets the [Stage.Data]: Data is item represented by this main stage -- used for recycling windows
func (*Stage) SetFullWindow ¶
SetFullWindow sets the [Stage.FullWindow]: FullWindow, if NewWindow is false, makes DialogStages and WindowStages take up the entire window they are created in.
func (*Stage) SetIgnoreEvents ¶
SetIgnoreEvents sets the [Stage.IgnoreEvents]: IgnoreEvents is whether to send no events to the stage and just pass them down to lower stages.
func (*Stage) SetMain ¶
SetMain sets the [Stage.Main]: If a Popup Stage, this is the Main Stage that owns it (via its PopupMgr) If a Main Stage, it points to itself.
func (*Stage) SetMainMgr ¶
SetMainMgr sets the MainMgr to given Main StageMgr (on RenderWin) and also sets the RenderContext from that.
func (*Stage) SetModal ¶
SetModal sets modal flag for blocking other input (for dialogs). Also updates Scrim accordingly if not modal.
func (*Stage) SetMovable ¶
SetMovable sets the [Stage.Movable]: Movable, if true, adds a handle titlebar Decor for moving dialogs.
func (*Stage) SetName ¶
SetName sets the [Stage.Name]: Name is the name of the Stage, which is generally auto-set based on the Scene Name.
func (*Stage) SetNameFromScene ¶
SetNameFromString sets the name of this Stage based on existing Scene and Type settings.
func (*Stage) SetNewWindow ¶
SetNewWindow sets the [Stage.NewWindow]: NewWindow, if true, opens a WindowStage or DialogStage in its own separate operating system window (RenderWin). This is true by default for WindowStage on non-mobile platforms, otherwise false.
func (*Stage) SetPopupMgr ¶
SetPopupMgr sets the PopupMgr and MainMgr from the given *Main* Stage to which this PopupStage belongs.
func (*Stage) SetPos ¶
SetPos sets the [Stage.Pos]: Pos is the target position for Scene to be placed within RenderWin.
func (*Stage) SetRenderContext ¶
func (t *Stage) SetRenderContext(v *RenderContext) *Stage
SetRenderContext sets the [Stage.RenderContext]: rendering context which has info about the RenderWin onto which we render. This should be used instead of the RenderWin itself for all relevant rendering information. This is only available once a Stage is Run, and must always be checked for nil.
func (*Stage) SetResizable ¶
SetResizable sets the [Stage.Resizable]: Resizable, if true, adds a resize handle Decor for resizing dialogs.
func (*Stage) SetScrim ¶
SetScrim sets the [Stage.Scrim]: Scrim, if true, places a darkening scrim over other stages, if not a full window.
func (*Stage) SetSpriteDragging ¶
SetSpriteDragging sets the [Stage.SpriteDragging]: name of sprite that is being dragged -- sprite event function is responsible for setting this.
func (*Stage) SetSprites ¶
SetSprites sets the [Stage.Sprites]: sprites are named images that are rendered last overlaying everything else.
func (*Stage) SetTimeout ¶
SetTimeout sets the [Stage.Timeout]: Timeout, if greater than 0, results in a popup stages disappearing after a timeout duration.
func (*Stage) SetTitle ¶
SetTitle sets the [Stage.Title]: Title is the title of the Stage, which is generally auto-set based on the Scene Title. Used for title of WindowStage and DialogStage types.
func (*Stage) SetType ¶
func (st *Stage) SetType(typ StageTypes) *Stage
SetType sets the type and also sets default parameters based on that type
type StageMgr ¶
type StageMgr struct { // stack of stages managed by this stage manager. Stack ordmap.Map[string, *Stage] `set:"-"` // Modified is set to true whenever the stack has been modified. // This is cleared by the RenderWin each render cycle. Modified bool // rendering context provides key rendering information and locking // for the RenderWin in which the stages are running. // the MainStageMgr within the RenderWin RenderContext *RenderContext // render window to which we are rendering. // rely on the RenderContext wherever possible. RenderWin *RenderWindow // growing stack of viewing history of all stages. History []*Stage `set:"-"` // Main is the Main Stage that owns this StageMgr, only set for Popup stages Main *Stage // mutex protecting reading / updating of the Stack. // Destructive stack updating gets a Write lock, else Read. Mu sync.RWMutex `view:"-" set:"-"` }
StageMgr manages a stack of Stage elements
func (*StageMgr) DeleteAll ¶
func (sm *StageMgr) DeleteAll()
DeleteAll deletes all of the stages. For when Stage with Popups is Deleted, or when a RenderWindow is closed. requires outer RenderContext mutex!
func (*StageMgr) DeleteStage ¶
DeleteStage deletes given stage (removing from stack, calling Delete on Stage), returning true if found. It runs under Write lock.
func (*StageMgr) DeleteStageAndBelow ¶
DeleteStageAndBelow deletes given stage (removing from stack, calling Delete on Stage), returning true if found. And also deletes all stages of the same type immediately below it. It runs under Write lock.
func (*StageMgr) MainHandleEvent ¶
MainHandleEvent calls MainHandleEvent on relevant stages in reverse order.
func (*StageMgr) MoveToTop ¶
MoveToTop moves the given stage to the top of the stack, returning true if found. It runs under Write lock.
func (*StageMgr) Pop ¶
Pop pops current Stage off the stack, returning it or nil if none. It runs under Write lock.
func (*StageMgr) PopDelete ¶
func (sm *StageMgr) PopDelete()
PopDelete pops current top--most Stage off the stack and calls Delete on it.
func (*StageMgr) PopDeleteType ¶
func (sm *StageMgr) PopDeleteType(typ StageTypes)
PopDeleteType pops the top-most Stage of the given type off the stack and calls Delete on it.
func (*StageMgr) PopType ¶
func (sm *StageMgr) PopType(typ StageTypes) *Stage
PopType pops the top-most Stage of the given type of the stack, returning it or nil if none. It runs under Write lock.
func (*StageMgr) PopupHandleEvent ¶
PopupHandleEvent processes Popup events. requires outer RenderContext mutex.
func (*StageMgr) Resize ¶
Resize calls Resize on all stages within based on the given window render geom.
func (*StageMgr) SendShowEvents ¶
func (sm *StageMgr) SendShowEvents()
func (*StageMgr) TopIsModal ¶
TopIsModal returns true if there is a Top PopupStage and it is Modal.
func (*StageMgr) TopNotType ¶
func (sm *StageMgr) TopNotType(typ StageTypes) *Stage
TopNotType returns the top-most Stage in the Stack that is NOT the given type, under Read Lock
func (*StageMgr) TopOfType ¶
func (sm *StageMgr) TopOfType(typ StageTypes) *Stage
TopOfType returns the top-most Stage in the Stack of the given type, under Read Lock
func (*StageMgr) UniqueName ¶
UniqueName returns unique name for given item
func (*StageMgr) UpdateAll ¶
UpdateAll iterates through all Stages and calls DoUpdate on them. returns stageMods = true if any Stages have been modified (Main or Popup), and sceneMods = true if any Scenes have been modified. Stage calls DoUpdate on its Scene, ensuring everything is updated at the Widget level. If nothing is needed, nothing is done. This is called only during RenderWin.RenderWindow, under the global RenderContext.Mu Write lock so nothing else can happen.
type StageTypes ¶
type StageTypes int32 //enums:enum
StageTypes are the types of Stage containers. There are two main categories: MainStage and PopupStage. MainStage are WindowStage and DialogStage: large and potentially complex Scenes that persist until dismissed, and can have Decor widgets that control display. PopupStage are Menu, Tooltip, Snackbar, Chooser that are transitory and simple, without additional decor. MainStages live in a StageMgr associated with a RenderWin window, and manage their own set of PopupStages via a PopupStageMgr.
const ( // WindowStage is a MainStage that displays a Scene in a full window. // One of these must be created first, as the primary App contents, // and it typically persists throughout. It fills the RenderWin window. // Additional Windows can be created either within the same RenderWin // (Mobile) or in separate RenderWin windows (Desktop, NewWindow). WindowStage StageTypes = iota // DialogStage is a MainStage that displays Scene in a smaller dialog window // on top of a Window, or in its own RenderWin (on Desktop only). // It can be Modal or not. DialogStage // MenuStage is a PopupStage that displays a Scene with Action Widgets // overlaid on a MainStage. // It is typically Modal and ClickOff, and closes when // an Action is selected. MenuStage // TooltipStage is a PopupStage that displays a Scene with extra info // overlaid on a MainStage. // It is typically ClickOff and not Modal. TooltipStage // SnackbarStage is a PopupStage displays a Scene with info and typically // an additional optional Action, usually displayed at the bottom. // It is typically not ClickOff or Modal, but has a timeout. SnackbarStage // CompleterStage is a PopupStage that displays a Scene with text completions, // spelling corrections, or other such dynamic info. // It is typically ClickOff, not Modal, dynamically updating, // and closes when something is selected or typing renders // it no longer relevant. CompleterStage )
const StageTypesN StageTypes = 6
StageTypesN is the highest valid value for type StageTypes, plus one.
func StageTypesValues ¶
func StageTypesValues() []StageTypes
StageTypesValues returns all possible values for the type StageTypes.
func (StageTypes) Desc ¶
func (i StageTypes) Desc() string
Desc returns the description of the StageTypes value.
func (StageTypes) Int64 ¶
func (i StageTypes) Int64() int64
Int64 returns the StageTypes value as an int64.
func (StageTypes) IsMain ¶
func (st StageTypes) IsMain() bool
IsMain returns true if this type of Stage is a Main stage that manages its own set of popups
func (StageTypes) IsPopup ¶
func (st StageTypes) IsPopup() bool
IsPopup returns true if this type of Stage is a Popup, managed by another Main stage.
func (StageTypes) MarshalText ¶
func (i StageTypes) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*StageTypes) SetInt64 ¶
func (i *StageTypes) SetInt64(in int64)
SetInt64 sets the StageTypes value from an int64.
func (*StageTypes) SetString ¶
func (i *StageTypes) SetString(s string) error
SetString sets the StageTypes value from its string representation, and returns an error if the string is invalid.
func (StageTypes) String ¶
func (i StageTypes) String() string
String returns the string representation of this StageTypes value.
func (*StageTypes) UnmarshalText ¶
func (i *StageTypes) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (StageTypes) Values ¶
func (i StageTypes) Values() []enums.Enum
Values returns all possible values for the type StageTypes.
type Stretch ¶
type Stretch struct {
WidgetBase
}
Stretch adds a stretchy element that grows to fill all available space. You can set styles.Style.Grow to change how much it grows relative to other growing elements.
func NewStretch ¶
NewStretch adds a new Stretch with the given name to the given parent: Stretch adds a stretchy element that grows to fill all available space. You can set styles.Style.Grow to change how much it grows relative to other growing elements.
func (*Stretch) NodeType ¶
NodeType returns the *types.Type of Stretch
func (*Stretch) SetTooltip ¶
SetTooltip sets the [Stretch.Tooltip]
type Switch ¶
type Switch struct { Box // the type of switch that this is Type SwitchTypes `set:"-"` // the label text for the switch Text string // icon to use for the on, checked state of the switch IconOn icons.Icon `view:"show-name"` // icon to use for the off, unchecked state of the switch IconOff icons.Icon `view:"show-name"` // icon to use for the indeterminate (unknown) state IconIndeterminate icons.Icon `view:"show-name"` }
Switch is a widget that can toggle between an on and off state. It can be displayed as a switch, checkbox, or radio button.
func NewSwitch ¶
NewSwitch adds a new Switch with the given name to the given parent: Switch is a widget that can toggle between an on and off state. It can be displayed as a switch, checkbox, or radio button.
func (*Switch) ClearIcons ¶
ClearIcons sets all of the switch icons to icons.None
func (*Switch) HandleEvents ¶
func (sw *Switch) HandleEvents()
func (*Switch) LabelWidget ¶
LabelWidget returns the label widget if present
func (*Switch) NodeType ¶
NodeType returns the *types.Type of Switch
func (*Switch) SetChecked ¶
SetChecked sets the checked state and updates the icon accordingly
func (*Switch) SetIconFromState ¶
func (sw *Switch) SetIconFromState()
SetIconFromState updates icon state based on checked status
func (*Switch) SetIconIndeterminate ¶
SetIconIndeterminate sets the [Switch.IconIndeterminate]: icon to use for the indeterminate (unknown) state
func (*Switch) SetIconOff ¶
SetIconOff sets the [Switch.IconOff]: icon to use for the off, unchecked state of the switch
func (*Switch) SetIconOn ¶
SetIconOn sets the [Switch.IconOn]: icon to use for the on, checked state of the switch
func (*Switch) SetIcons ¶
SetIcons sets the icons for the on (checked), off (unchecked) and indeterminate (unknown) states. See [SetIconsUpdate] for a version that updates the icon rendering
func (*Switch) SetTooltip ¶
SetTooltip sets the [Switch.Tooltip]
func (*Switch) SetType ¶
func (sw *Switch) SetType(typ SwitchTypes) *Switch
SetType sets the styling type of the switch
type SwitchItem ¶
type SwitchItem struct { // Label is the label displayed to the user for this item. Label string // Tooltip is the tooltip displayed to the user for this item. Tooltip string }
SwitchItem contains the properties of one item in a Switches.
type SwitchTypes ¶
type SwitchTypes int32 //enums:enum -trim-prefix Switch
SwitchTypes contains the different types of [Switch]es
const ( // SwitchSwitch indicates to display a switch as a switch (toggle slider). SwitchSwitch SwitchTypes = iota // SwitchChip indicates to display a switch as chip (like Material Design's filter chip), // which is typically only used in the context of [Switches]. SwitchChip // SwitchCheckbox indicates to display a switch as a checkbox. SwitchCheckbox // SwitchRadioButton indicates to display a switch as a radio button. SwitchRadioButton // SwitchSegmentedButton indicates to display a segmented button, which is typically only used in // the context of [Switches]. SwitchSegmentedButton )
const SwitchTypesN SwitchTypes = 5
SwitchTypesN is the highest valid value for type SwitchTypes, plus one.
func SwitchTypesValues ¶
func SwitchTypesValues() []SwitchTypes
SwitchTypesValues returns all possible values for the type SwitchTypes.
func (SwitchTypes) Desc ¶
func (i SwitchTypes) Desc() string
Desc returns the description of the SwitchTypes value.
func (SwitchTypes) Int64 ¶
func (i SwitchTypes) Int64() int64
Int64 returns the SwitchTypes value as an int64.
func (SwitchTypes) MarshalText ¶
func (i SwitchTypes) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*SwitchTypes) SetInt64 ¶
func (i *SwitchTypes) SetInt64(in int64)
SetInt64 sets the SwitchTypes value from an int64.
func (*SwitchTypes) SetString ¶
func (i *SwitchTypes) SetString(s string) error
SetString sets the SwitchTypes value from its string representation, and returns an error if the string is invalid.
func (SwitchTypes) String ¶
func (i SwitchTypes) String() string
String returns the string representation of this SwitchTypes value.
func (*SwitchTypes) UnmarshalText ¶
func (i *SwitchTypes) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (SwitchTypes) Values ¶
func (i SwitchTypes) Values() []enums.Enum
Values returns all possible values for the type SwitchTypes.
type Switches ¶
type Switches struct { Frame // the type of switches that will be made Type SwitchTypes // Items are the items displayed to the user. Items []SwitchItem // whether to make the items mutually exclusive (checking one turns off all the others) Mutex bool }
Switches is a widget for containing a set of switches. It can optionally enforce mutual exclusivity (i.e., Radio Buttons). The buttons are all in the Parts of the widget and the Parts layout determines how they are displayed.
func AsSwitches ¶
AsSwitches returns the given value as a value of type Switches if the type of the given value embeds Switches, or nil otherwise
func NewSwitches ¶
NewSwitches adds a new Switches with the given name to the given parent: Switches is a widget for containing a set of switches. It can optionally enforce mutual exclusivity (i.e., Radio Buttons). The buttons are all in the Parts of the widget and the Parts layout determines how they are displayed.
func (*Switches) AsSwitches ¶
AsSwitches satisfies the SwitchesEmbedder interface
func (*Switches) HandleSwitchEvents ¶
HandleSwitchEvents handles the events for the given switch.
func (*Switches) NodeType ¶
NodeType returns the *types.Type of Switches
func (*Switches) SelectItem ¶
SelectItem activates a given item but does NOT send a change event. See SelectItemAction for event emitting version. returns error if index is out of range.
func (*Switches) SelectItemAction ¶
SelectItemAction activates a given item and emits a change event. This is mainly for Mutex use. returns error if index is out of range.
func (*Switches) SelectedItem ¶
SelectedItem returns the first selected (checked) switch label. It is only useful when [Switches.Mutex] is true; if it is not, use Switches.SelectedItems. If no switches are selected, it returns "".
func (*Switches) SelectedItems ¶
SelectedItems returns all of the currently selected (checked) switch labels. If [Switches.Mutex] is true, you should use Switches.SelectedItem instead.
func (*Switches) SetEnum ¶
SetEnum sets the [Switches.Items] from the enums.Enum.Values of the given enum.
func (*Switches) SetItems ¶
func (t *Switches) SetItems(v ...SwitchItem) *Switches
SetItems sets the [Switches.Items]: Items are the items displayed to the user.
func (*Switches) SetMutex ¶
SetMutex sets the [Switches.Mutex]: whether to make the items mutually exclusive (checking one turns off all the others)
func (*Switches) SetStrings ¶
SetStrings sets the [Switches.Items] from the given strings.
func (*Switches) SetTooltip ¶
SetTooltip sets the [Switches.Tooltip]
func (*Switches) SetType ¶
func (t *Switches) SetType(v SwitchTypes) *Switches
SetType sets the [Switches.Type]: the type of switches that will be made
func (*Switches) UnCheckAllBut ¶
UnCheckAllBut unchecks all switches except given one
func (*Switches) UpdateBitFlag ¶
func (sw *Switches) UpdateBitFlag(bitflag enums.BitFlagSetter)
UpdateBitFlag sets the given bitflag value to the value specified by the checked state of the switches.
func (*Switches) UpdateFromBitFlag ¶
UpdateFromBitFlags sets the checked state of the switches from the given bit flag enum value.
type SwitchesEmbedder ¶
type SwitchesEmbedder interface {
AsSwitches() *Switches
}
SwitchesEmbedder is an interface that all types that embed Switches satisfy
type SystemSettingsData ¶
type SystemSettingsData struct { SettingsBase // text editor settings Editor EditorSettings // whether to use a 24-hour clock (instead of AM and PM) Clock24 bool `label:"24-hour clock"` // SnackbarTimeout is the default amount of time until snackbars // disappear (snackbars show short updates about app processes // at the bottom of the screen) SnackbarTimeout time.Duration `default:"5s"` // only support closing the currently selected active tab; if this is set to true, pressing the close button on other tabs will take you to that tab, from which you can close it OnlyCloseActiveTab bool `default:"false"` // the limit of file size, above which user will be prompted before opening / copying, etc. BigFileSize int `default:"10000000"` // maximum number of saved paths to save in FileView SavedPathsMax int `default:"50"` // extra font paths, beyond system defaults -- searched first FontPaths []string // user info -- partially filled-out automatically if empty / when prefs first created User User // favorite paths, shown in FileViewer and also editable there FavPaths FavPaths // column to sort by in FileView, and :up or :down for direction -- updated automatically via FileView FileViewSort string `view:"-"` // the maximum height of any menu popup panel in units of font height; // scroll bars are enforced beyond that size. MenuMaxHeight int `default:"30" min:"5" step:"1"` // the amount of time to wait before offering completions CompleteWaitDuration time.Duration `default:"0ms" min:"0ms" max:"10s" step:"10ms"` // the maximum number of completions offered in popup CompleteMaxItems int `default:"25" min:"5" step:"1"` // time interval for cursor blinking on and off -- set to 0 to disable blinking CursorBlinkTime time.Duration `default:"500ms" min:"0ms" max:"1s" step:"5ms"` // The amount of time to wait before trying to autoscroll again LayoutAutoScrollDelay time.Duration `default:"25ms" min:"1ms" step:"5ms"` // number of steps to take in PageUp / Down events in terms of number of items LayoutPageSteps int `default:"10" min:"1" step:"1"` // the amount of time between keypresses to combine characters into name to search for within layout -- starts over after this delay LayoutFocusNameTimeout time.Duration `default:"500ms" min:"0ms" max:"5s" step:"20ms"` // the amount of time since last focus name event to allow tab to focus on next element with same name. LayoutFocusNameTabTime time.Duration `default:"2s" min:"10ms" max:"10s" step:"100ms"` // the number of map elements at or below which an inline representation // of the map will be presented, which is more convenient for small #'s of properties MapInlineLength int `default:"2" min:"1" step:"1"` // the number of elemental struct fields at or below which an inline representation // of the struct will be presented, which is more convenient for small structs StructInlineLength int `default:"4" min:"2" step:"1"` // the number of slice elements below which inline will be used SliceInlineLength int `default:"4" min:"2" step:"1"` }
SystemSettingsData is the data type of the global Cogent Core settings.
func (*SystemSettingsData) Apply ¶
func (ss *SystemSettingsData) Apply()
Apply detailed settings to all the relevant settings.
func (*SystemSettingsData) Defaults ¶
func (ss *SystemSettingsData) Defaults()
func (*SystemSettingsData) Open ¶
func (ss *SystemSettingsData) Open() error
func (*SystemSettingsData) TimeFormat ¶
func (ss *SystemSettingsData) TimeFormat() string
TimeFormat returns the Go time format layout string that should be used for displaying times to the user, based on the value of [SystemSettingsData.Clock24].
func (*SystemSettingsData) UpdateUser ¶
func (ss *SystemSettingsData) UpdateUser()
UpdateUser gets the user info from the OS
type Tab ¶
type Tab struct { Box // Type is the styling type of the tab. This property // must be set on the parent [Tabs] for it to work correctly. Type TabTypes // Text is the label text for the tab. // If it is nil, no label is shown. // Labels are never shown for [NavigationRail] tabs. Text string // Icon is the icon for the tab. // If it is "" or [icons.None], no icon is shown. Icon icons.Icon // CloseIcon is the icon used as a close button for the tab. // If it is "" or [icons.None], the tab is not closeable. // The default value is [icons.Close]. // Only [FunctionalTabs] can be closed; all other types of // tabs will not render a close button and can not be closed. CloseIcon icons.Icon // Maximum number of characters to include in tab label. // Elides labels that are longer than that MaxChars int }
Tab is a tab button that contains any, all, or none of a label, an icon, and a close icon. Tabs should be made using the Tabs.NewTab function.
func (*Tab) SetCloseIcon ¶
SetCloseIcon sets the [Tab.CloseIcon]: CloseIcon is the icon used as a close button for the tab. If it is "" or icons.None, the tab is not closeable. The default value is icons.Close. Only FunctionalTabs can be closed; all other types of tabs will not render a close button and can not be closed.
func (*Tab) SetIcon ¶
SetIcon sets the [Tab.Icon]: Icon is the icon for the tab. If it is "" or icons.None, no icon is shown.
func (*Tab) SetMaxChars ¶
SetMaxChars sets the [Tab.MaxChars]: Maximum number of characters to include in tab label. Elides labels that are longer than that
func (*Tab) SetText ¶
SetText sets the [Tab.Text]: Text is the label text for the tab. If it is nil, no label is shown. Labels are never shown for NavigationRail tabs.
type TabTypes ¶
type TabTypes int32 //enums:enum
TabTypes are the different styling types of tabs.
const ( // StandardTabs indicates to render the standard type // of Material Design style tabs. StandardTabs TabTypes = iota // FunctionalTabs indicates to render functional tabs // like those in Google Chrome. These tabs take up less // space and are the only kind that can be closed. // They can also be moved. FunctionalTabs // [NavigationBar], [NavigationRail], or [NavigationDrawer], // if [WidgetBase.SizeClass] is [SizeCompact], [SizeMedium], // or [SizeExpanded], respectively. NavigationAuto should // typically be used instead of one of the specific navigation // types for better cross-platform compatability. NavigationAuto // bottom navigation bar with text and icons. NavigationBar // side navigation rail, which only has icons. NavigationRail // side navigation drawer, which has full text labels and icons. NavigationDrawer )
const TabTypesN TabTypes = 6
TabTypesN is the highest valid value for type TabTypes, plus one.
func TabTypesValues ¶
func TabTypesValues() []TabTypes
TabTypesValues returns all possible values for the type TabTypes.
func (TabTypes) Effective ¶
EffectiveType returns the effective tab type in the context of the given widget, handling NavigationAuto based on WidgetBase.SizeClass.
func (TabTypes) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*TabTypes) SetString ¶
SetString sets the TabTypes value from its string representation, and returns an error if the string is invalid.
func (*TabTypes) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Tabs ¶
type Tabs struct { Layout // Type is the styling type of the tabs. If it is changed after // the tabs are first configured, Update needs to be called on // the tabs. Type TabTypes // NewTabButton is whether to show a new tab button at the end of the list of tabs. NewTabButton bool // MaxChars is the maximum number of characters to include in the tab label. // It elides labels that are longer than that. MaxChars int // CloseIcon is the icon used for tab close buttons. // If it is "" or [icons.None], the tab is not closeable. // The default value is [icons.Close]. // Only [FunctionalTabs] can be closed; all other types of // tabs will not render a close button and can not be closed. CloseIcon icons.Icon // PrevEffectiveType is the previous effective type of the tabs // as computed by [TabTypes.Effective]. PrevEffectiveType TabTypes `copier:"-" json:"-" xml:"-" set:"-"` // Mu is a mutex protecting updates to tabs. Tabs can be driven // programmatically and via user input so need extra protection. Mu sync.Mutex `copier:"-" json:"-" xml:"-" view:"-" set:"-"` }
Tabs switches among child widgets via tabs. The selected widget gets the full allocated space avail after the tabs are accounted for. The Tabs is just a Vertical layout that manages two child widgets: a HorizFlow Layout for the tabs (which can flow across multiple rows as needed) and a Stacked Frame that actually contains all the children, and provides scrollbars as needed to any content within. Typically should have max stretch and a set preferred size, so it expands.
func AsTabs ¶
AsTabs returns the given value as a value of type Tabs if the type of the given value embeds Tabs, or nil otherwise
func NewTabs ¶
NewTabs adds a new Tabs with the given name to the given parent: Tabs switches among child widgets via tabs. The selected widget gets the full allocated space avail after the tabs are accounted for. The Tabs is just a Vertical layout that manages two child widgets: a HorizFlow Layout for the tabs (which can flow across multiple rows as needed) and a Stacked Frame that actually contains all the children, and provides scrollbars as needed to any content within. Typically should have max stretch and a set preferred size, so it expands.
func (*Tabs) AddTab ¶
AddTab adds an already existing frame as a new tab with the given tab label and returns the index of that tab.
func (*Tabs) Config ¶
func (ts *Tabs) Config()
Config configures the tabs widget children if necessary. Only the 2 primary children (Frames) need to be configured. Re-config is needed when the type of tabs changes, but not when a new tab is added, which only requires a new layout pass.
func (*Tabs) ConfigNewTabButton ¶
ConfigNewTabButton configures the new tab button at the end of the list of tabs, if applicable.
func (*Tabs) DeleteTabIndex ¶
DeleteTabIndex deletes tab at given index, returning whether it was successful.
func (*Tabs) Frame ¶
Frame returns the stacked frame layout (the second element within us). It configures the Tabs if necessary.
func (*Tabs) InsertNewTab ¶
InsertNewTab inserts a new tab with the given label at the given index position within the list of tabs and returns the resulting tab frame. An optional icon can also be passed for the tab button.
func (*Tabs) InsertTab ¶
InsertTab inserts a frame into given index position within list of tabs. An optional icon can also be passed for the tab button.
func (*Tabs) InsertTabOnlyAt ¶
InsertTabOnlyAt inserts just the tab button at given index, after the panel has already been added to the frame; assumed to be wrapped in update. Generally for internal use only. An optional icon can also be passed for the tab button.
func (*Tabs) NewTab ¶
NewTab adds a new tab with the given label and returns the resulting tab frame. It is the main end-user API for creating new tabs. An optional icon can also be passed for the tab button.
func (*Tabs) NodeType ¶
NodeType returns the *types.Type of Tabs
func (*Tabs) RecycleTab ¶
RecycleTab returns a tab with given name, first by looking for an existing one, and if not found, making a new one. If sel, then select it. It returns the frame for the tab.
func (*Tabs) RecycleTabWidget ¶
RecycleTabWidget returns a tab with given widget type in the tab frame, first by looking for an existing one, with given name, and if not found, making and configuring a new one. If sel, then select it. It returns the Widget item for the tab.
func (*Tabs) SelectTabByName ¶
SelectTabByName selects tab by widget name, returning it. The widget name is the original full tab label, prior to any eliding.
func (*Tabs) SelectTabIndex ¶
SelectTabIndex selects tab at given index, returning it. Returns false if index is invalid. This is the final tab selection path.
func (*Tabs) SetCloseIcon ¶
SetCloseIcon sets the [Tabs.CloseIcon]: CloseIcon is the icon used for tab close buttons. If it is "" or icons.None, the tab is not closeable. The default value is icons.Close. Only FunctionalTabs can be closed; all other types of tabs will not render a close button and can not be closed.
func (*Tabs) SetMaxChars ¶
SetMaxChars sets the [Tabs.MaxChars]: MaxChars is the maximum number of characters to include in the tab label. It elides labels that are longer than that.
func (*Tabs) SetNewTabButton ¶
SetNewTabButton sets the [Tabs.NewTabButton]: NewTabButton is whether to show a new tab button at the end of the list of tabs.
func (*Tabs) SetTooltip ¶
SetTooltip sets the [Tabs.Tooltip]
func (*Tabs) SetType ¶
SetType sets the [Tabs.Type]: Type is the styling type of the tabs. If it is changed after the tabs are first configured, Update needs to be called on the tabs.
func (*Tabs) TabAtIndex ¶
TabAtIndex returns content frame and tab button at given index, false if index out of range (emits log message)
func (*Tabs) TabByName ¶
TabByName returns tab Frame with given widget name (nil if not found) The widget name is the original full tab label, prior to any eliding.
func (*Tabs) TabIndexByName ¶
TabIndexByName returns the tab index for the given tab widget name and -1 if it can not be found. The widget name is the original full tab label, prior to any eliding.
func (*Tabs) Tabs ¶
Tabs returns the layout containing the tabs (the first element within us). It configures the Tabs if necessary.
func (*Tabs) UnselectOtherTabs ¶
UnselectOtherTabs turns off all the tabs except given one
type TabsEmbedder ¶
type TabsEmbedder interface {
AsTabs() *Tabs
}
TabsEmbedder is an interface that all types that embed Tabs satisfy
type TextField ¶
type TextField struct { WidgetBase // Type is the styling type of the text field. Type TextFieldTypes // Placeholder is the text that is displayed // when the text field is empty. Placeholder string // Validator is a function used to validate the input // of the text field. If it returns a non-nil error, // then an error color, icon, and tooltip will be displayed. Validator func() error `json:"-" xml:"-"` // LeadingIcon, if specified, indicates to add a button // at the start of the text field with this icon. LeadingIcon icons.Icon `set:"-"` // LeadingIconOnClick, if specified, is the function to call when // the LeadingIcon is clicked. If this is nil, the leading icon // will not be interactive. LeadingIconOnClick func(e events.Event) `json:"-" xml:"-"` // TrailingIcon, if specified, indicates to add a button // at the end of the text field with this icon. TrailingIcon icons.Icon `set:"-"` // TrailingIconOnClick, if specified, is the function to call when // the TrailingIcon is clicked. If this is nil, the trailing icon // will not be interactive. TrailingIconOnClick func(e events.Event) `json:"-" xml:"-"` // NoEcho is whether replace displayed characters with bullets to conceal text // (for example, for a password input). NoEcho bool // CursorWidth is the width of the text field cursor. // It should be set in Style like all other style properties. // By default, it is 1dp. CursorWidth units.Value // CursorColor is the color used for the text field cursor (caret). // It should be set in Style like all other style properties. // By default, it is [colors.Scheme.Primary.Base]. CursorColor image.Image // PlaceholderColor is the color used for the Placeholder text. // It should be set in Style like all other style properties. // By default, it is [colors.Scheme.OnSurfaceVariant]. PlaceholderColor image.Image // SelectColor is the color used for the text selection background color. // It should be set in Style like all other style properties. // By default, it is [colors.Scheme.Select.Container] SelectColor image.Image // Complete contains functions and data for text field completion. // It must be set using [TextField.SetCompleter]. Complete *Complete `copier:"-" json:"-" xml:"-" set:"-"` // Txt is the last saved value of the text string being edited. Txt string `json:"-" xml:"-" set:"-"` // Edited is whether the text has been edited relative to the original. Edited bool `json:"-" xml:"-" set:"-"` // EditTxt is the live text string being edited, with the latest modifications. EditTxt []rune `copier:"-" json:"-" xml:"-" set:"-"` // Error is the current validation error of the text field. Error error `json:"-" xml:"-" set:"-"` // EffPos is the effective position with any leading icon space added. EffPos math32.Vector2 `copier:"-" json:"-" xml:"-" set:"-"` // EffSize is the effective size, subtracting any leading and trailing icon space. EffSize math32.Vector2 `copier:"-" json:"-" xml:"-" set:"-"` // StartPos is the starting display position in the string. StartPos int `copier:"-" json:"-" xml:"-" set:"-"` // EndPos is the ending display position in the string. EndPos int `copier:"-" json:"-" xml:"-" set:"-"` // CursorPos is the current cursor position. CursorPos int `copier:"-" json:"-" xml:"-" set:"-"` // CursorLine is the current cursor line position. CursorLine int `copier:"-" json:"-" xml:"-" set:"-"` // CharWidth is the approximate number of chars that can be // displayed at any time, which is computed from the font size. CharWidth int `copier:"-" json:"-" xml:"-" set:"-"` // SelectStart is the starting position of selection in the string. SelectStart int `copier:"-" json:"-" xml:"-" set:"-"` // SelectEnd is the ending position of selection in the string. SelectEnd int `copier:"-" json:"-" xml:"-" set:"-"` // SelectInit is the initial selection position (where it started). SelectInit int `copier:"-" json:"-" xml:"-" set:"-"` // SelectMode is whether to select text as the cursor moves. SelectMode bool `copier:"-" json:"-" xml:"-"` // RenderAll is the render version of entire text, for sizing. RenderAll paint.Text `copier:"-" json:"-" xml:"-" set:"-"` // RenderVis is the render version of just the visible text. RenderVis paint.Text `copier:"-" json:"-" xml:"-" set:"-"` // number of lines from last render update, for word-wrap version NLines int `copier:"-" json:"-" xml:"-" set:"-"` // FontHeight is the font height cached during styling. FontHeight float32 `copier:"-" json:"-" xml:"-" set:"-"` // BlinkOn oscillates between on and off for blinking. BlinkOn bool `copier:"-" json:"-" xml:"-" set:"-"` // CursorMu is the mutex for updating the cursor between blinker and field. CursorMu sync.Mutex `copier:"-" json:"-" xml:"-" view:"-" set:"-"` // the undo manager UndoMgr TextFieldUndoMgr }
TextField is a widget for editing a line of text. With the default WhiteSpaceNormal style setting, text will wrap onto multiple lines as needed. Set to WhiteSpaceNowrap (e.g., Styles.SetTextWrap(false)) to force everything to be on a single line. With multi-line wrapped text, the text is still treated as a contiguous wrapped text.
func AsTextField ¶
AsTextField returns the given value as a value of type TextField if the type of the given value embeds TextField, or nil otherwise
func NewTextField ¶
NewTextField adds a new TextField with the given name to the given parent: TextField is a widget for editing a line of text. With the default WhiteSpaceNormal style setting, text will wrap onto multiple lines as needed. Set to WhiteSpaceNowrap (e.g., Styles.SetTextWrap(false)) to force everything to be on a single line. With multi-line wrapped text, the text is still treated as a contiguous wrapped text.
func (*TextField) AddClearButton ¶
AddClearButton adds a trailing icon button at the end of the textfield that clears the text in the textfield when pressed
func (*TextField) ApplyStyle ¶
func (tf *TextField) ApplyStyle()
func (*TextField) AsTextField ¶
AsTextField satisfies the TextFieldEmbedder interface
func (*TextField) AutoScroll ¶
func (tf *TextField) AutoScroll()
AutoScroll scrolls the starting position to keep the cursor visible
func (*TextField) CancelComplete ¶
func (tf *TextField) CancelComplete()
CancelComplete cancels any pending completion -- call this when new events have moved beyond any prior completion scenario
func (*TextField) CharPos ¶
CharPos returns the relative starting position of the given rune, in the overall RenderAll of all the text. These positions can be out of visible range: see CharRenderPos
func (*TextField) CharRenderPos ¶
CharRenderPos returns the starting render coords for the given character position in string -- makes no attempt to rationalize that pos (i.e., if not in visible range, position will be out of range too). if wincoords is true, then adds window box offset -- for cursor, popups
func (*TextField) ClearCursor ¶
func (tf *TextField) ClearCursor()
ClearCursor turns off cursor and stops it from blinking
func (*TextField) ClearSelected ¶
func (tf *TextField) ClearSelected()
ClearSelected resets both the global selected flag and any current selection
func (*TextField) CompleteText ¶
CompleteText edits the text field using the string chosen from the completion menu
func (*TextField) ConfigTextSize ¶
func (*TextField) ContextMenu ¶
func (*TextField) Copy ¶
Copy copies any selected text to the clipboard. Satisfies Clipper interface -- can be extended in subtypes. optionally resetting the current selection
func (*TextField) CursorBackspace ¶
CursorBackspace deletes character(s) immediately before cursor
func (*TextField) CursorBackspaceWord ¶
CursorBackspaceWord deletes words(s) immediately before cursor
func (*TextField) CursorBackward ¶
CursorBackward moves the cursor backward
func (*TextField) CursorBackwardWord ¶
CursorBackwardWord moves the cursor backward by words
func (*TextField) CursorDelete ¶
CursorDelete deletes character(s) immediately after the cursor
func (*TextField) CursorDeleteWord ¶
CursorDeleteWord deletes word(s) immediately after the cursor
func (*TextField) CursorDown ¶
CursorDown moves the cursor down
func (*TextField) CursorEnd ¶
func (tf *TextField) CursorEnd()
CursorEnd moves the cursor to the end of the text
func (*TextField) CursorForward ¶
CursorForward moves the cursor forward
func (*TextField) CursorForwardWord ¶
CursorForwardWord moves the cursor forward by words
func (*TextField) CursorKill ¶
func (tf *TextField) CursorKill()
CursorKill deletes text from cursor to end of text
func (*TextField) CursorSprite ¶
CursorSprite returns the Sprite for the cursor (which is only rendered once with a vertical bar, and just activated and inactivated depending on render status). On sets the On status of the cursor.
func (*TextField) CursorStart ¶
func (tf *TextField) CursorStart()
CursorStart moves the cursor to the start of the text, updating selection if select mode is active
func (*TextField) Cut ¶
func (tf *TextField) Cut()
Cut cuts any selected text and adds it to the clipboard
func (*TextField) DeleteSelection ¶
DeleteSelection deletes any selected text, without adding to clipboard -- returns text deleted
func (*TextField) EditDone ¶
func (tf *TextField) EditDone()
EditDone completes editing and copies the active edited text to the text -- called when the return key is pressed or goes out of focus
func (*TextField) HandleEvents ¶
func (tf *TextField) HandleEvents()
func (*TextField) HandleKeyEvents ¶
func (tf *TextField) HandleKeyEvents()
func (*TextField) HasSelection ¶
HasSelection returns whether there is a selected region of text
func (*TextField) HasWordWrap ¶
HasWordWrap returns true if the layout is multi-line word wrapping
func (*TextField) InsertAtCursor ¶
InsertAtCursor inserts given text at current cursor position
func (*TextField) IsWordBreak ¶
IsWordBreak defines what counts as a word break for the purposes of selecting words
func (*TextField) LeadingIconButton ¶
LeadingIconButton returns the [LeadingIcon] Button if present.
func (*TextField) NodeType ¶
NodeType returns the *types.Type of TextField
func (*TextField) OfferComplete ¶
func (tf *TextField) OfferComplete()
OfferComplete pops up a menu of possible completions
func (*TextField) Paste ¶
func (tf *TextField) Paste()
Paste inserts text from the clipboard at current cursor position -- if cursor is within a current selection, that selection is replaced. Satisfies Clipper interface -- can be extended in subtypes.
func (*TextField) PixelToCursor ¶
PixelToCursor finds the cursor position that corresponds to the given pixel location
func (*TextField) RelCharPos ¶
RelCharPos returns the text width in dots between the two text string positions (ed is exclusive -- +1 beyond actual char).
func (*TextField) RenderCursor ¶
RenderCursor renders the cursor on or off, as a sprite that is either on or off
func (*TextField) RenderSelect ¶
func (tf *TextField) RenderSelect()
RenderSelect renders the selected region, if any, underneath the text
func (*TextField) Revert ¶
func (tf *TextField) Revert()
Revert aborts editing and reverts to last saved text
func (*TextField) ScrollLayoutToCursor ¶
ScrollLayoutToCursor scrolls any scrolling layout above us so that the cursor is in view
func (*TextField) SelectModeToggle ¶
func (tf *TextField) SelectModeToggle()
SelectModeToggle toggles the SelectMode, updating selection with cursor movement
func (*TextField) SelectRegUpdate ¶
SelectRegUpdate updates current select region based on given cursor position relative to SelectStart position
func (*TextField) SelectUpdate ¶
func (tf *TextField) SelectUpdate()
SelectUpdate updates the select region after any change to the text, to keep it in range
func (*TextField) SelectWord ¶
func (tf *TextField) SelectWord()
SelectWord selects the word (whitespace delimited) that the cursor is on
func (*TextField) SetCompleter ¶
SetCompleter sets completion functions so that completions will automatically be offered as the user types
func (*TextField) SetCursorColor ¶
SetCursorColor sets the [TextField.CursorColor]: CursorColor is the color used for the text field cursor (caret). It should be set in Style like all other style properties. By default, it is [colors.Scheme.Primary.Base].
func (*TextField) SetCursorFromPixel ¶
func (tf *TextField) SetCursorFromPixel(pt image.Point, selMode events.SelectModes)
SetCursorFromPixel finds cursor location from given scene-relative pixel location, and sets current cursor to it, updating selection too.
func (*TextField) SetCursorWidth ¶
SetCursorWidth sets the [TextField.CursorWidth]: CursorWidth is the width of the text field cursor. It should be set in Style like all other style properties. By default, it is 1dp.
func (*TextField) SetEffPosAndSize ¶
func (tf *TextField) SetEffPosAndSize()
SetEffPosAndSize sets the effective position and size of the textfield based on its base position and size and its icons or lack thereof
func (*TextField) SetLeadingIcon ¶
SetLeadingIcon sets the leading icon of the text field to the given icon. If an on click function is specified, it also sets the leading icon on click function to that function. If no function is specified, it does not override any already set function.
func (*TextField) SetLeadingIconOnClick ¶
SetLeadingIconOnClick sets the [TextField.LeadingIconOnClick]: LeadingIconOnClick, if specified, is the function to call when the LeadingIcon is clicked. If this is nil, the leading icon will not be interactive.
func (*TextField) SetNoEcho ¶
SetNoEcho sets the [TextField.NoEcho]: NoEcho is whether replace displayed characters with bullets to conceal text (for example, for a password input).
func (*TextField) SetPlaceholder ¶
SetPlaceholder sets the [TextField.Placeholder]: Placeholder is the text that is displayed when the text field is empty.
func (*TextField) SetPlaceholderColor ¶
SetPlaceholderColor sets the [TextField.PlaceholderColor]: PlaceholderColor is the color used for the Placeholder text. It should be set in Style like all other style properties. By default, it is colors.Scheme.OnSurfaceVariant.
func (*TextField) SetSelectColor ¶
SetSelectColor sets the [TextField.SelectColor]: SelectColor is the color used for the text selection background color. It should be set in Style like all other style properties. By default, it is [colors.Scheme.Select.Container]
func (*TextField) SetSelectMode ¶
SetSelectMode sets the [TextField.SelectMode]: SelectMode is whether to select text as the cursor moves.
func (*TextField) SetText ¶
SetText sets the text to be edited and reverts any current edit to reflect this new text.
func (*TextField) SetTooltip ¶
SetTooltip sets the [TextField.Tooltip]
func (*TextField) SetTrailingIcon ¶
SetTrailingIcon sets the trailing icon of the text field to the given icon. If an on click function is specified, it also sets the trailing icon on click function to that function. If no function is specified, it does not override any already set function.
func (*TextField) SetTrailingIconOnClick ¶
SetTrailingIconOnClick sets the [TextField.TrailingIconOnClick]: TrailingIconOnClick, if specified, is the function to call when the TrailingIcon is clicked. If this is nil, the trailing icon will not be interactive.
func (*TextField) SetType ¶
func (t *TextField) SetType(v TextFieldTypes) *TextField
SetType sets the [TextField.Type]: Type is the styling type of the text field.
func (*TextField) SetTypePassword ¶
SetTypePassword enables [TextField.NoEcho] and adds a trailing icon button at the end of the textfield that toggles [TextField.NoEcho]. It also sets styles.Style.VirtualKeyboard to styles.KeyboardPassword.
func (*TextField) SetUndoMgr ¶
func (t *TextField) SetUndoMgr(v TextFieldUndoMgr) *TextField
SetUndoMgr sets the [TextField.UndoMgr]: the undo manager
func (*TextField) SetValidator ¶
SetValidator sets the [TextField.Validator]: Validator is a function used to validate the input of the text field. If it returns a non-nil error, then an error color, icon, and tooltip will be displayed.
func (*TextField) ShiftSelect ¶
ShiftSelect sets the selection start if the shift key is down but wasn't previously. If the shift key has been released, the selection info is cleared.
func (*TextField) StartCursor ¶
func (tf *TextField) StartCursor()
StartCursor starts the cursor blinking and renders it
func (*TextField) StopCursor ¶
func (tf *TextField) StopCursor()
StopCursor stops the cursor from blinking
func (*TextField) Text ¶
Text returns the current text -- applies any unapplied changes first, and sends a signal if so -- this is the end-user method to get the current value of the field.
func (*TextField) TrailingIconButton ¶
TrailingIconButton returns the [TrailingIcon] Button if present.
func (*TextField) Validate ¶
func (tf *TextField) Validate()
Validate runs [TextField.Validator] and takes any necessary actions as a result of that.
func (*TextField) WidgetTooltip ¶
type TextFieldEmbedder ¶
type TextFieldEmbedder interface {
AsTextField() *TextField
}
TextFieldEmbedder is an interface that all types that embed TextField satisfy
type TextFieldTypes ¶
type TextFieldTypes int32 //enums:enum -trim-prefix TextField
TextFieldTypes is an enum containing the different possible types of text fields
const ( // TextFieldFilled represents a filled // TextField with a background color // and a bottom border TextFieldFilled TextFieldTypes = iota // TextFieldOutlined represents an outlined // TextField with a border on all sides // and no background color TextFieldOutlined )
const TextFieldTypesN TextFieldTypes = 2
TextFieldTypesN is the highest valid value for type TextFieldTypes, plus one.
func TextFieldTypesValues ¶
func TextFieldTypesValues() []TextFieldTypes
TextFieldTypesValues returns all possible values for the type TextFieldTypes.
func (TextFieldTypes) Desc ¶
func (i TextFieldTypes) Desc() string
Desc returns the description of the TextFieldTypes value.
func (TextFieldTypes) Int64 ¶
func (i TextFieldTypes) Int64() int64
Int64 returns the TextFieldTypes value as an int64.
func (TextFieldTypes) MarshalText ¶
func (i TextFieldTypes) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*TextFieldTypes) SetInt64 ¶
func (i *TextFieldTypes) SetInt64(in int64)
SetInt64 sets the TextFieldTypes value from an int64.
func (*TextFieldTypes) SetString ¶
func (i *TextFieldTypes) SetString(s string) error
SetString sets the TextFieldTypes value from its string representation, and returns an error if the string is invalid.
func (TextFieldTypes) String ¶
func (i TextFieldTypes) String() string
String returns the string representation of this TextFieldTypes value.
func (*TextFieldTypes) UnmarshalText ¶
func (i *TextFieldTypes) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (TextFieldTypes) Values ¶
func (i TextFieldTypes) Values() []enums.Enum
Values returns all possible values for the type TextFieldTypes.
type TextFieldUndoMgr ¶
type TextFieldUndoMgr struct { // stack of undo records Stack []TextFieldUndoRec // position within the undo stack Pos int // last time undo was saved, for grouping LastSave time.Time }
TextFieldUndoMgr manages everything about the undo process
func (*TextFieldUndoMgr) Redo ¶
func (um *TextFieldUndoMgr) Redo() *TextFieldUndoRec
func (*TextFieldUndoMgr) SaveUndo ¶
func (um *TextFieldUndoMgr) SaveUndo(txt []rune, curpos int)
func (*TextFieldUndoMgr) Undo ¶
func (um *TextFieldUndoMgr) Undo(txt []rune, curpos int) *TextFieldUndoRec
type TextFieldUndoRec ¶
TextFieldUndoRec holds one undo record
func (*TextFieldUndoRec) Set ¶
func (ur *TextFieldUndoRec) Set(txt []rune, curpos int)
type Themes ¶
type Themes int32 //enums:enum -trim-prefix Theme
Themes are the different possible themes that a user can select in their settings.
const ThemesN Themes = 3
ThemesN is the highest valid value for type Themes, plus one.
func ThemesValues ¶
func ThemesValues() []Themes
ThemesValues returns all possible values for the type Themes.
func (Themes) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Themes) SetString ¶
SetString sets the Themes value from its string representation, and returns an error if the string is invalid.
func (*Themes) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Toolbar ¶
type Toolbar struct { Frame // items moved from the main toolbar, will be shown in the overflow menu OverflowItems tree.Slice `set:"-" json:"-" xml:"-"` // functions for overflow menu: use AddOverflowMenu to add. // These are processed in _reverse_ order (last in, first called) // so that the default items are added last. OverflowMenus []func(m *Scene) `set:"-" json:"-" xml:"-"` // ToolbarFuncs contains functions for configuring this toolbar, // called on Config ToolbarFuncs ToolbarFuncs // This is the overflow button OverflowButton *Button `copier:"-"` }
Toolbar is a Frame that is useful for holding [Button]s that do things. It automatically moves items that do not fit into an overflow menu, and manages additional items that are always placed onto this overflow menu. In general it should be possible to use a single toolbar + overflow to manage all an app's functionality, in a way that is portable across mobile and desktop environments. See [Widget.ConfigToolbar] for the standard toolbar config method for any given widget, and [Scene.AppBars] for ToolbarFuncs for Scene elements who should be represented in the main AppBar (e.g., TopAppBar).
func AsToolbar ¶
AsToolbar returns the given value as a value of type Toolbar if the type of the given value embeds Toolbar, or nil otherwise
func NewToolbar ¶
NewToolbar adds a new Toolbar with the given name to the given parent: Toolbar is a Frame that is useful for holding [Button]s that do things. It automatically moves items that do not fit into an overflow menu, and manages additional items that are always placed onto this overflow menu. In general it should be possible to use a single toolbar + overflow to manage all an app's functionality, in a way that is portable across mobile and desktop environments. See [Widget.ConfigToolbar] for the standard toolbar config method for any given widget, and [Scene.AppBars] for ToolbarFuncs for Scene elements who should be represented in the main AppBar (e.g., TopAppBar).
func RecycleToolbar ¶
RecycleToolbar constructs or returns a Toolbar in given parent Widget
func (*Toolbar) AddOverflowMenu ¶
AddOverflowMenu adds the given menu function to the overflow menu list. These functions are called in reverse order such that the last added function is called first when constructing the menu.
func (*Toolbar) AllItemsToChildren ¶
func (tb *Toolbar) AllItemsToChildren()
AllItemsToChildren moves the overflow items back to the children, so the full set is considered for the next layout round, and ensures the overflow button is made and moves it to the end of the list.
func (*Toolbar) AppChooser ¶
AppChooser returns the app Chooser used for searching for items. It will only be non-nil if this toolbar has been configured with an app chooser, which typically only happens for app bars.
func (*Toolbar) AsToolbar ¶
AsToolbar satisfies the ToolbarEmbedder interface
func (*Toolbar) DeleteShortcuts ¶
func (tb *Toolbar) DeleteShortcuts()
DeleteShortcuts deletes the shortcuts -- called when destroyed
func (*Toolbar) MoveToOverflow ¶
func (tb *Toolbar) MoveToOverflow()
MoveToOverflow moves overflow out of children to the OverflowItems list
func (*Toolbar) NodeType ¶
NodeType returns the *types.Type of Toolbar
func (*Toolbar) OverflowMenu ¶
OverflowMenu is the overflow menu function
func (*Toolbar) ParentSize ¶
func (*Toolbar) SetOverflowButton ¶
SetOverflowButton sets the [Toolbar.OverflowButton]: This is the overflow button
func (*Toolbar) SetShortcuts ¶
func (tb *Toolbar) SetShortcuts()
SetShortcuts sets the shortcuts to window associated with Toolbar
func (*Toolbar) SetToolbarFuncs ¶
func (t *Toolbar) SetToolbarFuncs(v ToolbarFuncs) *Toolbar
SetToolbarFuncs sets the [Toolbar.ToolbarFuncs]: ToolbarFuncs contains functions for configuring this toolbar, called on Config
func (*Toolbar) SetTooltip ¶
SetTooltip sets the [Toolbar.Tooltip]
func (*Toolbar) SizeFromChildren ¶
func (tb *Toolbar) SizeFromChildren(iter int, pass LayoutPasses) math32.Vector2
func (*Toolbar) StandardOverflowMenu ¶
StandardOverflowMenu adds standard overflow menu items.
type ToolbarEmbedder ¶
type ToolbarEmbedder interface {
AsToolbar() *Toolbar
}
ToolbarEmbedder is an interface that all types that embed Toolbar satisfy
type ToolbarFuncs ¶
type ToolbarFuncs []func(tb *Toolbar)
ToolbarFuncs are functions for creating control bars, attached to different sides of a Scene (e.g., TopAppBar at Top, NavBar at Bottom, etc). Functions are called in forward order so first added are called first.
func (*ToolbarFuncs) Add ¶
func (bf *ToolbarFuncs) Add(fun func(tb *Toolbar)) *ToolbarFuncs
Add adds the given function for configuring a toolbar
func (*ToolbarFuncs) Call ¶
func (bf *ToolbarFuncs) Call(tb *Toolbar)
Call calls all the functions for configuring given toolbar
func (*ToolbarFuncs) IsEmpty ¶
func (bf *ToolbarFuncs) IsEmpty() bool
IsEmpty returns true if there are no functions added
type Toolbarer ¶
type Toolbarer interface {
ConfigToolbar(tb *Toolbar)
}
Toolbarer interface is for ConfigToolbar function access for those that define it
type Updater ¶
type Updater interface { // Update updates anything in this type that might depend on other state // which could have just been changed. It is the responsibility of the // type to determine what might have changed, or just generically update // everything assuming anything could have changed. Update() }
Updater defines an interface for something that has an Update() method this will be called by GUI actions that update values of a type including struct, slice, and map views in giv
type User ¶
type User struct { user.User // default email address -- e.g., for recording changes in a version control system Email string }
User basic user information that might be needed for different apps
type Validator ¶
type Validator interface { // Validate returns an error if the value is invalid. Validate() error }
Validator is an interface for types to provide a Validate method that is used in views to validate string Values using [TextField.Validator].
type Widget ¶
type Widget interface { tree.Node // AsWidget returns the WidgetBase embedded field for any Widget node. // The Widget interface defines only methods that can be overridden // or need to be called on other nodes. Everything else that is common // to all Widgets is in the WidgetBase. AsWidget() *WidgetBase // OnWidgetAdded adds a function to call when a widget is added // as a child to the widget or any of its children. OnWidgetAdded(f func(w Widget)) *WidgetBase // Style sets the styling of the widget by adding a Styler function. Style(s func(s *styles.Style)) *WidgetBase // Update does a general purpose update of the widget and everything // below it by reconfiguring it, applying its styles, and indicating // that it needs a new layout pass. It is the main way that end users // should update widgets, and it should be called after making any // changes to the core properties of a widget (for example, the text // of a label, the icon of a button, or the slice of a table view). // // If you are calling this in a separate goroutine outside of the main // configuration, rendering, and event handling structure, you need to // call [WidgetBase.AsyncLock] and [WidgetBase.AsyncUnlock] before and // after this, respectively. Update() // Config configures the widget, typically primarily configuring its Parts. // it does not call Config on its children, just on itself. // ApplyStyle must generally be called after Config; it is called // automatically when the Scene is first shown, but must be called // manually thereafter as needed after configuration changes. // See Update for a convenience function that does both and also // triggers a new layout pass. ConfigScene on Scene handles the full // tree configuration. Config() // StateIs returns whether the widget has the given [states.States] flag set StateIs(flag states.States) bool // AbilityIs returns whether the widget has the given [abilities.Abilities] flag set AbilityIs(flag abilities.Abilities) bool // SetState sets the given [states.State] flags to the given value SetState(on bool, state ...states.States) *WidgetBase // SetAbilities sets the given [abilities.Abilities] flags to the given value SetAbilities(on bool, able ...abilities.Abilities) *WidgetBase // ApplyStyle applies style functions to the widget based on current state. // It is typically not overridden; instead, call Style to apply custom styling. ApplyStyle() // SizeUp (bottom-up) gathers Actual sizes from our Children & Parts, // based on Styles.Min / Max sizes and actual content sizing // (e.g., text size). Flexible elements (e.g., Label, Flex Wrap, // TopAppBar) should reserve the _minimum_ size possible at this stage, // and then Grow based on SizeDown allocation. SizeUp() // SizeDown (top-down, multiple iterations possible) provides top-down // size allocations based initially on Scene available size and // the SizeUp Actual sizes. If there is extra space available, it is // allocated according to the Grow factors. // Flexible elements (e.g., Flex Wrap layouts and Label with word wrap) // update their Actual size based on available Alloc size (re-wrap), // to fit the allocated shape vs. the initial bottom-up guess. // However, do NOT grow the Actual size to match Alloc at this stage, // as Actual sizes must always represent the minimums (see Position). // Returns true if any change in Actual size occurred. SizeDown(iter int) bool // SizeFinal: (bottom-up) similar to SizeUp but done at the end of the // Sizing phase: first grows widget Actual sizes based on their Grow // factors, up to their Alloc sizes. Then gathers this updated final // actual Size information for layouts to register their actual sizes // prior to positioning, which requires accurate Actual vs. Alloc // sizes to perform correct alignment calculations. SizeFinal() // Position uses the final sizes to set relative positions within layouts // according to alignment settings, and Grow elements to their actual // Alloc size per Styles settings and widget-specific behavior. Position() // ScenePos computes scene-based absolute positions and final BBox // bounding boxes for rendering, based on relative positions from // Position step and parents accumulated position and scroll offset. // This is the only step needed when scrolling (very fast). ScenePos() // Render is the method that widgets should implement to define their // custom rendering steps. It should not be called outside of // [Widget.RenderWidget], which also does other steps applicable // for all widgets. Render() // RenderWidget renders the widget and any parts and children that it has. // It does not render if the widget is invisible. It calls Widget.Render] // for widget-specific rendering. RenderWidget() // On adds an event listener function for the given event type On(etype events.Types, fun func(e events.Event)) *WidgetBase // OnClick adds an event listener function for [events.Click] events OnClick(fun func(e events.Event)) *WidgetBase // 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. HandleEvent(e 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. Send(e events.Types, orig ...events.Event) // WidgetTooltip returns the tooltip text that should be used for this // widget. By default, it just returns [WidgetBase.Tooltip], but widgets // can override it to do different things. For example, buttons add their // shortcut to the tooltip here. WidgetTooltip() string // AddContextMenu adds the given context menu to [WidgetBase.ContextMenus]. // It is the main way that code should modify a widget's context menus. // Context menu functions are run in reverse order. AddContextMenu(menu func(m *Scene)) *WidgetBase // ApplyContextMenus adds the [Widget.ContextMenus] to the given menu scene // in reverse order. ApplyContextMenus(m *Scene) // ContextMenuPos returns the default position for popup menus; // by default in the middle its Bounding Box, but can be adapted as // appropriate for different widgets. ContextMenuPos(e events.Event) image.Point // ShowContextMenu displays the context menu of various actions // to perform on a Widget, activated by default on the ShowContextMenu // event, triggered by a Right mouse click. // Returns immediately, and actions are all executed directly // (later) via the action signals. Calls ContextMenu and // ContextMenuPos. ShowContextMenu(e events.Event) // IsVisible returns true if a node is visible for rendering according // to the [states.Invisible] flag on it or any of its parents. // This flag is also set by [styles.DisplayNone] during [ApplyStyle]. // This does *not* check for an empty TotalBBox, indicating that the widget // is out of render range -- that is done by [PushBounds] prior to rendering. // Non-visible nodes are automatically not rendered and do not get // window events. // This call recursively calls the parent, which is typically a short path. IsVisible() bool // ChildBackground returns the background color (Image) for given child Widget. // By default, this is just our [Styles.Actualbackground] but it can be computed // specifically for the child (e.g., for zebra stripes in views.SliceViewGrid) ChildBackground(child Widget) image.Image // DirectRenderImage uploads image directly into given system.Drawer at given index // Typically this is a drw.SetGoImage call with an [image.RGBA], or // drw.SetFrameImage with a [vgpu.FrameBuffer] DirectRenderImage(drw system.Drawer, idx int) // DirectRenderDraw draws the current image at index onto the RenderWin window, // typically using drw.Copy, drw.Scale, or drw.Fill. // flipY is the default setting for whether the Y axis needs to be flipped during drawing, // which is typically passed along to the Copy or Scale methods. DirectRenderDraw(drw system.Drawer, idx int, flipY bool) }
Widget is the interface for all Cogent Core widgets.
func NonNilContext ¶
NonNilContext returns a non-nil context widget, falling back on the top scene of the current window.
func WidgetLastChild ¶
WidgetLastChild returns the last child under given node, or node itself if no children. Starts with Children, not Parts
func WidgetLastChildParts ¶
WidgetLastChildParts returns the last child under given node, or node itself if no children. Starts with Parts,
func WidgetNext ¶
WidgetNext returns the next widget in the tree, including Parts, which are considered to come after Children. returns nil if no more.
func WidgetNextFunc ¶
WidgetNextFunc returns the next widget in the tree, including Parts, which are considered to come after children, continuing until the given function returns true. nil if no more.
func WidgetNextSibling ¶
WidgetNextSibling returns next sibling or nil if none, including Parts, which are considered to come after Children.
func WidgetPrev ¶
WidgetPrev returns the previous widget in the tree, including Parts, which are considered to come after Children. nil if no more.
type WidgetBase ¶
type WidgetBase struct { tree.NodeBase // Tooltip is the text for the tooltip for this widget, // which can use HTML formatting. Tooltip string // Parts are a separate tree of sub-widgets that implement discrete parts // of a widget. Positions are relative to the parent widget. // These are fully managed by the parent widget Parts *Layout `copier:"-" json:"-" xml:"-" set:"-"` // Geom has the full layout geometry for size and position of this Widget Geom GeomState `edit:"-" copier:"-" json:"-" xml:"-" set:"-"` // If true, Override the computed styles and allow directly editing Style OverrideStyle bool `copier:"-" json:"-" xml:"-" set:"-"` // Styles are styling settings for this widget. // These are set in SetApplyStyle which should be called after any Config // change (e.g., as done by the Update method). See Stylers for functions // that set all of the styles, ordered from initial base defaults to later // added overrides. Styles styles.Style `json:"-" xml:"-" set:"-"` // Stylers are a slice of functions that are called in sequential // ascending order (so the last added styler is called last and // thus overrides all other functions) to style the element. // These should be set using Style function. FirstStylers and // FinalStylers are called before and after these stylers, respectively. Stylers []func(s *styles.Style) `copier:"-" json:"-" xml:"-" set:"-" edit:"-"` // FirstStylers are a slice of functions that are called in sequential // ascending order (so the last added styler is called last and // thus overrides all other functions) to style the element. // These should be set using StyleFirst function. These stylers // are called before Stylers and FinalStylers. FirstStylers []func(s *styles.Style) `copier:"-" json:"-" xml:"-" set:"-"` // FinalStylers are a slice of functions that are called in sequential // ascending order (so the last added styler is called last and // thus overrides all other functions) to style the element. // These should be set using StyleFinal function. These stylers // are called after FirstStylers and Stylers. FinalStylers []func(s *styles.Style) `copier:"-" json:"-" xml:"-" set:"-"` // Listeners are event listener functions for processing events on this widget. // They are called in sequential descending order (so the last added listener // is called first). They should be added using the On function. FirstListeners // and FinalListeners are called before and after these listeners, respectively. Listeners events.Listeners `copier:"-" json:"-" xml:"-" set:"-"` // FirstListeners are event listener functions for processing events on this widget. // They are called in sequential descending order (so the last added listener // is called first). They should be added using the OnFirst function. These listeners // are called before Listeners and FinalListeners. FirstListeners events.Listeners `copier:"-" json:"-" xml:"-" set:"-"` // FinalListeners are event listener functions for processing events on this widget. // They are called in sequential descending order (so the last added listener // is called first). They should be added using the OnFinal function. These listeners // are called after FirstListeners and Listeners. FinalListeners events.Listeners `copier:"-" json:"-" xml:"-" set:"-"` // A slice of functions to call on all widgets that are added as children // to this widget or its children. These functions are called in sequential // ascending order, so the last added one is called last and thus can // override anything set by the other ones. These should be set using // OnWidgetAdded, which can be called by both end-user and internal code. OnWidgetAdders []func(w Widget) `copier:"-" json:"-" xml:"-" set:"-"` // ContextMenus is a slice of menu functions to call to construct // the widget's context menu on an [events.ContextMenu]. The // functions are called in reverse order such that the elements // added in the last function are the first in the menu. // Context menus should be added through [Widget.AddContextMenu]. // Separators will be added between each context menu function. ContextMenus []func(m *Scene) `copier:"-" json:"-" xml:"-" set:"-"` // Scene is the overall Scene to which we belong. It is automatically // by widgets whenever they are added to another widget parent. Scene *Scene `copier:"-" json:"-" xml:"-" set:"-"` }
WidgetBase is the base type for all Widget Widget elements, which are managed by a containing Layout, and use all 5 rendering passes. All elemental widgets must support the ReadOnly and Selected states in a reasonable way (Selected only essential when also ReadOnly), so they can function appropriately in a chooser (e.g., SliceView or TableView) -- this includes toggling selection on left mouse press.
func AsWidgetBase ¶
func AsWidgetBase(n tree.Node) *WidgetBase
AsWidgetBase returns the given tree node object as a WidgetBase, or nil, for direct use of the return value in cases where that is needed.
func (*WidgetBase) AbilityIs ¶
func (wb *WidgetBase) AbilityIs(able abilities.Abilities) bool
AbilityIs returns whether the widget has the given abilities.Abilities flag set
func (*WidgetBase) AddCloseDialog ¶
func (wb *WidgetBase) AddCloseDialog(config func(d *Body) bool) *WidgetBase
AddCloseDialog adds a dialog that confirms that the user wants to close the Scene associated with this widget when they try to close it. It calls the given config function to configure the dialog. It is the responsibility of this config function to add the title and close button to the dialog, which is necessary so that the close dialog can be fully customized. If this function returns false, it does not make the dialog. This can be used to make the dialog conditional on other things, like whether something is saved.
Example ¶
b := NewBody() b.AddCloseDialog(func(d *Body) bool { d.AddTitle("Are you sure?").AddText("Are you sure you want to close the Cogent Core Demo?") d.AddBottomBar(func(parent Widget) { d.AddOK(parent).SetText("Close").OnClick(func(e events.Event) { b.Scene.Close() }) }) return true }) b.RunMainWindow()
Output:
func (*WidgetBase) AddContextMenu ¶
func (wb *WidgetBase) AddContextMenu(menu func(m *Scene)) *WidgetBase
AddContextMenu adds the given context menu to [WidgetBase.ContextMenus]. It is the main way that code should modify a widget's context menus. Context menu functions are run in reverse order, and separators are automatically added between each context menu function.
func (*WidgetBase) ApplyContextMenus ¶
func (wb *WidgetBase) ApplyContextMenus(m *Scene)
ApplyContextMenus adds the [Widget.ContextMenus] to the given menu scene in reverse order. It also adds separators between each context menu function.
func (*WidgetBase) ApplyStyle ¶
func (wb *WidgetBase) ApplyStyle()
func (*WidgetBase) ApplyStyleParts ¶
func (wb *WidgetBase) ApplyStyleParts()
ApplyStyleParts styles the parts. Automatically called by the default ApplyStyleWidget function.
func (*WidgetBase) ApplyStyleSettings ¶
func (wb *WidgetBase) ApplyStyleSettings()
ApplyStyleSettings applies [AppearanceSettingsData.Spacing] and [AppearanceSettings.FontSize] to the style values for the widget.
func (*WidgetBase) ApplyStyleTree ¶
func (wb *WidgetBase) ApplyStyleTree()
ApplyStyleTree calls ApplyStyle on every Widget in the tree from me. Called during FullRender
func (*WidgetBase) ApplyStyleUpdate ¶
func (wb *WidgetBase) ApplyStyleUpdate()
ApplyStyleUpdate calls ApplyStyleTree and NeedsRender. This is the main call needed to ensure that state-sensitive styling is updated, when the state changes.
func (*WidgetBase) ApplyStyleWidget ¶
func (wb *WidgetBase) ApplyStyleWidget()
ApplyStyleWidget is the primary styling function for all Widgets. Handles inheritance and runs the Styler functions.
func (*WidgetBase) AsWidget ¶
func (wb *WidgetBase) AsWidget() *WidgetBase
func (*WidgetBase) AsyncLock ¶
func (wb *WidgetBase) AsyncLock()
AsyncLock must be called before making any updates in a separate goroutine outside of the main configuration, rendering, and event handling structure. It must have a matching WidgetBase.AsyncUnlock after it.
func (*WidgetBase) AsyncUnlock ¶
func (wb *WidgetBase) AsyncUnlock()
AsyncUnlock must be called after making any updates in a separate goroutine outside of the main configuration, rendering, and event handling structure. It must have a matching WidgetBase.AsyncLock before it.
func (*WidgetBase) BaseType ¶
func (wb *WidgetBase) BaseType() *types.Type
func (*WidgetBase) BoxSpace ¶
func (wb *WidgetBase) BoxSpace() styles.SideFloats
BoxSpace returns the style BoxSpace value under read lock
func (*WidgetBase) CanFocus ¶
func (wb *WidgetBase) CanFocus() bool
CanFocus checks if this node can receive keyboard focus
func (*WidgetBase) ChildBackground ¶
func (wb *WidgetBase) ChildBackground(child Widget) image.Image
ChildBackground returns the background color (Image) for given child Widget. By default, this is just our [Styles.Actualbackground] but it can be computed specifically for the child (e.g., for zebra stripes in views.SliceViewGrid)
func (*WidgetBase) Clipboard ¶
func (wb *WidgetBase) Clipboard() system.Clipboard
Clipboard returns the clipboard for the Widget to use.
func (*WidgetBase) Config ¶
func (wb *WidgetBase) Config()
Config is the interface method called by Config that should be defined for each Widget type, which actually does the configuration work.
func (*WidgetBase) ConfigParts ¶
func (wb *WidgetBase) ConfigParts(config tree.Config, after ...func())
ConfigParts initializes the parts of the widget if they are not already through WidgetBase.NewParts, calls tree.NodeBase.ConfigChildren on those parts with the given config, calls the given after function if it is specified, and then handles necessary updating logic.
func (*WidgetBase) ConfigTree ¶
func (wb *WidgetBase) ConfigTree()
ConfigTree calls Config on every Widget in the tree from me.
func (*WidgetBase) ContainsFocus ¶
func (wb *WidgetBase) ContainsFocus() bool
ContainsFocus returns true if this widget contains the current focus widget as maintained in the RenderWin
func (*WidgetBase) ContextMenuPos ¶
func (wb *WidgetBase) ContextMenuPos(e events.Event) image.Point
ContextMenuPos returns the default position for the context menu upper left corner. The event will be from a mouse ContextMenu event if non-nil: should handle both cases.
func (*WidgetBase) CopyFieldsFrom ¶
func (wb *WidgetBase) CopyFieldsFrom(from tree.Node)
func (*WidgetBase) DeleteParts ¶
func (wb *WidgetBase) DeleteParts()
func (*WidgetBase) Destroy ¶
func (wb *WidgetBase) Destroy()
func (*WidgetBase) DirectRenderDraw ¶
func (wb *WidgetBase) DirectRenderDraw(drw system.Drawer, idx int, flipY bool)
DirectRenderDraw draws the current image at index onto the RenderWin window, typically using drw.Copy, drw.Scale, or drw.Fill. flipY is the default setting for whether the Y axis needs to be flipped during drawing, which is typically passed along to the Copy or Scale methods.
func (*WidgetBase) DirectRenderImage ¶
func (wb *WidgetBase) DirectRenderImage(drw system.Drawer, idx int)
DirectRenderImage uploads image directly into given system.Drawer at given index Typically this is a drw.SetGoImage call with an image.RGBA, or drw.SetFrameImage with a [vgpu.FrameBuffer]
func (*WidgetBase) DoNeedsRender ¶
func (wb *WidgetBase) DoNeedsRender()
DoNeedsRender calls Render on tree from me for nodes with NeedsRender flags set
func (*WidgetBase) EventMgr ¶
func (wb *WidgetBase) EventMgr() *EventMgr
EventMgr returns the higher-level core event manager for this Widget's Scene.
func (*WidgetBase) FieldByName ¶
func (wb *WidgetBase) FieldByName(field string) (tree.Node, error)
FieldByName allows tree.Node.FindPath to go through parts.
func (*WidgetBase) FinalHandleEvent ¶
func (wb *WidgetBase) FinalHandleEvent(ev events.Event)
FinalHandleEvent sends the given event to the FinalListeners for that event type. Does NOT do any state updating.
func (*WidgetBase) FirstHandleEvent ¶
func (wb *WidgetBase) FirstHandleEvent(ev events.Event)
FirstHandleEvent sends the given event to the FirstListeners for that event type. Does NOT do any state updating.
func (*WidgetBase) FlagType ¶
func (wb *WidgetBase) FlagType() enums.BitFlagSetter
func (*WidgetBase) FocusClear ¶
func (wb *WidgetBase) FocusClear()
FocusClear resets focus to nil, but keeps the previous focus to pick up next time..
func (*WidgetBase) FocusNext ¶
func (wb *WidgetBase) FocusNext()
FocusNext moves the focus onto the next item
func (*WidgetBase) FocusPrev ¶
func (wb *WidgetBase) FocusPrev()
FocusPrev moves the focus onto the previous item
func (*WidgetBase) FocusableInMe ¶
func (wb *WidgetBase) FocusableInMe() Widget
FocusableInMe returns the first Focusable element within this widget
func (*WidgetBase) GrowToAlloc ¶
func (wb *WidgetBase) GrowToAlloc() bool
GrowToAlloc grows our Actual size up to current Alloc size for any dimension with a non-zero Grow factor. If Grow is < 1, then the size is increased in proportion, but any factor > 1 produces a full fill along that dimension. Returns true if this resulted in a change in our Total size.
func (*WidgetBase) GrowToAllocSize ¶
GrowToAllocSize returns the potential size that widget could grow, for any dimension with a non-zero Grow factor. If Grow is < 1, then the size is increased in proportion, but any factor > 1 produces a full fill along that dimension. Returns true if this resulted in a change.
func (*WidgetBase) HandleClickOnEnterSpace ¶
func (wb *WidgetBase) HandleClickOnEnterSpace()
HandleClickOnEnterSpace adds key event handler for Enter or Space to generate a Click action. This is not added by default, but is added in Button and Switch Widgets for example.
func (*WidgetBase) HandleEvent ¶
func (wb *WidgetBase) HandleEvent(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 (*WidgetBase) HandleEvents ¶
func (wb *WidgetBase) HandleEvents()
HandleEvents sets the default WidgetBase event handlers
func (*WidgetBase) HandleLongHoverTooltip ¶
func (wb *WidgetBase) HandleLongHoverTooltip()
HandleLongHoverTooltip listens for LongHover and LongPress events and pops up and deletes tooltips based on those. Most widgets should call this as part of their event handler methods.
func (*WidgetBase) HandleSelectToggle ¶
func (wb *WidgetBase) HandleSelectToggle()
HandleSelectToggle does basic selection handling logic on widget, as just a toggle on individual selection state, including ensuring consistent selection flagging for parts. This is not called by WidgetBase but should be called for simple Widget types. More complex container / View widgets likely implement their own more complex selection logic.
func (*WidgetBase) HandleWidgetClick ¶
func (wb *WidgetBase) HandleWidgetClick()
HandleWidgetClick handles the Click event for basic Widget behavior. For Left button: If Checkable, toggles Checked. if Focusable, Focuses or clears, If Selectable, updates state and sends Select, Deselect.
func (*WidgetBase) HandleWidgetContextMenu ¶
func (wb *WidgetBase) HandleWidgetContextMenu()
func (*WidgetBase) HandleWidgetMagnify ¶
func (wb *WidgetBase) HandleWidgetMagnify()
HandleWidgetMagnifyEvent calls RenderWindow.StepZoom on events.Magnify
func (*WidgetBase) HandleWidgetStateFromFocus ¶
func (wb *WidgetBase) HandleWidgetStateFromFocus()
HandleWidgetStateFromFocus updates standard State flags based on Focus events
func (*WidgetBase) HandleWidgetStateFromMouse ¶
func (wb *WidgetBase) HandleWidgetStateFromMouse()
HandleWidgetStateFromMouse updates all standard State flags based on mouse events, such as MouseDown / Up -> Active and MouseEnter / Leave -> Hovered. None of these "consume" the event by setting Handled flag, as they are designed to work in conjunction with more specific handlers. Note that Disabled and Invisible widgets do NOT receive these events so it is not necessary to check that.
func (*WidgetBase) HasFlagWithin ¶
func (wb *WidgetBase) HasFlagWithin(flag enums.BitFlag) bool
HasFlagWithin returns whether the current node or any of its children have the given flag.
func (*WidgetBase) HasSc ¶
func (wb *WidgetBase) HasSc() bool
HasSc checks that the Sc Scene has been set. Called prior to using -- logs an error if not.
func (*WidgetBase) HasStateWithin ¶
func (wb *WidgetBase) HasStateWithin(state states.States) bool
HasStateWithin returns whether the current node or any of its children have the given state flag.
func (*WidgetBase) IsDisabled ¶
func (wb *WidgetBase) IsDisabled() bool
IsDisabled tests if this node is flagged as [Disabled]. If so, behave and style appropriately.
func (*WidgetBase) IsFirstChild ¶
func (wb *WidgetBase) IsFirstChild() bool
IsFirstChild returns whether the node is the first child of its parent
func (*WidgetBase) IsLastChild ¶
func (wb *WidgetBase) IsLastChild() bool
IsLastChild returns whether the node is the last child of its parent
func (*WidgetBase) IsNthChild ¶
func (wb *WidgetBase) IsNthChild(n int) bool
IsNthChild returns whether the node is nth-child of its parent
func (*WidgetBase) IsOnlyChild ¶
func (wb *WidgetBase) IsOnlyChild() bool
IsOnlyChild returns whether the node is the only child of its parent
func (*WidgetBase) IsReadOnly ¶
func (wb *WidgetBase) IsReadOnly() bool
IsReadOnly tests if this node is flagged as [ReadOnly] or [Disabled]. If so, behave appropriately. Styling is based on each state separately, but behaviors are often the same for both of these states.
func (*WidgetBase) IsVisible ¶
func (wb *WidgetBase) IsVisible() bool
IsVisible returns true if a node is visible for rendering according to the states.Invisible flag on it or any of its parents. This flag is also set by styles.DisplayNone during [ApplyStyle]. This does *not* check for an empty TotalBBox, indicating that the widget is out of render range -- that is done by [PushBounds] prior to rendering. Non-visible nodes are automatically not rendered and do not get window events. This call recursively calls the parent, which is typically a short path.
func (*WidgetBase) NeedsLayout ¶
func (wb *WidgetBase) NeedsLayout()
NeedsLayout specifies that the widget's scene needs to do a layout. This needs to be called after any changes that affect the structure and/or size of elements.
func (*WidgetBase) NeedsRebuild ¶
func (wb *WidgetBase) NeedsRebuild() bool
NeedsRebuild returns true if the RenderContext indicates a full rebuild is needed.
func (*WidgetBase) NeedsRender ¶
func (wb *WidgetBase) NeedsRender()
NeedsRender specifies that the widget needs to be rendered.
func (*WidgetBase) NewParts ¶
func (wb *WidgetBase) NewParts() *Layout
NewParts makes the Parts layout if not already there.
func (*WidgetBase) NodeType ¶
func (t *WidgetBase) NodeType() *types.Type
NodeType returns the *types.Type of WidgetBase
func (*WidgetBase) NodeWalkDown ¶
func (wb *WidgetBase) NodeWalkDown(fun func(tree.Node) bool)
NodeWalkDown extends WalkPre to Parts, which is key for getting full Update protection.
func (*WidgetBase) On ¶
func (wb *WidgetBase) On(etype events.Types, fun func(e events.Event)) *WidgetBase
On adds the given event handler to the widget's Listeners for the given event type. Listeners are called in sequential descending order, so this listener will be called before all of the ones added before it. On is one of the main ways for both end-user and internal code to add an event handler to a widget, in addition to OnFirst and OnFinal, which add event handlers that are called before and after those added by this function, respectively.
func (*WidgetBase) OnAdd ¶
func (wb *WidgetBase) OnAdd()
OnAdd is called when widgets are added to a parent. It sets the scene of the widget to its widget parent. It should be called by all other OnAdd functions defined by widget types.
func (*WidgetBase) OnChange ¶
func (wb *WidgetBase) OnChange(fun func(e events.Event)) *WidgetBase
OnChange adds an event listener function for events.Change events
func (*WidgetBase) OnChildAdded ¶
func (wb *WidgetBase) OnChildAdded(child tree.Node)
func (*WidgetBase) OnClick ¶
func (wb *WidgetBase) OnClick(fun func(e events.Event)) *WidgetBase
OnClick adds an event listener function for events.Click events
func (*WidgetBase) OnClose ¶
func (wb *WidgetBase) OnClose(fun func(e events.Event)) *WidgetBase
OnClose adds an event listener function for events.Close events on the widget's Scene. Directly listening to Close events for non-scene widgets does not work, so it must go through the Scene.
func (*WidgetBase) OnDoubleClick ¶
func (wb *WidgetBase) OnDoubleClick(fun func(e events.Event)) *WidgetBase
OnDoubleClick adds an event listener function for events.DoubleClick events
func (*WidgetBase) OnFinal ¶
OnFinal adds the given event handler to the widget's FinalListeners for the given event type. FinalListeners are called in sequential descending order, so this final listener will be called before all of the ones added before it. OnFinal is one of the main ways for both end-user and internal code to add an event handler to a widget, in addition to OnFirst and On, which add event handlers that are called before those added by this function.
func (*WidgetBase) OnFirst ¶
OnFirst adds the given event handler to the widget's FirstListeners for the given event type. FirstListeners are called in sequential descending order, so this first listener will be called before all of the ones added before it. OnFirst is one of the main ways for both end-user and internal code to add an event handler to a widget, in addition to On and OnFinal, which add event handlers that are called after those added by this function.
func (*WidgetBase) OnFocus ¶
func (wb *WidgetBase) OnFocus(fun func(e events.Event)) *WidgetBase
OnFocus adds an event listener function for events.Focus events
func (*WidgetBase) OnFocusLost ¶
func (wb *WidgetBase) OnFocusLost(fun func(e events.Event)) *WidgetBase
OnFocusLost adds an event listener function for events.FocusLost events
func (*WidgetBase) OnInit ¶
func (wb *WidgetBase) OnInit()
OnInit should be called by every Widget type in its custom OnInit if it has one to establish all the default styling and event handling that applies to all widgets.
func (*WidgetBase) OnInput ¶
func (wb *WidgetBase) OnInput(fun func(e events.Event)) *WidgetBase
OnInput adds an event listener function for events.Input events
func (*WidgetBase) OnKeyChord ¶
func (wb *WidgetBase) OnKeyChord(fun func(e events.Event)) *WidgetBase
OnKeyChord adds an event listener function for events.KeyChord events
func (*WidgetBase) OnSelect ¶
func (wb *WidgetBase) OnSelect(fun func(e events.Event)) *WidgetBase
OnSelect adds an event listener function for events.Select events
func (*WidgetBase) OnShow ¶
func (wb *WidgetBase) OnShow(fun func(e events.Event)) *WidgetBase
OnShow adds an event listener function for events.Show events on the widget's Scene. Directly listening to Show events for non-scene widgets does not work, so it must go through the Scene. This must typically be called in OnAdd() or later, and definitely NOT in OnInit, because only then will the Scene be set.
func (*WidgetBase) OnWidgetAdded ¶
func (wb *WidgetBase) OnWidgetAdded(fun func(w Widget)) *WidgetBase
OnWidgetAdded adds a function to call when a widget is added as a child to the widget or any of its children.
func (*WidgetBase) ParentActualBackground ¶
func (wb *WidgetBase) ParentActualBackground() image.Image
ParentActualBackground returns the actual background of the parent of the widget. If it has no parent, it returns nil.
func (*WidgetBase) ParentLayout ¶
func (wb *WidgetBase) ParentLayout() *Layout
ParentLayout returns the parent layout
func (*WidgetBase) ParentScrollLayout ¶
func (wb *WidgetBase) ParentScrollLayout() *Layout
ParentScrollLayout returns the parent layout that has active scrollbars
func (*WidgetBase) ParentWidget ¶
func (wb *WidgetBase) ParentWidget() *WidgetBase
ParentWidget returns the parent as a WidgetBase or nil if this is the root and has no parent.
func (*WidgetBase) ParentWidgetIf ¶
func (wb *WidgetBase) ParentWidgetIf(fun func(p *WidgetBase) bool) *WidgetBase
ParentWidgetIf returns the nearest widget parent of the widget for which the given function returns true. It returns nil if no such parent is found.
func (*WidgetBase) PointToRelPos ¶
func (wb *WidgetBase) PointToRelPos(pt image.Point) image.Point
PointToRelPos translates a point in Scene pixel coords into relative position within node, based on the Content BBox
func (*WidgetBase) PopBounds ¶
func (wb *WidgetBase) PopBounds()
PopBounds pops our bounding box bounds. This is the last step in Render implementations after rendering children.
func (*WidgetBase) PosInScBBox ¶
func (wb *WidgetBase) PosInScBBox(pos image.Point) bool
PosInScBBox returns true if given position is within this node's scene bbox
func (*WidgetBase) Position ¶
func (wb *WidgetBase) Position()
Position uses the final sizes to set relative positions within layouts according to alignment settings.
func (*WidgetBase) PositionChildren ¶
func (wb *WidgetBase) PositionChildren()
PositionChildren runs Position on the children
func (*WidgetBase) PositionParts ¶
func (wb *WidgetBase) PositionParts()
func (*WidgetBase) PositionWidget ¶
func (wb *WidgetBase) PositionWidget()
func (*WidgetBase) PositionWithinAllocMainX ¶
func (wb *WidgetBase) PositionWithinAllocMainX(pos math32.Vector2, parJustify, parAlign styles.Aligns)
func (*WidgetBase) PositionWithinAllocMainY ¶
func (wb *WidgetBase) PositionWithinAllocMainY(pos math32.Vector2, parJustify, parAlign styles.Aligns)
func (*WidgetBase) PushBounds ¶
func (wb *WidgetBase) PushBounds() bool
PushBounds pushes our bounding box bounds onto the bounds stack if they are non-empty. This automatically limits our drawing to our own bounding box. This must be called as the first step in Render implementations. It returns whether the new bounds are empty or not; if they are empty, then don't render.
func (*WidgetBase) Render ¶
func (wb *WidgetBase) Render()
Render is the method that widgets should implement to define their custom rendering steps. It should not be called outside of [Widget.RenderWidget], which also does other steps applicable for all widgets.
func (*WidgetBase) RenderBoxImpl ¶
RenderBoxImpl implements the standard box model rendering -- assumes all paint params have already been set
func (*WidgetBase) RenderChildren ¶
func (wb *WidgetBase) RenderChildren()
RenderChildren renders all of the widget's children.
func (*WidgetBase) RenderParts ¶
func (wb *WidgetBase) RenderParts()
func (*WidgetBase) RenderStandardBox ¶
func (wb *WidgetBase) RenderStandardBox()
RenderStandardBox renders the standard box model.
func (*WidgetBase) RenderWidget ¶
func (wb *WidgetBase) RenderWidget()
RenderWidget renders the widget and any parts and children that it has. It does not render if the widget is invisible. It calls Widget.Render] for widget-specific rendering.
func (*WidgetBase) ResetStyleSettings ¶
func (wb *WidgetBase) ResetStyleSettings()
ResetStyleSettings reverses the effects of [ApplyStyleSettings] for the widget's font size so that it does not create cascading inhereted font size values. It only does this for non-root elements, as the root element must receive the larger font size so that all other widgets inherit it. It must be called before WidgetBase.RunStylers and WidgetBase.ApplyStyleSettings.
func (*WidgetBase) ResetStyleWidget ¶
func (wb *WidgetBase) ResetStyleWidget()
ResetStyleWidget resets the widget styles and applies the basic default styles specified in styles.Style.Defaults. It is called automatically in [ApplyStyleWidget] and should not need to be called by end-user code.
func (*WidgetBase) RunStylers ¶
func (wb *WidgetBase) RunStylers()
RunStylers runs the stylers specified in the widget's FirstStylers, Stylers, and FinalStylers in that order in a sequential ascending order.
func (*WidgetBase) ScenePos ¶
func (wb *WidgetBase) ScenePos()
ScenePos computes scene-based absolute positions and final BBox bounding boxes for rendering, based on relative positions from Position step and parents accumulated position and scroll offset. This is the only step needed when scrolling (very fast).
func (*WidgetBase) ScenePosChildren ¶
func (wb *WidgetBase) ScenePosChildren()
ScenePosChildren runs ScenePos on the children
func (*WidgetBase) ScenePosParts ¶
func (wb *WidgetBase) ScenePosParts()
func (*WidgetBase) ScenePosWidget ¶
func (wb *WidgetBase) ScenePosWidget()
func (*WidgetBase) ScrollToMe ¶
func (wb *WidgetBase) ScrollToMe() bool
ScrollToMe tells my parent layout (that has scroll bars) to scroll to keep this widget in view -- returns true if scrolled
func (*WidgetBase) Send ¶
func (wb *WidgetBase) 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 (*WidgetBase) SendChange ¶
func (wb *WidgetBase) SendChange(orig ...events.Event)
SendChange sends the events.Change event, which is widely used to signal updating for most widgets. It takes the event that the new change event is derived from, if any.
func (*WidgetBase) SendKey ¶
func (wb *WidgetBase) SendKey(kf keymap.Functions, orig ...events.Event)
func (*WidgetBase) SendKeyChord ¶
func (wb *WidgetBase) SendKeyChord(kc key.Chord, orig ...events.Event)
func (*WidgetBase) SendKeyChordRune ¶
func (*WidgetBase) SetAbilities ¶
func (wb *WidgetBase) SetAbilities(on bool, able ...abilities.Abilities) *WidgetBase
SetAbilities sets the given abilities.Abilities flags to the given value
func (*WidgetBase) SetBBoxes ¶
func (wb *WidgetBase) SetBBoxes()
func (*WidgetBase) SetBBoxesFromAllocs ¶
func (wb *WidgetBase) SetBBoxesFromAllocs()
SetBBoxesFromAllocs sets BBox and ContentBBox from Geom.Pos and .Size This does NOT intersect with parent content BBox, which is done in SetBBoxes. Use this for elements that are dynamically positioned outside of parent BBox.
func (*WidgetBase) SetContentPosFromPos ¶
func (wb *WidgetBase) SetContentPosFromPos()
SetContentPosFromPos sets the Pos.Content position based on current Pos plus the BoxSpace position offset.
func (*WidgetBase) SetEnabled ¶
func (wb *WidgetBase) SetEnabled(enabled bool) *WidgetBase
SetEnabled sets the Disabled flag
func (*WidgetBase) SetFocus ¶
func (wb *WidgetBase) SetFocus()
SetFocus sets the keyboard input focus on this item or the first item within it that can be focused (if none, then goes ahead and sets focus to this object). This does NOT send an events.Focus event, which typically results in the widget being styled as focused. See [SetFocusEvent] for one that does.
func (*WidgetBase) SetFocusEvent ¶
func (wb *WidgetBase) SetFocusEvent()
SetFocusEvent sets the keyboard input focus on this item or the first item within it that can be focused (if none, then goes ahead and sets focus to this object). This sends an events.Focus event, which typically results in the widget being styled as focused. See [SetFocus] for one that does not.
func (*WidgetBase) SetPosFromParent ¶
func (wb *WidgetBase) SetPosFromParent()
func (*WidgetBase) SetReadOnly ¶
func (wb *WidgetBase) SetReadOnly(ro bool) *WidgetBase
SetReadOnly sets the ReadOnly state flag to given value
func (*WidgetBase) SetScene ¶
func (wb *WidgetBase) SetScene(sc *Scene)
SetScene sets the Scene pointer for this widget and all of its children. This can be necessary when creating widgets outside the usual "NewWidget" paradigm, e.g., when reading from a JSON file.
func (*WidgetBase) SetSelected ¶
func (wb *WidgetBase) SetSelected(sel bool)
SetSelected sets the Selected flag to given value for the entire Widget and calls ApplyStyleTree to apply any style changes.
func (*WidgetBase) SetState ¶
func (wb *WidgetBase) SetState(on bool, state ...states.States) *WidgetBase
SetState sets the given states.State flags to the given value
func (*WidgetBase) SetStyles ¶
func (wb *WidgetBase) SetStyles()
SetStyles sets the base, widget-universal default style function that applies to all widgets. It is added and called first in the styling order. Because it handles default styling in response to State flags such as Disabled and Selected, these state flags must be set prior to calling this. Use [StyleFirst] to add a function that is called prior to this, to update state flags.
func (*WidgetBase) SetTooltip ¶
func (t *WidgetBase) SetTooltip(v string) *WidgetBase
SetTooltip sets the [WidgetBase.Tooltip]: Tooltip is the text for the tooltip for this widget, which can use HTML formatting.
func (*WidgetBase) ShowContextMenu ¶
func (wb *WidgetBase) ShowContextMenu(e events.Event)
func (*WidgetBase) SizeClass ¶
func (wb *WidgetBase) SizeClass() SizeClasses
SizeClass returns the size class of the scene in which it is contained.
func (*WidgetBase) SizeDown ¶
func (wb *WidgetBase) SizeDown(iter int) bool
SizeDown (top-down, multiple iterations possible) provides top-down size allocations based initially on Scene available size and the SizeUp Actual sizes. If there is extra space available, it is allocated according to the Grow factors. Flexible elements (e.g., Flex Wrap layouts and Label with word wrap) update their Actual size based on available Alloc size (re-wrap), to fit the allocated shape vs. the initial bottom-up guess. However, do NOT grow the Actual size to match Alloc at this stage, as Actual sizes must always represent the minimums (see Position). Returns true if any change in Actual size occurred.
func (*WidgetBase) SizeDownChildren ¶
func (wb *WidgetBase) SizeDownChildren(iter int) bool
SizeDownChildren calls SizeDown on the Children. The kids must have their Size.Alloc set prior to this, which is what Layout type does. Other special widget types can do custom layout and call this too.
func (*WidgetBase) SizeDownParts ¶
func (wb *WidgetBase) SizeDownParts(iter int) bool
func (*WidgetBase) SizeDownWidget ¶
func (wb *WidgetBase) SizeDownWidget(iter int) bool
SizeDownWidget is the standard widget implementation of SizeDown. It just delegates to the Parts.
func (*WidgetBase) SizeFinal ¶
func (wb *WidgetBase) SizeFinal()
SizeFinal: (bottom-up) similar to SizeUp but done at the end of the Sizing phase: first grows widget Actual sizes based on their Grow factors, up to their Alloc sizes. Then gathers this updated final actual Size information for layouts to register their actual sizes prior to positioning, which requires accurate Actual vs. Alloc sizes to perform correct alignment calculations.
func (*WidgetBase) SizeFinalChildren ¶
func (wb *WidgetBase) SizeFinalChildren()
SizeFinalChildren calls SizeFinal on all the children of this node
func (*WidgetBase) SizeFinalParts ¶
func (wb *WidgetBase) SizeFinalParts()
SizeFinalParts adjusts the Content size to hold the Parts Final sizes
func (*WidgetBase) SizeFinalWidget ¶
func (wb *WidgetBase) SizeFinalWidget()
SizeFinalWidget is the standard Widget SizeFinal pass
func (*WidgetBase) SizeFromStyle ¶
func (wb *WidgetBase) SizeFromStyle()
SizeFromStyle sets the initial Actual Sizes from Style.Min, Max. Required first call in SizeUp.
func (*WidgetBase) SizeUp ¶
func (wb *WidgetBase) SizeUp()
SizeUp (bottom-up) gathers Actual sizes from our Children & Parts, based on Styles.Min / Max sizes and actual content sizing (e.g., text size). Flexible elements (e.g., Label, Flex Wrap, TopAppBar) should reserve the _minimum_ size possible at this stage, and then Grow based on SizeDown allocation.
func (*WidgetBase) SizeUpChildren ¶
func (wb *WidgetBase) SizeUpChildren()
SizeUpChildren calls SizeUp on all the children of this node
func (*WidgetBase) SizeUpParts ¶
func (wb *WidgetBase) SizeUpParts()
SizeUpParts adjusts the Content size to hold the Parts layout if present
func (*WidgetBase) SizeUpWidget ¶
func (wb *WidgetBase) SizeUpWidget()
SizeUpWidget is the standard Widget SizeUp pass
func (*WidgetBase) SpaceFromStyle ¶
func (wb *WidgetBase) SpaceFromStyle()
SpaceFromStyle sets the Space based on Style BoxSpace().Size()
func (*WidgetBase) StartFocus ¶
func (wb *WidgetBase) StartFocus()
StartFocus specifies this widget to give focus to when the window opens
func (*WidgetBase) StateIs ¶
func (wb *WidgetBase) StateIs(state states.States) bool
StateIs returns whether the widget has the given states.States flag set
func (*WidgetBase) Style ¶
func (wb *WidgetBase) Style(s func(s *styles.Style)) *WidgetBase
Style adds the given styler to the widget's Stylers. It is one of the main ways for both end-user and internal code to set the styles of a widget, in addition to StyleFirst and StyleFinal, which add stylers that are called before and after the stylers added by this function, respectively.
func (*WidgetBase) StyleFinal ¶
func (wb *WidgetBase) StyleFinal(s func(s *styles.Style)) *WidgetBase
StyleFinal adds the given styler to the widget's FinalStylers. It is one of the main ways for both end-user and internal code to set the styles of a widget, in addition to StyleFirst and Style, which add stylers that are called before the stylers added by this function.
func (*WidgetBase) StyleFirst ¶
func (wb *WidgetBase) StyleFirst(s func(s *styles.Style)) *WidgetBase
StyleFirst adds the given styler to the widget's FirstStylers. It is one of the main ways for both end-user and internal code to set the styles of a widget, in addition to Style and StyleFinal, which add stylers that are called after the stylers added by this function.
func (*WidgetBase) StyleSizeUpdate ¶
func (wb *WidgetBase) StyleSizeUpdate() bool
StyleSizeUpdate updates styling size values for widget and its parent, which should be called after these are updated. Returns true if any changed.
func (*WidgetBase) SystemEventMgr ¶
func (wb *WidgetBase) SystemEventMgr() *events.Mgr
SystemEventMgr returns the lower-level system event manager for this Widget's Scene.
func (*WidgetBase) Update ¶
func (wb *WidgetBase) Update()
Update does a general purpose update of the widget and everything below it by reconfiguring it, applying its styles, and indicating that it needs a new layout pass. It is the main way that end users should update widgets, and it should be called after making any changes to the core properties of a widget (for example, the text of a label, the icon of a button, or the slice of a table view).
If you are calling this in a separate goroutine outside of the main configuration, rendering, and event handling structure, you need to call WidgetBase.AsyncLock and WidgetBase.AsyncUnlock before and after this, respectively.
func (*WidgetBase) VisibleKidsIter ¶
func (wb *WidgetBase) VisibleKidsIter(fun func(i int, kwi Widget, kwb *WidgetBase) bool)
VisibleKidsIter iterates through the Kids, as widgets, calling the given function, excluding any with the *local* states.Invisible flag set (does not check parents). This is used e.g., for layout functions to exclude non-visible direct children. Return tree.Continue (true) to continue, and tree.Break (false) to terminate.
func (*WidgetBase) WidgetKidsIter ¶
func (wb *WidgetBase) WidgetKidsIter(fun func(i int, kwi Widget, kwb *WidgetBase) bool)
WidgetKidsIter iterates through the Kids, as widgets, calling the given function. Return tree.Continue (true) to continue, and tree.Break (false) to terminate.
func (*WidgetBase) WidgetTooltip ¶
func (wb *WidgetBase) WidgetTooltip() string
WidgetTooltip is the base implementation of [Widget.WidgetTooltip], which just returns [WidgetBase.Tooltip].
func (*WidgetBase) WidgetWalkPre ¶
func (wb *WidgetBase) WidgetWalkPre(fun func(kwi Widget, kwb *WidgetBase) bool)
WidgetWalkPre is a version of the ki WalkPre iterator that automatically filters nil or deleted items and operates on Widget types. Return tree.Continue (true) to continue, and tree.Break (false) to terminate.
func (*WidgetBase) WinBBox ¶
func (wb *WidgetBase) WinBBox() image.Rectangle
WinBBox returns the RenderWin based bounding box for the widget by adding the Scene position to the ScBBox
type WidgetFlags ¶
WidgetFlags define Widget node bitflags for tracking common high-frequency GUI state, mostly having to do with event processing. Extends tree.Flags.
const ( // NeedsRender needs to be rendered on next render iteration NeedsRender WidgetFlags = WidgetFlags(tree.FlagsN) + iota )
const WidgetFlagsN WidgetFlags = 2
WidgetFlagsN is the highest valid value for type WidgetFlags, plus one.
func WidgetFlagsValues ¶
func WidgetFlagsValues() []WidgetFlags
WidgetFlagsValues returns all possible values for the type WidgetFlags.
func (WidgetFlags) BitIndexString ¶
func (i WidgetFlags) BitIndexString() string
BitIndexString returns the string representation of this WidgetFlags value if it is a bit index value (typically an enum constant), and not an actual bit flag value.
func (WidgetFlags) Desc ¶
func (i WidgetFlags) Desc() string
Desc returns the description of the WidgetFlags value.
func (WidgetFlags) HasFlag ¶
func (i WidgetFlags) HasFlag(f enums.BitFlag) bool
HasFlag returns whether these bit flags have the given bit flag set.
func (WidgetFlags) Int64 ¶
func (i WidgetFlags) Int64() int64
Int64 returns the WidgetFlags value as an int64.
func (WidgetFlags) MarshalText ¶
func (i WidgetFlags) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*WidgetFlags) SetFlag ¶
func (i *WidgetFlags) SetFlag(on bool, f ...enums.BitFlag)
SetFlag sets the value of the given flags in these flags to the given value.
func (*WidgetFlags) SetInt64 ¶
func (i *WidgetFlags) SetInt64(in int64)
SetInt64 sets the WidgetFlags value from an int64.
func (*WidgetFlags) SetString ¶
func (i *WidgetFlags) SetString(s string) error
SetString sets the WidgetFlags value from its string representation, and returns an error if the string is invalid.
func (*WidgetFlags) SetStringOr ¶
func (i *WidgetFlags) SetStringOr(s string) error
SetStringOr sets the WidgetFlags value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.
func (WidgetFlags) String ¶
func (i WidgetFlags) String() string
String returns the string representation of this WidgetFlags value.
func (*WidgetFlags) UnmarshalText ¶
func (i *WidgetFlags) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (WidgetFlags) Values ¶
func (i WidgetFlags) Values() []enums.Enum
Values returns all possible values for the type WidgetFlags.
type WindowFlags ¶
type WindowFlags int64 //enums:bitflag -trim-prefix Window
WindowFlags represent RenderWindow state
const ( // WindowHasSavedGeom indicates if this window has WindowGeometry setting that // sized it -- affects whether other default geom should be applied. WindowHasSavedGeom WindowFlags = iota // WindowClosing is atomic flag indicating window is closing WindowClosing // WindowResizing is atomic flag indicating window is resizing WindowResizing // WindowGotFocus indicates that have we received RenderWin focus WindowGotFocus // WindowSentShow have we sent the show event yet? Only ever sent ONCE WindowSentShow // WindowStopEventLoop is set when event loop stop is requested WindowStopEventLoop // WindowSelectionMode indicates that the window is in Cogent Core inspect editor edit mode WindowSelectionMode )
const WindowFlagsN WindowFlags = 7
WindowFlagsN is the highest valid value for type WindowFlags, plus one.
func WindowFlagsValues ¶
func WindowFlagsValues() []WindowFlags
WindowFlagsValues returns all possible values for the type WindowFlags.
func (WindowFlags) BitIndexString ¶
func (i WindowFlags) BitIndexString() string
BitIndexString returns the string representation of this WindowFlags value if it is a bit index value (typically an enum constant), and not an actual bit flag value.
func (WindowFlags) Desc ¶
func (i WindowFlags) Desc() string
Desc returns the description of the WindowFlags value.
func (WindowFlags) HasFlag ¶
func (i WindowFlags) HasFlag(f enums.BitFlag) bool
HasFlag returns whether these bit flags have the given bit flag set.
func (WindowFlags) Int64 ¶
func (i WindowFlags) Int64() int64
Int64 returns the WindowFlags value as an int64.
func (WindowFlags) MarshalText ¶
func (i WindowFlags) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*WindowFlags) SetFlag ¶
func (i *WindowFlags) SetFlag(on bool, f ...enums.BitFlag)
SetFlag sets the value of the given flags in these flags to the given value.
func (*WindowFlags) SetInt64 ¶
func (i *WindowFlags) SetInt64(in int64)
SetInt64 sets the WindowFlags value from an int64.
func (*WindowFlags) SetString ¶
func (i *WindowFlags) SetString(s string) error
SetString sets the WindowFlags value from its string representation, and returns an error if the string is invalid.
func (*WindowFlags) SetStringOr ¶
func (i *WindowFlags) SetStringOr(s string) error
SetStringOr sets the WindowFlags value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.
func (WindowFlags) String ¶
func (i WindowFlags) String() string
String returns the string representation of this WindowFlags value.
func (*WindowFlags) UnmarshalText ¶
func (i *WindowFlags) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (WindowFlags) Values ¶
func (i WindowFlags) Values() []enums.Enum
Values returns all possible values for the type WindowFlags.
type WindowGeometries ¶
type WindowGeometries map[string]map[string]WindowGeometry
WindowGeometries is the data structure for recording the window geometries by window name and screen name.
type WindowGeometry ¶
WindowGeometry records the geometry settings used for a given window
func (*WindowGeometry) ConstrainGeom ¶
func (wg *WindowGeometry) ConstrainGeom(sc *system.Screen)
ConstrainGeom constrains geometry based on screen params
func (*WindowGeometry) Pos ¶
func (wg *WindowGeometry) Pos() image.Point
func (*WindowGeometry) SetPos ¶
func (wg *WindowGeometry) SetPos(ps image.Point)
func (*WindowGeometry) SetSize ¶
func (wg *WindowGeometry) SetSize(sz image.Point)
func (*WindowGeometry) Size ¶
func (wg *WindowGeometry) Size() image.Point
type WindowGeometrySaver ¶
type WindowGeometrySaver struct { // the full set of window geometries Geometries WindowGeometries // temporary cached geometries -- saved to Geometries after SaveDelay Cache WindowGeometries // base name of the settings file in Cogent Core settings directory Filename string // when settings were last saved -- if we weren't the last to save, then we need to re-open before modifying LastSave time.Time // if true, we are setting geometry so don't save -- caller must call SettingStart() SettingEnd() to block SettingNoSave bool // read-write mutex that protects updating of WindowGeometry Mu sync.RWMutex // wait time before trying to lock file again LockSleep time.Duration // wait time before saving the Cache into Geometries SaveDelay time.Duration // contains filtered or unexported fields }
WindowGeometrySaver records window geometries in a persistent file, which is then used when opening new windows to restore.
func (*WindowGeometrySaver) AbortSave ¶
func (mgr *WindowGeometrySaver) AbortSave()
AbortSave cancels any pending saving of the currently-cached info. this is called if a screen event occured
func (*WindowGeometrySaver) DeleteAll ¶
func (mgr *WindowGeometrySaver) DeleteAll()
DeleteAll deletes the file that saves the position and size of each window, by screen, and clear current in-memory cache. You shouldn't need to use this but sometimes useful for testing.
func (*WindowGeometrySaver) Init ¶
func (mgr *WindowGeometrySaver) Init()
Init does initialization if not yet initialized
func (*WindowGeometrySaver) LockFile ¶
func (mgr *WindowGeometrySaver) LockFile() error
LockFile attempts to create the window geometry lock file
func (*WindowGeometrySaver) NeedToReload ¶
func (mgr *WindowGeometrySaver) NeedToReload() bool
NeedToReload returns true if the last save time of settings file is more recent than when we last saved. Called under mutex.
func (*WindowGeometrySaver) Open ¶
func (mgr *WindowGeometrySaver) Open() error
Open RenderWin Geom settings from Cogent Core standard settings directory called under mutex or at start
func (*WindowGeometrySaver) Pref ¶
func (mgr *WindowGeometrySaver) Pref(winName string, scrn *system.Screen) *WindowGeometry
Pref returns an existing preference for given window name, for given screen. if the window name has a colon, only the part prior to the colon is used. if no saved pref is available for that screen, nil is returned.
func (*WindowGeometrySaver) RecordPref ¶
func (mgr *WindowGeometrySaver) RecordPref(win *RenderWindow)
RecordPref records current state of window as preference
func (*WindowGeometrySaver) ResetCache ¶
func (mgr *WindowGeometrySaver) ResetCache()
ResetCache resets the cache -- call under mutex
func (*WindowGeometrySaver) RestoreAll ¶
func (mgr *WindowGeometrySaver) RestoreAll()
RestoreAll restores size and position of all windows, for current screen. Called when screen changes.
func (*WindowGeometrySaver) Save ¶
func (mgr *WindowGeometrySaver) Save() error
Save RenderWin Geom Settings to Cogent Core standard prefs directory assumed to be under mutex and lock still
func (*WindowGeometrySaver) SaveCached ¶
func (mgr *WindowGeometrySaver) SaveCached()
SaveCached saves the cached prefs -- called after timer delay, under the Mu.Lock
func (*WindowGeometrySaver) SaveLastSave ¶
func (mgr *WindowGeometrySaver) SaveLastSave()
SaveLastSave saves timestamp (now) of last save to win geom
func (*WindowGeometrySaver) SettingEnd ¶
func (mgr *WindowGeometrySaver) SettingEnd()
SettingEnd turns off SettingNoSave -- safe to call even if Start not called.
func (*WindowGeometrySaver) SettingStart ¶
func (mgr *WindowGeometrySaver) SettingStart()
SettingStart turns on SettingNoSave to prevent subsequent redundant calls to save a geometry that was being set from already-saved settings. Must call SettingEnd to turn off (safe to call even if Start not called).
func (*WindowGeometrySaver) UnlockFile ¶
func (mgr *WindowGeometrySaver) UnlockFile()
UnLockFile unlocks the window geometry lock file (just removes it)
func (*WindowGeometrySaver) WinName ¶
func (mgr *WindowGeometrySaver) WinName(winName string) string
WinName returns window name before first colon, if exists. This is the part of the name used to record settings
Source Files ¶
- app.go
- bars.go
- blinker.go
- body.go
- box.go
- button.go
- canvas.go
- chooser.go
- completer.go
- dialogs.go
- enumgen.go
- eventmgr.go
- events.go
- flags.go
- frame.go
- handle.go
- icon.go
- image.go
- init.go
- interfaces.go
- label.go
- layimpl.go
- layout.go
- mainstage.go
- menu.go
- meter.go
- names.go
- popupstage.go
- recover.go
- render.go
- renderwindow.go
- scene.go
- scroll.go
- separator.go
- settings.go
- sizeclasses.go
- slider.go
- snackbar.go
- spinner.go
- splits.go
- sprite.go
- stage.go
- stagemgr.go
- strings.go
- style.go
- svg.go
- switch.go
- switches.go
- tabs.go
- testing.go
- textfield.go
- themes.go
- toolbar.go
- tooltip.go
- typegen.go
- views.go
- widget.go
- windowgeometry.go
- windowlists.go