sampler-fork/widgets/component.go

39 lines
528 B
Go
Raw Normal View History

2019-02-01 05:07:25 +00:00
package widgets
2019-01-31 00:02:38 +00:00
import (
. "github.com/sqshq/termui"
)
2019-01-31 01:41:51 +00:00
type Component struct {
Drawable Drawable
2019-01-31 00:02:38 +00:00
Position Position
Size Size
Type ComponentType
2019-01-31 00:02:38 +00:00
}
type ComponentType string
const (
TypeRunChart ComponentType = "runchart"
)
2019-01-31 00:02:38 +00:00
type Position struct {
X int `yaml:"x"`
Y int `yaml:"y"`
}
type Size struct {
X int `yaml:"x"`
Y int `yaml:"y"`
}
2019-01-31 01:41:51 +00:00
func (self *Component) Move(x, y int) {
2019-01-31 00:02:38 +00:00
self.Position.X += x
self.Position.Y += y
}
2019-01-31 01:41:51 +00:00
func (self *Component) Resize(x, y int) {
2019-01-31 00:02:38 +00:00
self.Size.X += x
self.Size.Y += y
}