You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
576 B
Go
35 lines
576 B
Go
4 years ago
|
package app
|
||
|
|
||
|
import (
|
||
|
"github.com/gdamore/tcell/v2"
|
||
|
"github.com/jordanorelli/astro-domu/internal/math"
|
||
|
)
|
||
|
|
||
|
type containerView struct {
|
||
|
children []*node
|
||
|
focussed int
|
||
|
}
|
||
|
|
||
|
func (c *containerView) handleEvent(e tcell.Event) change {
|
||
|
switch e.(type) {
|
||
|
case *tcell.EventKey:
|
||
|
return c.children[c.focussed].handleEvent(e)
|
||
|
|
||
|
default:
|
||
|
// ui.Debug("screen saw unhandled event of type %T", e)
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (c *containerView) draw(img canvas, st *state) {
|
||
|
for _, n := range c.children {
|
||
|
n.draw(cut(img, n.frame), st)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
type node struct {
|
||
|
view
|
||
|
frame math.Rect
|
||
|
}
|