Documentation
¶
Index ¶
- Constants
- func FloatButtons(c *ui.Context, helpImg, runImg *ui.Bitmap, onHelp, onRun func())
- func IconButton(c *ui.Context, opt IconButtonOption) ui.Element
- func ImageButton(c *ui.Context, img *ui.Bitmap, onClick func())
- func LevelGroups(n int, id func(int) string) [][]int
- func LoadPrefs()
- func Painting(c *ui.Context, left, right *ui.Bitmap)
- func PaintingActive(c *ui.Context, until time.Time) bool
- func SaveSVG(defaultName string, data []byte, notice *Notice)
- func ShowDialogWithImage(c *ui.Context, opt DialogOption)
- type Alert
- type CopyButton
- type DialogOption
- type Help
- type HelpConfig
- type IconButtonOption
- type Notice
- type Workspace
- type WorkspaceConfig
Constants ¶
const PaintingDuration = 1200 * time.Millisecond
PaintingDuration is how long the painting overlay shows.
Variables ¶
This section is empty.
Functions ¶
func FloatButtons ¶
FloatButtons renders the help and run buttons in the bottom corners.
func IconButton ¶
func IconButton(c *ui.Context, opt IconButtonOption) ui.Element
func ImageButton ¶
ImageButton renders an image button sized for the floating corners. The image eases larger while the pointer is over the button.
func LevelGroups ¶
LevelGroups groups level indexes by chapter, from each level id's leading digit: 1.03 is chapter one, 2.20 is chapter two.
func LoadPrefs ¶
func LoadPrefs()
LoadPrefs reads the settings file and applies sound and theme. Call once at startup, before the first frame.
func PaintingActive ¶
PaintingActive reports whether the painting overlay shows until.
func ShowDialogWithImage ¶
func ShowDialogWithImage(c *ui.Context, opt DialogOption)
ShowDialogWithImage shows an image dialog; the last button is the primary action.
Types ¶
type Alert ¶
type Alert struct {
// contains filtered or unexported fields
}
Alert is a feedback alert that closes itself on outside click, Escape or through the close function passed to content.
type CopyButton ¶
type CopyButton struct {
// contains filtered or unexported fields
}
CopyButton copies code to the clipboard and shows a check mark briefly.
func NewCopyButton ¶
func NewCopyButton(getContent func() string) *CopyButton
NewCopyButton creates a CopyButton.
type DialogOption ¶
type Help ¶
type Help struct {
// contains filtered or unexported fields
}
Help owns the docs viewer state.
type HelpConfig ¶
HelpConfig configures the Help component.
type IconButtonOption ¶
type Notice ¶
type Notice struct {
// contains filtered or unexported fields
}
Notice shows a message in the middle of the window for a while.
type Workspace ¶
Workspace lays out the canvas, code editor, help dialog and floating buttons.
func NewWorkspace ¶
func NewWorkspace(fsys fs.FS, cfg WorkspaceConfig) *Workspace
NewWorkspace creates a workspace.
func (*Workspace) FocusEditor ¶
func (w *Workspace) FocusEditor()
FocusEditor focuses the code editor in the next frame.
type WorkspaceConfig ¶
type WorkspaceConfig struct {
Code string
DocModule string
Canvas func(c *ui.Context)
OnRun func(c *ui.Context)
OnPractice func(level int) // fired on tutorial toggle: 0 to enter, -1 to leave
OnHelp func() // replaces opening the docs, e.g. with a level hint
}
WorkspaceConfig configures the shared workspace shell.