gi

package
v0.0.0-...-5f41422 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2018 License: BSD-3-Clause Imports: 45 Imported by: 0

README

gi

GoGi is part of the GoKi Go language (golang) full strength tree structure system (ki = tree in Japanese)

package gi -- scenegraph based 2D and 3D GUI / graphics interface (Gi) in Go

THIS IS ARCHIVED -- active version at: https://github.com/goki

GoGi uses the GoKi tree infrastructure to implement a simple, elegant, GUI framework in full native idiomatic Go (with minimal OS-specific backend interfaces based on the Shiny drivers). The overall design is an attempt to integrate existing standards and conventions from widely-used frameworks, including Qt (overall widget design), HTML / CSS (styling), and SVG (rendering). Rendering HTML and SVG is directly supported by the GoGi 2D scenegraph, with enhanced functionality for interactive GUI's. This 2D framework also integrates with a (planned) 3D scenegraph, supporting interesting combinations of these frameworks. Currently GoGi is focused on desktop systems, but nothing prevents adaptation to mobile.

GoGi also incorporates reflection-based View elements that enable automatic representation and editing of all native Go data structures, providing a built-in native first-order GUI framework with no additional coding. This enables built-in GUI editor / inspector for designing gui elements themselves. Just press Control+Alt+E (or I) on any window to pull up this editor / inspector. Scene graphs can be automatically saved / loaded from JSON files, to provide a basic GUI designer framework -- just load and add appropriate connections..

Code Map

  • examples/widgets -- main example widget gallery -- go build ... in there to give it a try -- see README there for more info
  • node*.go -- NodeBase, Node2DBase, 3D structs and interfaces -- all Gi nodes are of this type
  • geom2d.go -- Vec2D is main geom type used for 2D, plus transform matrix
  • paint.go -- Paint struct that does all the direct rendering, based on gg (todo: update to oksvg)
    • stroke.go, fill.go -- StrokeStyle and FillStyle structs for stroke, fill settings
  • style.go -- Style and associated structs for CSS-based Widget styling
  • viewport2d.go -- Viewport2D that has an Image.RGBA that Paint renders onto
  • window.go -- Window is the top-level window that manages an OS-specific oswin.Window and handles the event loop.
  • shapes2d.go -- All the basic 2D SVG-based shapes: Rect, Circle etc
  • font.go, text.go -- FontStyle, TextStyle, Text2D node
  • layout.go -- main Layout object with various ways of arranging widget elements, and Frame which does layout and renders a surrounding frame
  • widget.go -- WidgetBase for all widgets
  • buttons.go -- ButtonBase, Button and other basic command button types
  • action.go -- Action is a Button-type used in menus and toolbars, with a simplified ActionTriggered signal
  • sliders.go -- SliderBase, Slider, ScrollBar
  • textwidgets.go -- Label, TextField, ComboBox -- also defines the gi.Labeler interface and ToLabel converter method (which falls back on kit.ToString using Stringer), which is used for generating a gui-appropriate label for an object -- e.g., for reflect.Type it just presents the raw type name without prefix.
  • *view.go -- TreeView widget shows a graphical view of a tree, StructView for editing structs, MapView, SliceView, etc. ValueView framework for managing mapping between reflect.Value's and gui widgets for displaying them.

Design notes

The 2D Gi is based entirely on the SVG2 spec: https://www.w3.org/TR/SVG2/Overview.html, and renders directly to an Image struct (Viewport2D)

The 3D Gi is based on TBD (will be impl later) and renders directly into a Viewport3D offscreen image buffer (OpenGL for now, but with generalization to Vulkan etc).

Any number of such (nested or otherwise) Viewport nodes can be created and they are all then composted into the final underlying bitmap of the Window.

Within a given rendering parent (Viewport2D or Viewport3D), only nodes of the appropriate type (GiNode2D or GiNode3D) may be used -- each has a pointer to their immediate parent viewport (indirectly through a ViewBox in 2D)

There are nodes to embed a Viewport2D bitmap within a Viewport3D scene, and vice-versa. For a 2D viewport in a 3D scene, it acts like a texture and can be mapped onto a plane or anything else. For a 3D viewport in a 2D scene, it just composts into the bitmap directly.

The overall parent Window can either provide a 2D or 3D viewport, which map directly into the underlying pixels of the window, and provide the "native" mode of the window, for efficiency.

2D Design

  • There are three main types of 2D nodes:

    • Viewport2D nodes that manage their own oswin.Image bitmap and can upload that directly to the oswin.Texture that then uploads directly to the oswin.Window. The parent Window has a master Viewport2D that backs the entire window, and is what most Widget's render into.
      • Popup Dialog and Menu's have their own viewports that are layered on top of the main window viewport.
      • SVG and its subclass Icon are containers for SVG-rendering nodes.
    • Widget nodes that use the full CSS-based styling (e.g., the Box model etc), are typically placed within a Layout -- they use units system with arbitrary DPI to transform sizes into actual rendered dots (term for actual raw resolution-dependent pixels -- "pixel" has been effectively co-opted as a 96dpi display-independent unit at this point). Widgets have non-overlapping bounding boxes (BBox).
    • SVG rendering nodes that directly set properties on the Paint object and typically have their own geometry etc -- they should be within a parent SVG viewport, and their geom units are determined entirely by the transforms etc and we do not support any further unit specification -- just raw float values.
  • Rendering: there are 2 3 major render frameworks:

    • https://godoc.org/github.com/golang/freetype/raster
    • https://godoc.org/golang.org/x/image/vector
    • https://github.com/srwiley/rasterx -- todo: probably move over to this and attempt to integrate with https://github.com/srwiley/oksvg
    • This code: https://github.com/fogleman/gg uses freetype and handles the majority of SVG. Freetype has a Painter interface that is key for supporting the more flexible types of patterns, images, etc that can be used for the final render step. It also directly supports line joins (round, bevel) and caps: square, butt, round. It uses fixed.Int26_6 values. The image/vector code is highly optimized based on this rust-based rasterizer: https://medium.com/@raphlinus/inside-the-fastest-font-renderer-in-the-world-75ae5270c445 and uses SIMD instructions. It switches between float32 and fixed.Int22_10 values depending on size. Presumably the optimal case would be a merge of these different technologies for the best-of-all but I'm not sure how the Painter flexibility could be incorporated. Also, the freetype system is already supported for fonts -- would need to integrate that. This is clearly a job for nigeltao.. :)
    • Converted the gg system to float32 instead of 64, using the geom.go Vec2D core element. Note that the github.com/go-gl/mathgl/mgl32/ math elements (vectors, matricies) which build on the basic golang.org/x/image/math/f32 do not have appropriate 2D rendering transforms etc.
  • The SVG and most 2D default coordinate systems have 0,0 at the upper-left. The default 3D coordinate system flips the Y axis so 0,0 is at the lower left effectively (actually it uses center-based coordinates so 0,0 is in the center of the image, effectively -- everything is defined by the camera anyway)

  • Basic CSS styling is based on the Box model: https://www.w3schools.com/css/css_boxmodel.asp -- see also the Box shadow model https://www.w3schools.com/css/css3_shadows.asp -- general html spec: https://www.w3.org/TR/html5/index.html#contents -- better ref section of w3schools for css spec: https://www.w3schools.com/cssref/default.asp

  • Naming conventions for scenegraph / html / css objects: it seems conventional in HTML to use lowercase with hyphen separator for id naming. And states such as :hover :active etc: https://stackoverflow.com/questions/1696864/naming-class-and-id-html-attributes-dashes-vs-underlines https://stackoverflow.com/questions/70579/what-are-valid-values-for-the-id-attribute-in-html -- so we use that convention, which then provides a clear contrast to the UpperCase Go code (see ki/README.md for Go conventions). Specific defined selectors: https://www.w3schools.com/cssref/css_selectors.asp -- note that read-only is used

  • Every non-terminal Widget must either be a Layout or take full responsibility for everything under it -- i.e., all arbitrary collections of widgets must be Layouts -- only the layout has all the logic necessary for organizing the geometry of its children. There is only one Layout type that supports all forms of Layout -- and it is a proper Widget -- not a side class like in Qt Widgets. The Frame is a type of Layout that draws a frame around itself.

  • General Widget method conventions:

    • SetValue kinds of methods are wrapped in updates, but do NOT emit a signal
    • SetValueAction calls SetValue and emits the signal
    • this allows other users of the widget that also recv the signal to not trigger themselves, but typically you want the update, so it makes sense to have that in the basic version. ValueView in particular requires this kind of behavior. todo: go back and make this more consistent.
TODO
  • style parsing crash on font-family? now just seems to ignore it?a

  • tab widget basic fix

  • tab widget and integrate with tree view editor? Popups show up in a separate tab?

  • separator not rendering..

  • MenuBar / Toolbar -- just a layout really, with some styling?

  • basic rich text formatting -- , and bold / italic styles for fonts?

  • word wrap in widgets demo

  • really want an additional spacing parameter on layout -- needs to be separate from margin / padding which just apply to the frame-like property

  • main menu (mac)

  • highlight, lowlight versions of lighter-darker that are relative to current lightness for dark-style themes.

  • add a painter guy based on that to generate gradients, and then we're in the shadow business, etc

  • arg view / dialog and button tags

  • DND for slices, trees: need the restore under vp, draw vp sequence to work right -- maybe after new rendering.

  • fix issue with tiny window and dialog not scrolling and blocking interface

  • Structview: condshow / edit

  • test SVG path rendering

  • property-based xforms for svg

  • Layout flow types

  • keyboard shortcuts -- need to register with window / event manager on a signal list..

  • add a new icon for color editor..

  • Reminder: grep all todo: in code -- lots!

Missing Widgets

see http://doc.qt.io/qt-5/qtquickcontrols2-differences.html for ref

  • FileView view and dialog
  • RadioButton -- checkbox + mutex logic -- everyone within same parent is mutex -- easy
  • ProgressBar -- very simple
  • ToolTip
  • TextArea
Remaining features for widgets
  • TextField -- needs selection / clipboard, constraints
  • TreeView (NodeWidget) -- needs dnd, clip, -- see about LI, UL lists..
  • TabWidget -- needs updating
  • Label -- done -- could make lots of H1, etc alts
Performance issues
  • Styling and ToDots
    • currently compiling default of main style, but derived state / sub styles MUST be styled dynamically otherwise css and props changes don't propagate -- this doesn't add much -- was previously caching those but then they were not responsive to overall changes.
    • Lots of redundant ToDots is happening, but it is difficult to figure out exactly when minimal recompute is necessary. right now only for nil props. computing prop diffs might be more expensive and complex than just redoing everything.
    • 4.6sec on FindConnectionIndex when making new Connections -- hash map? -- this is most of the time in Init2D

3D Design

  • keep all the elements separate: geometry, material, transform, etc. Including shader programs. Maximum combinatorial flexibility. not clear if Qt3D really obeys this principle, but Inventor does, and probably other systems do to.

SVG

GUI

Material design

Go graphics

3D

Documentation

Overview

Package Gi (GoGi) provides a Graphical Interface based on GoKi Tree Node structs

2D and 3D scenegraphs supported, each rendering to respective Viewport2D or 3D which in turn can be integrated within the other type of scenegraph.

Within 2D scenegraph, the following are supported

  • SVG-based rendering nodes for basic shapes, paths, curves, arcs
  • Widget nodes for GUI actions (Buttons, Views etc)
  • Layouts for placing widgets
  • CSS-based styling, directly on Node Props (properties), and css sheets
  • HTML elements -- the 2D scenegraph can render html documents

Layout Logic

For Widget-based displays, *everything* should be contained in a Layout, because a layout provides the primary logic for organizing widgets within the constraints of the display. Typically start with a vertical LayoutCol in a viewport, with LayoutCol's within that, or a LayoutGrid for more complex layouts:

	win := gi.NewWindow2D("test window", width, height)
	vp := win.WinViewport2D()
	updt := vp.UpdateStart()

	vpfill := vp.AddNewChildNamed(gi.KiT_Viewport2DFill, "vpfill").(*gi.Viewport2DFill)
	vpfill.SetProp("fill", "#FFF") // white background

	vlay := vpfill.AddNewChildNamed(gi.KiT_Layout, "vlay").(*gi.Layout)
	vlay.Lay = gi.LayoutCol

	row1 := vlay.AddNewChildNamed(gi.KiT_Layout, "row1").(*gi.Layout)
	row1.Lay = gi.LayoutRow

	...

    vp.UpdateEnd(updt)

