This commit is contained in:
2025-07-09 16:14:11 -05:00
parent 4763d1be26
commit 2e2aa50b82
13 changed files with 763 additions and 124 deletions

View File

@@ -26,6 +26,8 @@ import "github.com/gdamore/tcell"
type Widget interface {
Init(string, tcell.Style)
Id() string
// HandleResize sets things up to be drawn based on the width and height
// given to it through SetW & SetH
HandleResize(*tcell.EventResize)
HandleKey(*tcell.EventKey) bool
HandleTime(*tcell.EventTime)
@@ -40,15 +42,27 @@ type Widget interface {
GetX() int
GetY() int
SetPos(Coord)
// Whatever is managing this widget (parent widget, screen, etc) should
// tell it exactly what the Width & Height are.
// It _should_ try to base this off of WantW & WantH
SetW(int)
SetH(int)
GetW() int
GetH() int
// Given infinite space, WantW & WantH are what this widget wants
WantW() int
WantH() int
SetSize(Coord)
}
func WidgetBottom(w Widget) int {
return w.GetY() + w.GetH()
}
func WidgetRight(w Widget) int {
return w.GetX() + w.GetW()
}
type Coord struct {
X, Y int
}