summary refs log tree commit diff stats
path: root/lib/ui/interfaces.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-01-20 13:51:34 -0500
committerDrew DeVault <sir@cmpwn.com>2019-01-20 13:51:34 -0500
commit87fa305848a893b1c85472ea394f24486bd478b6 (patch)
tree1f0f95a185b4615d342fde1e0841dcf0fa47bdb7 /lib/ui/interfaces.go
parent0b37441f177a46d40aad55f4553fa844bd4dbf6d (diff)
downloadaerc-87fa305848a893b1c85472ea394f24486bd478b6.tar.gz
Merge lib/ui/interfaces.go and add another
Diffstat (limited to 'lib/ui/interfaces.go')
-rw-r--r--lib/ui/interfaces.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/ui/interfaces.go b/lib/ui/interfaces.go
new file mode 100644
index 0000000..320183f
--- /dev/null
+++ b/lib/ui/interfaces.go
@@ -0,0 +1,42 @@
+package ui
+
+import (
+	"github.com/gdamore/tcell"
+)
+
+type Drawable interface {
+	// Called when this renderable should draw itself
+	Draw(ctx *Context)
+	// Specifies a function to call when this cell needs to be redrawn
+	OnInvalidate(callback func(d Drawable))
+	// Invalidates the drawable
+	Invalidate()
+}
+
+type Interactive interface {
+	// Returns true if the event was handled by this component
+	Event(event tcell.Event) bool
+}
+
+type Simulator interface {
+	// Queues up the given input events for simulation
+	Simulate(events []tcell.Event)
+}
+
+type DrawableInteractive interface {
+	Drawable
+	Interactive
+}
+
+// A drawable which contains other drawables
+type Container interface {
+	Drawable
+	// A list of all drawables which are children of this one (do not recurse
+	// into your grandchildren).
+	Children() []Drawable
+	// Return the "focused" child, or none of no preference. Does not actually
+	// have to be Interactive. If there is a preferred child, input events will
+	// be directed to it. If there's no preference, events will be delivered to
+	// all children.
+	InteractiveChild() Drawable
+}
href='#n196'>196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251