Work
This commit is contained in:
14
widget.go
14
widget.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user