1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Streamlining the widget creation process a bit more. Coords into config

This commit is contained in:
Chris Cummer
2018-04-07 23:36:05 -07:00
committed by Chris Cummer
parent cbf5b45c62
commit 9bda045ce1
4 changed files with 88 additions and 59 deletions

View File

@@ -7,4 +7,8 @@ import (
type TextViewer interface {
Enabler
TextView() *tview.TextView
Top() int
Left() int
Width() int
Height() int
}

View File

@@ -11,20 +11,39 @@ import (
var Config *config.Config
type Position struct {
Top int
Left int
Width int
Height int
top int
left int
width int
height int
}
func (pos *Position) Top() int {
return pos.top
}
func (pos *Position) Left() int {
return pos.left
}
func (pos *Position) Width() int {
return pos.width
}
func (pos *Position) Height() int {
return pos.height
}
/* -------------------- TextWidget -------------------- */
type TextWidget struct {
enabled bool
Name string
Position Position
RefreshedAt time.Time
RefreshInt int
View *tview.TextView
Position
}
func NewTextWidget(name string, configKey string) TextWidget {
@@ -32,6 +51,12 @@ func NewTextWidget(name string, configKey string) TextWidget {
enabled: Config.UBool(fmt.Sprintf("wtf.%s.enabled", configKey), false),
Name: name,
RefreshInt: Config.UInt(fmt.Sprintf("wtf.%s.refreshInterval", configKey)),
Position: Position{
top: Config.UInt(fmt.Sprintf("wtf.%s.position.top", configKey)),
left: Config.UInt(fmt.Sprintf("wtf.%s.position.left", configKey)),
height: Config.UInt(fmt.Sprintf("wtf.%s.position.height", configKey)),
width: Config.UInt(fmt.Sprintf("wtf.%s.position.width", configKey)),
},
}
return widget