Debian Codegraph @

lib/ui/interfaces.go

raw
1 package ui
2
3 import (
4 "go.rockorager.dev/vaxis"
5 )
6
7 // Drawable is a UI component that can draw. Unless specified, all methods must
8 // only be called from a single goroutine, the UI goroutine.
9 type Drawable interface {
10 // Called when this renderable should draw itself.
11 Draw(ctx *Context)
12 // Invalidates the UI. This can be called from any goroutine.
13 Invalidate()
14 }
15
16 type Closeable interface {
17 Close()
18 }
19
20 type Visible interface {
21 // Indicate that this component is visible or not
22 Show(bool)
23 }
24
25 type Focusable interface {
26 // Indicates whether or not this control will receive input events
27 Focus(focus bool)
28 }
29
30 type Interactive interface {
31 Focusable
32 // Returns true if the event was handled by this component
33 Event(event vaxis.Event) bool
34 }
35
36 type Beeper interface {
37 OnBeep(func())
38 }
39
40 type DrawableInteractive interface {
41 Drawable
42 Interactive
43 }
44
45 type DrawableInteractiveBeeper interface {
46 DrawableInteractive
47 Beeper
48 }
49
50 // A drawable which contains other drawables
51 type Container interface {
52 Drawable
53 // Return all of the drawables which are children of this one (do not
54 // recurse into your grandchildren).
55 Children() []Drawable
56 }
57
58 type MouseHandler interface {
59 // Handle a mouse event which occurred at the local x and y positions
60 MouseEvent(localX int, localY int, event vaxis.Event)
61 }
62
63 // A drawable that can be interacted with by the mouse
64 type Mouseable interface {
65 Drawable
66 MouseHandler
67 }
68
69 type MouseableDrawableInteractive interface {
70 DrawableInteractive
71 MouseHandler
72 }