Controlling the layout involves the following style properties:

  • width / height: sets the preferred size of item -- layout tries to give this amount of space unless it can't in which case it falls back on:

  • min-width / min-height: minimum size -- will not scale below this size. if not specified, it defaults to 1 em (the size of 1 character)

  • max-width / max-height: maximum size -- will not exceed this size if specified, otherwise if 0 it is ignored and preferred size is used. If a negative number is specified, then the item stretches to take up available room. The Stretch node is a builtin type that has this property set automatically, and can be added to any layout to fill up any available space. The preferred size of the item is used to determine how much of the space is used by each stretchable element, so you can set that to achieve different proportional spacing. By default the Stretch is just the minumum 1em in preferred size.

  • align-horiz / align-vert: for the other dimension in a Layout (e.g., for LayoutRow, the vertical dimension) this specifies how the items are aligned within the available space (e.g., tops, bottoms, centers). In the dimension of the Layout (horiz for LayoutRow) it determines how extra space is allocated (only if there aren't any infinitely stretchy elements), e.g., right / left / center or justified.

  • SetFixedWidth / Height method can be used to set all size params to the same value, causing that item to be definitively sized. This is convenient for sizing the Space node which adds a fixed amount of space (1em by default).

Signals

All widgets send appropriate signals about user actions -- Connect to those and check the signal type to determine the type of event.

Views

Views are Widgets that automatically display and interact with structured data, providing powerful GUI elements, with extensive property-based customization options. They can easily provide the foundation for entire apps.

TreeView

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

The properties controlling the TreeView include:

  • "view-closed" -- node starts out closed (default is open)
  • "background-color" -- color of the background of node box
  • "color" -- font color in rendering node label
  • "inactive" -- do not display the editing menu actions

StructView

The StructView displays an arbitrary struct object, showing its fields and values, in an editable form, with type-appropriate widgets.

Index

Constants

This section is empty.

Variables

View Source
var (
	ColorModel    color.Model = color.ModelFunc(colorModel)
	RGBAf32Model  color.Model = color.ModelFunc(rgbaf32Model)
	NRGBAf32Model color.Model = color.ModelFunc(nrgbaf32Model)
	HSLAModel     color.Model = color.ModelFunc(hslaf32Model)
)
View Source
var ActionProps = ki.Props{
	"border-width":     units.NewValue(0, units.Px),
	"border-radius":    units.NewValue(0, units.Px),
	"border-color":     &Prefs.BorderColor,
	"border-style":     BorderSolid,
	"padding":          units.NewValue(2, units.Px),
	"margin":           units.NewValue(0, units.Px),
	"box-shadow.color": &Prefs.ShadowColor,
	"text-align":       AlignCenter,
	"vertical-align":   AlignTop,
	"background-color": &Prefs.ControlColor,
	"#icon": ki.Props{
		"width":   units.NewValue(1, units.Em),
		"height":  units.NewValue(1, units.Em),
		"margin":  units.NewValue(0, units.Px),
		"padding": units.NewValue(0, units.Px),
		"fill":    &Prefs.IconColor,
		"stroke":  &Prefs.FontColor,
	},
	"#label": ki.Props{
		"margin":  units.NewValue(0, units.Px),
		"padding": units.NewValue(0, units.Px),
	},
	"#indicator": ki.Props{
		"width":          units.NewValue(1.5, units.Ex),
		"height":         units.NewValue(1.5, units.Ex),
		"margin":         units.NewValue(0, units.Px),
		"padding":        units.NewValue(0, units.Px),
		"vertical-align": AlignBottom,
		"fill":           &Prefs.IconColor,
		"stroke":         &Prefs.FontColor,
	},
	ButtonSelectors[ButtonActive]: ki.Props{},
	ButtonSelectors[ButtonInactive]: ki.Props{
		"border-color": "lighter-50",
		"color":        "lighter-50",
	},
	ButtonSelectors[ButtonHover]: ki.Props{
		"background-color": "darker-10",
	},
	ButtonSelectors[ButtonFocus]: ki.Props{
		"border-width":     units.NewValue(2, units.Px),
		"background-color": "lighter-40",
	},
	ButtonSelectors[ButtonDown]: ki.Props{
		"color":            "lighter-90",
		"background-color": "darker-30",
	},
	ButtonSelectors[ButtonSelected]: ki.Props{
		"background-color": &Prefs.SelectColor,
	},
}
View Source
var ButtonBaseFields = initButtonBase()

ButtonBaseFields contain the StyledFields for ButtonBase type

View Source
var ButtonBaseProps = ki.Props{
	"base-type": true,
}
View Source
var ButtonProps = ki.Props{
	"border-width":        units.NewValue(1, units.Px),
	"border-radius":       units.NewValue(4, units.Px),
	"border-color":        &Prefs.BorderColor,
	"border-style":        BorderSolid,
	"padding":             units.NewValue(4, units.Px),
	"margin":              units.NewValue(4, units.Px),
	"box-shadow.h-offset": units.NewValue(4, units.Px),
	"box-shadow.v-offset": units.NewValue(4, units.Px),
	"box-shadow.blur":     units.NewValue(4, units.Px),
	"box-shadow.color":    &Prefs.ShadowColor,
	"text-align":          AlignCenter,
	"vertical-align":      AlignTop,
	"background-color":    &Prefs.ControlColor,
	"#icon": ki.Props{
		"width":   units.NewValue(1, units.Em),
		"height":  units.NewValue(1, units.Em),
		"margin":  units.NewValue(0, units.Px),
		"padding": units.NewValue(0, units.Px),
		"fill":    &Prefs.IconColor,
		"stroke":  &Prefs.FontColor,
	},
	"#label": ki.Props{
		"margin":  units.NewValue(0, units.Px),
		"padding": units.NewValue(0, units.Px),
	},
	"#indicator": ki.Props{
		"width":          units.NewValue(1.5, units.Ex),
		"height":         units.NewValue(1.5, units.Ex),
		"margin":         units.NewValue(0, units.Px),
		"padding":        units.NewValue(0, units.Px),
		"vertical-align": AlignBottom,
		"fill":           &Prefs.IconColor,
		"stroke":         &Prefs.FontColor,
	},
	ButtonSelectors[ButtonActive]: ki.Props{},
	ButtonSelectors[ButtonInactive]: ki.Props{
		"border-color": "lighter-50",
		"color":        "lighter-50",
	},
	ButtonSelectors[ButtonHover]: ki.Props{
		"background-color": "darker-10",
	},
	ButtonSelectors[ButtonFocus]: ki.Props{
		"border-width":     units.NewValue(2, units.Px),
		"background-color": "lighter-40",
	},
	ButtonSelectors[ButtonDown]: ki.Props{
		"color":            "lighter-90",
		"background-color": "darker-30",
	},
	ButtonSelectors[ButtonSelected]: ki.Props{
		"background-color": &Prefs.SelectColor,
	},
}
View Source
var ButtonSelectors = []string{":active", ":inactive", ":hover", ":focus", ":down", ":selected"}

Style selector names for the different states: https://www.w3schools.com/cssref/css_selectors.asp

View Source
var CheckBoxProps = ki.Props{
	"text-align":       AlignLeft,
	"background-color": &Prefs.ControlColor,
	"#icon0": ki.Props{
		"width":            units.NewValue(1, units.Em),
		"height":           units.NewValue(1, units.Em),
		"margin":           units.NewValue(0, units.Px),
		"padding":          units.NewValue(0, units.Px),
		"background-color": color.Transparent,
		"fill":             &Prefs.ControlColor,
		"stroke":           &Prefs.FontColor,
	},
	"#icon1": ki.Props{
		"width":            units.NewValue(1, units.Em),
		"height":           units.NewValue(1, units.Em),
		"margin":           units.NewValue(0, units.Px),
		"padding":          units.NewValue(0, units.Px),
		"background-color": color.Transparent,
		"fill":             &Prefs.ControlColor,
		"stroke":           &Prefs.FontColor,
	},
	"#space": ki.Props{
		"width": units.NewValue(1, units.Ex),
	},
	"#label": ki.Props{
		"margin":  units.NewValue(0, units.Px),
		"padding": units.NewValue(0, units.Px),
	},
	ButtonSelectors[ButtonActive]: ki.Props{},
	ButtonSelectors[ButtonInactive]: ki.Props{
		"border-color": "lighter-50",
		"color":        "lighter-50",
	},
	ButtonSelectors[ButtonHover]: ki.Props{
		"background-color": "darker-10",
	},
	ButtonSelectors[ButtonFocus]: ki.Props{
		"border-width":     units.NewValue(2, units.Px),
		"background-color": "lighter-20",
	},
	ButtonSelectors[ButtonDown]: ki.Props{
		"color":            "lighter-90",
		"background-color": "darker-30",
	},
	ButtonSelectors[ButtonSelected]: ki.Props{
		"background-color": &Prefs.SelectColor,
	},
}
View Source
var ColorProps = ki.Props{
	"style-prop": true,
}
View Source
var ColorViewProps = ki.Props{
	"background-color": &Prefs.BackgroundColor,
	"#title": ki.Props{
		"max-width":      units.NewValue(-1, units.Px),
		"text-align":     AlignCenter,
		"vertical-align": AlignTop,
	},
}
View Source
var ComboBoxProps = ki.Props{
	"border-width":     units.NewValue(1, units.Px),
	"border-radius":    units.NewValue(4, units.Px),
	"border-color":     &Prefs.BorderColor,
	"border-style":     BorderSolid,
	"padding":          units.NewValue(4, units.Px),
	"margin":           units.NewValue(4, units.Px),
	"text-align":       AlignCenter,
	"vertical-align":   AlignMiddle,
	"background-color": &Prefs.ControlColor,
	"#icon": ki.Props{
		"width":   units.NewValue(1, units.Em),
		"height":  units.NewValue(1, units.Em),
		"margin":  units.NewValue(0, units.Px),
		"padding": units.NewValue(0, units.Px),
		"fill":    &Prefs.IconColor,
		"stroke":  &Prefs.FontColor,
	},
	"#label": ki.Props{
		"margin":  units.NewValue(0, units.Px),
		"padding": units.NewValue(0, units.Px),
	},
	"#indicator": ki.Props{
		"width":          units.NewValue(1.5, units.Ex),
		"height":         units.NewValue(1.5, units.Ex),
		"margin":         units.NewValue(0, units.Px),
		"padding":        units.NewValue(0, units.Px),
		"vertical-align": AlignBottom,
		"fill":           &Prefs.IconColor,
		"stroke":         &Prefs.FontColor,
	},
	ButtonSelectors[ButtonActive]: ki.Props{},
	ButtonSelectors[ButtonInactive]: ki.Props{
		"border-color": "lighter-50",
		"color":        "lighter-50",
	},
	ButtonSelectors[ButtonHover]: ki.Props{
		"background-color": "darker-10",
	},
	ButtonSelectors[ButtonFocus]: ki.Props{
		"border-width":     units.NewValue(2, units.Px),
		"background-color": "lighter-20",
	},
	ButtonSelectors[ButtonDown]: ki.Props{
		"color":            "lighter-90",
		"background-color": "darker-30",
	},
	ButtonSelectors[ButtonSelected]: ki.Props{
		"background-color": "darker-25",
		"color":            "lighter-90",
	},
}
View Source
var DefaultKeyMap = KeyMap{
	"UpArrow":             KeyFunMoveUp,
	"Control+P":           KeyFunMoveUp,
	"DownArrow":           KeyFunMoveDown,
	"Control+N":           KeyFunMoveDown,
	"RightArrow":          KeyFunMoveRight,
	"Control+F":           KeyFunMoveRight,
	"LeftArrow":           KeyFunMoveLeft,
	"Control+B":           KeyFunMoveLeft,
	"Control+UpArrow":     KeyFunPageUp,
	"Control+U":           KeyFunPageUp,
	"Control+DownArrow":   KeyFunPageDown,
	"Control+V":           KeyFunPageDown,
	"Control+RightArrow":  KeyFunPageRight,
	"Control+LeftArrow":   KeyFunPageLeft,
	"Home":                KeyFunHome,
	"Control+A":           KeyFunHome,
	"Meta+LeftArrow":      KeyFunHome,
	"End":                 KeyFunEnd,
	"Control+E":           KeyFunEnd,
	"Meta+RightArrow":     KeyFunEnd,
	"Tab":                 KeyFunFocusNext,
	"Shift+Tab":           KeyFunFocusPrev,
	"ReturnEnter":         KeyFunSelectItem,
	"KeypadEnter":         KeyFunSelectItem,
	"Control+ReturnEnter": KeyFunAccept,
	"Escape":              KeyFunAbort,
	"Control+G":           KeyFunCancelSelect,

	"Control+Spacebar": KeyFunSelectText,
	"DeleteBackspace":  KeyFunBackspace,
	"DeleteForward":    KeyFunDelete,
	"Control+D":        KeyFunDelete,
	"Control+H":        KeyFunBackspace,
	"Control+K":        KeyFunKill,
	"Control+M":        KeyFunDuplicate,
	"Control+I":        KeyFunInsert,
	"Control+O":        KeyFunInsertAfter,
	"Control+Alt+I":    KeyFunGoGiEditor,
	"Control+Alt+E":    KeyFunGoGiEditor,
	"Shift+Meta+=":     KeyFunZoomIn,
	"Meta+=":           KeyFunZoomIn,
	"Meta+-":           KeyFunZoomOut,
	"Shift+Meta+-":     KeyFunZoomOut,
	"Control+Alt+P":    KeyFunPrefs,
	"F5":               KeyFunRefresh,
}

the default map has emacs-style navigation etc

View Source
var DialogProps = ki.Props{
	"#frame": ki.Props{
		"border-width":        units.NewValue(2, units.Px),
		"margin":              units.NewValue(8, units.Px),
		"padding":             units.NewValue(4, units.Px),
		"box-shadow.h-offset": units.NewValue(4, units.Px),
		"box-shadow.v-offset": units.NewValue(4, units.Px),
		"box-shadow.blur":     units.NewValue(4, units.Px),
		"box-shadow.color":    "#CCC",
	},
	"#title": ki.Props{

		"max-width":        units.NewValue(-1, units.Px),
		"text-align":       AlignCenter,
		"vertical-align":   AlignTop,
		"background-color": "none",
	},
	"#prompt": ki.Props{
		"max-width":        units.NewValue(-1, units.Px),
		"text-align":       AlignLeft,
		"vertical-align":   AlignTop,
		"background-color": "none",
	},
}
View Source
var DialogsSepWindow = true

DialogsSepWindow determines if dialog windows open in a separate OS-level window, or do they open within the same parent window. If only within parent window, then they are always effectively modal. This is also in gi.Prefs and updated from there

View Source
var EventSkipLagMSec = 50

EventSkipLagMSec is the number of milliseconds of lag between the time the event was sent to the time it is being processed, above which a repeated event type (scroll, drag, resize) is skipped

View Source
var FrameProps = ki.Props{
	"border-width":     units.NewValue(2, units.Px),
	"border-radius":    units.NewValue(0, units.Px),
	"border-color":     &Prefs.BorderColor,
	"border-style":     BorderSolid,
	"padding":          units.NewValue(2, units.Px),
	"margin":           units.NewValue(2, units.Px),
	"color":            &Prefs.FontColor,
	"background-color": &Prefs.BackgroundColor,
}
View Source
var IconProps = ki.Props{
	"background-color": color.Transparent,
}
View Source
var KiT_Action = kit.Types.AddType(&Action{}, ActionProps)
View Source
var KiT_Align = kit.Enums.AddEnumAltLower(AlignN, false, StylePropProps, "Align")
View Source
var KiT_BoolValueView = kit.Types.AddType(&BoolValueView{}, nil)
View Source
var KiT_BorderDrawStyle = kit.Enums.AddEnumAltLower(BorderN, false, StylePropProps, "Border")
View Source
var KiT_BoxSides = kit.Enums.AddEnumAltLower(BoxN, false, StylePropProps, "Box")
View Source
var KiT_Button = kit.Types.AddType(&Button{}, ButtonProps)
View Source
var KiT_ButtonBase = kit.Types.AddType(&ButtonBase{}, ButtonBaseProps)
View Source
var KiT_ButtonStates = kit.Enums.AddEnumAltLower(ButtonStatesN, false, StylePropProps, "Button")
View Source
var KiT_CheckBox = kit.Types.AddType(&CheckBox{}, CheckBoxProps)
View Source
var KiT_Circle = kit.Types.AddType(&Circle{}, nil)
View Source
var KiT_Color = kit.Types.AddType(&Color{}, ColorProps)
View Source
var KiT_ColorValueView = kit.Types.AddType(&ColorValueView{}, nil)
View Source
var KiT_ColorView = kit.Types.AddType(&ColorView{}, ColorViewProps)
View Source
var KiT_ComboBox = kit.Types.AddType(&ComboBox{}, ComboBoxProps)
View Source
var KiT_Dialog = kit.Types.AddType(&Dialog{}, DialogProps)
View Source
var KiT_Dims2D = kit.Enums.AddEnumAltLower(Dims2DN, false, nil, "")
View Source
var KiT_Ellipse = kit.Types.AddType(&Ellipse{}, nil)
View Source
var KiT_EnumValueView = kit.Types.AddType(&EnumValueView{}, nil)
View Source
var KiT_FillRule = kit.Enums.AddEnumAltLower(FillRuleN, false, StylePropProps, "FillRule")
View Source
var KiT_FloatValueView = kit.Types.AddType(&FloatValueView{}, nil)
View Source
var KiT_FontStyles = kit.Enums.AddEnumAltLower(FontStylesN, false, StylePropProps, "Font")
View Source
var KiT_FontWeights = kit.Enums.AddEnumAltLower(FontWeightsN, false, StylePropProps, "Weight")
View Source
var KiT_Frame = kit.Types.AddType(&Frame{}, FrameProps)
View Source
var KiT_Icon = kit.Types.AddType(&Icon{}, IconProps)
View Source
var KiT_IconContexts = kit.Enums.AddEnum(IconContextsN, false, nil)
View Source
var KiT_IntValueView = kit.Types.AddType(&IntValueView{}, nil)
View Source
var KiT_KeyFunctions = kit.Enums.AddEnumAltLower(KeyFunctionsN, false, StylePropProps, "KeyFun")
View Source
var KiT_KiPtrValueView = kit.Types.AddType(&KiPtrValueView{}, nil)
View Source
var KiT_Label = kit.Types.AddType(&Label{}, LabelProps)
View Source
var KiT_Layout = kit.Types.AddType(&Layout{}, nil)
View Source
var KiT_Layouts = kit.Enums.AddEnumAltLower(LayoutsN, false, StylePropProps, "Layout")
View Source
var KiT_Line = kit.Types.AddType(&Line{}, nil)
View Source
var KiT_LineCap = kit.Enums.AddEnumAltLower(LineCapN, false, StylePropProps, "LineCap")
View Source
var KiT_LineJoin = kit.Enums.AddEnumAltLower(LineJoinN, false, StylePropProps, "LineJoin")
View Source
var KiT_MapInlineValueView = kit.Types.AddType(&MapInlineValueView{}, nil)
View Source
var KiT_MapValueView = kit.Types.AddType(&MapValueView{}, nil)
View Source
var KiT_MapView = kit.Types.AddType(&MapView{}, MapViewProps)
View Source
var KiT_MapViewInline = kit.Types.AddType(&MapViewInline{}, MapViewInlineProps)
View Source
var KiT_MenuButton = kit.Types.AddType(&MenuButton{}, MenuButtonProps)
View Source
var KiT_Node2DBase = kit.Types.AddType(&Node2DBase{}, Node2DBaseProps)
View Source
var KiT_Node3DBase = kit.Types.AddType(&Node3DBase{}, nil)
View Source
var KiT_NodeBase = kit.Types.AddType(&NodeBase{}, NodeBaseProps)
View Source
var KiT_NodeFlags = kit.Enums.AddEnum(NodeFlagsN, true, nil) // true = bitflags
View Source
var KiT_Overflow = kit.Enums.AddEnumAltLower(OverflowN, false, StylePropProps, "Overflow")
View Source
var KiT_PaintServers = kit.Enums.AddEnumAltLower(PaintServersN, false, StylePropProps, "Paint")
View Source
var KiT_Path = kit.Types.AddType(&Path{}, nil)
View Source
var KiT_Polygon = kit.Types.AddType(&Polygon{}, nil)
View Source
var KiT_Polyline = kit.Types.AddType(&Polyline{}, nil)
View Source
var KiT_Rect = kit.Types.AddType(&Rect{}, nil)
View Source
var KiT_RowCol = kit.Enums.AddEnumAltLower(RowColN, false, StylePropProps, "")
View Source
var KiT_SVG = kit.Types.AddType(&SVG{}, nil)
View Source
var KiT_ScrollBar = kit.Types.AddType(&ScrollBar{}, ScrollBarProps)
View Source
var KiT_Separator = kit.Types.AddType(&Separator{}, SeparatorProps)
View Source
var KiT_SliceValueView = kit.Types.AddType(&SliceValueView{}, nil)
View Source
var KiT_SliceView = kit.Types.AddType(&SliceView{}, SliceViewProps)
View Source
var KiT_SliceViewInline = kit.Types.AddType(&SliceViewInline{}, SliceViewInlineProps)
View Source
var KiT_Slider = kit.Types.AddType(&Slider{}, SliderProps)
View Source
var KiT_SliderBase = kit.Types.AddType(&SliderBase{}, SliderBaseProps)
View Source
var KiT_Space = kit.Types.AddType(&Space{}, SpaceProps)
View Source
var KiT_SpinBox = kit.Types.AddType(&SpinBox{}, SpinBoxProps)
View Source
var KiT_SplitView = kit.Types.AddType(&SplitView{}, SplitViewProps)
View Source
var KiT_Splitter = kit.Types.AddType(&Splitter{}, SplitterProps)
View Source
var KiT_Stretch = kit.Types.AddType(&Stretch{}, StretchProps)
View Source
var KiT_StructInlineValueView = kit.Types.AddType(&StructInlineValueView{}, nil)
View Source
var KiT_StructValueView = kit.Types.AddType(&StructValueView{}, nil)
View Source
var KiT_StructView = kit.Types.AddType(&StructView{}, StructViewProps)
View Source
var KiT_StructViewInline = kit.Types.AddType(&StructViewInline{}, StructViewInlineProps)
View Source
var KiT_TabView = kit.Types.AddType(&TabView{}, nil)
View Source
var KiT_Text2D = kit.Types.AddType(&Text2D{}, nil)
View Source
var KiT_TextField = kit.Types.AddType(&TextField{}, TextFieldProps)
View Source
var KiT_TreeView = kit.Types.AddType(&TreeView{}, TreeViewProps)
View Source
var KiT_TypeValueView = kit.Types.AddType(&TypeValueView{}, nil)
View Source
var KiT_ValueViewBase = kit.Types.AddType(&ValueViewBase{}, ValueViewBaseProps)
View Source
var KiT_Viewport2D = kit.Types.AddType(&Viewport2D{}, Viewport2DProps)
View Source
var KiT_Viewport2DFill = kit.Types.AddType(&Viewport2DFill{}, nil)
View Source
var KiT_WidgetBase = kit.Types.AddType(&WidgetBase{}, WidgetBaseProps)
View Source
var KiT_Window = kit.Types.AddType(&Window{}, nil)
View Source
var LabelProps = ki.Props{
	"padding":          units.NewValue(2, units.Px),
	"margin":           units.NewValue(2, units.Px),
	"vertical-align":   AlignTop,
	"background-color": color.Transparent,
}
View Source
var Layout2DTrace bool = false

set this variable to true to obtain a trace of all layouts (just printfs to stdout)

View Source
var MapViewInlineProps = ki.Props{
	"min-width": units.NewValue(60, units.Ex),
}
View Source
var MapViewProps = ki.Props{
	"background-color": &Prefs.BackgroundColor,
	"#title": ki.Props{
		"max-width":      units.NewValue(-1, units.Px),
		"text-align":     AlignCenter,
		"vertical-align": AlignTop,
	},
}
View Source
var MenuButtonProps = ki.Props{
	"border-width":     units.NewValue(1, units.Px),
	"border-radius":    units.NewValue(4, units.Px),
	"border-color":     &Prefs.BorderColor,
	"border-style":     BorderSolid,
	"padding":          units.NewValue(4, units.Px),
	"margin":           units.NewValue(4, units.Px),
	"box-shadow.color": &Prefs.ShadowColor,
	"text-align":       AlignCenter,
	"vertical-align":   AlignMiddle,
	"background-color": &Prefs.ControlColor,
	"#icon": ki.Props{
		"width":   units.NewValue(1, units.Em),
		"height":  units.NewValue(1, units.Em),
		"margin":  units.NewValue(0, units.Px),
		"padding": units.NewValue(0, units.Px),
		"fill":    &Prefs.IconColor,
		"stroke":  &Prefs.FontColor,
	},
	"#label": ki.Props{
		"margin":  units.NewValue(0, units.Px),
		"padding": units.NewValue(0, units.Px),
	},
	"#indicator": ki.Props{
		"width":          units.NewValue(1.5, units.Ex),
		"height":         units.NewValue(1.5, units.Ex),
		"margin":         units.NewValue(0, units.Px),
		"padding":        units.NewValue(0, units.Px),
		"vertical-align": AlignBottom,
		"fill":           &Prefs.IconColor,
		"stroke":         &Prefs.FontColor,
	},
	ButtonSelectors[ButtonActive]: ki.Props{},
	ButtonSelectors[ButtonInactive]: ki.Props{
		"border-color": "lighter-50",
		"color":        "lighter-50",
	},
	ButtonSelectors[ButtonHover]: ki.Props{
		"background-color": "darker-10",
	},
	ButtonSelectors[ButtonFocus]: ki.Props{
		"border-width":     units.NewValue(2, units.Px),
		"background-color": "lighter-40",
	},
	ButtonSelectors[ButtonDown]: ki.Props{
		"color":            "lighter-90",
		"background-color": "darker-30",
	},
	ButtonSelectors[ButtonSelected]: ki.Props{
		"background-color": &Prefs.SelectColor,
	},
}
View Source
var MenuFrameProps = ki.Props{
	"border-width":        units.NewValue(0, units.Px),
	"border-color":        "none",
	"margin":              units.NewValue(4, units.Px),
	"padding":             units.NewValue(2, units.Px),
	"box-shadow.h-offset": units.NewValue(2, units.Px),
	"box-shadow.v-offset": units.NewValue(2, units.Px),
	"box-shadow.blur":     units.NewValue(2, units.Px),
	"box-shadow.color":    &Prefs.ShadowColor,
}
View Source
var Node2DBaseProps = ki.Props{
	"base-type": true,
}
View Source
var NodeBaseProps = ki.Props{
	"base-type": true,
}
View Source
var PaintFields = initPaint()

PaintFields contain the StyledFields for Paint type

View Source
var Prefs = Preferences{}

Prefs are the overall preferences

View Source
var RebuildDefaultStyles bool

RebuildDefaultStyles is a global state var used by Prefs to trigger rebuild of all the default styles, which are otherwise compiled and not updated

View Source
var Render2DTrace bool = false

set this variable to true to obtain a trace of the nodes rendering (just printfs to stdout)

View Source
var ScrollBarProps = ki.Props{
	"border-width":                units.NewValue(1, units.Px),
	"border-radius":               units.NewValue(4, units.Px),
	"border-color":                &Prefs.BorderColor,
	"border-style":                BorderSolid,
	"padding":                     units.NewValue(0, units.Px),
	"margin":                      units.NewValue(2, units.Px),
	"background-color":            &Prefs.ControlColor,
	SliderSelectors[SliderActive]: ki.Props{},
	SliderSelectors[SliderInactive]: ki.Props{
		"border-color": "lighter-50",
		"color":        "lighter-50",
	},
	SliderSelectors[SliderHover]: ki.Props{
		"background-color": "darker-10",
	},
	SliderSelectors[SliderFocus]: ki.Props{
		"border-width":     units.NewValue(2, units.Px),
		"background-color": "lighter-20",
	},
	SliderSelectors[SliderDown]: ki.Props{
		"background-color": "lighter-20",
	},
	SliderSelectors[SliderValue]: ki.Props{
		"border-color":     &Prefs.IconColor,
		"background-color": &Prefs.IconColor,
	},
	SliderSelectors[SliderBox]: ki.Props{
		"border-color":     &Prefs.BackgroundColor,
		"background-color": &Prefs.BackgroundColor,
	},
}
View Source
var SeparatorProps = ki.Props{
	"padding":      units.NewValue(2, units.Px),
	"margin":       units.NewValue(2, units.Px),
	"align-vert":   AlignCenter,
	"align-horiz":  AlignCenter,
	"stroke-width": units.NewValue(2, units.Px),
	"color":        &Prefs.FontColor,
	"stroke":       &Prefs.FontColor,
}
View Source
var SliceViewInlineProps = ki.Props{
	"min-width": units.NewValue(20, units.Ex),
}
View Source
var SliceViewProps = ki.Props{
	"background-color": &Prefs.BackgroundColor,
	"#title": ki.Props{

		"max-width":      units.NewValue(-1, units.Px),
		"text-align":     AlignCenter,
		"vertical-align": AlignTop,
	},
}
View Source
var SliderBaseProps = ki.Props{
	"base-type": true,
}
View Source
var SliderFields = initSlider()

SliderFields contain the StyledFields for Slider type

View Source
var SliderProps = ki.Props{
	"border-width":     units.NewValue(1, units.Px),
	"border-radius":    units.NewValue(4, units.Px),
	"border-color":     &Prefs.BorderColor,
	"border-style":     BorderSolid,
	"padding":          units.NewValue(6, units.Px),
	"margin":           units.NewValue(4, units.Px),
	"background-color": &Prefs.ControlColor,
	"#icon": ki.Props{
		"width":   units.NewValue(1, units.Em),
		"height":  units.NewValue(1, units.Em),
		"margin":  units.NewValue(0, units.Px),
		"padding": units.NewValue(0, units.Px),
		"fill":    &Prefs.IconColor,
		"stroke":  &Prefs.FontColor,
	},
	SliderSelectors[SliderActive]: ki.Props{},
	SliderSelectors[SliderInactive]: ki.Props{
		"border-color": "lighter-50",
		"color":        "lighter-50",
	},
	SliderSelectors[SliderHover]: ki.Props{
		"background-color": "darker-10",
	},
	SliderSelectors[SliderFocus]: ki.Props{
		"border-width":     units.NewValue(2, units.Px),
		"background-color": "lighter-20",
	},
	SliderSelectors[SliderDown]: ki.Props{
		"background-color": "lighter-20",
	},
	SliderSelectors[SliderValue]: ki.Props{
		"border-color":     &Prefs.IconColor,
		"background-color": &Prefs.IconColor,
	},
	SliderSelectors[SliderBox]: ki.Props{
		"border-color":     &Prefs.BackgroundColor,
		"background-color": &Prefs.BackgroundColor,
	},
}
View Source
var SliderSelectors = []string{":active", ":inactive", ":hover", ":focus", ":down", ":value", ":box"}

Style selector names for the different states

View Source
var SpaceProps = ki.Props{
	"width":  units.NewValue(1, units.Em),
	"height": units.NewValue(1, units.Em),
}
View Source
var SpinBoxProps = ki.Props{
	"#buttons": ki.Props{
		"vert-align": AlignMiddle,
	},
	"#up": ki.Props{
		"max-width":  units.NewValue(1.5, units.Ex),
		"max-height": units.NewValue(1.5, units.Ex),
		"margin":     units.NewValue(1, units.Px),
		"padding":    units.NewValue(0, units.Px),
		"fill":       &Prefs.IconColor,
		"stroke":     &Prefs.FontColor,
	},
	"#down": ki.Props{
		"max-width":  units.NewValue(1.5, units.Ex),
		"max-height": units.NewValue(1.5, units.Ex),
		"margin":     units.NewValue(1, units.Px),
		"padding":    units.NewValue(0, units.Px),
		"fill":       &Prefs.IconColor,
		"stroke":     &Prefs.FontColor,
	},
	"#space": ki.Props{
		"width": units.NewValue(.1, units.Ex),
	},
	"#text-field": ki.Props{
		"min-width": units.NewValue(4, units.Ex),
		"width":     units.NewValue(8, units.Ex),
		"margin":    units.NewValue(2, units.Px),
		"padding":   units.NewValue(2, units.Px),
	},
}
View Source
var SplitViewProps = ki.Props{
	"max-width":  -1.0,
	"max-height": -1.0,
	"margin":     0,
	"padding":    0,
}

auto-max-stretch

View Source
var SplitterProps = ki.Props{
	"padding":          units.NewValue(0, units.Px),
	"margin":           units.NewValue(0, units.Px),
	"background-color": &Prefs.BackgroundColor,
	"#icon": ki.Props{
		"max-width":  units.NewValue(1, units.Em),
		"max-height": units.NewValue(5, units.Em),
		"min-width":  units.NewValue(1, units.Em),
		"min-height": units.NewValue(5, units.Em),
		"margin":     units.NewValue(0, units.Px),
		"padding":    units.NewValue(0, units.Px),
		"vert-align": AlignMiddle,
		"fill":       &Prefs.IconColor,
		"stroke":     &Prefs.FontColor,
	},
	SliderSelectors[SliderActive]: ki.Props{},
	SliderSelectors[SliderInactive]: ki.Props{
		"border-color": "lighter-50",
		"color":        "lighter-50",
	},
	SliderSelectors[SliderHover]: ki.Props{
		"background-color": "darker-10",
	},
	SliderSelectors[SliderFocus]: ki.Props{
		"border-width":     units.NewValue(2, units.Px),
		"background-color": "lighter-20",
	},
	SliderSelectors[SliderDown]: ki.Props{},
	SliderSelectors[SliderValue]: ki.Props{
		"border-color":     &Prefs.IconColor,
		"background-color": &Prefs.IconColor,
	},
	SliderSelectors[SliderBox]: ki.Props{
		"border-color":     &Prefs.BackgroundColor,
		"background-color": &Prefs.BackgroundColor,
	},
}
View Source
var StdDialogVSpace = float32(2.0)

standard vertical space between elements in a dialog, in Em units

View Source
var StdDialogVSpaceUnits = units.Value{StdDialogVSpace, units.Em, 0}
View Source
var StdIconNames = [IconContextsN][]string{
	{
		"widget-wedge-down",
		"widget-wedge-up",
		"widget-wedge-left",
		"widget-wedge-right",
		"widget-checkmark",
		"widget-checked-box",
		"widget-unchecked-box",
		"widget-circlebutton-on",
		"widget-circlebutton-off",
		"widget-handle-circles",
	}, {
		"edit-clear",
		"edit-copy",
		"edit-cut",
		"edit-delete",
		"edit-find",
		"edit-find-replace",
		"edit-paste",
		"edit-redo",
		"edit-select-all",
		"edit-undo",
		"list-add",
		"list-remove",
	}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
}

list of standard icon names that we expect to find in an IconSet

View Source
var StretchProps = ki.Props{
	"max-width":  -1.0,
	"max-height": -1.0,
}
View Source
var StructViewInlineProps = ki.Props{
	"min-width": units.NewValue(20, units.Ex),
}
View Source
var StructViewProps = ki.Props{
	"background-color": &Prefs.BackgroundColor,
	"#title": ki.Props{
		"max-width":      units.NewValue(-1, units.Px),
		"text-align":     AlignCenter,
		"vertical-align": AlignTop,
	},
}
View Source
var StyleFields = initStyle()

StyleFields contain the StyledFields for Style type

View Source
var StylePropProps = ki.Props{
	"style-prop": true,
}

StylePropProps should be set as type props for any enum (not struct types, which must have their own props) that is useful as a styling property -- use this for selecting types to add to Props

View Source
var TVBranchProps = ki.Props{
	"fill":   &Prefs.IconColor,
	"stroke": &Prefs.FontColor,
}
View Source
var TabButtonProps = ki.Props{
	"border-width":        units.NewValue(1, units.Px),
	"border-radius":       units.NewValue(0, units.Px),
	"border-color":        &Prefs.BorderColor,
	"border-style":        BorderSolid,
	"padding":             units.NewValue(4, units.Px),
	"margin":              units.NewValue(0, units.Px),
	"background-color":    &Prefs.ControlColor,
	"box-shadow.h-offset": units.NewValue(0, units.Px),
	"box-shadow.v-offset": units.NewValue(0, units.Px),
	"box-shadow.blur":     units.NewValue(0, units.Px),
	"box-shadow.color":    &Prefs.ShadowColor,
	"text-align":          AlignCenter,
}
View Source
var TextFieldProps = ki.Props{
	"border-width":                      units.NewValue(1, units.Px),
	"border-color":                      &Prefs.BorderColor,
	"border-style":                      BorderSolid,
	"padding":                           units.NewValue(4, units.Px),
	"margin":                            units.NewValue(1, units.Px),
	"text-align":                        AlignLeft,
	"vertical-align":                    AlignTop,
	"background-color":                  &Prefs.ControlColor,
	TextFieldSelectors[TextFieldActive]: ki.Props{},
	TextFieldSelectors[TextFieldFocus]: ki.Props{
		"border-width":     units.NewValue(2, units.Px),
		"background-color": "lighter-80",
	},
	TextFieldSelectors[TextFieldInactive]: ki.Props{
		"background-color": "darker-20",
	},
}
View Source
var TextFieldSelectors = []string{":active", ":focus", ":inactive"}

Style selector names for the different states

View Source
var TreeViewFields = initTreeView()

TreeViewFields contain the StyledFields for TreeView type

View Source
var TreeViewProps = ki.Props{
	"indent":           units.NewValue(2, units.Ch),
	"border-width":     units.NewValue(0, units.Px),
	"border-radius":    units.NewValue(0, units.Px),
	"padding":          units.NewValue(1, units.Px),
	"margin":           units.NewValue(1, units.Px),
	"text-align":       AlignLeft,
	"vertical-align":   AlignTop,
	"background-color": "inherit",
	"#branch": ki.Props{
		"vertical-align":   AlignMiddle,
		"margin":           units.NewValue(0, units.Px),
		"padding":          units.NewValue(0, units.Px),
		"background-color": color.Transparent,
		"max-width":        units.NewValue(.8, units.Em),
		"max-height":       units.NewValue(.8, units.Em),
	},
	"#space": ki.Props{
		"width": units.NewValue(.5, units.Em),
	},
	"#label": ki.Props{
		"margin":    units.NewValue(0, units.Px),
		"padding":   units.NewValue(0, units.Px),
		"min-width": units.NewValue(16, units.Ex),
	},
	"#menu": ki.Props{
		"indicator": "none",
	},
	TreeViewSelectors[TreeViewActive]: ki.Props{
		"background-color": "inherit",
	},
	TreeViewSelectors[TreeViewSel]: ki.Props{
		"background-color": &Prefs.SelectColor,
	},
	TreeViewSelectors[TreeViewFocus]: ki.Props{
		"background-color": &Prefs.ControlColor,
	},
}
View Source
var TreeViewSelectors = []string{":active", ":selected", ":focus"}

Style selector names for the different states:

View Source
var Update2DTrace bool = false

set this variable to true to obtain a trace of updates that trigger re-rendering

View Source
var ValueViewBaseProps = ki.Props{
	"base-type": true,
}
View Source
var Vec2DZero = Vec2D{0, 0}
View Source
var Viewport2DProps = ki.Props{
	"background-color": &Prefs.BackgroundColor,
}
View Source
var WidgetBaseProps = ki.Props{
	"base-type": true,
}

Functions

func AggCSS

func AggCSS(agg *ki.Props, css ki.Props)

AggCSS aggregates css properties

func ApplyCSS

func ApplyCSS(node Node2D, key string, css ki.Props) bool

ApplyCSS applies css styles to given node, using key to select sub-props from overall properties list

func Degrees

func Degrees(radians float32) float32

func FixedToFloat32

func FixedToFloat32(x fixed.Int26_6) float32

func Float32ToFixed

func Float32ToFixed(x float32) fixed.Int26_6

func Float32ToFixedPoint

func Float32ToFixedPoint(x, y float32) fixed.Point26_6

func FloatMod

func FloatMod(val, mod float64) float64

FloatMod ensures that a floating point value is an even multiple of a given value

func FloatMod32

func FloatMod32(val, mod float32) float32

FloatMod ensures that a floating point value is an even multiple of a given value

func GoGiEditorOf

func GoGiEditorOf(obj ki.Ki)

open an interactive editor of the given Ki tree, at its root

func HSLtoRGBf32

func HSLtoRGBf32(h, s, l float32) (r, g, b float32)

HSLtoRGBf32 converts HSL values to RGB float32 0..1 values (non alpha-premultiplied) -- based on https://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion, https://www.w3.org/TR/css-color-3/ and github.com/lucasb-eyer/go-colorful

func InRange

func InRange(val, min, max float64) float64

InRange returns the value constrained to the min / max range

func InRange32

func InRange32(val, min, max float32) float32

InRange32 returns the value constrained to the min / max range

func InRangeInt

func InRangeInt(val, min, max int) int

InRangeInt returns the value constrained to the min / max range

func Init

func Init()

Init performs overall initialization of the gogi system: loading prefs, etc

func Init2DButtonEvents

func Init2DButtonEvents(bw ButtonWidget)

handles all the basic button events

func IsAlignEnd

func IsAlignEnd(a Align) bool

is this a generalized alignment to end of container?

func IsAlignMiddle

func IsAlignMiddle(a Align) bool

is this a generalized alignment to middle of container?

func IsAlignStart

func IsAlignStart(a Align) bool

is this a generalized alignment to start of container?

func KiToNode2D

func KiToNode2D(k ki.Ki) (Node2D, *Node2DBase)

convert Ki to a Node2D interface and a Node2DBase obj -- nil if not

func LoadFontFace

func LoadFontFace(path string, points float64) (font.Face, error)

func LoadImage

func LoadImage(path string) (image.Image, error)

func LoadPNG

func LoadPNG(path string) (image.Image, error)

func Max32

func Max32(a, b float32) float32

func MaxInt

func MaxInt(a, b int) int

func MeasureChars

func MeasureChars(f font.Face, s string) []float32

MeasureChars returns inter-character points for each char, in float32

func Min32

func Min32(a, b float32) float32

func MinInt

func MinInt(a, b int) int

func MinPos

func MinPos(a, b float64) float64

MinPos returns the minimum of the two values, excluding any that are 0

func MinPos32

func MinPos32(a, b float32) float32

MinPos32 returns the minimum of the two values, excluding any that are 0

func NewKiDialogValues

func NewKiDialogValues(dlg *Dialog) (int, reflect.Type)

get the user-set values from a NewKiDialog

func PathDataRender

func PathDataRender(data []PathData, pc *Paint, rs *RenderState)

PathDataRender traverses the path data and renders it using paint and render state -- we assume all the data has been validated and that n's are sufficient, etc

func PopupIsMenu

func PopupIsMenu(pop ki.Ki) bool

PopupIsMenu returns true if the given popup item is a menu

func PromptDialog

func PromptDialog(avp *Viewport2D, title, prompt string, ok, cancel bool, recv ki.Ki, fun ki.RecvFunc)

PromptDialog opens a basic standard dialog with a title, prompt, and ok / cancel buttons -- any empty text will not be added -- optionally connects to given signal receiving object and function for dialog signals (nil to ignore)

func RGBtoHSLf32

func RGBtoHSLf32(r, g, b float32) (h, s, l float32)

RGBtoHSLf32 converts RGB 0..1 values (non alpha-premultiplied) to HSL -- based on https://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion, https://www.w3.org/TR/css-color-3/ and github.com/lucasb-eyer/go-colorful

func Radians

func Radians(degrees float32) float32

func RectFromPosSize

func RectFromPosSize(pos, sz Vec2D) image.Rectangle

RectFromPosSize returns an image.Rectangle from max dims of pos, size (floor on pos, ceil on size)

func SavePNG

func SavePNG(path string, im image.Image) error

func SetButtonIcon

func SetButtonIcon(bw ButtonWidget, ic *Icon)

set the Icon (could be nil) and update button

func SetButtonText

func SetButtonText(bw ButtonWidget, txt string)

set the text and update button

func SignalViewport2D

func SignalViewport2D(vpki, send ki.Ki, sig int64, data interface{})

each node calls this signal method to notify its parent viewport whenever it changes, causing a re-render

func SignalWindowFlush

func SignalWindowFlush(winki, node ki.Ki, sig int64, data interface{})

func SrcNodeSignal

func SrcNodeSignal(tvki, send ki.Ki, sig int64, data interface{})

function for receiving node signals from our SrcNode

func StringPromptDialogValue

func StringPromptDialogValue(dlg *Dialog) string

StringPromptValue gets the string value the user set

func StyleCSSWidget

func StyleCSSWidget(node Node2D, css ki.Props)

func StyleEffTag

func StyleEffTag(tag, outerTag string) string

get the full effective tag based on outer tag plus given tag

func StyleUnitsValue

func StyleUnitsValue(tag string, uv *units.Value, props ki.Props) bool

manual method for getting a units value directly

func TabButtonClicked

func TabButtonClicked(recv, send ki.Ki, sig int64, d interface{})

func ToLabel

func ToLabel(it interface{}) string

ToLabel returns the gui-appropriate label for an item, using the Labeler interface if it is defined, and falling back on kit.ToString converter otherwise -- also contains label impls for basic interface types for which we cannot easily define the Labeler interface

func Truncate

func Truncate(val float64, prec int) float64

Truncate a floating point number to given level of precision -- slow.. uses string conversion

func Truncate32

func Truncate32(val float32, prec int) float32

Truncate a floating point number to given level of precision -- slow.. uses string conversion

func WalkStyleStruct

func WalkStyleStruct(obj interface{}, outerTag string, baseoff uintptr, fun WalkStyleFieldFunc)

WalkStyleStruct walks through a struct, calling a function on fields with xml tags that are not "-", recursively through all the fields

Types

type Action

type Action struct {
	ButtonBase
	Data      interface{} `json:"-" xml:"-" desc:"optional data that is sent with the ActionSig when it is emitted"`
	ActionSig ki.Signal   `` /* 148-byte string literal not displayed */
}

Action is a button widget that can display a text label and / or an icon and / or a keyboard shortcut -- this is what is put in menus and toolbars

func (*Action) ButtonAsBase

func (g *Action) ButtonAsBase() *ButtonBase

func (*Action) ButtonRelease

func (g *Action) ButtonRelease()

trigger action signal

func (*Action) ConfigParts

func (g *Action) ConfigParts()

func (*Action) ConfigPartsButton

func (g *Action) ConfigPartsButton()

func (*Action) ConfigPartsMenu

func (g *Action) ConfigPartsMenu()

func (*Action) Init2D

func (g *Action) Init2D()

func (*Action) New

func (n *Action) New() ki.Ki

type Align

type Align int32

all different types of alignment -- only some are applicable to different contexts, but there is also so much overlap that it makes sense to have them all in one list -- some are not standard CSS and used by layout

const (
	AlignLeft Align = iota
	AlignTop
	AlignCenter
	// middle = vertical version of center
	AlignMiddle
	AlignRight
	AlignBottom
	AlignBaseline
	// same as CSS space-between
	AlignJustify
	AlignSpaceAround
	AlignFlexStart
	AlignFlexEnd
	AlignTextTop
	AlignTextBottom
	// align to subscript
	AlignSub
	// align to superscript
	AlignSuper
	AlignN
)

func (*Align) FromString

func (i *Align) FromString(s string) error

func (Align) MarshalJSON

func (ev Align) MarshalJSON() ([]byte, error)

func (Align) String

func (i Align) String() string

func (*Align) UnmarshalJSON

func (ev *Align) UnmarshalJSON(b []byte) error

type BackgroundStyle

type BackgroundStyle struct {
	Color Color `xml:"color" desc:"background color"`
}

style parameters for backgrounds

func (*BackgroundStyle) Defaults

func (b *BackgroundStyle) Defaults()

type BoolValueView

type BoolValueView struct {
	ValueViewBase
}

BoolValueView presents a checkbox for a boolean

func (*BoolValueView) ConfigWidget

func (vv *BoolValueView) ConfigWidget(widg Node2D)

func (*BoolValueView) New

func (n *BoolValueView) New() ki.Ki

func (*BoolValueView) UpdateWidget

func (vv *BoolValueView) UpdateWidget()

func (*BoolValueView) WidgetType

func (vv *BoolValueView) WidgetType() reflect.Type

type BorderDrawStyle

type BorderDrawStyle int32

how to draw the border

const (
	BorderSolid BorderDrawStyle = iota
	BorderDotted
	BorderDashed
	BorderDouble
	BorderGroove
	BorderRidge
	BorderInset
	BorderOutset
	BorderNone
	BorderHidden
	BorderN
)

func (*BorderDrawStyle) FromString

func (i *BorderDrawStyle) FromString(s string) error

func (BorderDrawStyle) MarshalJSON

func (ev BorderDrawStyle) MarshalJSON() ([]byte, error)

func (BorderDrawStyle) String

func (i BorderDrawStyle) String() string

func (*BorderDrawStyle) UnmarshalJSON

func (ev *BorderDrawStyle) UnmarshalJSON(b []byte) error

type BorderStyle

type BorderStyle struct {
	Style  BorderDrawStyle `xml:"style" desc:"how to draw the border"`
	Width  units.Value     `xml:"width" desc:"width of the border"`
	Radius units.Value     `xml:"radius" desc:"rounding of the corners"`
	Color  Color           `xml:"color" desc:"color of the border"`
}

style parameters for borders

type BoxSides

type BoxSides int32

sides of a box -- some properties can be specified per each side (e.g., border) or not

const (
	BoxTop BoxSides = iota
	BoxRight
	BoxBottom
	BoxLeft
	BoxN
)

func (*BoxSides) FromString

func (i *BoxSides) FromString(s string) error

func (BoxSides) MarshalJSON

func (ev BoxSides) MarshalJSON() ([]byte, error)

func (BoxSides) String

func (i BoxSides) String() string

func (*BoxSides) UnmarshalJSON

func (ev *BoxSides) UnmarshalJSON(b []byte) error

type Button

type Button struct {
	ButtonBase
}

Button is a standard command button -- PushButton in Qt Widgets, and Button in Qt Quick -- by default it puts the icon to the left and the text to the right

func (*Button) ButtonAsBase

func (g *Button) ButtonAsBase() *ButtonBase

func (*Button) New

func (n *Button) New() ki.Ki

type ButtonBase

type ButtonBase struct {
	WidgetBase
	Text         string               `xml:"text" desc:"label for the button -- if blank then no label is presented"`
	Icon         *Icon                `` /* 151-byte string literal not displayed */
	Indicator    string               `` /* 157-byte string literal not displayed */
	Shortcut     string               `xml:"shortcut" desc:"keyboard shortcut -- todo: need to figure out ctrl, alt etc"`
	StateStyles  [ButtonStatesN]Style `` /* 237-byte string literal not displayed */
	State        ButtonStates         `json:"-" xml:"-" desc:"current state of the button based on gui interaction"`
	ButtonSig    ki.Signal            `json:"-" xml:"-" desc:"signal for button -- see ButtonSignals for the types"`
	Menu         ki.Slice             `desc:"the menu items for this menu -- typically add Action elements for menus, along with separators"`
	MakeMenuFunc MakeMenuFunc         `json:"-" xml:"-" desc:"set this to make a menu on demand -- if set then this button acts like a menu button"`
}

ButtonBase has common button functionality for all buttons, including Button, Action, MenuButton, CheckBox, etc

var ButtonBaseDefault ButtonBase

ButtonBaseDefault is default obj that can be used when property specifies "default"

func (*ButtonBase) AddMenuText

func (g *ButtonBase) AddMenuText(txt string, sigTo ki.Ki, data interface{}, fun ki.RecvFunc) *Action

AddMenuText adds an action to the menu with a text label -- todo: shortcuts

func (*ButtonBase) AddSeparator

func (g *ButtonBase) AddSeparator(name string) *Separator

AddSeparator adds a separator at the next point in the menu

func (*ButtonBase) ButtonAsBase

func (g *ButtonBase) ButtonAsBase() *ButtonBase

func (*ButtonBase) ButtonEnterHover

func (g *ButtonBase) ButtonEnterHover()

button starting hover-- todo: keep track of time and popup a tooltip -- signal?

func (*ButtonBase) ButtonExitHover

func (g *ButtonBase) ButtonExitHover()

button exiting hover

func (*ButtonBase) ButtonPressed

func (g *ButtonBase) ButtonPressed()

set the button in the down state -- mouse clicked down but not yet up -- emits ButtonPressed signal -- ButtonClicked is down and up

func (*ButtonBase) ButtonRelease

func (g *ButtonBase) ButtonRelease()

func (*ButtonBase) ButtonReleased

func (g *ButtonBase) ButtonReleased()

the button has just been released -- sends a released signal and returns state to normal, and emits clicked signal if if it was previously in pressed state

func (*ButtonBase) ConfigParts

func (g *ButtonBase) ConfigParts()

func (*ButtonBase) ConfigPartsAddIndicator

func (g *ButtonBase) ConfigPartsAddIndicator(config *kit.TypeAndNameList, defOn bool) int

ConfigPartsAddIndicator adds a menu indicator if there is a menu present, and the Indicator field is not "none" -- defOn = true means default to adding the indicator even if no menu is yet present -- returns the index in Parts of the indicator object, which is named "indicator" -- an "indic-stretch" is added as well to put on the right by default

func (*ButtonBase) ConfigPartsIfNeeded

func (g *ButtonBase) ConfigPartsIfNeeded()

func (*ButtonBase) ConfigPartsIndicator

func (g *ButtonBase) ConfigPartsIndicator(indIdx int)

func (*ButtonBase) FocusChanged2D

func (g *ButtonBase) FocusChanged2D(gotFocus bool)

func (*ButtonBase) HasMenu

func (g *ButtonBase) HasMenu() bool

HasMenu returns true if there is a menu or menu-making function set, or the explicit ButtonFlagMenu has been set

func (*ButtonBase) Init2D

func (g *ButtonBase) Init2D()

func (*ButtonBase) IsCheckable

func (g *ButtonBase) IsCheckable() bool

is this button checkable

func (*ButtonBase) IsChecked

func (g *ButtonBase) IsChecked() bool

is this button checked

func (*ButtonBase) IsMenu

func (g *ButtonBase) IsMenu() bool

IsMenu returns true this button is on a menu -- it is a menu item

func (*ButtonBase) IsSelected

func (g *ButtonBase) IsSelected() bool

is this button selected?

func (*ButtonBase) Layout2D

func (g *ButtonBase) Layout2D(parBBox image.Rectangle)

func (*ButtonBase) New

func (n *ButtonBase) New() ki.Ki

func (*ButtonBase) OpenMenu

func (g *ButtonBase) OpenMenu() bool

OpenMenu will open any menu associated with this element -- returns true if menu opened, false if not

func (*ButtonBase) Render2D

func (g *ButtonBase) Render2D()

func (*ButtonBase) Render2DDefaultStyle

func (g *ButtonBase) Render2DDefaultStyle()

func (*ButtonBase) ResetMenu

func (g *ButtonBase) ResetMenu()

ResetMenu removes all items in the menu

func (*ButtonBase) SetAsButton

func (g *ButtonBase) SetAsButton()

SetAsButton clears the explicit ButtonFlagMenu -- if there are menu items or a menu function then it will still behave as a menu

func (*ButtonBase) SetAsMenu

func (g *ButtonBase) SetAsMenu()

SetAsMenu ensures that this functions as a menu even before menu items are added

func (*ButtonBase) SetButtonState

func (g *ButtonBase) SetButtonState(state ButtonStates)

set the button state to target

func (*ButtonBase) SetCheckable

func (g *ButtonBase) SetCheckable(checkable bool)

SetCheckable sets whether this button is checkable -- emits ButtonToggled signals if so

func (*ButtonBase) SetChecked

func (g *ButtonBase) SetChecked(chk bool)

set the checked state of this button -- does not emit signal or update

func (*ButtonBase) SetIcon

func (g *ButtonBase) SetIcon(ic *Icon)

SetIcon sets the Icon (could be nil) and updates the button

func (*ButtonBase) SetSelected

func (g *ButtonBase) SetSelected(sel bool)

set the selected state of this button -- does not emit signal or update

func (*ButtonBase) SetText

func (g *ButtonBase) SetText(txt string)

SetText sets the text and updates the button

func (*ButtonBase) Style2D

func (g *ButtonBase) Style2D()

func (*ButtonBase) Style2DWidget

func (g *ButtonBase) Style2DWidget()

func (*ButtonBase) ToggleChecked

func (g *ButtonBase) ToggleChecked()

ToggleChecked toggles the checked state of this button -- does not emit signal or update

type ButtonSignals

type ButtonSignals int64

signals that buttons can send

const (
	// ButtonClicked is the main signal to check for normal button activation
	// -- button pressed down and up
	ButtonClicked ButtonSignals = iota

	// Pressed means button pushed down but not yet up
	ButtonPressed

	// Released means mose button was released - typically look at
	// ButtonClicked instead of this one
	ButtonReleased

	// Toggled means the checked / unchecked state was toggled -- only sent
	// for buttons with Checkable flag set
	ButtonToggled

	ButtonSignalsN
)

func (*ButtonSignals) FromString

func (i *ButtonSignals) FromString(s string) error

func (ButtonSignals) String

func (i ButtonSignals) String() string

type ButtonStates

type ButtonStates int32

mutually-exclusive button states -- determines appearance

const (
	// normal active state -- there but not being interacted with
	ButtonActive ButtonStates = iota

	// inactive -- not pressable -- no events
	ButtonInactive

	// mouse is hovering over the button
	ButtonHover

	// button is the focus -- will respond to keyboard input
	ButtonFocus

	// button is currently being pressed down
	ButtonDown

	// button has been selected -- maintains selected state
	ButtonSelected

	// total number of button states
	ButtonStatesN
)

func (*ButtonStates) FromString

func (i *ButtonStates) FromString(s string) error

func (ButtonStates) MarshalJSON

func (ev ButtonStates) MarshalJSON() ([]byte, error)

func (ButtonStates) String

func (i ButtonStates) String() string

func (*ButtonStates) UnmarshalJSON

func (ev *ButtonStates) UnmarshalJSON(b []byte) error

type ButtonWidget

type ButtonWidget interface {
	// get the button base for most basic functions -- reduces interface size
	ButtonAsBase() *ButtonBase
	// called for release of button -- this is where buttons actually differ in functionality
	ButtonRelease()
	// configure the parts of the button -- called during init and style
	ConfigParts()
	// configure the parts of the button, only if needed -- called during layout and render
	ConfigPartsIfNeeded()
}

ButtonWidget is an interface for button widgets allowing ButtonBase defaults to handle most cases

type CheckBox

type CheckBox struct {
	ButtonBase
	IconOff *Icon `json:"-" xml:"-" desc:"icon to use for the off, unchecked state of the icon -- plain Icon holds the On state"`
}

CheckBox toggles between a checked and unchecked state

func (*CheckBox) ButtonAsBase

func (g *CheckBox) ButtonAsBase() *ButtonBase

func (*CheckBox) ButtonRelease

func (g *CheckBox) ButtonRelease()

func (*CheckBox) ConfigParts

func (g *CheckBox) ConfigParts()

func (*CheckBox) ConfigPartsIfNeeded

func (g *CheckBox) ConfigPartsIfNeeded()

func (*CheckBox) Init2D

func (g *CheckBox) Init2D()

func (*CheckBox) New

func (n *CheckBox) New() ki.Ki

func (*CheckBox) SetIcons

func (g *CheckBox) SetIcons(icOn, icOff *Icon)

set the Icons for the On (checked) and Off (unchecked) states, and updates button

type Circle

type Circle struct {
	Node2DBase
	Pos    Vec2D   `xml:"{cx,cy}" desc:"position of the center of the circle"`
	Radius float32 `xml:"r" desc:"radius of the circle"`
}

2D circle

func (*Circle) BBox2D

func (g *Circle) BBox2D() image.Rectangle

func (*Circle) New

func (n *Circle) New() ki.Ki

func (*Circle) ReRender2D

func (g *Circle) ReRender2D() (node Node2D, layout bool)

func (*Circle) Render2D

func (g *Circle) Render2D()

type Color

type Color struct {
	R, G, B, A uint8
}

Color extends image/color.RGBA with more methods for converting to / from strings etc -- it has standard uint8 0..255 color values

var NilColor Color

func ColorFromString

func ColorFromString(str string, base color.Color) (Color, error)

ColorFromString returns a new color set from given string and optional base color for transforms -- see SetString

func (*Color) Blend

func (c *Color) Blend(pct float32, clr color.Color) Color

Blend returns a color that is the given percent blend between current color and given clr -- 10 = 10% of the clr and 90% of the current color, etc -- blending is done directly on non-pre-multiplied RGB values

func (*Color) Clearer

func (c *Color) Clearer(pct float32) Color

Clearer returns a color that is given percent more transparent (lower alpha value) relative to current alpha level

func (*Color) Darker

func (c *Color) Darker(pct float32) Color

Darker returns a color that is darker by the given percent, e.g., 50 = 50% darker, relative to maximum possible darkness -- converts to HSL, multiplies the L factor, and then converts back to RGBA

func (*Color) IsNil

func (c *Color) IsNil() bool

check if color is the nil initial default color -- a = 0 means fully transparent black

func (*Color) Lighter

func (c *Color) Lighter(pct float32) Color

Lighter returns a color that is lighter by the given percent, e.g., 50 = 50% lighter, relative to maximum possible lightness -- converts to HSL, multiplies the L factor, and then converts back to RGBA

func (*Color) Opaquer

func (c *Color) Opaquer(pct float32) Color

Opaquer returns a color that is given percent more opaque (higher alpha value) relative to current alpha level

func (*Color) ParseHex

func (c *Color) ParseHex(x string) error

parse Hex color -- this is from fogelman/gg I think..

func (*Color) Pastel

func (c *Color) Pastel(pct float32) Color

Pastel returns a color that is less saturated (more pastel-like) by the given percent: 100 = 100% less saturated (i.e., grey) -- converts to HSL, multiplies the S factor, and then converts back to RGBA

func (Color) RGBA

func (c Color) RGBA() (r, g, b, a uint32)

implements color.Color interface -- returns values in range 0x0000 - 0xffff

func (*Color) Saturate

func (c *Color) Saturate(pct float32) Color

Saturate returns a color that is more saturated by the given percent: 100 = 100% more saturated, etc -- converts to HSL, multiplies the S factor, and then converts back to RGBA

func (*Color) SetColor

func (c *Color) SetColor(ci color.Color)

func (*Color) SetFloat32

func (c *Color) SetFloat32(r, g, b, a float32)

Convert from 0-1 normalized floating point numbers

func (*Color) SetFloat64

func (c *Color) SetFloat64(r, g, b, a float64)

Convert from 0-1 normalized floating point numbers

func (*Color) SetHSL

func (c *Color) SetHSL(h, s, l float32)

Convert from HSL: [0..360], Saturation [0..1], and Luminance (lightness) [0..1] of the color using float32 values

func (*Color) SetHSLA

func (c *Color) SetHSLA(h, s, l, a float32)

Convert from HSLA: [0..360], Saturation [0..1], and Luminance (lightness) [0..1] of the color using float32 values

func (*Color) SetInt

func (c *Color) SetInt(r, g, b, a int)

func (*Color) SetNPFloat32

func (c *Color) SetNPFloat32(r, g, b, a float32)

Convert from 0-1 normalized floating point numbers, non alpha-premultiplied

func (*Color) SetString

func (c *Color) SetString(str string, base color.Color) error

SetString sets color value from string, including # hex specs, standard color names, "none" or "off", or the following transformations (which use a non-nil base color as the starting point, if it is provided):

* lighter-PCT or darker-PCT: PCT is amount to lighten or darken (using HSL), e.g., 10=10% * saturate-PCT or pastel-PCT: manipulates the saturation level in HSL by PCT * clearer-PCT or opaquer-PCT: manipulates the alpha level by PCT * blend-PCT-color: blends given percent of given color name relative to base (or current)

func (*Color) SetToNil

func (c *Color) SetToNil()

func (*Color) SetUInt32

func (c *Color) SetUInt32(r, g, b, a uint32)

func (*Color) SetUInt8

func (c *Color) SetUInt8(r, g, b, a uint8)

func (Color) ToFloat32

func (c Color) ToFloat32() (r, g, b, a float32)

Convert to 0-1 normalized floating point numbers, still alpha-premultiplied

func (*Color) ToHSLA

func (c *Color) ToHSLA() (h, s, l, a float32)

Convert to HSLA: [0..360], Saturation [0..1], and Luminance (lightness) [0..1] of the color using float32 values

func (Color) ToNPFloat32

func (c Color) ToNPFloat32() (r, g, b, a float32)

Convert to 0-1 normalized floating point numbers, not alpha premultiplied

func (Color) ValueView

func (cl Color) ValueView() ValueView

This registers the color value view as the view for Color types

type ColorValueView

type ColorValueView struct {
	ValueViewBase
}

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

func (*ColorValueView) ConfigWidget

func (vv *ColorValueView) ConfigWidget(widg Node2D)

func (*ColorValueView) New

func (n *ColorValueView) New() ki.Ki

func (*ColorValueView) UpdateWidget

func (vv *ColorValueView) UpdateWidget()

func (*ColorValueView) WidgetType

func (vv *ColorValueView) WidgetType() reflect.Type

type ColorView

type ColorView struct {
	Frame
	Color   *Color    `desc:"the color that we view"`
	Title   string    `desc:"title / prompt to show above the editor fields"`
	TmpSave ValueView `` /* 189-byte string literal not displayed */
	ViewSig ki.Signal `` /* 179-byte string literal not displayed */
}

ColorView represents a color, using sliders to set values

func (*ColorView) ButtonBox

func (sv *ColorView) ButtonBox() (*Layout, int)

ButtonBox returns the ButtonBox layout widget, and its index, within frame -- nil, -1 if not found

func (*ColorView) Config

func (sv *ColorView) Config()

Config configures a standard setup of entire view

func (*ColorView) ConfigHSLSlider

func (sv *ColorView) ConfigHSLSlider(sl *Slider, hsl int)

func (*ColorView) ConfigLabel

func (sv *ColorView) ConfigLabel(lab *Label, txt string)

func (*ColorView) ConfigRGBSlider

func (sv *ColorView) ConfigRGBSlider(sl *Slider, rgb int)

func (*ColorView) ConfigSliderGrid

func (sv *ColorView) ConfigSliderGrid()

ConfigSliderGrid configures the SliderGrid

func (*ColorView) New

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

func (*ColorView) ReRender2D

func (sv *ColorView) ReRender2D() (node Node2D, layout bool)

func (*ColorView) Render2D

func (sv *ColorView) Render2D()

func (*ColorView) SetColor

func (sv *ColorView) SetColor(color *Color, tmpSave ValueView)

SetColor sets the source color

func (*ColorView) SetFrame

func (sv *ColorView) SetFrame()

SetFrame configures view as a frame

func (*ColorView) SetHSLValue

func (sv *ColorView) SetHSLValue(val float32, hsl int)

func (*ColorView) SetRGBValue

func (sv *ColorView) SetRGBValue(val float32, rgb int)

func (*ColorView) SetTitle

func (sv *ColorView) SetTitle(title string)

SetTitle sets the title and updates the Title label

func (*ColorView) SliderGrid

func (sv *ColorView) SliderGrid() (*Layout, int)

func (*ColorView) StdFrameConfig

func (sv *ColorView) StdFrameConfig() kit.TypeAndNameList

StdFrameConfig returns a TypeAndNameList for configuring a standard Frame -- can modify as desired before calling ConfigChildren on Frame using this

func (*ColorView) StdSliderConfig

func (sv *ColorView) StdSliderConfig() kit.TypeAndNameList

StdSliderConfig returns a TypeAndNameList for configuring a standard sliders

func (*ColorView) StdValueLayConfig

func (sv *ColorView) StdValueLayConfig() kit.TypeAndNameList

func (*ColorView) Style2D

func (sv *ColorView) Style2D()

func (*ColorView) TitleWidget

func (sv *ColorView) TitleWidget() (*Label, int)

Title returns the title label widget, and its index, within frame -- nil, -1 if not found

func (*ColorView) Update

func (sv *ColorView) Update()

func (*ColorView) UpdateHSLSlider

func (sv *ColorView) UpdateHSLSlider(sl *Slider, hsl int)

func (*ColorView) UpdateRGBSlider

func (sv *ColorView) UpdateRGBSlider(sl *Slider, rgb int)

func (*ColorView) UpdateSliderGrid

func (sv *ColorView) UpdateSliderGrid()

func (*ColorView) Value

func (sv *ColorView) Value() (*Frame, int)

func (*ColorView) ValueLay

func (sv *ColorView) ValueLay() (*Layout, int)

func (*ColorView) ValueLayConfig

func (sv *ColorView) ValueLayConfig()

type ComboBox

type ComboBox struct {
	ButtonBase
	Editable  bool          `desc:"provide a text field for editing the value, or just a button for selecting items?"`
	CurVal    interface{}   `json:"-" xml:"-" desc:"current selected value"`
	CurIndex  int           `json:"-" xml:"-" desc:"current index in list of possible items"`
	Items     []interface{} `json:"-" xml:"-" desc:"items available for selection"`
	ItemsMenu ki.Slice      `json:"-" xml:"-" desc:"the menu of actions for selecting items -- automatically generated from Items"`
	ComboSig  ki.Signal     `` /* 160-byte string literal not displayed */
	MaxLength int           `desc:"maximum label length (in runes)"`
}

func (*ComboBox) ButtonAsBase

func (g *ComboBox) ButtonAsBase() *ButtonBase

func (*ComboBox) ButtonRelease

func (g *ComboBox) ButtonRelease()

func (*ComboBox) ConfigParts

func (g *ComboBox) ConfigParts()

func (*ComboBox) ConfigPartsIfNeeded

func (g *ComboBox) ConfigPartsIfNeeded()

func (*ComboBox) FindItem

func (g *ComboBox) FindItem(it interface{}) int

FindItem finds an item on list of items and returns its index

func (*ComboBox) FocusChanged2D

func (g *ComboBox) FocusChanged2D(gotFocus bool)

func (*ComboBox) Init2D

func (g *ComboBox) Init2D()

func (*ComboBox) ItemsFromEnum

func (g *ComboBox) ItemsFromEnum(enumtyp reflect.Type, setFirst bool, maxLen int)

ItemsFromEnum sets the Items list from an enum type, which must be registered on kit.EnumRegistry -- if setFirst then set current item to the first item in the list, and maxLen if > 0 auto-sets the width of the button to the contents, with the given upper limit -- see kit.EnumRegistry, and maxLen if > 0 auto-sets the width of the button to the contents, with the given upper limit

func (*ComboBox) ItemsFromEnumList

func (g *ComboBox) ItemsFromEnumList(el []kit.EnumValue, setFirst bool, maxLen int)

ItemsFromEnumList sets the Items list from a list of enum values (see kit.EnumRegistry) -- if setFirst then set current item to the first item in the list, and maxLen if > 0 auto-sets the width of the button to the contents, with the given upper limit

func (*ComboBox) ItemsFromTypes

func (g *ComboBox) ItemsFromTypes(tl []reflect.Type, setFirst, sort bool, maxLen int)

ItemsFromTypes sets the Items list from a list of types -- see e.g., AllImplementersOf or AllEmbedsOf in kit.TypeRegistry -- if setFirst then set current item to the first item in the list, sort sorts the list in ascending order, and maxLen if > 0 auto-sets the width of the button to the contents, with the given upper limit

func (*ComboBox) Layout2D

func (g *ComboBox) Layout2D(parBBox image.Rectangle)

func (*ComboBox) MakeItems

func (g *ComboBox) MakeItems(reset bool, capacity int)

MakeItems makes sure the Items list is made, and if not, or reset is true, creates one with the given capacity

func (*ComboBox) MakeItemsMenu

func (g *ComboBox) MakeItemsMenu()

make menu of all the items

func (*ComboBox) New

func (n *ComboBox) New() ki.Ki

func (*ComboBox) Render2D

func (g *ComboBox) Render2D()

func (*ComboBox) Render2DDefaultStyle

func (g *ComboBox) Render2DDefaultStyle()

render using a default style if not otherwise styled

func (*ComboBox) SelectItem

func (g *ComboBox) SelectItem(idx int)

SelectItem selects a given item and emits the index as the ComboSig signal and the selected item as the data

func (*ComboBox) SetCurIndex

func (g *ComboBox) SetCurIndex(idx int) interface{}

SetCurIndex sets the current index (CurIndex) and the corresponding CurVal for that item on the current Items list (-1 if not found) -- returns value -- and sets the text to the string value of that value (using standard Stringer string conversion)

func (*ComboBox) SetCurVal

func (g *ComboBox) SetCurVal(it interface{}) int

SetCurVal sets the current value (CurVal) and the corresponding CurIndex for that item on the current Items list (adds to items list if not found) -- returns that index -- and sets the text to the string value of that value (using standard Stringer string conversion)

func (*ComboBox) SetIcon

func (g *ComboBox) SetIcon(ic *Icon)

set the Icon (could be nil) and update button

func (*ComboBox) SetText

func (g *ComboBox) SetText(txt string)

set the text and update button -- does NOT change the currently-selected value or index

func (*ComboBox) SetToMaxLength

func (g *ComboBox) SetToMaxLength(maxLen int)

SetToMaxLength gets the maximum label length so that the width of the button label is automatically set according to the max length of all items in the list -- if maxLen > 0 then it is used as an upper do-not-exceed length

func (*ComboBox) Size2D

func (g *ComboBox) Size2D()

func (*ComboBox) SortItems

func (g *ComboBox) SortItems(ascending bool)

SortItems sorts the items according to their labels

func (*ComboBox) Style2D

func (g *ComboBox) Style2D()

type Dialog

type Dialog struct {
	Viewport2D
	Title     string      `desc:"title text displayed at the top row of the dialog"`
	Prompt    string      `desc:"a prompt string displayed below the title"`
	Modal     bool        `desc:"open the dialog in a modal state, blocking all other input"`
	State     DialogState `desc:"state of the dialog"`
	DialogSig ki.Signal   `json:"-" xml:"-" desc:"signal for dialog -- sends a signal when opened, accepted, or canceled"`
}

Dialog supports dialog functionality -- based on a viewport that can either be rendered in a separate window or on top of an existing one

func ColorViewDialog

func ColorViewDialog(avp *Viewport2D, clr *Color, tmpSave ValueView, title, prompt string, recv ki.Ki, fun ki.RecvFunc) *Dialog

ColorViewDialog for editing a color using a ColorView -- optionally connects to given signal receiving object and function for dialog signals (nil to ignore)

func MapViewDialog

func MapViewDialog(avp *Viewport2D, mp interface{}, tmpSave ValueView, title, prompt string, recv ki.Ki, fun ki.RecvFunc) *Dialog

MapViewDialog is for editing elements of a map using a MapView -- optionally connects to given signal receiving object and function for dialog signals (nil to ignore)

func NewKiDialog

func NewKiDialog(avp *Viewport2D, iface reflect.Type, title, prompt string, recv ki.Ki, fun ki.RecvFunc) *Dialog

New Ki item(s) of type dialog, showing types that implement given interface -- use construct of form: reflect.TypeOf((*gi.Node2D)(nil)).Elem() to get the interface type -- optionally connects to given signal receiving object and function for dialog signals (nil to ignore)

func NewStdDialog

func NewStdDialog(name, title, prompt string, ok, cancel bool) *Dialog

NewStdDialog returns a basic standard dialog with a name, title, prompt, and ok / cancel buttons -- any empty text will not be added -- returns with UpdateStart started but NOT ended -- must call UpdateEnd(true) once done configuring!

func SliceViewDialog

func SliceViewDialog(avp *Viewport2D, mp interface{}, tmpSave ValueView, title, prompt string, recv ki.Ki, fun ki.RecvFunc) *Dialog

SliceViewDialog for editing elements of a slice using a SliceView -- optionally connects to given signal receiving object and function for dialog signals (nil to ignore)

func StringPromptDialog

func StringPromptDialog(avp *Viewport2D, strval, title, prompt string, recv ki.Ki, fun ki.RecvFunc) *Dialog

StringPromptDialog prompts the user for a string value -- optionally connects to given signal receiving object and function for dialog signals (nil to ignore)

func StructViewDialog

func StructViewDialog(avp *Viewport2D, stru interface{}, tmpSave ValueView, title, prompt string, recv ki.Ki, fun ki.RecvFunc) *Dialog

StructViewDialog is for editing fields of a structure using a StructView -- optionally connects to given signal receiving object and function for dialog signals (nil to ignore)

func (*Dialog) Accept

func (dlg *Dialog) Accept()

Accept accepts the dialog, activated by the default Ok button

func (*Dialog) AddButtonBox

func (dlg *Dialog) AddButtonBox(spaceBefore float32, stretchBefore bool, frame *Frame) *Layout

AddButtonBox adds a button box (Row Layout) named "buttons" to given frame, with optional fixed space and stretch elements before it

func (*Dialog) ButtonBox

func (dlg *Dialog) ButtonBox(frame *Frame) (*Layout, int)

ButtonBox returns the ButtonBox layout widget, and its index, within frame -- nil, -1 if not found

func (*Dialog) Cancel

func (dlg *Dialog) Cancel()

Cancel cancels the dialog, activated by the default Cancel button

func (*Dialog) Close

func (dlg *Dialog) Close()

Close requests that the dialog be closed -- it does not alter any state or send any signals

func (*Dialog) Frame

func (dlg *Dialog) Frame() *Frame

Frame returns the main frame for the dialog, assumed to be the first element in the dialog

func (*Dialog) HasFocus2D

func (dlg *Dialog) HasFocus2D() bool

func (*Dialog) Init2D

func (dlg *Dialog) Init2D()

func (*Dialog) New

func (n *Dialog) New() ki.Ki

func (*Dialog) Open

func (dlg *Dialog) Open(x, y int, avp *Viewport2D) bool

Open this dialog, in given location (0 = middle of window), finding window from given viewport -- returns false if it fails for any reason

func (*Dialog) PromptWidget

func (dlg *Dialog) PromptWidget(frame *Frame) (*Label, int)

Prompt returns the prompt label widget, and its index, within frame -- if nil returns the title widget (flexible if prompt is nil)

func (*Dialog) SetFrame

func (dlg *Dialog) SetFrame() *Frame

SetFrame creates a standard vertical column frame layout as first element of the dialog, named "frame"

func (*Dialog) SetPrompt

func (dlg *Dialog) SetPrompt(prompt string, spaceBefore float32, frame *Frame) *Label

SetPrompt sets the prompt and adds a Label named "prompt" to the given frame layout if passed, with the given amount of space before it, sized in "Em"'s (units of font size), if > 0

func (*Dialog) SetTitle

func (dlg *Dialog) SetTitle(title string, frame *Frame) *Label

SetTitle sets the title and adds a Label named "title" to the given frame layout if passed

func (*Dialog) StdButtonConfig

func (dlg *Dialog) StdButtonConfig(stretch, ok, cancel bool) kit.TypeAndNameList

StdButtonConfig returns a kit.TypeAndNameList for calling on ConfigChildren of a button box, to create standard Ok, Cancel buttons (if true), optionally starting with a Stretch element that will cause the buttons to be arranged on the right -- a space element is added between buttons if more than one

func (*Dialog) StdButtonConnect

func (dlg *Dialog) StdButtonConnect(ok, cancel bool, bb *Layout)

StdButtonConnnect connects standard buttons in given button box layout to Accept / Cancel actions

func (*Dialog) StdDialog

func (dlg *Dialog) StdDialog(title, prompt string, ok, cancel bool)

StdDialog configures a basic standard dialog with a title, prompt, and ok / cancel buttons -- any empty text will not be added

func (*Dialog) TitleWidget

func (dlg *Dialog) TitleWidget(frame *Frame) (*Label, int)

Title returns the title label widget, and its index, within frame -- nil, -1 if not found

type DialogState

type DialogState int64

state of the dialog

const (
	// existential state -- struct exists and is likely being constructed
	DialogExists DialogState = iota
	// dialog is open in a modal state, blocking all other input
	DialogOpenModal
	// dialog is open in a modeless state, allowing other input
	DialogOpenModeless
	// Ok was pressed -- dialog accepted
	DialogAccepted
	// Cancel was pressed -- button canceled
	DialogCanceled
	DialogStateN
)

func (*DialogState) FromString

func (i *DialogState) FromString(s string) error

func (DialogState) String

func (i DialogState) String() string

type Dims2D

type Dims2D int32

dimensions

const (
	X Dims2D = iota
	Y
	Dims2DN
)

func OtherDim

func OtherDim(d Dims2D) Dims2D

get the other dimension

func (*Dims2D) FromString

func (i *Dims2D) FromString(s string) error

func (Dims2D) MarshalJSON

func (ev Dims2D) MarshalJSON() ([]byte, error)

func (Dims2D) String

func (i Dims2D) String() string

func (*Dims2D) UnmarshalJSON

func (ev *Dims2D) UnmarshalJSON(b []byte) error

type Ellipse

type Ellipse struct {
	Node2DBase
	Pos   Vec2D `xml:"{cx,cy}" desc:"position of the center of the ellipse"`
	Radii Vec2D `xml:"{rx, ry}" desc:"radii of the ellipse in the horizontal, vertical axes"`
}

2D ellipse

func (*Ellipse) BBox2D

func (g *Ellipse) BBox2D() image.Rectangle

func (*Ellipse) New

func (n *Ellipse) New() ki.Ki

func (*Ellipse) ReRender2D

func (g *Ellipse) ReRender2D() (node Node2D, layout bool)

func (*Ellipse) Render2D

func (g *Ellipse) Render2D()

type EnumValueView

type EnumValueView struct {
	ValueViewBase
}

EnumValueView presents a combobox for choosing enums

func (*EnumValueView) ConfigWidget

func (vv *EnumValueView) ConfigWidget(widg Node2D)

func (*EnumValueView) EnumType

func (vv *EnumValueView) EnumType() reflect.Type

func (*EnumValueView) New

func (n *EnumValueView) New() ki.Ki

func (*EnumValueView) SetEnumValueFromInt

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

func (*EnumValueView) UpdateWidget

func (vv *EnumValueView) UpdateWidget()

func (*EnumValueView) WidgetType

func (vv *EnumValueView) WidgetType() reflect.Type

type FieldValueViewer

type FieldValueViewer interface {
	FieldValueView(field string, fval interface{}) ValueView
}

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

type FillRule

type FillRule int
const (
	FillRuleNonZero FillRule = iota
	FillRuleEvenOdd
	FillRuleN
)

func (*FillRule) FromString

func (i *FillRule) FromString(s string) error

func (FillRule) MarshalJSON

func (ev FillRule) MarshalJSON() ([]byte, error)

func (FillRule) String

func (i FillRule) String() string

func (*FillRule) UnmarshalJSON

func (ev *FillRule) UnmarshalJSON(b []byte) error

type FillStyle

type FillStyle struct {
	On      bool        `desc:"is fill active -- if property is none then false"`
	Color   Color       `xml:"fill" desc:"default fill color when such a color is needed -- Server could be anything"`
	Opacity float64     `xml:"fill-opacity" desc:"global alpha opacity / transparency factor"`
	Server  PaintServer `view:"-" desc:"paint server for the fill -- if solid color, defines fill color"`
	Rule    FillRule    `xml:"fill-rule" desc:"rule for how to fill more complex shapes with crossing lines"`
}

FillStyle contains all the properties specific to filling a region

func (*FillStyle) Defaults

func (pf *FillStyle) Defaults()

initialize default values for paint fill

func (*FillStyle) SetColor

func (pf *FillStyle) SetColor(cl *Color)

func (*FillStyle) SetStylePost

func (pf *FillStyle) SetStylePost()

need to do some updating after setting the style from user properties

type FloatValueView

type FloatValueView struct {
	ValueViewBase
}

FloatValueView presents a spinbox

func (*FloatValueView) ConfigWidget

func (vv *FloatValueView) ConfigWidget(widg Node2D)

func (*FloatValueView) New

func (n *FloatValueView) New() ki.Ki

func (*FloatValueView) UpdateWidget

func (vv *FloatValueView) UpdateWidget()

func (*FloatValueView) WidgetType

func (vv *FloatValueView) WidgetType() reflect.Type

type FontLib

type FontLib struct {
	FontPaths  []string
	FontsAvail map[string]string `desc:"map of font name to path to file"`
	Faces      map[string]map[float64]font.Face
	// contains filtered or unexported fields
}
var FontLibrary FontLib

we export this font library

func (*FontLib) AddFontPaths

func (fl *FontLib) AddFontPaths(paths ...string) bool

func (*FontLib) Font

func (fl *FontLib) Font(fontnm string, points float64) (font.Face, error)

get a particular font

func (*FontLib) Init

func (fl *FontLib) Init()

func (*FontLib) InitFontPaths

func (fl *FontLib) InitFontPaths(paths ...string)

InitFontPaths initializes font paths to system defaults, only if no paths have yet been set

func (*FontLib) UpdateFontsAvail

func (fl *FontLib) UpdateFontsAvail() bool

type FontStyle

type FontStyle struct {
	Face     font.Face   `desc:"actual font codes for drawing text -- just a pointer into FontLibrary of loaded fonts"`
	Height   float32     `desc:"recommended line hieight of font in dots"`
	FaceName string      `desc:"name corresponding to Face"`
	Size     units.Value `xml:"size" desc:"size of font to render -- convert to points when getting font to use"`
	Family   string      `` /* 140-byte string literal not displayed */
	Style    FontStyles  `xml:"style" inherit:"true","desc:"style -- normal, italic, etc"`
	Weight   FontWeights `xml:"weight" inherit:"true","desc:"weight: normal, bold, etc"`
}

font style information -- used in Paint and in Style -- see style.go

func (*FontStyle) Defaults

func (p *FontStyle) Defaults()

func (*FontStyle) LoadFont

func (p *FontStyle) LoadFont(ctxt *units.Context, fallback string)

func (*FontStyle) SetStylePost

func (p *FontStyle) SetStylePost()

any updates after generic xml-tag property setting?

func (*FontStyle) SetUnitContext

func (p *FontStyle) SetUnitContext(ctxt *units.Context)

type FontStyles

type FontStyles int32

styles of font: normal, italic, etc

const (
	FontNormal FontStyles = iota
	FontItalic
	FontOblique
	FontStylesN
)

func (*FontStyles) FromString

func (i *FontStyles) FromString(s string) error

func (FontStyles) MarshalJSON

func (ev FontStyles) MarshalJSON() ([]byte, error)

func (FontStyles) String

func (i FontStyles) String() string

func (*FontStyles) UnmarshalJSON

func (ev *FontStyles) UnmarshalJSON(b []byte) error

type FontWeights

type FontWeights int32

styles of font: normal, italic, etc

const (
	WeightNormal FontWeights = iota
	WeightBold
	WeightBolder
	WeightLighter
	//	Weight100...900  todo: seriously?  400 = normal, 700 = bold
	FontWeightsN
)

func (*FontWeights) FromString

func (i *FontWeights) FromString(s string) error

func (FontWeights) MarshalJSON

func (ev FontWeights) MarshalJSON() ([]byte, error)

func (FontWeights) String

func (i FontWeights) String() string

func (*FontWeights) UnmarshalJSON

func (ev *FontWeights) UnmarshalJSON(b []byte) error

type Frame

type Frame struct {
	Layout
}

Frame is a basic container for widgets -- a layout that renders the standard box model

func (*Frame) New

func (n *Frame) New() ki.Ki

func (*Frame) Render2D

func (g *Frame) Render2D()

func (*Frame) Style2D

func (g *Frame) Style2D()

type HSLA

type HSLA struct {
	H, S, L, A float32
}

HSLA represents the Hue [0..360], Saturation [0..1], and Luminance (lightness) [0..1] of the color using float32 values

func (HSLA) RGBA

func (c HSLA) RGBA() (r, g, b, a uint32)

Implements the color.Color interface

type Icon

type Icon struct {
	SVG
	Rendered     bool        `` /* 160-byte string literal not displayed */
	RenderedSize image.Point `json:"-" xml:"-" desc:"size at which we previously rendered"`
}

Icon is an SVG that is assumed to contain no color information -- it should just be a filled shape where the fill and stroke colors come from the surrounding context / paint settings. The rendered version can be cached for a given set of fill / stroke paint values, as an optimization.

func IconByName

func IconByName(name string) *Icon

IconByName is main function to get icon by name -- looks in CurIconSet and falls back to DefaultIconSet if not found there -- logs a message and returns nil if not found

func IconListSorted

func IconListSorted(is IconSet) []*Icon

IconListSorted returns a slice of all the icons in the icon set sorted by name

func (*Icon) CopyFromIcon

func (vp *Icon) CopyFromIcon(cp *Icon)

copy from a source icon, typically one from a library -- preserves all the exisiting render state etc for the current icon, so that only a new render is required

func (*Icon) Init2D

func (vp *Icon) Init2D()

func (*Icon) Layout2D

func (vp *Icon) Layout2D(parBBox image.Rectangle)

func (*Icon) New

func (n *Icon) New() ki.Ki

func (*Icon) Render2D

func (vp *Icon) Render2D()

func (*Icon) SetNormXForm

func (vp *Icon) SetNormXForm()

set a normalized 0-1 scaling transform so svg's use 0-1 coordinates that map to actual size of the viewport -- used e.g. for Icon

func (*Icon) Size2D

func (vp *Icon) Size2D()

func (*Icon) Style2D

func (vp *Icon) Style2D()

type IconContexts

type IconContexts int32

different types of standard icon name spaces, from https://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html -- we organize our IconSets into these different contexts

const (
	// Icons that are used as parts of standard widgets -- these are available built-in
	WidgetIcons IconContexts = iota
	// Icons which are generally used in menus and dialogs for interacting with the user.
	ActionIcons
	// Animated images used to represent loading web sites, or other background processing which may be less suited to more verbose progress reporting in the user interface.
	AnimationIcons
	// Icons that describe what an application is, for use in the Programs menu, window decorations, and the task list. These may or may not be generic depending on the application and its purpose.
	ApplicationIcons
	// Icons that are used for categories in the Programs menu, or the Control Center, for separating applications, preferences, and settings for display to the user.
	CategoryIcons
	// Icons for hardware that is contained within or connected to the computing device. Naming for extended devices in this group, is of the form <primary function>-<manufacturer>-<model>. This allows ease of fallback to the primary function device name, or ones more targeted for a specific series of models from a manufacturer.
	DeviceIcons
	// Icons for tags and properties of files, that are displayed in the file manager. This context contains emblems for such things as read-only or photos
	EmblemIcons
	// Icons for emotions that are expressed through text chat applications such as :-) or :-P in IRC or instant messengers.
	EmoteIcons
	// Icons for international denominations such as flags.
	IntnlIcons
	// Icons for different types of data, such as audio or image files.
	MimeIcons
	// Icons used to represent locations, either on the local filesystem, or through remote connections. Folders, trash, and workgroups are some example.
	PlaceIcons
	// Icons for presenting status to the user. This context contains icons for warning and error dialogs, as well as for the current weather, appointment alarms, and battery status
	StatusIcons
	IconContextsN
)

func (*IconContexts) FromString

func (i *IconContexts) FromString(s string) error

func (IconContexts) MarshalJSON

func (ev IconContexts) MarshalJSON() ([]byte, error)

func (IconContexts) String

func (i IconContexts) String() string

func (*IconContexts) UnmarshalJSON

func (ev *IconContexts) UnmarshalJSON(b []byte) error

type IconSet

type IconSet map[string]*Icon

an IconSet is a collection of icons styled in the same themes - lookup by name

var CurIconSet *IconSet = DefaultIconSet

the current icon set can be set to any icon set

var DefaultIconSet *IconSet = MakeDefaultIcons()

the default icon set is loaded by default

func MakeDefaultIcons

func MakeDefaultIcons() *IconSet

note: icons must use a normalized 0-1 coordinate system!

type ImagePaintServer

type ImagePaintServer struct {
	Image image.Image
	Op    RepeatOp
}

Image PaintServer

func (*ImagePaintServer) ColorAt

func (p *ImagePaintServer) ColorAt(x, y int) color.Color

func (*ImagePaintServer) ServerType

func (p *ImagePaintServer) ServerType() PaintServers

type IntValueView

type IntValueView struct {
	ValueViewBase
}

IntValueView presents a spinbox

func (*IntValueView) ConfigWidget

func (vv *IntValueView) ConfigWidget(widg Node2D)

func (*IntValueView) New

func (n *IntValueView) New() ki.Ki

func (*IntValueView) UpdateWidget

func (vv *IntValueView) UpdateWidget()

func (*IntValueView) WidgetType

func (vv *IntValueView) WidgetType() reflect.Type

type KeyFunctions

type KeyFunctions int64

functions that keyboard events can perform in the gui

const (
	KeyFunNil KeyFunctions = iota
	KeyFunMoveUp
	KeyFunMoveDown
	KeyFunMoveRight
	KeyFunMoveLeft
	KeyFunPageUp
	KeyFunPageDown
	KeyFunPageRight
	KeyFunPageLeft
	KeyFunHome
	KeyFunEnd
	KeyFunFocusNext
	KeyFunFocusPrev
	KeyFunSelectItem // enter
	KeyFunAccept     // accept any changes and close dialog / move to next
	KeyFunAbort
	KeyFunCancelSelect
	KeyFunExtendSelect
	KeyFunSelectText
	KeyFunEditItem
	KeyFunCopy
	KeyFunCut
	KeyFunPaste
	KeyFunBackspace
	KeyFunDelete
	KeyFunKill
	KeyFunDuplicate
	KeyFunInsert
	KeyFunInsertAfter
	KeyFunGoGiEditor
	// either shift key
	KeyFunShift
	// the control key: command for mac, ctrl for others?
	KeyFunCtrl
	KeyFunZoomOut
	KeyFunZoomIn
	KeyFunPrefs
	KeyFunRefresh
	KeyFunctionsN
)

func KeyFun

func KeyFun(chord string) KeyFunctions

translate chord into keyboard function -- use oswin key.ChordString to get chord

func (*KeyFunctions) FromString

func (i *KeyFunctions) FromString(s string) error

func (KeyFunctions) MarshalJSON

func (ev KeyFunctions) MarshalJSON() ([]byte, error)

func (KeyFunctions) String

func (i KeyFunctions) String() string

func (*KeyFunctions) UnmarshalJSON

func (ev *KeyFunctions) UnmarshalJSON(b []byte) error

type KeyMap

type KeyMap map[string]KeyFunctions
var ActiveKeyMap *KeyMap = &DefaultKeyMap

ActiveKeyMap points to the active map -- users can set this to an alternative map in Prefs

type KiPtrValueView

type KiPtrValueView struct {
	ValueViewBase
}

KiPtrValueView provides a chooser for pointers to Ki objects

func (*KiPtrValueView) ConfigWidget

func (vv *KiPtrValueView) ConfigWidget(widg Node2D)

func (*KiPtrValueView) KiStruct

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

get the Ki struct itself (or nil)

func (*KiPtrValueView) New

func (n *KiPtrValueView) New() ki.Ki

func (*KiPtrValueView) UpdateWidget

func (vv *KiPtrValueView) UpdateWidget()

func (*KiPtrValueView) WidgetType

func (vv *KiPtrValueView) WidgetType() reflect.Type

type Label

type Label struct {
	WidgetBase
	Text string `xml:"text" desc:"label to display"`
}

Label is a widget for rendering text labels -- supports full widget model including box rendering

func (*Label) New

func (n *Label) New() ki.Ki

func (*Label) Render2D

func (g *Label) Render2D()

func (*Label) Size2D

func (g *Label) Size2D()

func (*Label) Style2D

func (g *Label) Style2D()

type Labeler

type Labeler interface {
	Label() string
}

the labeler interface provides a GUI-appropriate label (todo: rich text html tags!?) for an item -- use ToLabel converter to attempt to use this interface and then fall back on Stringer via kit.ToString conversion function

type Layout

type Layout struct {
	Node2DBase
	Lay       Layouts               `xml:"lay" desc:"type of layout to use"`
	CSS       ki.Props              `` /* 191-byte string literal not displayed */
	CSSAgg    ki.Props              `json:"-" xml:"-" desc:"aggregated css properties from all higher nodes down to me"`
	StackTop  ki.Ptr                `desc:"pointer to node to use as the top of the stack -- only node matching this pointer is rendered, even if this is nil"`
	ChildSize Vec2D                 `json:"-" xml:"-" desc:"total max size of children as laid out"`
	ExtraSize Vec2D                 `json:"-" xml:"-" desc:"extra size in each dim due to scrollbars we add"`
	HasScroll [Dims2DN]bool         `json:"-" xml:"-" desc:"whether scrollbar is used for given dim"`
	Scrolls   [Dims2DN]*ScrollBar   `json:"-" xml:"-" desc:"scroll bars -- we fully manage them as needed"`
	GridSize  image.Point           `json:"-" xml:"-" desc:"computed size of a grid layout based on all the constraints -- computed during Size2D pass"`
	GridData  [RowColN][]LayoutData `json:"-" xml:"-" desc:"grid data for rows in [0] and cols in [1]"`
}

Layout is the primary node type responsible for organizing the sizes and positions of child widgets -- all arbitrary collections of widgets should generally be contained within a layout -- otherwise the parent widget must take over responsibility for positioning. The alignment is NOT inherited by default so must be specified per child, except that the parent alignment is used within the relevant dimension (e.g., align-horiz for a LayoutRow layout, to determine left, right, center, justified). Layouts can automatically add scrollbars depending on the Overflow layout style

func (*Layout) AllocFromParent

func (ly *Layout) AllocFromParent()

if we are not a child of a layout, then get allocation from a parent obj that has a layout size

func (*Layout) AsLayout2D

func (g *Layout) AsLayout2D() *Layout

func (*Layout) AsNode2D

func (ly *Layout) AsNode2D() *Node2DBase

func (*Layout) AsViewport2D

func (ly *Layout) AsViewport2D() *Viewport2D

func (*Layout) AvailSize

func (ly *Layout) AvailSize() Vec2D

AvailSize returns the total size avail to this layout -- typically AllocSize except for top-level layout which uses VpBBox in case less is avail

func (*Layout) BBox2D

func (ly *Layout) BBox2D() image.Rectangle

func (*Layout) CSSProps

func (g *Layout) CSSProps() (css, agg *ki.Props)

func (*Layout) ChildrenBBox2D

func (ly *Layout) ChildrenBBox2D() image.Rectangle

func (*Layout) ComputeBBox2D

func (ly *Layout) ComputeBBox2D(parBBox image.Rectangle, delta image.Point)

func (*Layout) DeactivateScroll

func (ly *Layout) DeactivateScroll(sc *ScrollBar)

func (*Layout) DeleteScroll

func (ly *Layout) DeleteScroll(d Dims2D)

todo: we are leaking the scrollbars..

func (*Layout) FinalizeLayout

func (ly *Layout) FinalizeLayout()

final pass through children to finalize the layout, computing summary size stats

func (*Layout) FocusChanged2D

func (ly *Layout) FocusChanged2D(gotFocus bool)

func (*Layout) GatherSizes

func (ly *Layout) GatherSizes()

first pass: gather the size information from the children

func (*Layout) GatherSizesGrid

func (ly *Layout) GatherSizesGrid()

first pass: gather the size information from the children, grid version

func (*Layout) Init2D

func (ly *Layout) Init2D()

func (*Layout) Layout2D

func (ly *Layout) Layout2D(parBBox image.Rectangle)

func (*Layout) LayoutAll

func (ly *Layout) LayoutAll(dim Dims2D)

layout all children along given dim -- only affects that dim -- e.g., use LayoutSingle for other dim

func (*Layout) LayoutGrid

func (ly *Layout) LayoutGrid()

func (*Layout) LayoutGridDim

func (ly *Layout) LayoutGridDim(rowcol RowCol, dim Dims2D)

layout grid data along each dimension (row, Y; col, X), same as LayoutAll. For cols, X has width prefs of each -- turn that into an actual allocated width for each column, and likewise for rows.

func (*Layout) LayoutScrolls

func (ly *Layout) LayoutScrolls()

func (*Layout) LayoutSingle

func (ly *Layout) LayoutSingle(dim Dims2D)

layout item in single-dimensional case -- e.g., orthogonal dimension from LayoutRow / Col

func (*Layout) LayoutSingleImpl

func (ly *Layout) LayoutSingleImpl(avail, need, pref, max, spc float32, al Align) (pos, size float32)

calculations to layout a single-element dimension, returns pos and size

func (*Layout) ManageOverflow

func (ly *Layout) ManageOverflow()

process any overflow according to overflow settings

func (*Layout) Move2D

func (ly *Layout) Move2D(delta image.Point, parBBox image.Rectangle)

func (*Layout) Move2DDelta

func (ly *Layout) Move2DDelta(delta image.Point) image.Point

we add our own offset here

func (*Layout) New

func (n *Layout) New() ki.Ki

func (*Layout) ReRender2D

func (ly *Layout) ReRender2D() (node Node2D, layout bool)

func (*Layout) Render2D

func (ly *Layout) Render2D()

func (*Layout) Render2DChildren

func (ly *Layout) Render2DChildren()

render the children

func (*Layout) RenderScrolls

func (ly *Layout) RenderScrolls()

func (*Layout) ScrollDelta

func (ly *Layout) ScrollDelta(del image.Point) bool

ScrollDelta processes a scroll event with given delta -- returns true if scroll was processed

func (*Layout) SetScroll

func (ly *Layout) SetScroll(d Dims2D)

func (*Layout) ShowChildAtIndex

func (ly *Layout) ShowChildAtIndex(idx int) error

convenience for LayoutStacked to show child node at a given index

func (*Layout) Size2D

func (ly *Layout) Size2D()

func (*Layout) Style2D

func (ly *Layout) Style2D()

func (*Layout) SumDim

func (ly *Layout) SumDim(d Dims2D) bool

do we sum up elements along given dimension? else max

type LayoutData

type LayoutData struct {
	Size         SizePrefs   `desc:"size constraints for this item -- from layout style"`
	Margins      Margins     `desc:"margins around this item"`
	GridPos      image.Point `desc:"position within a grid"`
	GridSpan     image.Point `desc:"number of grid elements that we take up in each direction"`
	AllocSize    Vec2D       `desc:"allocated size of this item, by the parent layout"`
	AllocPos     Vec2D       `desc:"position of this item, computed by adding in the AllocPosRel to parent position"`
	AllocPosRel  Vec2D       `desc:"allocated relative position of this item, computed by the parent layout"`
	AllocPosOrig Vec2D       `` /* 134-byte string literal not displayed */
}

LayoutData contains all the data needed to specify the layout of an item within a layout -- includes computed values of style prefs -- everything is concrete and specified here, whereas style may not be fully resolved

func (*LayoutData) Defaults

func (ld *LayoutData) Defaults()

func (*LayoutData) Reset

func (ld *LayoutData) Reset()

called at start of layout process -- resets all values back to 0

func (*LayoutData) SetFromStyle

func (ld *LayoutData) SetFromStyle(ls *LayoutStyle)

func (*LayoutData) UpdateSizes

func (ld *LayoutData) UpdateSizes()

update our sizes based on AllocSize and Max constraints, etc

type LayoutStyle

type LayoutStyle struct {
	AlignH    Align       `` /* 127-byte string literal not displayed */
	AlignV    Align       `` /* 127-byte string literal not displayed */
	PosX      units.Value `xml:"x" desc:"horizontal position -- often superceded by layout but otherwise used"`
	PosY      units.Value `xml:"y" desc:"vertical position -- often superceded by layout but otherwise used"`
	Width     units.Value `xml:"width" desc:"specified size of element -- 0 if not specified"`
	Height    units.Value `xml:"height" desc:"specified size of element -- 0 if not specified"`
	MaxWidth  units.Value `xml:"max-width" desc:"specified maximum size of element -- 0  means just use other values, negative means stretch"`
	MaxHeight units.Value `xml:"max-height" desc:"specified maximum size of element -- 0 means just use other values, negative means stretch"`
	MinWidth  units.Value `xml:"min-width" desc:"specified mimimum size of element -- 0 if not specified"`
	MinHeight units.Value `xml:"min-height" desc:"specified mimimum size of element -- 0 if not specified"`
	Margin    units.Value `xml:"margin" desc:"outer-most transparent space around box element -- todo: can be specified per side"`
	Padding   units.Value `` /* 185-byte string literal not displayed */
	Overflow  Overflow    `` /* 147-byte string literal not displayed */
	Columns   int         `` /* 178-byte string literal not displayed */
	Row       int         `xml:"row" desc:"specifies the row that this element should appear within a grid layout"`
	Col       int         `xml:"col" desc:"specifies the column that this element should appear within a grid layout"`
	RowSpan   int         `` /* 146-byte string literal not displayed */
	ColSpan   int         `xml:"col-span" desc:"specifies the number of sequential columns that this element should occupy within a grid layout"`

	ScrollBarWidth units.Value `xml:"scrollbar-width" desc:"width of a layout scrollbar"`
	// contains filtered or unexported fields
}

style preferences on the layout of the element

func (*LayoutStyle) AlignDim

func (ls *LayoutStyle) AlignDim(d Dims2D) Align

return the alignment for given dimension

func (*LayoutStyle) Defaults

func (ls *LayoutStyle) Defaults()

func (*LayoutStyle) MaxSizeDots

func (ls *LayoutStyle) MaxSizeDots() Vec2D

size max settings, in dots

func (*LayoutStyle) MinSizeDots

func (ls *LayoutStyle) MinSizeDots() Vec2D

size min settings, in dots

func (*LayoutStyle) PosDots

func (ls *LayoutStyle) PosDots() Vec2D

position settings, in dots

func (*LayoutStyle) SetStylePost

func (ls *LayoutStyle) SetStylePost()

func (*LayoutStyle) SizeDots

func (ls *LayoutStyle) SizeDots() Vec2D

size settings, in dots

type Layouts

type Layouts int32

different types of layouts

const (
	// arrange items horizontally across a row
	LayoutRow Layouts = iota
	// arrange items vertically in a column
	LayoutCol
	// arrange items according to a grid
	LayoutGrid
	// arrange items horizontally across a row, overflowing vertically as needed
	LayoutRowFlow
	// arrange items vertically within a column, overflowing horizontally as needed
	LayoutColFlow
	// arrange items stacked on top of each other -- Top index indicates which to show -- overall size accommodates largest in each dimension
	LayoutStacked
	// nil layout -- don't do anything -- for cases when a parent wants to take over the job of the layout
	LayoutNil
	LayoutsN
)

func (*Layouts) FromString

func (i *Layouts) FromString(s string) error

func (Layouts) MarshalJSON

func (ev Layouts) MarshalJSON() ([]byte, error)

func (Layouts) String

func (i Layouts) String() string

func (*Layouts) UnmarshalJSON

func (ev *Layouts) UnmarshalJSON(b []byte) error

type Line

type Line struct {
	Node2DBase
	Start Vec2D `xml:"{x1,y1}" desc:"position of the start of the line"`
	End   Vec2D `xml:"{x2, y2}" desc:"position of the end of the line"`
}

a 2D line

func (*Line) BBox2D

func (g *Line) BBox2D() image.Rectangle

func (*Line) New

func (n *Line) New() ki.Ki

func (*Line) ReRender2D

func (g *Line) ReRender2D() (node Node2D, layout bool)

func (*Line) Render2D

func (g *Line) Render2D()

type LineCap

type LineCap int

end-cap of a line: stroke-linecap property in SVG

const (
	LineCapButt LineCap = iota
	LineCapRound
	LineCapSquare
	LineCapN
)

func (*LineCap) FromString

func (i *LineCap) FromString(s string) error

func (LineCap) MarshalJSON

func (ev LineCap) MarshalJSON() ([]byte, error)

func (LineCap) String

func (i LineCap) String() string

func (*LineCap) UnmarshalJSON

func (ev *LineCap) UnmarshalJSON(b []byte) error

type LineJoin

type LineJoin int

the way in which lines are joined together: stroke-linejoin property in SVG

const (
	LineJoinMiter     LineJoin = iota
	LineJoinMiterClip          // SVG2 -- not yet supported
	LineJoinRound
	LineJoinBevel
	LineJoinArcs // SVG2 -- not yet supported
	LineJoinN
)

func (*LineJoin) FromString

func (i *LineJoin) FromString(s string) error

func (LineJoin) MarshalJSON

func (ev LineJoin) MarshalJSON() ([]byte, error)

func (LineJoin) String

func (i LineJoin) String() string

func (*LineJoin) UnmarshalJSON

func (ev *LineJoin) UnmarshalJSON(b []byte) error

type MakeMenuFunc

type MakeMenuFunc func(mb *ButtonBase)

MakeMenuFunc is a callback for making the menu on demand

type MapInlineValueView

type MapInlineValueView struct {
	ValueViewBase
}

MapInlineValueView presents a MapViewInline for a map

func (*MapInlineValueView) ConfigWidget

func (vv *MapInlineValueView) ConfigWidget(widg Node2D)

func (*MapInlineValueView) New

func (n *MapInlineValueView) New() ki.Ki

func (*MapInlineValueView) UpdateWidget

func (vv *MapInlineValueView) UpdateWidget()

func (*MapInlineValueView) WidgetType

func (vv *MapInlineValueView) WidgetType() reflect.Type

type MapValueView

type MapValueView struct {
	ValueViewBase
}

MapValueView presents a button to edit maps

func (*MapValueView) ConfigWidget

func (vv *MapValueView) ConfigWidget(widg Node2D)

func (*MapValueView) New

func (n *MapValueView) New() ki.Ki

func (*MapValueView) UpdateWidget

func (vv *MapValueView) UpdateWidget()

func (*MapValueView) WidgetType

func (vv *MapValueView) WidgetType() reflect.Type

type MapView

type MapView struct {
	Frame
	Map     interface{} `desc:"the map that we are a view onto"`
	Title   string      `desc:"title / prompt to show above the editor fields"`
	Keys    []ValueView `json:"-" xml:"-" desc:"ValueView representations of the map keys"`
	Values  []ValueView `json:"-" xml:"-" desc:"ValueView representations of the map values"`
	TmpSave ValueView   `` /* 189-byte string literal not displayed */
	ViewSig ki.Signal   `` /* 179-byte string literal not displayed */
}

MapView represents a map, creating a property editor of the values -- constructs Children widgets to show the key / value pairs, within an overall frame with an optional title, and a button box at the bottom where methods can be invoked

func (*MapView) ButtonBox

func (mv *MapView) ButtonBox() (*Layout, int)

ButtonBox returns the ButtonBox layout widget, and its index, within frame -- nil, -1 if not found

func (*MapView) ConfigMapButtons

func (mv *MapView) ConfigMapButtons()

ConfigMapButtons configures the buttons for map functions

func (*MapView) ConfigMapGrid

func (mv *MapView) ConfigMapGrid()

ConfigMapGrid configures the MapGrid for the current map

func (*MapView) MapAdd

func (mv *MapView) MapAdd()

func (*MapView) MapChangeValueType

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

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

func (*MapView) MapDelete

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

func (*MapView) MapGrid

func (mv *MapView) MapGrid() (*Layout, int)

MapGrid returns the MapGrid grid layout widget, which contains all the fields and values, and its index, within frame -- nil, -1 if not found

func (*MapView) New

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

func (*MapView) ReRender2D

func (mv *MapView) ReRender2D() (node Node2D, layout bool)

func (*MapView) Render2D

func (mv *MapView) Render2D()

func (*MapView) SetFrame

func (mv *MapView) SetFrame()

SetFrame configures view as a frame

func (*MapView) SetMap

func (mv *MapView) SetMap(mp interface{}, tmpSave ValueView)

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

func (*MapView) SetTitle

func (mv *MapView) SetTitle(title string)

SetTitle sets the title and updates the Title label

func (*MapView) StdConfig

func (mv *MapView) StdConfig() (mods, updt bool)

StdConfig configures a standard setup of the overall Frame -- returns mods, updt from ConfigChildren and does NOT call UpdateEnd

func (*MapView) StdFrameConfig

func (mv *MapView) StdFrameConfig() kit.TypeAndNameList

StdFrameConfig returns a TypeAndNameList for configuring a standard Frame -- can modify as desired before calling ConfigChildren on Frame using this

func (*MapView) Style2D

func (mv *MapView) Style2D()

needs full rebuild and this is where we do it:

func (*MapView) TitleWidget

func (mv *MapView) TitleWidget() (*Label, int)

Title returns the title label widget, and its index, within frame -- nil, -1 if not found

func (*MapView) UpdateFromMap

func (mv *MapView) UpdateFromMap()

func (*MapView) UpdateValues

func (mv *MapView) UpdateValues()

type MapViewInline

type MapViewInline struct {
	WidgetBase
	Map     interface{} `desc:"the map that we are a view onto"`
	Keys    []ValueView `json:"-" xml:"-" desc:"ValueView representations of the map keys"`
	Values  []ValueView `json:"-" xml:"-" desc:"ValueView representations of the fields"`
	TmpSave ValueView   `` /* 189-byte string literal not displayed */
	ViewSig ki.Signal   `` /* 179-byte string literal not displayed */
}

MapViewInline represents a map as a single line widget, for smaller maps and those explicitly marked inline -- constructs widgets in Parts to show the key names and editor vals for each value

func (*MapViewInline) ConfigParts

func (mv *MapViewInline) ConfigParts()

ConfigParts configures Parts for the current map

func (*MapViewInline) New

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

func (*MapViewInline) ReRender2D

func (mv *MapViewInline) ReRender2D() (node Node2D, layout bool)

todo: see notes on treeview

func (*MapViewInline) Render2D

func (mv *MapViewInline) Render2D()

func (*MapViewInline) SetMap

func (mv *MapViewInline) SetMap(mp interface{}, tmpSave ValueView)

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

func (*MapViewInline) Style2D

func (mv *MapViewInline) Style2D()

func (*MapViewInline) UpdateFromMap

func (mv *MapViewInline) UpdateFromMap()

func (*MapViewInline) UpdateValues

func (mv *MapViewInline) UpdateValues()

type Margins

type Margins struct {
	// contains filtered or unexported fields
}

2D margins

func (*Margins) SetMargin

func (m *Margins) SetMargin(marg float32)

set a single margin for all items

type MenuButton struct {
	ButtonBase
}
func (g *MenuButton) ButtonAsBase() *ButtonBase
func (g *MenuButton) ConfigParts()
func (n *MenuButton) New() ki.Ki

type NRGBAf32

type NRGBAf32 struct {
	R, G, B, A float32
}

NRGBAf32 stores non-alpha-premultiplied RGBA values in float32 0..1 normalized format -- more useful for converting to other spaces

func (NRGBAf32) RGBA

func (c NRGBAf32) RGBA() (r, g, b, a uint32)

Implements the color.Color interface

type Node2D

type Node2D interface {
	// nodes are Ki elements -- this comes for free by embedding ki.Node in all Node2D elements
	ki.Ki

	// AsNode2D returns a generic Node2DBase for our node -- gives generic
	// access to all the base-level data structures without requiring
	// interface methods
	AsNode2D() *Node2DBase

	// AsViewport2D returns Viewport2D if this node is one (has its own
	// bitmap, used for menus, dialogs, icons, etc), else nil
	AsViewport2D() *Viewport2D

	// AsLayout2D returns Layout if this is a Layout-derived node, else nil
	AsLayout2D() *Layout

	// Init2D initializes a node -- sets up event receiving connections etc --
	// must call InitNodeBase as first step set basic inits including setting
	// Viewport and connecting node signal to parent vp -- all code here must
	// be robust to being called repeatedly
	Init2D()

	// Style2D: In a MeFirst downward pass, all properties are cached out in
	// an inherited manner, and incorporating any css styles, into either the
	// Paint or Style object for each Node, depending on the type of node (SVG
	// does Paint, Widget does Style).  Only done once after structural
	// changes -- styles are not for dynamic changes.
	Style2D()

	// CSSProps: returns pointers to the css properties for this node, if node
	// supports css styles -- both the local CSS settings and the aggregated
	// values down to it
	CSSProps() (css, agg *ki.Props)

	// Size2D: DepthFirst downward pass, each node first calls
	// g.Layout.Reset(), then sets their LayoutSize according to their own
	// intrinsic size parameters, and/or those of its children if it is a
	// Layout
	Size2D()

	// Layout2D: MeFirst downward pass (each node calls on its children at
	// appropriate point) with relevant parent BBox that the children are
	// constrained to render within -- they then intersect this BBox with
	// their own BBox (from BBox2D) -- typically just call Layout2DBase for
	// default behavior -- and add parent position to AllocPos -- Layout does
	// all its sizing and positioning of children in this pass, based on the
	// Size2D data gathered bottom-up and constraints applied top-down from
	// higher levels
	Layout2D(parBBox image.Rectangle)

	// Move2D: optional MeFirst downward pass to move all elements by given
	// delta -- used for scrolling -- the layout pass assigns canonical
	// positions, saved in AllocPosOrig and BBox, and this adds the given
	// delta to that AllocPosOrig -- each node must call ComputeBBox2D to
	// update its bounding box information given the new position
	Move2D(delta image.Point, parBBox image.Rectangle)

	// BBox2D: compute the raw bounding box of this node relative to its
	// parent viewport -- called during Layout2D to set node BBox field, which
	// is then used in setting WinBBox and VpBBox
	BBox2D() image.Rectangle

	// Compute VpBBox and WinBBox from BBox, given parent VpBBox -- most nodes
	// call ComputeBBox2DBase but viewports require special code -- called
	// during Layout and Move
	ComputeBBox2D(parBBox image.Rectangle, delta image.Point)

	// ChildrenBBox2D: compute the bbox available to my children (content),
	// adjusting for margins, border, padding (BoxSpace) taken up by me --
	// operates on the existing VpBBox for this node -- this is what is passed
	// down as parBBox do the children's Layout2D
	ChildrenBBox2D() image.Rectangle

	// Render2D: Final rendering pass, each node is fully responsible for
	// calling Render2D on its own children, to provide maximum flexibility
	// (see Render2DChildren for default impl) -- bracket the render calls in
	// PushBounds / PopBounds and a false from PushBounds indicates that
	// VpBBox is empty and no rendering should occur
	Render2D()

	// ReRender2D: returns the node that should be re-rendered when an Update
	// signal is received for a given node, and whether a new layout pass from
	// that node down is needed) -- can be the node itself, any of its parents
	// or children, or nil to indicate that a full re-render is necessary.
	// For re-rendering to work, an opaque background should be painted first
	ReRender2D() (node Node2D, layout bool)

	// FocusChanged2D is called on node when it gets or loses focus -- focus
	// flag has current state too
	FocusChanged2D(gotFocus bool)

	// HasFocus2D returns true if this node has keyboard focus and should
	// receive keyboard events -- typically this just returns HasFocus based
	// on the Window-managed HasFocus flag, but some types may want to monitor
	// all keyboard activity for certain key keys..
	HasFocus2D() bool
}

primary interface for all Node2D nodes

type Node2DBase

type Node2DBase struct {
	NodeBase
	Style    Style       `` /* 137-byte string literal not displayed */
	DefStyle *Style      `` /* 198-byte string literal not displayed */
	Paint    Paint       `json:"-" xml:"-" desc:"full paint information for this node"`
	Viewport *Viewport2D `json:"-" xml:"-" desc:"our viewport -- set in Init2D (Base typically) and used thereafter"`
	LayData  LayoutData  `json:"-" xml:"-" desc:"all the layout information for this item"`
}

Base struct node for 2D rendering tree -- renders to a bitmap using Paint rendering functions operating on the RenderState in the parent Viewport

Rendering is done in 4 separate passes:

  1. Style2D: In a MeFirst downward pass, all properties are cached out in an inherited manner, and incorporating any css styles, into either the Paint (SVG) or Style (Widget) object for each Node. Only done once after structural changes -- styles are not for dynamic changes.

  2. Size2D: DepthFirst downward pass, each node first calls g.Layout.Reset(), then sets their LayoutSize according to their own intrinsic size parameters, and/or those of its children if it is a Layout

  3. Layout2D: MeFirst downward pass (each node calls on its children at appropriate point) with relevant parent BBox that the children are constrained to render within -- they then intersect this BBox with their own BBox (from BBox2D) -- typically just call Layout2DBase for default behavior -- and add parent position to AllocPos -- Layout does all its sizing and positioning of children in this pass, based on the Size2D data gathered bottom-up and constraints applied top-down from higher levels

  4. Render2D: Final rendering pass, each node is fully responsible for rendering its own children, to provide maximum flexibility (see Render2DChildren) -- bracket the render calls in PushBounds / PopBounds and a false from PushBounds indicates that VpBBox is empty and no rendering should occur

    * Move2D: optional pass invoked by scrollbars to move elements relative to their previously-assigned positions.

func (*Node2DBase) AddParentPos

func (g *Node2DBase) AddParentPos() Vec2D

add the position of our parent to our layout position -- layout computations are all relative to parent position, so they are finally cached out at this stage also returns the size of the parent for setting units context relative to parent objects

func (*Node2DBase) AsLayout2D

func (g *Node2DBase) AsLayout2D() *Layout

func (*Node2DBase) AsNode2D

func (g *Node2DBase) AsNode2D() *Node2DBase

func (*Node2DBase) AsViewport2D

func (g *Node2DBase) AsViewport2D() *Viewport2D

func (*Node2DBase) BBox2D

func (g *Node2DBase) BBox2D() image.Rectangle

func (*Node2DBase) BBoxFromAlloc

func (g *Node2DBase) BBoxFromAlloc() image.Rectangle

get our bbox from Layout allocation

func (*Node2DBase) BBoxReport

func (g *Node2DBase) BBoxReport() string

report on all the bboxes for everything in the tree

func (*Node2DBase) CSSProps

func (g *Node2DBase) CSSProps() (css, agg *ki.Props)

func (*Node2DBase) ChildrenBBox2D

func (g *Node2DBase) ChildrenBBox2D() image.Rectangle

func (*Node2DBase) ChildrenBBox2DWidget

func (g *Node2DBase) ChildrenBBox2DWidget() image.Rectangle

this provides a basic widget box-model subtraction of margin and padding to children -- call in ChildrenBBox2D for most widgets

func (*Node2DBase) ComputeBBox2D

func (g *Node2DBase) ComputeBBox2D(parBBox image.Rectangle, delta image.Point)

func (*Node2DBase) ComputeBBox2DBase

func (g *Node2DBase) ComputeBBox2DBase(parBBox image.Rectangle, delta image.Point)

ComputeBBox2DBase -- computes the VpBBox and WinBBox from BBox, with whatever delta may be in effect

func (*Node2DBase) CopyParentPaint

func (g *Node2DBase) CopyParentPaint() *Node2DBase

CopyParentPaint copy our paint from our parents -- called during Style for SVG

func (*Node2DBase) DefaultStyle2DWidget

func (g *Node2DBase) DefaultStyle2DWidget(selector string, part *Node2DBase) *Style

DefaultStyle2DWidget retrieves default style object for the type, from type properties -- selector is optional selector for state etc. Property key is "__DefStyle" + selector -- if part != nil, then use that obj for getting the default style starting point when creating a new style

func (*Node2DBase) FocusChanged2D

func (g *Node2DBase) FocusChanged2D(gotFocus bool)

func (*Node2DBase) FullRender2DTree

func (g *Node2DBase) FullRender2DTree()

full render of the tree

func (*Node2DBase) HasFocus2D

func (g *Node2DBase) HasFocus2D() bool

func (*Node2DBase) Init2D

func (g *Node2DBase) Init2D()

func (*Node2DBase) Init2DBase

func (g *Node2DBase) Init2DBase()

handles basic node initialization -- Init2D can then do special things

func (*Node2DBase) Init2DTree

func (g *Node2DBase) Init2DTree()

initialize scene graph tree from node it is called on -- only needs to be done once but must be robust to repeated calls -- use a flag if necessary -- needed after structural updates to ensure all nodes are updated

func (*Node2DBase) InitLayout2D

func (g *Node2DBase) InitLayout2D()

func (*Node2DBase) Layout2D

func (g *Node2DBase) Layout2D(parBBox image.Rectangle)

func (*Node2DBase) Layout2DBase

func (g *Node2DBase) Layout2DBase(parBBox image.Rectangle, initStyle bool)

basic Layout2D functions -- good for most cases

func (*Node2DBase) Layout2DChildren

func (g *Node2DBase) Layout2DChildren()

layout on all of node's children, giving them the ChildrenBBox2D -- default call at end of Layout2D

func (*Node2DBase) Layout2DTree

func (g *Node2DBase) Layout2DTree()

layout pass -- each node iterates over children for maximum control -- this starts with parent VpBBox -- can be called de novo

func (*Node2DBase) Move2D

func (g *Node2DBase) Move2D(delta image.Point, parBBox image.Rectangle)

func (*Node2DBase) Move2DBase

func (g *Node2DBase) Move2DBase(delta image.Point, parBBox image.Rectangle)

func (*Node2DBase) Move2DChildren

func (g *Node2DBase) Move2DChildren(delta image.Point)

move all of node's children, giving them the ChildrenBBox2D -- default call at end of Move2D

func (*Node2DBase) Move2DTree

func (g *Node2DBase) Move2DTree()

move2d pass -- each node iterates over children for maximum control -- this starts with parent VpBBox and current delta -- can be called de novo

func (*Node2DBase) New

func (n *Node2DBase) New() ki.Ki

func (*Node2DBase) ParentLayout

func (g *Node2DBase) ParentLayout() *Layout

func (*Node2DBase) ParentReRenderAnchor

func (g *Node2DBase) ParentReRenderAnchor() Node2D

find parent that is a ReRenderAnchor

func (*Node2DBase) ParentSVG

func (g *Node2DBase) ParentSVG() *SVG

func (*Node2DBase) ParentViewport

func (g *Node2DBase) ParentViewport() *Viewport2D

find parent viewport -- uses AsViewport2D() method on Node2D interface

func (*Node2DBase) ParentWindow

func (g *Node2DBase) ParentWindow() *Window

func (*Node2DBase) PopBounds

func (g *Node2DBase) PopBounds()

pop our bounding-box bounds -- last step in Render2D after rendering children

func (*Node2DBase) PushBounds

func (g *Node2DBase) PushBounds() bool

if non-empty, push our bounding-box bounds onto the bounds stack -- this limits our drawing to our own bounding box, automatically -- must be called as first step in Render2D returns whether the new bounds are empty or not -- if empty then don't render!

func (*Node2DBase) ReRender2D

func (g *Node2DBase) ReRender2D() (node Node2D, layout bool)

func (*Node2DBase) ReRender2DTree

func (g *Node2DBase) ReRender2DTree()

re-render of the tree -- after it has already been initialized and styled -- just does layout and render passes

func (*Node2DBase) ReceiveEventType

func (g *Node2DBase) ReceiveEventType(et oswin.EventType, fun ki.RecvFunc)

redefining this here gives access to the much faster ParentWindow method!

func (*Node2DBase) Render2D

func (g *Node2DBase) Render2D()

func (*Node2DBase) Render2DChildren

func (g *Node2DBase) Render2DChildren()

render all of node's children -- default call at end of Render2D()

func (*Node2DBase) Render2DTree

func (g *Node2DBase) Render2DTree()

render just calls on parent node and it takes full responsibility for managing the children -- this allows maximum flexibility for order etc of rendering

func (*Node2DBase) SetFixedHeight

func (g *Node2DBase) SetFixedHeight(val units.Value)

set all height options (height, min-height, max-height) to a fixed height value

func (*Node2DBase) SetFixedWidth

func (g *Node2DBase) SetFixedWidth(val units.Value)

set all width options (width, min-width, max-width) to a fixed width value

func (*Node2DBase) SetMinPrefHeight

func (g *Node2DBase) SetMinPrefHeight(val units.Value)

set minimum and preferred height-- will get at least this amount -- max unspecified

func (*Node2DBase) SetMinPrefWidth

func (g *Node2DBase) SetMinPrefWidth(val units.Value)

set minimum and preferred width -- will get at least this amount -- max unspecified

func (*Node2DBase) SetStretchMaxHeight

func (g *Node2DBase) SetStretchMaxHeight()

set stretchy max height -- can grow to take up avail room

func (*Node2DBase) SetStretchMaxWidth

func (g *Node2DBase) SetStretchMaxWidth()

set stretchy max width -- can grow to take up avail room

func (*Node2DBase) SetWinBBox

func (g *Node2DBase) SetWinBBox()

set our window-level BBox from vp and our bbox

func (*Node2DBase) Size2D

func (g *Node2DBase) Size2D()

func (*Node2DBase) Size2DTree

func (g *Node2DBase) Size2DTree()

do the sizing as a depth-first pass

func (*Node2DBase) Style2D

func (g *Node2DBase) Style2D()

func (*Node2DBase) Style2DSVG

func (g *Node2DBase) Style2DSVG()

Style2DSVG styles the Paint values directly from node properties -- for SVG-style nodes -- no relevant default styling here -- parents can just set props directly as needed

func (*Node2DBase) Style2DTree

func (g *Node2DBase) Style2DTree()

style scene graph tree from node it is called on -- only needs to be done after a structural update in case inherited options changed

func (*Node2DBase) Style2DWidget

func (g *Node2DBase) Style2DWidget()

Style2DWidget styles the Style values from node properties and optional base-level defaults -- for Widget-style nodes

func (*Node2DBase) StylePart

func (g *Node2DBase) StylePart(pk ki.Ki)

StylePart sets the style properties for a child in parts (or any other child) based on its name -- only call this when new parts were created -- name of properties is #partname (lower cased) and it should contain a ki.Props which is then added to the part's props -- this provides built-in defaults for parts, so it is separate from the CSS process

type Node3DBase

type Node3DBase struct {
	NodeBase
}

basic component node for 3D rendering -- has a 3D transform

func (*Node3DBase) New

func (n *Node3DBase) New() ki.Ki

type NodeBase

type NodeBase struct {
	ki.Node
	Class   string          `desc:"user-defined class name used primarily for attaching CSS styles to different display elements"`
	BBox    image.Rectangle `` /* 192-byte string literal not displayed */
	VpBBox  image.Rectangle `` /* 231-byte string literal not displayed */
	WinBBox image.Rectangle `` /* 198-byte string literal not displayed */
}

NodeBase is the base struct type for GoGi graphical interface system, containing infrastructure for both 2D and 3D scene graph nodes

func (*NodeBase) CanFocus

func (g *NodeBase) CanFocus() bool

can this node focus?

func (*NodeBase) ClearFullReRender

func (g *NodeBase) ClearFullReRender()

clear node as needing a full ReRender

func (*NodeBase) DisconnectAllEvents

func (g *NodeBase) DisconnectAllEvents(win *Window)

disconnect node from all events

func (*NodeBase) DisconnectAllEventsTree

func (g *NodeBase) DisconnectAllEventsTree(win *Window)

disconnect node from all events - todo: need a more generic Ki version of this

func (*NodeBase) GrabFocus

func (g *NodeBase) GrabFocus()

set node as focus node

func (*NodeBase) HasFocus

func (g *NodeBase) HasFocus() bool

does the current node have keyboard focus

func (*NodeBase) IsDragging

func (g *NodeBase) IsDragging() bool

is the current node currently receiving dragging events? set by window

func (*NodeBase) IsInactive

func (g *NodeBase) IsInactive() bool

is this node Inactive? if so, behave (ignore events) and style appropriately

func (*NodeBase) IsReRenderAnchor

func (g *NodeBase) IsReRenderAnchor() bool

is the current node a ReRenderAnchor?

func (*NodeBase) NeedsFullReRender

func (g *NodeBase) NeedsFullReRender() bool

node needs full re-render?

func (*NodeBase) New

func (n *NodeBase) New() ki.Ki

func (*NodeBase) ParentWindow

func (g *NodeBase) ParentWindow() *Window

func (*NodeBase) PointToRelPos

func (g *NodeBase) PointToRelPos(pt image.Point) image.Point

translate a point in global pixel coords into relative position within node

func (*NodeBase) ReceiveEventType

func (g *NodeBase) ReceiveEventType(et oswin.EventType, fun ki.RecvFunc)

register this node to receive a given type of GUI event signal from the parent window

func (*NodeBase) SetCanFocusIfActive

func (g *NodeBase) SetCanFocusIfActive()

set CanFocus only if not inactive

func (*NodeBase) SetFullReRender

func (g *NodeBase) SetFullReRender()

set node as needing a full ReRender

func (*NodeBase) SetInactive

func (g *NodeBase) SetInactive()

set the node as inactive

func (*NodeBase) SetInactiveState

func (g *NodeBase) SetInactiveState(readOnly bool)

set inactive state of the node

func (*NodeBase) SetReRenderAnchor

func (g *NodeBase) SetReRenderAnchor()

set node as a ReRenderAnchor

func (*NodeBase) StyleProps

func (g *NodeBase) StyleProps(selector string) ki.Props

StyleProps returns a property that contains another map of properties for a given styling selector, such as :normal :active :hover etc -- the convention is to prefix this selector with a : and use lower-case names, so we follow that.

type NodeFlags

type NodeFlags int32

gi node flags are bitflags for tracking common high-frequency GUI state, mostly having to do with event processing -- use properties map for less frequently used information -- uses ki Flags field

const (
	// button is selected
	ButtonFlagSelected NodeFlags = NodeFlagsN + iota

	// button is checkable -- enables display of check control
	ButtonFlagCheckable

	// button is checked
	ButtonFlagChecked

	// Menu flag means that the button is a menu item
	ButtonFlagMenu

	ButtonFlagsN
)

these extend NodeBase NodeFlags to hold button state

const (
	NodeFlagsNil NodeFlags = NodeFlags(ki.FlagsN) + iota

	// CanFocus: can this node accept focus to receive keyboard input events
	// -- set by default for typical nodes that do so, but can be overridden,
	// including by the style 'can-focus' property
	CanFocus

	// HasFocus: does this node currently have the focus for keyboard input
	// events?  use tab / alt tab and clicking events to update focus -- see
	// interface on Window
	HasFocus

	// FullReRender indicates that a full re-render is required due to nature
	// of update event -- otherwise default is local re-render -- used
	// internally for nodes to determine what to do on the ReRender step
	FullReRender

	// ReRenderAnchor: this node has a static size, and repaints its
	// background -- any children under it that need to dynamically resize on
	// a ReRender (Update) can refer the update up to rerendering this node,
	// instead of going further up the tree -- e.g., true of Frame's within a
	// SplitView
	ReRenderAnchor

	// Inactive disables interaction with widgets or other nodes -- they
	// should indicate this inactive state in an appropriate way, and not
	// process input events
	Inactive

	// InactiveEvents overrides the default behavior where inactive nodes are
	// not sent events from the Window -- for e.g., the TextField which can
	// still be selected and copied when inactive
	InactiveEvents

	// MouseHasEntered indicates that the MouseEnteredEvent was previously
	// registered on this node
	MouseHasEntered

	// NodeDragging indicates this node is currently dragging -- win.Dragging
	// set to this node
	NodeDragging

	// can extend node flags from here
	NodeFlagsN
)
const (
	// node is closed
	TreeViewFlagClosed NodeFlags = NodeFlagsN + iota
	// node is selected
	TreeViewFlagSelected
	// the shift key was pressed, putting the selection mode into continous selection mode
	TreeViewFlagContinuousSelect
	// the ctrl / cmd key was pressed, putting the selection mode into continous selection mode
	TreeViewFlagExtendSelect
)

these extend NodeBase NodeFlags to hold TreeView state

const (
	// VpFlagPopup means viewport is a popup (menu or dialog) -- does not obey
	// parent bounds (otherwise does)
	VpFlagPopup NodeFlags = NodeFlagsN + iota

	// VpFlagMenu means viewport is serving as a popup menu -- affects how window
	// processes clicks
	VpFlagMenu

	// VpFlagPopupDestroyAll means that if this is a popup, then destroy all
	// the children when it is deleted -- otherwise children below the main
	// layout under the vp will not be destroyed -- it is up to the caller to
	// manage those (typically these are reusable assets)
	VpFlagPopupDestroyAll

	// VpFlagSVG mans that this viewport is an SVG viewport -- SVG elements
	// look for this for re-rendering
	VpFlagSVG

	// VpFlagDrawIntoWin means it should draw into window directly instead of
	// drawing into parent -- i.e., as a sprite
	VpFlagDrawIntoWin
)

these flags extend NodeBase NodeFlags to hold viewport state

func StringToNodeFlags

func StringToNodeFlags(s string) (NodeFlags, error)

func (NodeFlags) String

func (i NodeFlags) String() string

type Overflow

type Overflow int32

overflow type -- determines what happens when there is too much stuff in a layout

const (
	// automatically add scrollbars as needed -- this is pretty much the only sensible option, and is the default here, but Visible is default in html
	OverflowAuto Overflow = iota
	// pretty much the same as auto -- we treat it as such
	OverflowScroll
	// make the overflow visible -- this is generally unsafe and not very feasible and will be ignored as long as possible -- currently falls back on auto, but could go to Hidden if that works better overall
	OverflowVisible
	// hide the overflow and don't present scrollbars (supported)
	OverflowHidden
	OverflowN
)

func (*Overflow) FromString

func (i *Overflow) FromString(s string) error

func (Overflow) MarshalJSON

func (ev Overflow) MarshalJSON() ([]byte, error)

func (Overflow) String

func (i Overflow) String() string

func (*Overflow) UnmarshalJSON

func (ev *Overflow) UnmarshalJSON(b []byte) error

type Paint

type Paint struct {
	Off         bool          `desc:"node and everything below it are off, non-rendering"`
	StyleSet    bool          `desc:"have the styles already been set?"`
	PropsNil    bool          `desc:"set to true if parent node has no props -- allows optimization of styling"`
	UnContext   units.Context `xml:"-" desc:"units context -- parameters necessary for anchoring relative units"`
	StrokeStyle StrokeStyle
	FillStyle   FillStyle
	FontStyle   FontStyle
	TextStyle   TextStyle
	XForm       XFormMatrix2D `xml:"-" json:"-" desc:"our additions to transform -- pushed to render state"`
	// contains filtered or unexported fields
}

The Paint object provides the full context (parameters) and functions for painting onto an image -- image is always passed as an argument so it can be applied to anything

var PaintDefault Paint

PaintDefault is default style can be used when property specifies "default"

func NewPaint

func NewPaint() Paint

func (*Paint) AsMask

func (pc *Paint) AsMask(rs *RenderState) *image.Alpha

AsMask returns an *image.Alpha representing the alpha channel of this context. This can be useful for advanced clipping operations where you first render the mask geometry and then use it as a mask.

func (*Paint) BoundingBox

func (pc *Paint) BoundingBox(rs *RenderState, minX, minY, maxX, maxY float32) image.Rectangle

get the bounding box for an element in pixel int coordinates

func (*Paint) BoundingBoxFromPoints

func (pc *Paint) BoundingBoxFromPoints(rs *RenderState, points []Vec2D) image.Rectangle

get the bounding box for a slice of points

func (*Paint) Clear

func (pc *Paint) Clear(rs *RenderState)

Clear fills the entire image with the current fill color.

func (*Paint) ClearPath

func (pc *Paint) ClearPath(rs *RenderState)

ClearPath clears the current path. There is no current point after this operation.

func (*Paint) Clip

func (pc *Paint) Clip(rs *RenderState)

Clip updates the clipping region by intersecting the current clipping region with the current path as it would be filled by pc.Fill(). The path is cleared after this operation.

func (*Paint) ClipPreserve

func (pc *Paint) ClipPreserve(rs *RenderState)

ClipPreserve updates the clipping region by intersecting the current clipping region with the current path as it would be filled by pc.Fill(). The path is preserved after this operation.

func (*Paint) ClosePath

func (pc *Paint) ClosePath(rs *RenderState)

ClosePath adds a line segment from the current point to the beginning of the current subpath. If there is no current point, this is a no-op.

func (*Paint) CopyFrom

func (pc *Paint) CopyFrom(cp *Paint)

CopyFrom copies from another Paint, while preserving relevant local state

func (*Paint) CubicTo

func (pc *Paint) CubicTo(rs *RenderState, x1, y1, x2, y2, x3, y3 float32)

CubicTo adds a cubic bezier curve to the current path starting at the current point. If there is no current point, it first performs MoveTo(x1, y1). Because freetype/raster does not support cubic beziers, this is emulated with many small line segments.

func (*Paint) Defaults

func (pc *Paint) Defaults()

func (*Paint) DrawArc

func (pc *Paint) DrawArc(rs *RenderState, x, y, r, angle1, angle2 float32)

func (*Paint) DrawCircle

func (pc *Paint) DrawCircle(rs *RenderState, x, y, r float32)

func (*Paint) DrawEllipse

func (pc *Paint) DrawEllipse(rs *RenderState, x, y, rx, ry float32)

func (*Paint) DrawEllipticalArc

func (pc *Paint) DrawEllipticalArc(rs *RenderState, x, y, rx, ry, angle1, angle2 float32)

func (*Paint) DrawImage

func (pc *Paint) DrawImage(rs *RenderState, fmIm image.Image, x, y int)

DrawImage draws the specified image at the specified point.

func (*Paint) DrawImageAnchored

func (pc *Paint) DrawImageAnchored(rs *RenderState, fmIm image.Image, x, y int, ax, ay float32)

DrawImageAnchored draws the specified image at the specified anchor point. The anchor point is x - w * ax, y - h * ay, where w, h is the size of the image. Use ax=0.5, ay=0.5 to center the image at the specified point.

func (*Paint) DrawLine

func (pc *Paint) DrawLine(rs *RenderState, x1, y1, x2, y2 float32)

func (*Paint) DrawPolygon

func (pc *Paint) DrawPolygon(rs *RenderState, points []Vec2D)

func (*Paint) DrawPolyline

func (pc *Paint) DrawPolyline(rs *RenderState, points []Vec2D)

func (*Paint) DrawRectangle

func (pc *Paint) DrawRectangle(rs *RenderState, x, y, w, h float32)

func (*Paint) DrawRegularPolygon

func (pc *Paint) DrawRegularPolygon(rs *RenderState, n int, x, y, r, rotation float32)

func (*Paint) DrawRoundedRectangle

func (pc *Paint) DrawRoundedRectangle(rs *RenderState, x, y, w, h, r float32)

func (*Paint) DrawString

func (pc *Paint) DrawString(rs *RenderState, s string, x, y, width float32)

DrawString according to current settings -- width is needed for alignment -- if non-zero, then x position is for the left edge of the width box, and alignment is WRT that width -- otherwise x position is as in DrawStringAnchored

func (*Paint) DrawStringAnchored

func (pc *Paint) DrawStringAnchored(rs *RenderState, s string, x, y, ax, ay, width float32)

DrawStringAnchored draws the specified text at the specified anchor point. The anchor point is x - w * ax, y - h * ay, where w, h is the size of the text. Use ax=0.5, ay=0.5 to center the text at the specified point.

func (*Paint) DrawStringLines

func (pc *Paint) DrawStringLines(rs *RenderState, lines []string, x, y, width, height float32)

func (*Paint) DrawStringLinesAnchored

func (pc *Paint) DrawStringLinesAnchored(rs *RenderState, lines []string, x, y, ax, ay, width, h, lineHeight float32)

func (*Paint) DrawStringWrapped

func (pc *Paint) DrawStringWrapped(rs *RenderState, s string, x, y, ax, ay, width, lineHeight float32)

DrawStringWrapped word-wraps the specified string to the given max width and then draws it at the specified anchor point using the given line spacing and text alignment.

func (*Paint) Fill

func (pc *Paint) Fill(rs *RenderState)

Fill fills the current path with the current color. Open subpaths are implicity closed. The path is cleared after this operation.

func (*Paint) FillBox

func (pc *Paint) FillBox(rs *RenderState, pos, size Vec2D, clr color.Color)

Fill box is an optimized fill of a square region with a uniform color -- currently Fill is the major bottleneck on performance..

func (*Paint) FillPreserve

func (pc *Paint) FillPreserve(rs *RenderState)

FillPreserve fills the current path with the current color. Open subpaths are implicity closed. The path is preserved after this operation.

func (*Paint) FillStrokeClear

func (pc *Paint) FillStrokeClear(rs *RenderState)

convenience for final draw for shapes when done

func (*Paint) FontHeight

func (pc *Paint) FontHeight() float32

FontHeight -- returns the height of the current font

func (*Paint) HasFill

func (pc *Paint) HasFill() bool

does the current Paint have an active fill to render?

func (*Paint) HasNoStrokeOrFill

func (pc *Paint) HasNoStrokeOrFill() bool

does the current Paint not have either a stroke or fill? in which case, often we just skip it

func (*Paint) HasStroke

func (pc *Paint) HasStroke() bool

does the current Paint have an active stroke to render?

func (*Paint) Identity

func (pc *Paint) Identity()

Identity resets the current transformation matrix to the identity matrix. This results in no translating, scaling, rotating, or shearing.

func (*Paint) InvertY

func (pc *Paint) InvertY(rs *RenderState)

InvertY flips the Y axis so that Y grows from bottom to top and Y=0 is at the bottom of the image.

func (*Paint) LineTo

func (pc *Paint) LineTo(rs *RenderState, x, y float32)

LineTo adds a line segment to the current path starting at the current point. If there is no current point, it is equivalent to MoveTo(x, y)

func (*Paint) LoadFontFace

func (pc *Paint) LoadFontFace(path string, points float64) error

func (*Paint) MeasureChars

func (pc *Paint) MeasureChars(s string) []float32

MeasureChars measures the rendered character positions of the given text in the current font

func (*Paint) MeasureString

func (pc *Paint) MeasureString(s string) (w, h float32)

MeasureString returns the rendered width and height of the specified text given the current font face.

func (*Paint) MeasureStringWrapped

func (pc *Paint) MeasureStringWrapped(s string, width, lineHeight float32) ([]string, float32)

func (*Paint) MoveTo

func (pc *Paint) MoveTo(rs *RenderState, x, y float32)

MoveTo starts a new subpath within the current path starting at the specified point.

func (*Paint) NewSubPath

func (pc *Paint) NewSubPath(rs *RenderState)

NewSubPath starts a new subpath within the current path. There is no current point after this operation.

func (*Paint) QuadraticTo

func (pc *Paint) QuadraticTo(rs *RenderState, x1, y1, x2, y2 float32)

QuadraticTo adds a quadratic bezier curve to the current path starting at the current point. If there is no current point, it first performs MoveTo(x1, y1)

func (*Paint) ResetClip

func (pc *Paint) ResetClip(rs *RenderState)

ResetClip clears the clipping region.

func (*Paint) Rotate

func (pc *Paint) Rotate(angle float32)

Rotate updates the current matrix with a clockwise rotation. Rotation occurs about the origin. Angle is specified in radians.

func (*Paint) RotateAbout

func (pc *Paint) RotateAbout(angle, x, y float32)

RotateAbout updates the current matrix with a clockwise rotation. Rotation occurs about the specified point. Angle is specified in radians.

func (*Paint) Scale

func (pc *Paint) Scale(x, y float32)

Scale updates the current matrix with a scaling factor. Scaling occurs about the origin.

func (*Paint) ScaleAbout

func (pc *Paint) ScaleAbout(sx, sy, x, y float32)

ScaleAbout updates the current matrix with a scaling factor. Scaling occurs about the specified point.

func (*Paint) SetFontFace

func (pc *Paint) SetFontFace(fontFace font.Face)

func (*Paint) SetMask

func (pc *Paint) SetMask(rs *RenderState, mask *image.Alpha) error

SetMask allows you to directly set the *image.Alpha to be used as a clipping mask. It must be the same size as the context, else an error is returned and the mask is unchanged.

func (*Paint) SetPixel

func (pc *Paint) SetPixel(rs *RenderState, x, y int)

SetPixel sets the color of the specified pixel using the current stroke color.

func (*Paint) SetStyle

func (pc *Paint) SetStyle(parent *Paint, props ki.Props)

SetStyle sets paint values based on given property map (name: value pairs), inheriting elements as appropriate from parent, and also having a default style for the "initial" setting

func (*Paint) SetUnitContext

func (pc *Paint) SetUnitContext(vp *Viewport2D, el Vec2D)

SetUnitContext sets the unit context based on size of viewport and parent element (from bbox) and then cache everything out in terms of raw pixel dots for rendering -- call at start of render

func (*Paint) Shear

func (pc *Paint) Shear(x, y float32)

Shear updates the current matrix with a shearing angle. Shearing occurs about the origin.

func (*Paint) ShearAbout

func (pc *Paint) ShearAbout(sx, sy, x, y float32)

ShearAbout updates the current matrix with a shearing angle. Shearing occurs about the specified point.

func (*Paint) Stroke

func (pc *Paint) Stroke(rs *RenderState)

Stroke strokes the current path with the current color, line width, line cap, line join and dash settings. The path is cleared after this operation.

func (*Paint) StrokePreserve

func (pc *Paint) StrokePreserve(rs *RenderState)

StrokePreserve strokes the current path with the current color, line width, line cap, line join and dash settings. The path is preserved after this operation.

func (*Paint) ToDots

func (pc *Paint) ToDots()

ToDots calls ToDots on all units.Value fields in the style (recursively) -- need to have set the UnContext first -- only after layout at render time is that possible

func (*Paint) TransformPoint

func (pc *Paint) TransformPoint(rs *RenderState, x, y float32) Vec2D

TransformPoint multiplies the specified point by the current transform matrix, returning a transformed position.

func (*Paint) Translate

func (pc *Paint) Translate(x, y float32)

Translate updates the current matrix with a translation.

func (*Paint) WordWrap

func (pc *Paint) WordWrap(s string, w float32) []string

WordWrap wraps the specified string to the given max width and current font face.

type PaintServer

type PaintServer interface {
	ColorAt(x, y int) color.Color
	ServerType() PaintServers
}

func NewImagePaintServer

func NewImagePaintServer(im image.Image, op RepeatOp) PaintServer

func NewSolidcolorPaintServer

func NewSolidcolorPaintServer(color color.Color) PaintServer

type PaintServers

type PaintServers int32

PaintServers provide patterned colors for stroke and fill operations

const (
	PaintSolidcolor PaintServers = iota
	PaintLinearGradient
	PaintRadialGradient
	PaintMeshGradient
	PaintPattern
	PaintHatch
	PaintHatchpath
	PaintImage // apparently not SVG-standard but we have it.
	PaintServersN
)

func (*PaintServers) FromString

func (i *PaintServers) FromString(s string) error

func (PaintServers) MarshalJSON

func (ev PaintServers) MarshalJSON() ([]byte, error)

func (PaintServers) String

func (i PaintServers) String() string

func (*PaintServers) UnmarshalJSON

func (ev *PaintServers) UnmarshalJSON(b []byte) error

type Path

type Path struct {
	Node2DBase
	Data     []PathData `` /* 171-byte string literal not displayed */
	MinCoord Vec2D      `desc:"minimum coord in path -- computed in BBox2D"`
	MaxCoord Vec2D      `desc:"maximum coord in path -- computed in BBox2D"`
}

2D Path, using SVG-style data that can render just about anything

func (*Path) BBox2D

func (g *Path) BBox2D() image.Rectangle

func (*Path) New

func (n *Path) New() ki.Ki

func (*Path) ReRender2D

func (g *Path) ReRender2D() (node Node2D, layout bool)

func (*Path) Render2D

func (g *Path) Render2D()

type PathCmds

type PathCmds byte

the commands within the path SVG drawing data type

const (
	// move pen, abs coords
	PcM PathCmds = iota
	// move pen, rel coords
	Pcm
	// lineto, abs
	PcL
	// lineto, rel
	Pcl
	// horizontal lineto, abs
	PcH
	// relative lineto, rel
	Pch
	// vertical lineto, abs
	PcV
	// vertical lineto, rel
	Pcv
	// Bezier curveto, abs
	PcC
	// Bezier curveto, rel
	Pcc
	// smooth Bezier curveto, abs
	PcS
	// smooth Bezier curveto, rel
	Pcs
	// quadratic Bezier curveto, abs
	PcQ
	// quadratic Bezier curveto, rel
	Pcq
	// smooth quadratic Bezier curveto, abs
	PcT
	// smooth quadratic Bezier curveto, rel
	Pct
	// elliptical arc, abs
	PcA
	// elliptical arc, rel
	Pca
	// close path
	PcZ
	// close path
	Pcz
)

func (PathCmds) EncCmd

func (pc PathCmds) EncCmd(n int) PathData

encode command and n into PathData

type PathData

type PathData float32

to encode the data, we use 32-bit floats which are converted into int32 for path commands, which contain the number of data points following the path command to interpret as numbers, in the lower and upper 2 bytes of the converted int32 number we don't need that many bits, but keeping 32-bit alignment is probably good and really these things don't need to be crazy compact as it is unlikely to make a relevant diff in size or perf to pack down further

func PathDataNext

func PathDataNext(data []PathData, i *int) PathData

PathDataNext gets the next path data element, incrementing the index -- ++ not an expression so its clunky -- hopefully this is inlined..

func PathDataParse

func PathDataParse(d string) []PathData

func (PathData) Cmd

func (pd PathData) Cmd() (PathCmds, int)

decode path data as a command and a number of subsequent values for that command

type Polygon

type Polygon struct {
	Node2DBase
	Points []Vec2D `` /* 137-byte string literal not displayed */
}

2D Polygon

func (*Polygon) BBox2D

func (g *Polygon) BBox2D() image.Rectangle

func (*Polygon) New

func (n *Polygon) New() ki.Ki

func (*Polygon) ReRender2D

func (g *Polygon) ReRender2D() (node Node2D, layout bool)

func (*Polygon) Render2D

func (g *Polygon) Render2D()

type Polyline

type Polyline struct {
	Node2DBase
	Points []Vec2D `xml:"points" desc:"the coordinates to draw -- does a moveto on the first, then lineto for all the rest"`
}

2D Polyline

func (*Polyline) BBox2D

func (g *Polyline) BBox2D() image.Rectangle

func (*Polyline) New

func (n *Polyline) New() ki.Ki

func (*Polyline) ReRender2D

func (g *Polyline) ReRender2D() (node Node2D, layout bool)

func (*Polyline) Render2D

func (g *Polyline) Render2D()

type Preferences

type Preferences struct {
	LogicalDPIScale  float32 `` /* 148-byte string literal not displayed */
	ScreenPrefs      map[string]Preferences
	DialogsSepWindow bool     `desc:"do dialog windows open in a separate OS-level window, or do they open within the same parent window"`
	DoubleClickMSec  int      `min:"100" step:"50" desc:"the maximum time interval in msec between button press events to count as a double-click"`
	FontColor        Color    `desc:"default font / pen color"`
	BackgroundColor  Color    `desc:"default background color"`
	ShadowColor      Color    `desc:"color for shadows -- should generally be a darker shade of the background color"`
	BorderColor      Color    `desc:"default border color, for button, frame borders, etc"`
	ControlColor     Color    `desc:"default main color for controls: buttons, etc"`
	IconColor        Color    `desc:"color for icons or other solidly-colored, small elements"`
	SelectColor      Color    `desc:"color for selected elements"`
	CustomKeyMap     KeyMap   `desc:"customized mapping from keys to interface functions"`
	PrefsOverride    bool     `` /* 146-byte string literal not displayed */
	CustomStyles     ki.Props `` /* 189-byte string literal not displayed */
	FontPaths        []string `desc:"extra font paths, beyond system defaults -- searched first"`
}

Preferences are the overall user preferences for GoGi, providing some basic customization -- in addition, most gui settings can be styled using CSS-style sheets under CustomStyle. These prefs are saved and loaded from the GoGi user preferences directory -- see oswin/App for further info

func (*Preferences) Apply

func (p *Preferences) Apply()

Apply preferences to all the relevant settings

func (*Preferences) DefaultKeyMap

func (p *Preferences) DefaultKeyMap()

DefaultKeyMap installs the current default key map, prior to editing

func (*Preferences) Defaults

func (p *Preferences) Defaults()

func (*Preferences) Edit

func (p *Preferences) Edit()

Edit Preferences in a separate window

func (*Preferences) Load

func (p *Preferences) Load() error

Load preferences from GoGi standard prefs directory

func (*Preferences) Save

func (p *Preferences) Save() error

Save Preferences to GoGi standard prefs directory

func (*Preferences) Update

func (p *Preferences) Update()

Update everything with current preferences -- triggers rebuild of default styles

type RGBAf32

type RGBAf32 struct {
	R, G, B, A float32
}

RGBAf32 stores alpha-premultiplied RGBA values in float32 0..1 normalized format -- more useful for converting to other spaces

func (RGBAf32) RGBA

func (c RGBAf32) RGBA() (r, g, b, a uint32)

Implements the color.Color interface

type Rect

type Rect struct {
	Node2DBase
	Pos    Vec2D `xml:"{x,y}" desc:"position of the top-left of the rectangle"`
	Size   Vec2D `xml:"{width,height}" desc:"size of the rectangle"`
	Radius Vec2D `xml:"{rx,ry}" desc:"radii for curved corners, as a proportion of width, height"`
}

2D rectangle, optionally with rounded corners

func (*Rect) BBox2D

func (g *Rect) BBox2D() image.Rectangle

func (*Rect) New

func (n *Rect) New() ki.Ki

func (*Rect) ReRender2D

func (g *Rect) ReRender2D() (node Node2D, layout bool)

func (*Rect) Render2D

func (g *Rect) Render2D()

type Region2D

type Region2D struct {
	Offset mgl32.Vec2
	Size   mgl32.Vec2
}

defines a region in 2D space

type RegionMap2D

type RegionMap2D struct {
	Target  Region2D   `desc:"target region to render into (e.g., in RenderPlane)"`
	Rescale mgl32.Vec2 `` /* 165-byte string literal not displayed */
	Size    mgl32.Vec2 `desc:"Our overall size: Target.Size * Rescale"`
}

defines how a region in 2D space is mapped

type RenderState

type RenderState struct {
	XForm       XFormMatrix2D     `desc:"current transform"`
	StrokePath  raster.Path       `desc:"current stroke path"`
	FillPath    raster.Path       `desc:"current fill path"`
	Start       Vec2D             `desc:"starting point, for close path"`
	Current     Vec2D             `desc:"current point"`
	HasCurrent  bool              `desc:"is current point current?"`
	Image       *image.RGBA       `desc:"pointer to image to render into"`
	Mask        *image.Alpha      `desc:"current mask"`
	Bounds      image.Rectangle   `` /* 136-byte string literal not displayed */
	XFormStack  []XFormMatrix2D   `desc:"stack of transforms"`
	BoundsStack []image.Rectangle `desc:"stack of bounds -- every render starts with a push onto this stack, and finishes with a pop"`
	ClipStack   []*image.Alpha    `desc:"stack of clips, if needed"`
}

The RenderState holds all the current rendering state information used while painting -- a viewport just has one of these

func (*RenderState) Defaults

func (rs *RenderState) Defaults()

func (*RenderState) PopBounds

func (rs *RenderState) PopBounds()

pop bounds off the stack and set to current bounds

func (*RenderState) PopClip

func (rs *RenderState) PopClip()

pop Mask off the clip stack and set to current mask

func (*RenderState) PopXForm

func (rs *RenderState) PopXForm()

pop xform off the stack and set to current xform

func (*RenderState) PushBounds

func (rs *RenderState) PushBounds(b image.Rectangle)

push current bounds onto stack and set new bounds

func (*RenderState) PushClip

func (rs *RenderState) PushClip()

push current Mask onto the clip stack

func (*RenderState) PushXForm

func (rs *RenderState) PushXForm(xf XFormMatrix2D)

push current xform onto stack and apply new xform on top of it

type RepeatOp

type RepeatOp int

todo: this is not SVG standard and needs to be updated for pattern paint server, the way in which the pattern repeats

const (
	RepeatBoth RepeatOp = iota
	RepeatX
	RepeatY
	RepeatNone
)

type RowCol

type RowCol int32

row / col for grid data

const (
	Row RowCol = iota
	Col
	RowColN
)

func (*RowCol) FromString

func (i *RowCol) FromString(s string) error

func (RowCol) MarshalJSON

func (ev RowCol) MarshalJSON() ([]byte, error)

func (RowCol) String

func (i RowCol) String() string

func (*RowCol) UnmarshalJSON

func (ev *RowCol) UnmarshalJSON(b []byte) error

type SVG

type SVG struct {
	Viewport2D
}

SVG is a viewport for containing SVG drawing objects, correponding to the svg tag in html -- it provides its own bitmap for drawing into

func (*SVG) Init2D

func (vp *SVG) Init2D()

func (*SVG) Layout2D

func (vp *SVG) Layout2D(parBBox image.Rectangle)

func (*SVG) New

func (n *SVG) New() ki.Ki

func (*SVG) Render2D

func (vp *SVG) Render2D()

func (*SVG) Style2D

func (vp *SVG) Style2D()

type ScreenPrefs

type ScreenPrefs struct {
	LogicalDPIScale float32 `` /* 127-byte string literal not displayed */
}

ScreenPrefs are the per-screen preferences -- see oswin/App/Screen() for info on the different screens -- these prefs are indexed by the Screen.Name -- settings here override those in the global preferences

type ScrollBar

type ScrollBar struct {
	SliderBase
}

ScrollBar has a proportional thumb size reflecting amount of content visible

func (*ScrollBar) Defaults

func (g *ScrollBar) Defaults()

func (*ScrollBar) FocusChanged2D

func (g *ScrollBar) FocusChanged2D(gotFocus bool)

func (*ScrollBar) Init2D

func (g *ScrollBar) Init2D()

func (*ScrollBar) Layout2D

func (g *ScrollBar) Layout2D(parBBox image.Rectangle)

func (*ScrollBar) New

func (n *ScrollBar) New() ki.Ki

func (*ScrollBar) Render2D

func (g *ScrollBar) Render2D()

func (*ScrollBar) Render2DDefaultStyle

func (g *ScrollBar) Render2DDefaultStyle()

render using a default style if not otherwise styled

func (*ScrollBar) Size2D

func (g *ScrollBar) Size2D()

func (*ScrollBar) Style2D

func (g *ScrollBar) Style2D()

type Separator

type Separator struct {
	WidgetBase
	Horiz bool `xml:"horiz" desc:"is this a horizontal separator -- otherwise vertical"`
}

Separator draws a vertical or horizontal line

func (*Separator) New

func (n *Separator) New() ki.Ki

func (*Separator) Render2D

func (g *Separator) Render2D()

func (*Separator) Style2D

func (g *Separator) Style2D()

type ShadowStyle

type ShadowStyle struct {
	HOffset units.Value `xml:".h-offset" desc:"horizontal offset of shadow -- positive = right side, negative = left side"`
	VOffset units.Value `xml:".v-offset" desc:"vertical offset of shadow -- positive = below, negative = above"`
	Blur    units.Value `xml:".blur" desc:"blur radius -- higher numbers = more blurry"`
	Spread  units.Value `xml:".spread" desc:"spread radius -- positive number increases size of shadow, negative descreases size"`
	Color   Color       `xml:".color" desc:"color of the shadow"`
	Inset   bool        `xml:".inset" desc:"shadow is inset within box instead of outset outside of box"`
}

style parameters for shadows

func (*ShadowStyle) HasShadow

func (s *ShadowStyle) HasShadow() bool

type SizePrefs

type SizePrefs struct {
	Need Vec2D `desc:"minimum size needed -- set to at least computed allocsize"`
	Pref Vec2D `desc:"preferred size -- start here for layout"`
	Max  Vec2D `desc:"maximum size -- will not be greater than this -- 0 = no constraint, neg = stretch"`
}

size preferences

func (SizePrefs) CanStretchNeed

func (sp SizePrefs) CanStretchNeed(d Dims2D) bool

return true if Pref > Need meaning can stretch more along given dimension

func (SizePrefs) HasMaxStretch

func (sp SizePrefs) HasMaxStretch(d Dims2D) bool

return true if Max < 0 meaning can stretch infinitely along given dimension

type SliceValueView

type SliceValueView struct {
	ValueViewBase
}

SliceValueView presents a button to edit slices

func (*SliceValueView) ConfigWidget

func (vv *SliceValueView) ConfigWidget(widg Node2D)

func (*SliceValueView) New

func (n *SliceValueView) New() ki.Ki

func (*SliceValueView) UpdateWidget

func (vv *SliceValueView) UpdateWidget()

func (*SliceValueView) WidgetType

func (vv *SliceValueView) WidgetType() reflect.Type

type SliceView

type SliceView struct {
	Frame
	Slice   interface{} `desc:"the slice that we are a view onto"`
	Title   string      `desc:"title / prompt to show above the editor fields"`
	Values  []ValueView `json:"-" xml:"-" desc:"ValueView representations of the slice values"`
	TmpSave ValueView   `` /* 189-byte string literal not displayed */
	ViewSig ki.Signal   `` /* 179-byte string literal not displayed */
}

SliceView represents a slice, creating a property editor of the values -- constructs Children widgets to show the index / value pairs, within an overall frame with an optional title, and a button box at the bottom where methods can be invoked

func (*SliceView) ButtonBox

func (sv *SliceView) ButtonBox() (*Layout, int)

ButtonBox returns the ButtonBox layout widget, and its index, within frame -- nil, -1 if not found

func (*SliceView) ConfigSliceButtons

func (sv *SliceView) ConfigSliceButtons()

ConfigSliceButtons configures the buttons for map functions

func (*SliceView) ConfigSliceGrid

func (sv *SliceView) ConfigSliceGrid()

ConfigSliceGrid configures the SliceGrid for the current slice

func (*SliceView) New

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

func (*SliceView) ReRender2D

func (sv *SliceView) ReRender2D() (node Node2D, layout bool)

func (*SliceView) Render2D

func (sv *SliceView) Render2D()

func (*SliceView) SetFrame

func (sv *SliceView) SetFrame()

SetFrame configures view as a frame

func (*SliceView) SetSlice

func (sv *SliceView) SetSlice(sl interface{}, tmpSave ValueView)

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

func (*SliceView) SetTitle

func (sv *SliceView) SetTitle(title string)

SetTitle sets the title and updates the Title label

func (*SliceView) SliceDelete

func (sv *SliceView) SliceDelete(idx int)

SliceDelete deletes element at given index from slice

func (*SliceView) SliceGrid

func (sv *SliceView) SliceGrid() (*Layout, int)

SliceGrid returns the SliceGrid grid layout widget, which contains all the fields and values, and its index, within frame -- nil, -1 if not found

func (*SliceView) SliceNewAt

func (sv *SliceView) SliceNewAt(idx int)

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

func (*SliceView) StdConfig

func (sv *SliceView) StdConfig() (mods, updt bool)

StdConfig configures a standard setup of the overall Frame -- returns mods, updt from ConfigChildren and does NOT call UpdateEnd

func (*SliceView) StdFrameConfig

func (sv *SliceView) StdFrameConfig() kit.TypeAndNameList

StdFrameConfig returns a TypeAndNameList for configuring a standard Frame -- can modify as desired before calling ConfigChildren on Frame using this

func (*SliceView) Style2D

func (sv *SliceView) Style2D()

needs full rebuild and this is where we do it:

func (*SliceView) TitleWidget

func (sv *SliceView) TitleWidget() (*Label, int)

Title returns the title label widget, and its index, within frame -- nil, -1 if not found

func (*SliceView) UpdateFromSlice

func (sv *SliceView) UpdateFromSlice()

func (*SliceView) UpdateValues

func (sv *SliceView) UpdateValues()

type SliceViewInline

type SliceViewInline struct {
	WidgetBase
	Slice   interface{} `desc:"the slice that we are a view onto"`
	Values  []ValueView `json:"-" xml:"-" desc:"ValueView representations of the fields"`
	TmpSave ValueView   `` /* 189-byte string literal not displayed */
	ViewSig ki.Signal   `` /* 179-byte string literal not displayed */
}

SliceViewInline represents a slice as a single line widget, for smaller slices and those explicitly marked inline -- constructs widgets in Parts to show the key names and editor vals for each value

func (*SliceViewInline) ConfigParts

func (sv *SliceViewInline) ConfigParts()

ConfigParts configures Parts for the current slice

func (*SliceViewInline) New

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

func (*SliceViewInline) ReRender2D

func (sv *SliceViewInline) ReRender2D() (node Node2D, layout bool)

todo: see notes on treeview

func (*SliceViewInline) Render2D

func (sv *SliceViewInline) Render2D()

func (*SliceViewInline) SetSlice

func (sv *SliceViewInline) SetSlice(sl interface{}, tmpSave ValueView)

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

func (*SliceViewInline) Style2D

func (sv *SliceViewInline) Style2D()

func (*SliceViewInline) UpdateFromSlice

func (sv *SliceViewInline) UpdateFromSlice()

func (*SliceViewInline) UpdateValues

func (sv *SliceViewInline) UpdateValues()

type Slider

type Slider struct {
	SliderBase
}

Slider is a standard value slider with a fixed-sized thumb knob -- if an Icon is set, it is used for the knob of the slider

func (*Slider) Defaults

func (g *Slider) Defaults()

func (*Slider) FocusChanged2D

func (g *Slider) FocusChanged2D(gotFocus bool)

func (*Slider) Init2D

func (g *Slider) Init2D()

func (*Slider) Layout2D

func (g *Slider) Layout2D(parBBox image.Rectangle)

func (*Slider) New

func (n *Slider) New() ki.Ki

func (*Slider) Render2D

func (g *Slider) Render2D()

func (*Slider) Render2DDefaultStyle

func (g *Slider) Render2DDefaultStyle()

render using a default style if not otherwise styled

func (*Slider) Size2D

func (g *Slider) Size2D()

func (*Slider) Style2D

func (g *Slider) Style2D()

type SliderBase

type SliderBase struct {
	WidgetBase
	Value       float32              `xml:"value" desc:"current value"`
	EmitValue   float32              `xml:"-" desc:"previous emitted value - don't re-emit if it is the same"`
	Min         float32              `xml:"min" desc:"minimum value in range"`
	Max         float32              `xml:"max" desc:"maximum value in range"`
	Step        float32              `xml:"step" desc:"smallest step size to increment"`
	PageStep    float32              `xml:"pagestep" desc:"larger PageUp / Dn step size"`
	Size        float32              `xml:"size" desc:"size of the slide box in the relevant dimension -- range of motion -- exclusive of spacing"`
	ThSize      float32              `` /* 145-byte string literal not displayed */
	ThumbSize   units.Value          `xml:"thumb-size" desc:"styled fixed size of the thumb"`
	Prec        int                  `` /* 212-byte string literal not displayed */
	Icon        *Icon                `json:"-" xml:"-" desc:"optional icon for the dragging knob"`
	ValThumb    bool                 `` /* 269-byte string literal not displayed */
	ThumbVal    float32              `xml:thumb-val" desc:"value that the thumb represents, in the same units"`
	Pos         float32              `xml:"pos" desc:"logical position of the slider relative to Size"`
	DragPos     float32              `xml:"-" desc:"underlying drag position of slider -- not subject to snapping"`
	VisPos      float32              `xml:"vispos" desc:"visual position of the slider -- can be different from pos in a RTL environment"`
	Dim         Dims2D               `desc:"dimension along which the slider slides"`
	Tracking    bool                 `` /* 183-byte string literal not displayed */
	TrackThr    float32              `xml:"track-thr" desc:"threshold for amount of change in scroll value before emitting a signal in Tracking mode"`
	Snap        bool                 `xml:"snap" desc:"snap the values to Step size increments"`
	State       SliderStates         `json:"-" xml:"-" desc:"state of slider"`
	StateStyles [SliderStatesN]Style `` /* 237-byte string literal not displayed */
	SliderSig   ki.Signal            `json:"-" xml:"-" desc:"signal for slider -- see SliderSignals for the types"`
	// contains filtered or unexported fields
}

SliderBase has common slider functionality -- two major modes: ValThumb = false is a slider with a fixed-size thumb knob, while = true has a thumb that represents a value, as in a scrollbar, and the scrolling range is size - thumbsize

var SliderDefault SliderBase

SliderDefault is default obj that can be used when property specifies "default"

func (*SliderBase) ConfigParts

func (g *SliderBase) ConfigParts()

func (*SliderBase) ConfigPartsIfNeeded

func (g *SliderBase) ConfigPartsIfNeeded(render bool)

func (*SliderBase) Defaults

func (g *SliderBase) Defaults()

func (*SliderBase) Init2DSlider

func (g *SliderBase) Init2DSlider()

func (*SliderBase) KeyInput

func (g *SliderBase) KeyInput(kt *key.ChordEvent)

func (*SliderBase) New

func (n *SliderBase) New() ki.Ki

func (*SliderBase) PointToRelPos

func (g *SliderBase) PointToRelPos(pt image.Point) image.Point

translate a point in global pixel coords into relative position within node

func (*SliderBase) SetSliderPos

func (g *SliderBase) SetSliderPos(pos float32)

SetSliderPos sets the position of the slider at the given position in pixels -- updates the corresponding Value

func (*SliderBase) SetSliderState

func (g *SliderBase) SetSliderState(state SliderStates)

set the slider state to target

func (*SliderBase) SetThumbValue

func (g *SliderBase) SetThumbValue(val float32)

func (*SliderBase) SetValue

func (g *SliderBase) SetValue(val float32)

SetValue sets the value and updates the slider position, but does not emit an updated signal

func (*SliderBase) SetValueAction

func (g *SliderBase) SetValueAction(val float32)

SetValueAction sets the value and updates the slider representation, and emits a changed signal

func (*SliderBase) SizeFromAlloc

func (g *SliderBase) SizeFromAlloc()

get size from allocation

func (*SliderBase) SliderEnterHover

func (g *SliderBase) SliderEnterHover()

slider starting hover-- todo: keep track of time and popup a tooltip -- signal?

func (*SliderBase) SliderExitHover

func (g *SliderBase) SliderExitHover()

slider exiting hover

func (*SliderBase) SliderMoved

func (g *SliderBase) SliderMoved(start, end float32)

slider moved along relevant axis

func (*SliderBase) SliderPressed

func (g *SliderBase) SliderPressed(pos float32)

set the slider in the down state -- mouse clicked down but not yet up -- emits SliderPressed signal

func (*SliderBase) SliderReleased

func (g *SliderBase) SliderReleased()

the slider has just been released -- sends a released signal and returns state to normal, and emits clicked signal if if it was previously in pressed state

func (*SliderBase) SnapValue

func (g *SliderBase) SnapValue()

if snap is set, then snap the value to step sizes

func (*SliderBase) UpdatePosFromValue

func (g *SliderBase) UpdatePosFromValue()

func (*SliderBase) UpdateThumbValSize

func (g *SliderBase) UpdateThumbValSize()

set thumb size as proportion of min / max (e.g., amount visible in scrollbar) -- max's out to full size

type SliderSignals

type SliderSignals int64

signals that sliders can send

const (
	// value has changed -- if tracking is enabled, then this tracks online changes -- otherwise only at the end
	SliderValueChanged SliderSignals = iota
	// slider pushed down but not yet up
	SliderPressed
	SliderReleased
	SliderMoved
	SliderSignalsN
)

func (*SliderSignals) FromString

func (i *SliderSignals) FromString(s string) error

func (SliderSignals) String

func (i SliderSignals) String() string

type SliderStates

type SliderStates int32

mutually-exclusive slider states -- determines appearance

const (
	// normal state -- there but not being interacted with
	SliderActive SliderStates = iota

	// inactive -- not responsive
	SliderInactive

	// mouse is hovering over the slider
	SliderHover

	// slider is the focus -- will respond to keyboard input
	SliderFocus

	// slider is currently being pressed down
	SliderDown

	// use background-color here to fill in selected value of slider
	SliderValue

	// these styles define the overall box around slider -- typically no border and a white background -- needs a background to allow local re-rendering
	SliderBox

	// total number of slider states
	SliderStatesN
)

func (*SliderStates) FromString

func (i *SliderStates) FromString(s string) error

func (SliderStates) String

func (i SliderStates) String() string

type SolidcolorPaintServer

type SolidcolorPaintServer struct {
	Color color.Color
}

Solid PaintServer

func (*SolidcolorPaintServer) ColorAt

func (p *SolidcolorPaintServer) ColorAt(x, y int) color.Color

func (*SolidcolorPaintServer) ServerType

func (p *SolidcolorPaintServer) ServerType() PaintServers

type Space

type Space struct {
	Node2DBase
}

Space adds a fixed sized (1 em by default) blank space to a layout -- set width / height property to change

func (*Space) Layout2D

func (g *Space) Layout2D(parBBox image.Rectangle)

func (*Space) New

func (n *Space) New() ki.Ki

func (*Space) Style2D

func (g *Space) Style2D()

type SpinBox

type SpinBox struct {
	WidgetBase
	Value      float32   `xml:"value" desc:"current value"`
	HasMin     bool      `xml:"has-min" desc:"is there a minimum value to enforce"`
	Min        float32   `xml:"min" desc:"minimum value in range"`
	HasMax     bool      `xml:"has-max" desc:"is there a maximumvalue to enforce"`
	Max        float32   `xml:"max" desc:"maximum value in range"`
	Step       float32   `xml:"step" desc:"smallest step size to increment"`
	PageStep   float32   `xml:"pagestep" desc:"larger PageUp / Dn step size"`
	Prec       int       `` /* 201-byte string literal not displayed */
	UpIcon     *Icon     `json:"-" xml:"-" desc:"icon to use for up button -- defaults to widget-wedge-up"`
	DownIcon   *Icon     `json:"-" xml:"-" desc:"icon to use for down button -- defaults to widget-wedge-down"`
	SpinBoxSig ki.Signal `json:"-" xml:"-" desc:"signal for spin box -- has no signal types, just emitted when the value changes"`
}

SpinBox combines a TextField with up / down buttons for incrementing / decrementing values -- all configured within the Parts of the widget

func (*SpinBox) ConfigParts

func (g *SpinBox) ConfigParts()

func (*SpinBox) ConfigPartsIfNeeded

func (g *SpinBox) ConfigPartsIfNeeded()

func (*SpinBox) Defaults

func (g *SpinBox) Defaults()

func (*SpinBox) IncrValue

func (g *SpinBox) IncrValue(steps float32)

IncrValue 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 (*SpinBox) Init2D

func (g *SpinBox) Init2D()

func (*SpinBox) Layout2D

func (g *SpinBox) Layout2D(parBBox image.Rectangle)

func (*SpinBox) New

func (n *SpinBox) New() ki.Ki

func (*SpinBox) Render2D

func (g *SpinBox) Render2D()

func (*SpinBox) SetMax

func (g *SpinBox) SetMax(max float32)

SetMax sets the max limits on the value

func (*SpinBox) SetMin

func (g *SpinBox) SetMin(min float32)

SetMin sets the min limits on the value

func (*SpinBox) SetMinMax

func (g *SpinBox) SetMinMax(hasMin bool, min float32, hasMax bool, max float32)

SetMinMax sets the min and max limits on the value

func (*SpinBox) SetValue

func (g *SpinBox) SetValue(val float32)

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

func (*SpinBox) SetValueAction

func (g *SpinBox) SetValueAction(val float32)

SetValueAction calls SetValue and also emits the signal

func (*SpinBox) Size2D

func (g *SpinBox) Size2D()

func (*SpinBox) Style2D

func (g *SpinBox) Style2D()

type SplitView

type SplitView struct {
	WidgetBase
	Splits      []float32 `desc:"proportion (0-1 normalized, enforced) of space allocated to each element -- can enter 0 to collapse a given element"`
	SavedSplits []float32 `desc:"A saved version of the splits which can be restored -- for dynamic collapse / expand operations"`
	Dim         Dims2D    `desc:"dimension along which to split the space"`
}

SplitView allocates a fixed proportion of space to each child, along given dimension, always using only the available space given to it by its parent (i.e., it will force its children, which should be layouts (typically Frame's), to have their own scroll bars as necesssary). It should generally be used as a main outer-level structure within a window, providing a framework for inner elements -- it allows individual child elements to update indpendently and thus is important for speeding update performance. It uses the Widget Parts to hold the splitter widgets separately from the children that contain the rest of the scenegraph to be displayed within each region.

func (*SplitView) CollapseChild

func (g *SplitView) CollapseChild(save bool, idxs ...int)

CollapseChild collapses given child(ren) (sets split proportion to 0), optionally saving the prior splits for later Restore function -- does an Update -- triggered by double-click of splitter

func (*SplitView) ConfigSplitters

func (g *SplitView) ConfigSplitters()

func (*SplitView) Init2D

func (g *SplitView) Init2D()

func (*SplitView) Layout2D

func (g *SplitView) Layout2D(parBBox image.Rectangle)

func (*SplitView) New

func (n *SplitView) New() ki.Ki

func (*SplitView) ReRender2D

func (g *SplitView) ReRender2D() (node Node2D, layout bool)

func (*SplitView) Render2D

func (g *SplitView) Render2D()

func (*SplitView) RestoreSplits

func (g *SplitView) RestoreSplits()

RestoreSplits restores a previously-saved set of splits (if it exists), does an update

func (*SplitView) SaveSplits

func (g *SplitView) SaveSplits()

SaveSplits saves the current set of splits in SavedSplits, for a later RestoreSplits

func (*SplitView) SetSplits

func (g *SplitView) SetSplits(splits ...float32)

SetSplits sets the split proportions -- can use 0 to hide / collapse a child entirely -- does an Update

func (*SplitView) SetSplitsAction

func (g *SplitView) SetSplitsAction(idx int, nwval float32)

func (*SplitView) Style2D

func (g *SplitView) Style2D()

func (*SplitView) UpdateSplits

func (g *SplitView) UpdateSplits()

UpdateSplits updates the splits to be same length as number of children, and normalized

type Splitter

type Splitter struct {
	SliderBase
}

Splitter provides the splitter handle and line separating two elements in a SplitView, with draggable resizing of the splitter -- parent is Parts layout of the SplitView -- based on SliderBase

func (*Splitter) ConfigPartsIfNeeded

func (g *Splitter) ConfigPartsIfNeeded(render bool)

func (*Splitter) Defaults

func (g *Splitter) Defaults()

func (*Splitter) FocusChanged2D

func (g *Splitter) FocusChanged2D(gotFocus bool)

func (*Splitter) Init2D

func (g *Splitter) Init2D()

func (*Splitter) Layout2D

func (g *Splitter) Layout2D(parBBox image.Rectangle)

func (*Splitter) New

func (n *Splitter) New() ki.Ki

func (*Splitter) ReRender2D

func (g *Splitter) ReRender2D() (node Node2D, layout bool)

func (*Splitter) Render2D

func (g *Splitter) Render2D()

func (*Splitter) Render2DDefaultStyle

func (g *Splitter) Render2DDefaultStyle()

render using a default style if not otherwise styled

func (*Splitter) Size2D

func (g *Splitter) Size2D()

func (*Splitter) Style2D

func (g *Splitter) Style2D()

type Stretch

type Stretch struct {
	Node2DBase
}

Stretch adds an infinitely stretchy element for spacing out layouts (max-size = -1) set the width / height property to determine how much it takes relative to other stretchy elements

func (*Stretch) Layout2D

func (g *Stretch) Layout2D(parBBox image.Rectangle)

func (*Stretch) New

func (n *Stretch) New() ki.Ki

func (*Stretch) Style2D

func (g *Stretch) Style2D()

type StrokeStyle

type StrokeStyle struct {
	On         bool        `desc:"is stroke active -- if property is none then false"`
	Color      Color       `xml:"stroke" desc:"default stroke color when such a color is needed -- Server could be anything"`
	Opacity    float32     `xml:"stroke-opacity" desc:"global alpha opacity / transparency factor"`
	Server     PaintServer `view:"-" desc:"paint server for the stroke -- if solid color, defines the stroke color"`
	Width      units.Value `xml:"stroke-width" desc:"line width"`
	Dashes     []float32   `xml:"stroke-dasharray" desc:"dash pattern"`
	Cap        LineCap     `xml:"stroke-linecap" desc:"how to draw the end cap of lines"`
	Join       LineJoin    `xml:"stroke-linejoin" desc:"how to join line segments"`
	MiterLimit float32     `xml:"stroke-miterlimit,min:"1" desc:"limit of how far to miter -- must be 1 or larger"`
}

StrokeStyle contains all the properties specific to painting a line -- the svg elements define the corresponding SVG style attributes, which are processed in StrokeStyle

func (*StrokeStyle) Defaults

func (ps *StrokeStyle) Defaults()

initialize default values for paint stroke

func (*StrokeStyle) SetColor

func (ps *StrokeStyle) SetColor(cl *Color)

func (*StrokeStyle) SetStylePost

func (ps *StrokeStyle) SetStylePost()

need to do some updating after setting the style from user properties

type StructInlineValueView

type StructInlineValueView struct {
	ValueViewBase
}

StructInlineValueView presents a StructViewInline for a struct

func (*StructInlineValueView) ConfigWidget

func (vv *StructInlineValueView) ConfigWidget(widg Node2D)

func (*StructInlineValueView) New

func (n *StructInlineValueView) New() ki.Ki

func (*StructInlineValueView) UpdateWidget

func (vv *StructInlineValueView) UpdateWidget()

func (*StructInlineValueView) WidgetType

func (vv *StructInlineValueView) WidgetType() reflect.Type

type StructValueView

type StructValueView struct {
	ValueViewBase
}

StructValueView presents a button to edit slices

func (*StructValueView) ConfigWidget

func (vv *StructValueView) ConfigWidget(widg Node2D)

func (*StructValueView) New

func (n *StructValueView) New() ki.Ki

func (*StructValueView) UpdateWidget

func (vv *StructValueView) UpdateWidget()

func (*StructValueView) WidgetType

func (vv *StructValueView) WidgetType() reflect.Type

type StructView

type StructView struct {
	Frame
	Struct     interface{} `desc:"the struct that we are a view onto"`
	Title      string      `desc:"title / prompt to show above the editor fields"`
	FieldViews []ValueView `json:"-" xml:"-" desc:"ValueView representations of the fields"`
	TmpSave    ValueView   `` /* 189-byte string literal not displayed */
	ViewSig    ki.Signal   `` /* 179-byte string literal not displayed */
}

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

func (*StructView) ButtonBox

func (sv *StructView) ButtonBox() (*Layout, int)

ButtonBox returns the ButtonBox layout widget, and its index, within frame -- nil, -1 if not found

func (*StructView) ConfigStructGrid

func (sv *StructView) ConfigStructGrid()

ConfigStructGrid configures the StructGrid for the current struct

func (*StructView) New

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

func (*StructView) ReRender2D

func (sv *StructView) ReRender2D() (node Node2D, layout bool)

func (*StructView) Render2D

func (sv *StructView) Render2D()

func (*StructView) SetFrame

func (sv *StructView) SetFrame()

SetFrame configures view as a frame

func (*StructView) SetStruct

func (sv *StructView) SetStruct(st interface{}, tmpSave ValueView)

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

func (*StructView) SetTitle

func (sv *StructView) SetTitle(title string)

SetTitle sets the title and updates the Title label

func (*StructView) StdConfig

func (sv *StructView) StdConfig() (mods, updt bool)

StdConfig configures a standard setup of the overall Frame -- returns mods, updt from ConfigChildren and does NOT call UpdateEnd

func (*StructView) StdFrameConfig

func (sv *StructView) StdFrameConfig() kit.TypeAndNameList

StdFrameConfig returns a TypeAndNameList for configuring a standard Frame -- can modify as desired before calling ConfigChildren on Frame using this

func (*StructView) StructGrid

func (sv *StructView) StructGrid() (*Layout, int)

StructGrid returns the grid layout widget, which contains all the fields and values, and its index, within frame -- nil, -1 if not found

func (*StructView) Style2D

func (sv *StructView) Style2D()

func (*StructView) TitleWidget

func (sv *StructView) TitleWidget() (*Label, int)

Title returns the title label widget, and its index, within frame -- nil, -1 if not found

func (*StructView) UpdateFields

func (sv *StructView) UpdateFields()

func (*StructView) UpdateFromStruct

func (sv *StructView) UpdateFromStruct()

type StructViewInline

type StructViewInline struct {
	WidgetBase
	Struct     interface{} `desc:"the struct that we are a view onto"`
	AddAction  bool        `` /* 135-byte string literal not displayed */
	FieldViews []ValueView `json:"-" xml:"-" desc:"ValueView representations of the fields"`
	TmpSave    ValueView   `` /* 189-byte string literal not displayed */
	ViewSig    ki.Signal   `` /* 179-byte string literal not displayed */
}

StructViewInline represents a struct as a single line widget, for smaller structs and those explicitly marked inline in the kit type registry type properties -- constructs widgets in Parts to show the field names and editor fields for each field

func (*StructViewInline) ConfigParts

func (sv *StructViewInline) ConfigParts()

ConfigParts configures Parts for the current struct

func (*StructViewInline) New

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

func (*StructViewInline) ReRender2D

func (sv *StructViewInline) ReRender2D() (node Node2D, layout bool)

func (*StructViewInline) Render2D

func (sv *StructViewInline) Render2D()

func (*StructViewInline) SetStruct

func (sv *StructViewInline) SetStruct(st interface{}, tmpSave ValueView)

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

func (*StructViewInline) UpdateFields

func (sv *StructViewInline) UpdateFields()

func (*StructViewInline) UpdateFromStruct

func (sv *StructViewInline) UpdateFromStruct()

type Style

type Style struct {
	IsSet         bool            `desc:"has this style been set from object values yet?"`
	PropsNil      bool            `desc:"set to true if parent node has no props -- allows optimization of styling"`
	Display       bool            `xml:"display" desc:"todo big enum of how to display item -- controls layout etc"`
	Visible       bool            `xml:"visible" desc:"todo big enum of how to display item -- controls layout etc"`
	Inactive      bool            `xml:"inactive" desc:"make a control inactive so it does not respond to input"`
	Layout        LayoutStyle     `desc:"layout styles -- do not prefix with any xml"`
	Border        BorderStyle     `xml:"border" desc:"border around the box element -- todo: can have separate ones for different sides"`
	BoxShadow     ShadowStyle     `xml:"box-shadow" desc:"type of shadow to render around box"`
	Font          FontStyle       `xml:"font" desc:"font parameters"`
	Text          TextStyle       `desc:"text parameters -- no xml prefix"`
	Color         Color           `xml:"color" inherit:"true" desc:"text color"`
	Background    BackgroundStyle `xml:"background" desc:"background settings"`
	Opacity       float32         `xml:"opacity" desc:"alpha value to apply to all elements"`
	Outline       BorderStyle     `xml:"outline" desc:"draw an outline around an element -- mostly same styles as border -- default to none"`
	PointerEvents bool            `xml:"pointer-events" desc:"does this element respond to pointer events -- default is true"`
	UnContext     units.Context   `xml:"-" desc:"units context -- parameters necessary for anchoring relative units"`
	// contains filtered or unexported fields
}

Style has all the CSS-based style elements -- used for widget-type objects

var StyleDefault Style

StyleDefault is default style can be used when property specifies "default"

func NewStyle

func NewStyle() Style

func (*Style) BoxSpace

func (s *Style) BoxSpace() float32

BoxSpace returns extra space around the central content in the box model, in dots -- todo: must complicate this if we want different spacing on different sides box outside-in: margin | border | padding | content

func (*Style) CopyFrom

func (s *Style) CopyFrom(cp *Style)

CopyFrom copies from another style, while preserving relevant local state

func (*Style) CopyUnitContext

func (s *Style) CopyUnitContext(ctxt *units.Context)

CopyUnitContext copies unit context from another, update with our font info, and then cache everything out in terms of raw pixel dots for rendering -- call at start of render

func (*Style) Defaults

func (s *Style) Defaults()

func (*Style) SetStyle

func (s *Style) SetStyle(parent *Style, props ki.Props)

SetStyle sets style values based on given property map (name: value pairs), inheriting elements as appropriate from parent

func (*Style) SetUnitContext

func (s *Style) SetUnitContext(vp *Viewport2D, el Vec2D)

SetUnitContext sets the unit context based on size of viewport and parent element (from bbox) and then cache everything out in terms of raw pixel dots for rendering -- call at start of render

func (*Style) ToDots

func (s *Style) ToDots()

ToDots calls ToDots on all units.Value fields in the style (recursively) -- need to have set the UnContext first -- only after layout at render time is that possible

type StyledField

type StyledField struct {
	Field   reflect.StructField
	NetOff  uintptr       `desc:"net accumulated offset from the overall main type, e.g., Style"`
	Default reflect.Value `desc:"value of default value of this field"`
}

StyledField contains the relevant data for a given stylable field in a struct

func (*StyledField) FieldIface

func (sf *StyledField) FieldIface(obj interface{}) interface{}

FieldIface returns an interface{} for a given object, computed from NetOff -- much faster -- use this

func (*StyledField) FieldValue

func (sf *StyledField) FieldValue(obj interface{}) reflect.Value

FieldValue returns a reflect.Value for a given object, computed from NetOff -- this is VERY expensive time-wise -- need to figure out a better solution..

func (*StyledField) FromProps

func (fld *StyledField) FromProps(fields map[string]*StyledField, obj, par, val interface{}, hasPar bool)

FromProps styles given field from property value val, with optional parent object obj

func (*StyledField) UnitsValue

func (sf *StyledField) UnitsValue(obj interface{}) *units.Value

UnitsValue returns a units.Value for a field, which must be of that type..

type StyledFields

type StyledFields struct {
	Fields   map[string]*StyledField `desc:"the compiled stylable fields, mapped for the xml and alt tags for the field"`
	Inherits []*StyledField          `desc:"the compiled stylable fields that have inherit:"true" tags and should thus be inherited from parent objects"`
	Units    []*StyledField          `desc:"the compiled stylable fields of the unit.Value type, which should have ToDots run on them"`
	Default  interface{}             `desc:"points to the Default instance of this type, initialized with the default values used for 'initial' keyword"`
}

StyledFields contains fields of a struct that are styled -- create one instance of this for each type that has styled fields (Style, Paint, and a few with ad-hoc styled fields)

func (*StyledFields) AddField

func (sf *StyledFields) AddField(def interface{}, fieldName string) error

AddField adds a single field -- must be a direct field on the object and not a field on an embedded type -- used for Widget objects where only one or a few fields are styled

func (*StyledFields) CompileFields

func (sf *StyledFields) CompileFields(def interface{})

CompileFields gathers all the fields with xml tag != "-", plus those that are units.Value's for later optimized processing of styles

func (*StyledFields) Inherit

func (sf *StyledFields) Inherit(obj, par interface{})

Inherit copies all the values from par to obj for fields marked as "inherit" -- inherited by default

func (*StyledFields) Init

func (sf *StyledFields) Init(def interface{})

func (*StyledFields) Style

func (sf *StyledFields) Style(obj, par interface{}, props ki.Props)

Style applies styles to the fields from given properties for given object

func (*StyledFields) ToDots

func (sf *StyledFields) ToDots(obj interface{}, uc *units.Context)

ToDots runs ToDots on unit values, to compile down to raw pixels

type TabView

type TabView struct {
	WidgetBase
	SrcNode    ki.Ptr    `` /* 132-byte string literal not displayed */
	TabViewSig ki.Signal `json:"-" xml:"-" desc:"signal for tab widget -- see TabViewSignals for the types"`
}

TabView represents children of a source node as tabs with a stacked layout of Frame widgets for each child in the source -- we create a LayoutCol with a LayoutRow of tab buttons and then the LayoutStacked of Frames

func (*TabView) InitTabView

func (g *TabView) InitTabView()

initialize the tab widget structure -- assumes it has been done if there is already a child node

func (*TabView) InitTabs

func (g *TabView) InitTabs()

make the initial tab frames for src node

func (*TabView) New

func (n *TabView) New() ki.Ki

func (*TabView) SelectTabIndex

func (g *TabView) SelectTabIndex(idx int) error

select tab at given index

func (*TabView) SetSrcNode

func (g *TabView) SetSrcNode(k ki.Ki)

set the source Ki Node that generates our tabs

func (*TabView) TabColLayout

func (g *TabView) TabColLayout() *Layout

get the overal column layout for the tab widget

func (*TabView) TabFrameAtIndex

func (g *TabView) TabFrameAtIndex(idx int) *Frame

get tab frame for given index

func (*TabView) TabRowLayout

func (g *TabView) TabRowLayout() *Layout

get the row layout of tabs across the top of the tab widget

func (*TabView) TabStackLayout

func (g *TabView) TabStackLayout() *Layout

get the stacked layout of tab frames

func (*TabView) UnselectAllTabButtons

func (g *TabView) UnselectAllTabButtons()

unselect all tabs

type TabViewSignals

type TabViewSignals int64

signals that buttons can send

const (
	// node was selected -- data is the tab widget
	TabSelected TabViewSignals = iota
	// tab widget unselected
	TabUnselected
	// collapsed tab widget was opened
	TabOpened
	// open tab widget was collapsed -- children not visible
	TabCollapsed
	TabViewSignalsN
)

func (*TabViewSignals) FromString

func (i *TabViewSignals) FromString(s string) error

func (TabViewSignals) String

func (i TabViewSignals) String() string

type Text2D

type Text2D struct {
	Node2DBase
	Pos         Vec2D    `xml:"{x,y}" desc:"position of the left, baseline of the text"`
	Width       float32  `xml:"width" desc:"width of text to render if using word-wrapping"`
	Text        string   `xml:"text" desc:"text string to render"`
	WrappedText []string `json:"-" xml:"-" "desc:word-wrapped version of the string"`
}

2D Text

func (*Text2D) BBox2D

func (g *Text2D) BBox2D() image.Rectangle

func (*Text2D) New

func (n *Text2D) New() ki.Ki

func (*Text2D) ReRender2D

func (g *Text2D) ReRender2D() (node Node2D, layout bool)

func (*Text2D) Render2D

func (g *Text2D) Render2D()

func (*Text2D) Size2D

func (g *Text2D) Size2D()

func (*Text2D) Style2D

func (g *Text2D) Style2D()

type TextField

type TextField struct {
	WidgetBase
	Text         string                  `json:"-" xml:"text" desc:"the last saved value of the text string being edited"`
	EditText     string                  `json:"-" xml:"-" desc:"the live text string being edited, with latest modifications"`
	StartPos     int                     `xml:"start-pos" desc:"starting display position in the string"`
	EndPos       int                     `xml:"end-pos" desc:"ending display position in the string"`
	CursorPos    int                     `xml:"cursor-pos" desc:"current cursor position"`
	CharWidth    int                     `xml:"char-width" desc:"approximate number of chars that can be displayed at any time -- computed from font size etc"`
	SelectMode   bool                    `xml:"select-mode" desc:"if true, select text as cursor moves"`
	TextFieldSig ki.Signal               `json:"-" xml:"-" desc:"signal for line edit -- see TextFieldSignals for the types"`
	StateStyles  [TextFieldStatesN]Style `json:"-" xml:"-" desc:"normal style and focus style"`
	CharPos      []float32               `` /* 151-byte string literal not displayed */
	// contains filtered or unexported fields
}

TextField is a widget for editing a line of text

func (*TextField) AutoScroll

func (g *TextField) AutoScroll()

AutoScroll scrolls the starting position to keep the cursor visible

func (*TextField) CursorBackspace

func (g *TextField) CursorBackspace(steps int)

func (*TextField) CursorBackward

func (g *TextField) CursorBackward(steps int)

func (*TextField) CursorDelete

func (g *TextField) CursorDelete(steps int)

func (*TextField) CursorEnd

func (g *TextField) CursorEnd()

func (*TextField) CursorForward

func (g *TextField) CursorForward(steps int)

func (*TextField) CursorKill

func (g *TextField) CursorKill()

func (*TextField) CursorStart

func (g *TextField) CursorStart()

func (*TextField) EditDone

func (g *TextField) EditDone()

done editing: return key pressed or out of focus

func (*TextField) FocusChanged2D

func (g *TextField) FocusChanged2D(gotFocus bool)

func (*TextField) Init2D

func (g *TextField) Init2D()

func (*TextField) InsertAtCursor

func (g *TextField) InsertAtCursor(str string)

func (*TextField) KeyInput

func (g *TextField) KeyInput(kt *key.ChordEvent)

func (*TextField) Layout2D

func (g *TextField) Layout2D(parBBox image.Rectangle)

func (*TextField) New

func (n *TextField) New() ki.Ki

func (*TextField) PixelToCursor

func (g *TextField) PixelToCursor(pixOff float32) int

PixelToCursor finds the cursor position that corresponds to the given pixel location

func (*TextField) Render2D

func (g *TextField) Render2D()

func (*TextField) RenderCursor

func (g *TextField) RenderCursor()

func (*TextField) RevertEdit

func (g *TextField) RevertEdit()

abort editing -- revert to last saved text

func (*TextField) SetCursorFromPixel

func (g *TextField) SetCursorFromPixel(pixOff float32)

func (*TextField) SetText

func (g *TextField) SetText(txt string)

func (*TextField) Size2D

func (g *TextField) Size2D()

func (*TextField) StartCharPos

func (g *TextField) StartCharPos(idx int) float32

StartCharPos returns the starting position of the given character -- CharPos contains the ending positions

func (*TextField) Style2D

func (g *TextField) Style2D()

func (*TextField) TextWidth

func (g *TextField) TextWidth(st, ed int) float32

TextWidth returns the text width in dots between the two text string positions (ed is exclusive -- +1 beyond actual char)

func (*TextField) UpdateCharPos

func (g *TextField) UpdateCharPos() bool

type TextFieldSignals

type TextFieldSignals int64

signals that buttons can send

const (
	// main signal -- return was pressed and an edit was completed -- data is the text
	TextFieldDone TextFieldSignals = iota
	TextFieldSignalsN
)

func (*TextFieldSignals) FromString

func (i *TextFieldSignals) FromString(s string) error

func (TextFieldSignals) String

func (i TextFieldSignals) String() string

type TextFieldStates

type TextFieldStates int32

mutually-exclusive textfield states -- determines appearance

const (
	// normal state -- there but not being interacted with
	TextFieldActive TextFieldStates = iota

	// textfield is the focus -- will respond to keyboard input
	TextFieldFocus

	// inactive -- not editable
	TextFieldInactive

	TextFieldStatesN
)

func (*TextFieldStates) FromString

func (i *TextFieldStates) FromString(s string) error

func (TextFieldStates) String

func (i TextFieldStates) String() string

type TextStyle

type TextStyle struct {
	Align         Align       `xml:"text-align" inherit:"true" desc:"how to align text"`
	AlignV        Align       `xml:"-" json:"-" desc:"vertical alignment of text -- copied from layout style AlignV"`
	LineHeight    float32     `` /* 185-byte string literal not displayed */
	LetterSpacing units.Value `xml:"letter-spacing" desc:"spacing between characters and lines"`
	Indent        units.Value `xml:"text-indent" inherit:"true" desc:"how much to indent the first line in a paragraph"`
	TabSize       units.Value `xml:"tab-size" inherit:"true" desc:"tab size"`
	WordSpacing   units.Value `xml:"word-spacing" inherit:"true" desc:"extra space to add between words"`
	WordWrap      bool        `xml:"word-wrap" inherit:"true" desc:"wrap text within a given size"`
}

all the style information associated with how to render text

func (*TextStyle) AlignFactors

func (p *TextStyle) AlignFactors() (ax, ay float32)

get basic text alignment factors for DrawString routines -- does not handle justified

func (*TextStyle) Defaults

func (p *TextStyle) Defaults()

func (*TextStyle) EffLineHeight

func (p *TextStyle) EffLineHeight() float32

effective line height (taking into account 0 value)

func (*TextStyle) SetStylePost

func (p *TextStyle) SetStylePost()

any updates after generic xml-tag property setting?

type Transform3D

type Transform3D struct {
	Transform   mgl32.Mat4 // overall compiled transform
	Scale       mgl32.Vec3
	Translation mgl32.Vec3
	Orientation mgl32.Quat
}

3D transform

type TreeView

type TreeView struct {
	WidgetBase
	SrcNode     ki.Ptr                 `desc:"Ki Node that this widget is viewing in the tree -- the source"`
	Indent      units.Value            `xml:"indent" desc:"styled amount to indent children relative to this node"`
	TreeViewSig ki.Signal              `` /* 157-byte string literal not displayed */
	StateStyles [TreeViewStatesN]Style `` /* 217-byte string literal not displayed */
	WidgetSize  Vec2D                  `desc:"just the size of our widget -- our alloc includes all of our children, but we only draw us"`
	Icon        *Icon                  `json:"-" xml:"-" desc:"optional icon, displayed to the the left of the text label"`
	RootWidget  *TreeView              `json:"-" xml:"-" view:"-" desc:"cached root widget"`
}

TreeView represents one node in the tree -- fully recursive -- creates

sub-nodes
var TreeViewDefault TreeView

TreeViewDefault is default obj that can be used when property specifies "default"

func (*TreeView) BBox2D

func (tv *TreeView) BBox2D() image.Rectangle

func (*TreeView) ChildrenBBox2D

func (tv *TreeView) ChildrenBBox2D() image.Rectangle

func (*TreeView) ClearSelectMods

func (tv *TreeView) ClearSelectMods()

func (*TreeView) Close

func (tv *TreeView) Close()

func (*TreeView) ConfigParts

func (tv *TreeView) ConfigParts()

func (*TreeView) ConfigPartsIfNeeded

func (tv *TreeView) ConfigPartsIfNeeded()

func (*TreeView) FocusChanged2D

func (tv *TreeView) FocusChanged2D(gotFocus bool)

func (*TreeView) HasClosedParent

func (tv *TreeView) HasClosedParent() bool

does this node have a closed parent? if so, don't render!

func (*TreeView) Init2D

func (tv *TreeView) Init2D()

func (*TreeView) IsClosed

func (tv *TreeView) IsClosed() bool

is this node itself closed?

func (*TreeView) IsSelected

func (tv *TreeView) IsSelected() bool

is this node selected?

func (*TreeView) Label

func (tv *TreeView) Label() string

func (*TreeView) Layout2D

func (tv *TreeView) Layout2D(parBBox image.Rectangle)

func (*TreeView) Layout2DParts

func (tv *TreeView) Layout2DParts(parBBox image.Rectangle)

func (*TreeView) MakeMenu

func (tv *TreeView) MakeMenu(mb *ButtonBase)

func (*TreeView) MoveDown

func (tv *TreeView) MoveDown()

func (*TreeView) MoveDownSibling

func (tv *TreeView) MoveDownSibling()

move down only to siblings, not down into children

func (*TreeView) MoveToLastChild

func (tv *TreeView) MoveToLastChild()

move up to the last child under me

func (*TreeView) MoveUp

func (tv *TreeView) MoveUp()

func (*TreeView) New

func (n *TreeView) New() ki.Ki

func (*TreeView) Open

func (tv *TreeView) Open()

func (*TreeView) ReRender2D

func (tv *TreeView) ReRender2D() (node Node2D, layout bool)

func (*TreeView) Render2D

func (tv *TreeView) Render2D()

func (*TreeView) RootTreeView

func (tv *TreeView) RootTreeView() *TreeView

root node of TreeView tree -- several properties stored there

func (*TreeView) RootUnselectAll

func (tv *TreeView) RootUnselectAll()

unselect everything below me -- call on Root to clear all

func (*TreeView) Select

func (tv *TreeView) Select()

func (*TreeView) SelectAction

func (tv *TreeView) SelectAction()

a select action has been received (e.g., a mouse click) -- translate into selection updates

func (*TreeView) SelectedSrcNodes

func (tv *TreeView) SelectedSrcNodes() ki.Slice

return a list of the currently-selected source nodes

func (*TreeView) SelectedTreeViews

func (tv *TreeView) SelectedTreeViews() []*TreeView

return a list of the currently-selected TreeViews

func (*TreeView) SetClosed

func (tv *TreeView) SetClosed()

func (*TreeView) SetClosedState

func (tv *TreeView) SetClosedState(closed bool)

func (*TreeView) SetContinuousSelect

func (tv *TreeView) SetContinuousSelect()

func (*TreeView) SetExtendSelect

func (tv *TreeView) SetExtendSelect()

func (*TreeView) SetSrcNode

func (tv *TreeView) SetSrcNode(sk ki.Ki)

set the source node that we are viewing

func (*TreeView) Size2D

func (tv *TreeView) Size2D()

func (*TreeView) SrcAddChild

func (tv *TreeView) SrcAddChild()

add a new child node in the source tree

func (*TreeView) SrcDelete

func (tv *TreeView) SrcDelete()

delete me in source tree

func (*TreeView) SrcDuplicate

func (tv *TreeView) SrcDuplicate()

duplicate item in source tree, add after

func (*TreeView) SrcInsertAfter

func (tv *TreeView) SrcInsertAfter()

insert a new node in the source tree

func (*TreeView) SrcInsertBefore

func (tv *TreeView) SrcInsertBefore()

insert a new node in the source tree

func (*TreeView) Style2D

func (tv *TreeView) Style2D()

func (*TreeView) SyncToSrc

func (tv *TreeView) SyncToSrc()

sync with the source tree

func (*TreeView) ToggleClose

func (tv *TreeView) ToggleClose()

func (*TreeView) Unselect

func (tv *TreeView) Unselect()

func (*TreeView) UnselectAll

func (tv *TreeView) UnselectAll()

unselect everything below me -- call on Root to clear all

type TreeViewSignals

type TreeViewSignals int64

signals that treeview can send -- these are all sent from the root tree view widget node, with data being the relevant node widget

const (
	// node was selected
	TreeViewSelected TreeViewSignals = iota
	// TreeView unselected
	TreeViewUnselected
	// closed TreeView was opened
	TreeViewOpened
	// open TreeView was closed -- children not visible
	TreeViewClosed
	TreeViewSignalsN
)

func (*TreeViewSignals) FromString

func (i *TreeViewSignals) FromString(s string) error

func (TreeViewSignals) String

func (i TreeViewSignals) String() string

type TreeViewStates

type TreeViewStates int32

mutually-exclusive tree view states -- determines appearance

const (
	// normal state -- there but not being interacted with
	TreeViewActive TreeViewStates = iota
	// selected
	TreeViewSel
	// in focus -- will respond to keyboard input
	TreeViewFocus
	TreeViewStatesN
)

func (*TreeViewStates) FromString

func (i *TreeViewStates) FromString(s string) error

func (TreeViewStates) String

func (i TreeViewStates) String() string

type TypeValueView

type TypeValueView struct {
	ValueViewBase
}

TypeValueView presents a combobox for choosing types

func (*TypeValueView) ConfigWidget

func (vv *TypeValueView) ConfigWidget(widg Node2D)

func (*TypeValueView) New

func (n *TypeValueView) New() ki.Ki

func (*TypeValueView) UpdateWidget

func (vv *TypeValueView) UpdateWidget()

func (*TypeValueView) WidgetType

func (vv *TypeValueView) WidgetType() reflect.Type

type ValueView

type ValueView interface {
	ki.Ki

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

	// SetStructValue sets the value, owner and field information for a struct field
	SetStructValue(val reflect.Value, owner interface{}, field *reflect.StructField, tmpSave ValueView)

	// SetMapKey sets the key value and owner for a map key
	SetMapKey(val reflect.Value, owner interface{}, tmpSave ValueView)

	// SetMapValue sets the value, owner and map key information for a map
	// element -- needs pointer to ValueView representation of key to track
	// current key value
	SetMapValue(val reflect.Value, owner interface{}, key interface{}, keyView ValueView, tmpSave ValueView)

	// SetSliceValue sets the value, owner and index information for a slice element
	SetSliceValue(val reflect.Value, owner interface{}, idx int, tmpSave ValueView)

	// OwnerKind returns the reflect.Kind of the owner: Struct, Map, or Slice
	OwnerKind() reflect.Kind

	// IsInactive returns whether the value is inactive -- e.g., Map owners
	// have Inactive values, and some fields can be marked as Inactive using a
	// struct tag
	IsInactive() bool

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

	// UpdateWidget updates the widget representation to reflect the current value
	UpdateWidget()

	// ConfigWidget configures a widget of WidgetType for representing the
	// value, including setting up the signal connections to set the value
	// when the user edits it (values are always set immediately when the
	// widget is updated)
	ConfigWidget(widg Node2D)

	// Val returns the reflect.Value representation for this item
	Val() reflect.Value

	// SetValue sets the value (if not Inactive), using Ki.SetField for Ki
	// types and kit.SetRobust otherwise -- emits a ViewSig signal when set
	SetValue(val interface{}) bool

	// ViewFieldTag returns tag associated with this field, if this is a field
	// in a struct ("" otherwise or if tag not set)
	ViewFieldTag(tagName string) string

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

ValueView is an interface for representing values (e.g., fields, map values, slice values) in Views (StructView, MapView, etc) -- the different types of ValueView are for different Kinds of values (bool, float, etc) -- which can have different Kinds of owners -- the ValueVuewBase class supports all the basic fields for managing the owner kinds

func FieldToValueView

func FieldToValueView(it interface{}, field string, fval interface{}) ValueView

FieldToValueView returns the appropriate ValueView for given field on a struct -- attempts to get the FieldValueViewer interface, and falls back on ToValueView otherwise, using field value (fval)

func ToValueView

func ToValueView(it interface{}) ValueView

ToValueView returns the appropriate ValueView for given item, based only on its type -- attempts to get the ValueViewer interface and failing that, falls back on default Kind-based options -- see FieldToValueView, MapToValueView, SliceToValue view for versions that take into account the properties of the owner (used in those appropriate contexts)

type ValueViewBase

type ValueViewBase struct {
	ki.Node
	ViewSig   ki.Signal            `` /* 213-byte string literal not displayed */
	Value     reflect.Value        `desc:"the reflect.Value representation of the value"`
	OwnKind   reflect.Kind         `desc:"kind of owner that we have -- reflect.Struct, .Map, .Slice are supported"`
	IsMapKey  bool                 `desc:"for OwnKind = Map, this value represents the Key -- otherwise the Value"`
	Owner     interface{}          `` /* 162-byte string literal not displayed */
	OwnerType reflect.Type         `desc:"non-pointer type of the Owner, for convenience"`
	Field     *reflect.StructField `desc:"if Owner is a struct, this is the reflect.StructField associated with the value"`
	Key       interface{}          `desc:"if Owner is a map, and this is a value, this is the key for this value in the map"`
	KeyView   ValueView            `` /* 159-byte string literal not displayed */
	Idx       int                  `desc:"if Owner is a slice, this is the index for the value in the slice"`
	WidgetTyp reflect.Type         `` /* 156-byte string literal not displayed */
	Widget    Node2D               `` /* 142-byte string literal not displayed */
	Label     string               `desc:"label for displaying this item -- based on Field.Name and optional label Tag value"`
	TmpSave   ValueView            `` /* 172-byte string literal not displayed */
}

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

func (*ValueViewBase) AsValueViewBase

func (vv *ValueViewBase) AsValueViewBase() *ValueViewBase

func (*ValueViewBase) ConfigWidget

func (vv *ValueViewBase) ConfigWidget(widg Node2D)

func (*ValueViewBase) CreateTempIfNotPtr

func (vv *ValueViewBase) CreateTempIfNotPtr() bool

func (*ValueViewBase) IsInactive

func (vv *ValueViewBase) IsInactive() bool

func (*ValueViewBase) New

func (n *ValueViewBase) New() ki.Ki

func (*ValueViewBase) OwnerKind

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

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

func (*ValueViewBase) SaveTmp

func (vv *ValueViewBase) SaveTmp()

func (*ValueViewBase) SetMapKey

func (vv *ValueViewBase) SetMapKey(key reflect.Value, owner interface{}, tmpSave ValueView)

func (*ValueViewBase) SetMapValue

func (vv *ValueViewBase) SetMapValue(val reflect.Value, owner interface{}, key interface{}, keyView ValueView, tmpSave ValueView)

func (*ValueViewBase) SetSliceValue

func (vv *ValueViewBase) SetSliceValue(val reflect.Value, owner interface{}, idx int, tmpSave ValueView)

func (*ValueViewBase) SetStructValue

func (vv *ValueViewBase) SetStructValue(val reflect.Value, owner interface{}, field *reflect.StructField, tmpSave ValueView)

func (*ValueViewBase) SetValue

func (vv *ValueViewBase) SetValue(val interface{}) bool

func (*ValueViewBase) UpdateWidget

func (vv *ValueViewBase) UpdateWidget()

func (*ValueViewBase) Val

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

func (*ValueViewBase) ViewFieldTag

func (vv *ValueViewBase) ViewFieldTag(tagName string) string

func (*ValueViewBase) WidgetType

func (vv *ValueViewBase) WidgetType() reflect.Type

type ValueViewer

type ValueViewer interface {
	ValueView() ValueView
}

ValueViewer interface supplies the appropriate type of ValueView -- called on a given receiver item if defined for that receiver type (tries both pointer and non-pointer receivers) -- can use this for custom types to provide alternative custom interfaces

type Vec2D

type Vec2D struct {
	X, Y float32
}

2D vector -- a point or size in 2D

func CubicBezier

func CubicBezier(x0, y0, x1, y1, x2, y2, x3, y3 float32) []Vec2D

func NewVec2D

func NewVec2D(x, y float32) Vec2D

func NewVec2DFmPoint

func NewVec2DFmPoint(pt image.Point) Vec2D

func PathDataMinMax

func PathDataMinMax(data []PathData) (min, max Vec2D)

PathDataMinMax traverses the path data and extracts the min and max point coords

func QuadraticBezier

func QuadraticBezier(x0, y0, x1, y1, x2, y2 float32) []Vec2D

func (Vec2D) Add

func (a Vec2D) Add(b Vec2D) Vec2D

func (Vec2D) AddVal

func (a Vec2D) AddVal(val float32) Vec2D

func (Vec2D) Dim

func (a Vec2D) Dim(d Dims2D) float32

return value along given dimension

func (Vec2D) Distance

func (a Vec2D) Distance(b Vec2D) float32

func (Vec2D) Div

func (a Vec2D) Div(b Vec2D) Vec2D

func (Vec2D) DivVal

func (a Vec2D) DivVal(val float32) Vec2D

func (Vec2D) Fixed

func (a Vec2D) Fixed() fixed.Point26_6

func (Vec2D) Interpolate

func (a Vec2D) Interpolate(b Vec2D, t float32) Vec2D

func (Vec2D) IsZero

func (a Vec2D) IsZero() bool

func (Vec2D) Max

func (a Vec2D) Max(b Vec2D) Vec2D

func (Vec2D) Min

func (a Vec2D) Min(b Vec2D) Vec2D

func (Vec2D) MinPos

func (a Vec2D) MinPos(b Vec2D) Vec2D

minimum of all positive (> 0) numbers

func (Vec2D) Mul

func (a Vec2D) Mul(b Vec2D) Vec2D

func (Vec2D) MulVal

func (a Vec2D) MulVal(val float32) Vec2D

func (*Vec2D) Set

func (a *Vec2D) Set(x, y float32)

set values

func (*Vec2D) SetAdd

func (a *Vec2D) SetAdd(b Vec2D)

func (*Vec2D) SetAddDim

func (a *Vec2D) SetAddDim(d Dims2D, val float32)

func (*Vec2D) SetAddVal

func (a *Vec2D) SetAddVal(val float32)

func (*Vec2D) SetDim

func (a *Vec2D) SetDim(d Dims2D, val float32)

set the value along a given dimension

func (*Vec2D) SetDiv

func (a *Vec2D) SetDiv(b Vec2D)

func (*Vec2D) SetDivDim

func (a *Vec2D) SetDivDim(d Dims2D, val float32)

func (*Vec2D) SetDivlVal

func (a *Vec2D) SetDivlVal(val float32)

func (*Vec2D) SetMax

func (a *Vec2D) SetMax(b Vec2D)

set to max of current vs. b

func (*Vec2D) SetMaxDim

func (a *Vec2D) SetMaxDim(d Dims2D, val float32)

set the value along a given dimension to max of current val and new val

func (*Vec2D) SetMaxVal

func (a *Vec2D) SetMaxVal(val float32)

set to max of current value and val

func (*Vec2D) SetMin

func (a *Vec2D) SetMin(b Vec2D)

set to min of current vs. b

func (*Vec2D) SetMinDim

func (a *Vec2D) SetMinDim(d Dims2D, val float32)

set the value along a given dimension to min of current val and new val

func (*Vec2D) SetMinPos

func (a *Vec2D) SetMinPos(b Vec2D)

set to minpos of current vs. b

func (*Vec2D) SetMinPosDim

func (a *Vec2D) SetMinPosDim(d Dims2D, val float32)

set the value along a given dimension to min of current val and new val

func (*Vec2D) SetMinPosVal

func (a *Vec2D) SetMinPosVal(val float32)

set to minpos of current value and val

func (*Vec2D) SetMinVal

func (a *Vec2D) SetMinVal(val float32)

set to min of current value and val

func (*Vec2D) SetMul

func (a *Vec2D) SetMul(b Vec2D)

func (*Vec2D) SetMulDim

func (a *Vec2D) SetMulDim(d Dims2D, val float32)

func (*Vec2D) SetMulVal

func (a *Vec2D) SetMulVal(val float32)

func (*Vec2D) SetPoint

func (a *Vec2D) SetPoint(pt image.Point)

func (*Vec2D) SetSub

func (a *Vec2D) SetSub(b Vec2D)

func (*Vec2D) SetSubDim

func (a *Vec2D) SetSubDim(d Dims2D, val float32)

func (*Vec2D) SetSubVal

func (a *Vec2D) SetSubVal(val float32)

func (*Vec2D) SetVal

func (a *Vec2D) SetVal(val float32)

set both dims to same value

func (Vec2D) String

func (a Vec2D) String() string

func (Vec2D) Sub

func (a Vec2D) Sub(b Vec2D) Vec2D

func (Vec2D) SubVal

func (a Vec2D) SubVal(val float32) Vec2D

func (Vec2D) ToPoint

func (a Vec2D) ToPoint() image.Point

func (Vec2D) ToPointCeil

func (a Vec2D) ToPointCeil() image.Point

func (Vec2D) ToPointFloor

func (a Vec2D) ToPointFloor() image.Point

func (Vec2D) ToPointRound

func (a Vec2D) ToPointRound() image.Point

type ViewBox2D

type ViewBox2D struct {
	Min                 image.Point                `svg:"{min-x,min-y}" desc:"offset or starting point in parent Viewport2D"`
	Size                image.Point                `svg:"{width,height}" desc:"size of viewbox within parent Viewport2D"`
	PreserveAspectRatio ViewBoxPreserveAspectRatio `svg:"preserveAspectRatio" desc:"how to scale the view box within parent Viewport2D"`
}

ViewBox defines a region in 2D bitmap image space -- it must ALWAYS be in terms of underlying pixels

func (*ViewBox2D) Bounds

func (vb *ViewBox2D) Bounds() image.Rectangle

convert viewbox to bounds

func (*ViewBox2D) SizeRect

func (vb *ViewBox2D) SizeRect() image.Rectangle

convert viewbox to rect version of size

type ViewBoxAlign

type ViewBoxAlign int32

ViewBoxAlign defines values for the PreserveAspectRatio alignment factor

const (
	None  ViewBoxAlign = 1 << iota          // do not preserve uniform scaling
	XMin                                    // align ViewBox.Min with smallest values of Viewport
	XMid                                    // align ViewBox.Min with midpoint values of Viewport
	XMax                                    // align ViewBox.Min+Size with maximum values of Viewport
	XMask ViewBoxAlign = XMin + XMid + XMax // mask for X values -- clear all X before setting new one
	YMin  ViewBoxAlign = 1 << iota          // align ViewBox.Min with smallest values of Viewport
	YMid                                    // align ViewBox.Min with midpoint values of Viewport
	YMax                                    // align ViewBox.Min+Size with maximum values of Viewport
	YMask ViewBoxAlign = YMin + YMid + YMax // mask for Y values -- clear all Y before setting new one
)

type ViewBoxMeetOrSlice

type ViewBoxMeetOrSlice int32

ViewBoxMeetOrSlice defines values for the PreserveAspectRatio meet or slice factor

const (
	Meet  ViewBoxMeetOrSlice = iota // the entire ViewBox is visible within Viewport, and it is scaled up as much as possible to meet the align constraints
	Slice ViewBoxMeetOrSlice = iota // the entire ViewBox is covered by the ViewBox, and the ViewBox is scaled down as much as possible, while still meeting the align constraints
)

func (*ViewBoxMeetOrSlice) FromString

func (i *ViewBoxMeetOrSlice) FromString(s string) error

func (ViewBoxMeetOrSlice) String

func (i ViewBoxMeetOrSlice) String() string

type ViewBoxPreserveAspectRatio

type ViewBoxPreserveAspectRatio struct {
	Align       ViewBoxAlign       `svg:"align" desc:"how to align x,y coordinates within viewbox"`
	MeetOrSlice ViewBoxMeetOrSlice `svg:"meetOrSlice" desc:"how to scale the view box relative to the viewport"`
}

ViewBoxPreserveAspectRatio determines how to scale the view box within parent Viewport2D

type Viewport2D

type Viewport2D struct {
	Node2DBase
	CSS     ki.Props    `` /* 191-byte string literal not displayed */
	CSSAgg  ki.Props    `json:"-" xml:"-" desc:"aggregated css properties from all higher nodes down to me"`
	Fill    bool        `desc:"fill the viewport with background-color from style"`
	ViewBox ViewBox2D   `xml:"viewBox" desc:"viewbox within any parent Viewport2D"`
	Render  RenderState `json:"-" xml:"-" view:"-" desc:"render state for rendering"`
	Pixels  *image.RGBA `json:"-" xml:"-" view:"-" desc:"live pixels that we render into, from OSImage"`
	OSImage oswin.Image `json:"-" xml:"-" view:"-" desc:"the oswin.Image that owns our pixels"`
	Win     *Window     `json:"-" xml:"-" desc:"our parent window that we render into"`
}

Viewport2D provides an image and a stack of Paint contexts for drawing onto the image with a convenience forwarding of the Paint methods operating on the current Paint

func NewViewport2D

func NewViewport2D(width, height int) *Viewport2D

NewViewport2D creates a new OSImage with the specified width and height, and intializes the renderer etc

func PopupMenu

func PopupMenu(menu ki.Slice, x, y int, parVp *Viewport2D, name string) *Viewport2D

PopupMenu just pops up a viewport with a layout that draws the supplied actions positions are relative to given viewport -- name is relevant base name to which Menu is appended

func (*Viewport2D) AsViewport2D

func (vp *Viewport2D) AsViewport2D() *Viewport2D

func (*Viewport2D) BBox2D

func (vp *Viewport2D) BBox2D() image.Rectangle

func (*Viewport2D) CSSProps

func (g *Viewport2D) CSSProps() (css, agg *ki.Props)

func (*Viewport2D) ChildrenBBox2D

func (vp *Viewport2D) ChildrenBBox2D() image.Rectangle

func (*Viewport2D) ComputeBBox2D

func (vp *Viewport2D) ComputeBBox2D(parBBox image.Rectangle, delta image.Point)

func (*Viewport2D) DeletePopup

func (vp *Viewport2D) DeletePopup()

Delete this viewport -- has already been disconnected from window events and parent is nil -- called by window when a popup is deleted -- it destroys the vp and its main layout, see VpFlagPopupDestroyAll for whether children are destroyed

func (*Viewport2D) DrawIntoParent

func (vp *Viewport2D) DrawIntoParent(parVp *Viewport2D)

draw our image into parents -- called at right place in Render

func (*Viewport2D) DrawIntoWindow

func (vp *Viewport2D) DrawIntoWindow()

draw a vp into window directly -- for most non-main vp's

func (*Viewport2D) DrawMainViewport

func (vp *Viewport2D) DrawMainViewport()

draw main viewport into window -- needs to redraw popups over top of it, so does a full update

func (*Viewport2D) DrawMainVpOverMe

func (vp *Viewport2D) DrawMainVpOverMe()

draw main window vp into region of this vp

func (*Viewport2D) EncodePNG

func (vp *Viewport2D) EncodePNG(w io.Writer) error

EncodePNG encodes the image as a PNG and writes it to the provided io.Writer.

func (*Viewport2D) FillViewport

func (vp *Viewport2D) FillViewport()

func (*Viewport2D) FocusChanged2D

func (g *Viewport2D) FocusChanged2D(gotFocus bool)

func (*Viewport2D) Init2D

func (vp *Viewport2D) Init2D()

func (*Viewport2D) IsMenu

func (vp *Viewport2D) IsMenu() bool

func (*Viewport2D) IsPopup

func (vp *Viewport2D) IsPopup() bool

func (*Viewport2D) IsSVG

func (vp *Viewport2D) IsSVG() bool

func (*Viewport2D) Layout2D

func (vp *Viewport2D) Layout2D(parBBox image.Rectangle)

func (*Viewport2D) Move2D

func (vp *Viewport2D) Move2D(delta image.Point, parBBox image.Rectangle)

func (*Viewport2D) New

func (n *Viewport2D) New() ki.Ki

func (*Viewport2D) PopBounds

func (vp *Viewport2D) PopBounds()

func (*Viewport2D) PushBounds

func (vp *Viewport2D) PushBounds() bool

we use our own render for these -- Viewport member is our parent!

func (*Viewport2D) ReRender2D

func (vp *Viewport2D) ReRender2D() (node Node2D, layout bool)

func (*Viewport2D) ReRender2DAnchor

func (vp *Viewport2D) ReRender2DAnchor(gni Node2D)

re-render a specific node that has said it can re-render

func (*Viewport2D) ReRender2DNode

func (vp *Viewport2D) ReRender2DNode(gni Node2D)

re-render a specific node that has said it can re-render

func (*Viewport2D) Render2D

func (vp *Viewport2D) Render2D()

func (*Viewport2D) RenderViewport2D

func (vp *Viewport2D) RenderViewport2D()

func (*Viewport2D) Resize

func (vp *Viewport2D) Resize(width, height int)

Resize resizes the viewport, creating a new image (no point in trying to resize the image -- need to re-render) -- updates ViewBox Size too -- triggers update -- wrap in other UpdateStart/End calls as appropriate

func (*Viewport2D) SavePNG

func (vp *Viewport2D) SavePNG(path string) error

SavePNG encodes the image as a PNG and writes it to disk.

func (*Viewport2D) SetCurWin

func (vp *Viewport2D) SetCurWin()

set our window pointer to point to the current window we are under

func (*Viewport2D) Size2D

func (vp *Viewport2D) Size2D()

func (*Viewport2D) Style2D

func (vp *Viewport2D) Style2D()

func (*Viewport2D) StyleCSS

func (g *Viewport2D) StyleCSS(node Node2D)

type Viewport2DFill

type Viewport2DFill struct {
	Rect
}

viewport fill fills entire viewport -- just a rect that automatically sets size to viewport

func (*Viewport2DFill) BBox2D

func (g *Viewport2DFill) BBox2D() image.Rectangle

func (*Viewport2DFill) Init2D

func (g *Viewport2DFill) Init2D()

func (*Viewport2DFill) New

func (n *Viewport2DFill) New() ki.Ki

func (*Viewport2DFill) ReRender2D

func (g *Viewport2DFill) ReRender2D() (node Node2D, layout bool)

func (*Viewport2DFill) Style2D

func (g *Viewport2DFill) Style2D()

type WalkStyleFieldFunc

type WalkStyleFieldFunc func(struf reflect.StructField, vf reflect.Value, tag string, baseoff uintptr)

this is the function to process a given field when walking the style

type WidgetBase

type WidgetBase struct {
	Node2DBase
	CSS    ki.Props `` /* 201-byte string literal not displayed */
	CSSAgg ki.Props `json:"-" xml:"-" desc:"aggregated css properties from all higher nodes down to me"`
	Parts  Layout   `` /* 214-byte string literal not displayed */
}

Widget base type -- manages control elements and provides standard box model rendering

func (*WidgetBase) CSSProps

func (g *WidgetBase) CSSProps() (css, agg *ki.Props)

func (*WidgetBase) ChildrenBBox2D

func (g *WidgetBase) ChildrenBBox2D() image.Rectangle

func (*WidgetBase) ComputeBBox2D

func (g *WidgetBase) ComputeBBox2D(parBBox image.Rectangle, delta image.Point)

func (*WidgetBase) ComputeBBox2DWidget

func (g *WidgetBase) ComputeBBox2DWidget(parBBox image.Rectangle, delta image.Point)

func (*WidgetBase) ConfigPartsIconLabel

func (g *WidgetBase) ConfigPartsIconLabel(icn *Icon, txt string) (config kit.TypeAndNameList, icIdx, lbIdx int)

ConfigPartsIconLabel returns a standard config for creating parts, of icon and label left-to right in a row, based on whether items are nil or empty

func (*WidgetBase) ConfigPartsSetIconLabel

func (g *WidgetBase) ConfigPartsSetIconLabel(icn *Icon, txt string, icIdx, lbIdx int)

set the icon and text values in parts, and get part style props, using given props if not set in object props

func (*WidgetBase) FocusChanged2D

func (g *WidgetBase) FocusChanged2D(gotFocus bool)

func (*WidgetBase) Init2D

func (g *WidgetBase) Init2D()

func (*WidgetBase) Init2DWidget

func (g *WidgetBase) Init2DWidget()

func (*WidgetBase) Layout2D

func (g *WidgetBase) Layout2D(parBBox image.Rectangle)

func (*WidgetBase) Layout2DParts

func (g *WidgetBase) Layout2DParts(parBBox image.Rectangle)

func (*WidgetBase) Layout2DWidget

func (g *WidgetBase) Layout2DWidget(parBBox image.Rectangle)

func (*WidgetBase) MeasureTextSize

func (g *WidgetBase) MeasureTextSize(txt string) (w, h float32)

measure given text string using current style

func (*WidgetBase) Move2D

func (g *WidgetBase) Move2D(delta image.Point, parBBox image.Rectangle)

func (*WidgetBase) Move2DWidget

func (g *WidgetBase) Move2DWidget(delta image.Point, parBBox image.Rectangle)

func (*WidgetBase) New

func (n *WidgetBase) New() ki.Ki

func (*WidgetBase) PartsNeedUpdateIconLabel

func (g *WidgetBase) PartsNeedUpdateIconLabel(icn *Icon, txt string) bool

check if parts need to be updated -- for ConfigPartsIfNeeded

func (*WidgetBase) ReRender2D

func (g *WidgetBase) ReRender2D() (node Node2D, layout bool)

func (*WidgetBase) Render2DParts

func (g *WidgetBase) Render2DParts()

func (*WidgetBase) Render2DText

func (g *WidgetBase) Render2DText(txt string)

render a text string in standard box model (e.g., label for a button, etc)

func (*WidgetBase) RenderBoxImpl

func (g *WidgetBase) RenderBoxImpl(pos Vec2D, sz Vec2D, rad float32)

func (*WidgetBase) RenderStdBox

func (g *WidgetBase) RenderStdBox(st *Style)

draw standard box using given style

func (*WidgetBase) Size2D

func (g *WidgetBase) Size2D()

func (*WidgetBase) Size2DAddSpace

func (g *WidgetBase) Size2DAddSpace()

add space to existing AllocSize

func (*WidgetBase) Size2DFromText

func (g *WidgetBase) Size2DFromText(txt string)

set our LayData.AllocSize from measured text size

func (*WidgetBase) Size2DFromWH

func (g *WidgetBase) Size2DFromWH(w, h float32)

set our LayData.AllocSize from constraints

func (*WidgetBase) Size2DWidget

func (g *WidgetBase) Size2DWidget()

func (*WidgetBase) SizeFromParts

func (g *WidgetBase) SizeFromParts()

type Window

type Window struct {
	NodeBase
	Viewport   *Viewport2D                 `json:"-" xml:"-" desc:"convenience pointer to our viewport child that handles all of our rendering"`
	OSWin      oswin.Window                `json:"-" xml:"-" desc:"OS-specific window interface"`
	WinTex     oswin.Texture               `` /* 127-byte string literal not displayed */
	EventSigs  [oswin.EventTypeN]ki.Signal `json:"-" xml:"-" desc:"signals for communicating each type of event"`
	Focus      ki.Ki                       `json:"-" xml:"-" desc:"node receiving keyboard events"`
	Dragging   ki.Ki                       `json:"-" xml:"-" desc:"node receiving mouse dragging events"`
	Popup      ki.Ki                       `jsom:"-" xml:"-" desc:"Current popup viewport that gets all events"`
	PopupStack []ki.Ki                     `jsom:"-" xml:"-" desc:"stack of popups"`
	FocusStack []ki.Ki                     `jsom:"-" xml:"-" desc:"stack of focus"`
	NextPopup  ki.Ki                       `json:"-" xml:"-" desc:"this popup will be pushed at the end of the current event cycle"`

	DoFullRender bool `json:"-" xml:"-" desc:"triggers a full re-render of the window within the event loop -- cleared once done"`
	// contains filtered or unexported fields
}

Window provides an OS-specific window and all the associated event handling

func NewDialogWin

func NewDialogWin(name string, width, height int, modal bool) *Window

NewDialogWin creates a new dialog window with given name and sizing (assumed to be in raw dots), without setting its main viewport -- user should do win.AddChild(vp); win.Viewport = vp to set their own viewport

func NewWindow

func NewWindow(name string, opts *oswin.NewWindowOptions) *Window

NewWindow creates a new window with given name and options

func NewWindow2D

func NewWindow2D(name string, width, height int, stdPixels bool) *Window

NewWindow2D creates a new standard 2D window with given name and sizing, with default positioning, and initializes a 2D viewport within it -- stdPixels means use standardized "pixel" units for the display size (96 per inch), not the actual underlying raw display dot pixels

func (*Window) BenchmarkFullRender

func (w *Window) BenchmarkFullRender()

run benchmark of 50 full re-renders, report targeted profile results

func (*Window) BenchmarkReRender

func (w *Window) BenchmarkReRender()

run benchmark of 50 just-re-renders, not full rebuilds

func (*Window) ClearNonFocus

func (w *Window) ClearNonFocus()

ClearNonFocus clears the focus of any non-w.Focus item -- sometimes can get off

func (*Window) ClosePopup

func (w *Window) ClosePopup(pop ki.Ki) bool

close given popup -- must be the current one -- returns false if not

func (*Window) DeletePopupMenu

func (w *Window) DeletePopupMenu(pop ki.Ki) bool

DeletePopupMenu returns true if the given popup item should be deleted

func (*Window) DisconnectNode

func (w *Window) DisconnectNode(recv ki.Ki)

disconnect node from all signals

func (*Window) DisconnectPopup

func (w *Window) DisconnectPopup(pop ki.Ki)

disconnect given popup -- typically the current one

func (*Window) EndCPUMemProfile

func (w *Window) EndCPUMemProfile()

func (*Window) EndTargProfile

func (w *Window) EndTargProfile()

end targeted profiling and print report

func (*Window) EventLoop

func (w *Window) EventLoop()

start the event loop running -- runs in a separate goroutine

func (*Window) FullReRender

func (w *Window) FullReRender()

FullReRender can be called to trigger a full re-render of the window

func (*Window) FullUpdate

func (w *Window) FullUpdate()

FullUpdate does a complete update of window pixels -- grab pixels from all the different active viewports

func (*Window) GenMouseFocusEvents

func (w *Window) GenMouseFocusEvents(mev *mouse.MoveEvent)

process mouse.MoveEvent to generate mouse.FocusEvent events

func (*Window) IsInScope

func (w *Window) IsInScope(gii Node2D, gi *Node2DBase) bool

IsInScope returns true if the given object is in scope for receiving events

func (*Window) LogicalDPI

func (w *Window) 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 (*Window) New

func (n *Window) New() ki.Ki

func (*Window) PopFocus

func (w *Window) PopFocus()

pop Mask off the focus stack and set to current focus

func (*Window) PopPopup

func (w *Window) PopPopup(pop ki.Ki)

pop current popup off the popup stack and set to current popup

func (*Window) Publish

func (w *Window) Publish()

func (*Window) PushFocus

func (w *Window) PushFocus(p ki.Ki)

push current focus onto stack and set new focus

func (*Window) PushPopup

func (w *Window) PushPopup(pop ki.Ki)

push current popup onto stack and set new popup

func (*Window) ReceiveEventType

func (w *Window) ReceiveEventType(recv ki.Ki, et oswin.EventType, fun ki.RecvFunc)

ReceiveEventType adds a Signal connection for given event type to given receiver

func (*Window) Resized

func (w *Window) Resized(sz image.Point)

func (*Window) SendEventSignal

func (w *Window) SendEventSignal(evi oswin.Event)

SendEventSignal sends given event signal to all receivers that want it -- note that because there is a different EventSig for each event type, we are ONLY looking at nodes that have registered to receive that type of event -- the further filtering is just to ensure that they are in the right position to receive the event (focus, popup filtering, etc)

func (*Window) SetFocusItem

func (w *Window) SetFocusItem(k ki.Ki) bool

set focus to given item -- returns true if focus changed

func (*Window) SetNextFocusItem

func (w *Window) SetNextFocusItem() bool

set the focus on the next item that can accept focus -- returns true if a focus item found

func (*Window) SetPrevFocusItem

func (w *Window) SetPrevFocusItem() bool

set the focus on the previous item

func (*Window) SetSize

func (w *Window) SetSize(sz image.Point)

func (*Window) StartCPUMemProfile

func (w *Window) StartCPUMemProfile()

func (*Window) StartEventLoop

func (w *Window) StartEventLoop()

func (*Window) StartEventLoopNoWait

func (w *Window) StartEventLoopNoWait()

func (*Window) StartTargProfile

func (w *Window) StartTargProfile()

start targeted profiling using prof package

func (*Window) StopEventLoop

func (w *Window) StopEventLoop()

tell the event loop to stop running

func (*Window) UpdateFullVpRegion

func (w *Window) UpdateFullVpRegion(vp *Viewport2D, vpBBox, winBBox image.Rectangle)

UpdateVpPixels updates pixels for one viewport region on the screen, in its entirety

func (*Window) UpdateVpRegion

func (w *Window) UpdateVpRegion(vp *Viewport2D, vpBBox, winBBox image.Rectangle)

UpdateVpRegion updates pixels for one viewport region on the screen, using vpBBox bounding box for the viewport, and winBBox bounding box for the window (which should not be empty given the overall logic driving updates) -- the Window has a its OnlySelfUpdate logic for determining when to flush changes to the underlying OSWindow -- wrap updates in win.UpdateStart / win.UpdateEnd to actually flush the updates to be visible

func (*Window) UpdateVpRegionFromMain

func (w *Window) UpdateVpRegionFromMain(winBBox image.Rectangle)

UpdateVpRegionFromMain basically clears the region where the vp would show up, from the main

func (*Window) WinViewport2D

func (w *Window) WinViewport2D() *Viewport2D

func (*Window) ZoomDPI

func (w *Window) ZoomDPI(steps int)

Zoom -- positive steps increase logical DPI, negative steps decrease it

type XFormMatrix2D

type XFormMatrix2D struct {
	XX, YX, XY, YY, X0, Y0 float32
}

func Identity2D

func Identity2D() XFormMatrix2D

func Rotate2D

func Rotate2D(angle float32) XFormMatrix2D

func Scale2D

func Scale2D(x, y float32) XFormMatrix2D

func Shear2D

func Shear2D(x, y float32) XFormMatrix2D

func Translate2D

func Translate2D(x, y float32) XFormMatrix2D

func (XFormMatrix2D) Multiply

func (XFormMatrix2D) Rotate

func (a XFormMatrix2D) Rotate(angle float32) XFormMatrix2D

func (XFormMatrix2D) Scale

func (a XFormMatrix2D) Scale(x, y float32) XFormMatrix2D

func (XFormMatrix2D) Shear

func (a XFormMatrix2D) Shear(x, y float32) XFormMatrix2D

func (XFormMatrix2D) TransformPoint

func (a XFormMatrix2D) TransformPoint(x, y float32) (tx, ty float32)

func (XFormMatrix2D) TransformPointToInt

func (a XFormMatrix2D) TransformPointToInt(x, y float32) (tx, ty int)

func (XFormMatrix2D) TransformVector

func (a XFormMatrix2D) TransformVector(x, y float32) (tx, ty float32)

func (XFormMatrix2D) Translate

func (a XFormMatrix2D) Translate(x, y float32) XFormMatrix2D

Directories

Path Synopsis
examples
Package oswin provides interfaces for OS-specific GUI hardware for portable two-dimensional graphics and input events.
Package oswin provides interfaces for OS-specific GUI hardware for portable two-dimensional graphics and input events.
driver
Package driver provides the default driver for accessing a screen.
Package driver provides the default driver for accessing a screen.
driver/gldriver
Package gldriver provides an OpenGL driver for accessing a screen.
Package gldriver provides an OpenGL driver for accessing a screen.
driver/internal/drawer
Package drawer provides functions that help implement screen.Drawer methods.
Package drawer provides functions that help implement screen.Drawer methods.
driver/internal/errapp
Package errapp provides a stub App implementation.
Package errapp provides a stub App implementation.
driver/internal/event
Package event provides an infinitely buffered double-ended queue of events.
Package event provides an infinitely buffered double-ended queue of events.
driver/internal/lifecycler
Package lifecycler tracks a window's lifecycle state.
Package lifecycler tracks a window's lifecycle state.
driver/internal/swizzle
Package swizzle provides functions for converting between RGBA pixel formats.
Package swizzle provides functions for converting between RGBA pixel formats.
driver/internal/x11key
x11key contains X11 numeric codes for the keyboard and mouse.
x11key contains X11 numeric codes for the keyboard and mouse.
driver/windriver
Package windriver provides the Windows driver for accessing a screen.
Package windriver provides the Windows driver for accessing a screen.
driver/x11driver
Package x11driver provides the X11 driver for accessing a screen.
Package x11driver provides the X11 driver for accessing a screen.
key
Package key defines an event for physical keyboard keys, for the GoGi GUI system.
Package key defines an event for physical keyboard keys, for the GoGi GUI system.
lifecycle
Package lifecycle defines an event for an app's lifecycle, for the GoGI GUI system.
Package lifecycle defines an event for an app's lifecycle, for the GoGI GUI system.
mouse
Package mouse defines mouse events, for the GoGi GUI system.
Package mouse defines mouse events, for the GoGi GUI system.
paint
Package paint defines an event for the app being ready to paint.
Package paint defines an event for the app being ready to paint.
touch
Package touch defines an event for touch input, for the GoGi GUI system.
Package touch defines an event for touch input, for the GoGi GUI system.
window
Package window defines an event associated with windows -- including changes in the dimensions, physical resolution and orientation of the app's window, and iconify, open and close events (see also lifecycle events, which pertain to the main app window -- these window events are for all windows including dialogs and popups)
Package window defines an event associated with windows -- including changes in the dimensions, physical resolution and orientation of the app's window, and iconify, open and close events (see also lifecycle events, which pertain to the main app window -- these window events are for all windows including dialogs and popups)
package oswin provides OS-specific windows and events.
package oswin provides OS-specific windows and events.
win
xgb
Package Units supports full range of CSS-style length units (em, px, dp, etc) The unit is stored along with a value, and can be converted at a later point into a raw display pixel value using the Context which contains all the necessary reference values to perform the conversion.
Package Units supports full range of CSS-style length units (em, px, dp, etc) The unit is stored along with a value, and can be converted at a later point into a raw display pixel value using the Context which contains all the necessary reference values to perform the conversion.

Jump to

Keyboard shortcuts

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