drop NewViewManager function

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-06-26 20:12:04 -04:00 committed by Jakub
parent abb276f6f1
commit c635fdd0c4
2 changed files with 4 additions and 17 deletions

View File

@ -38,8 +38,7 @@ func main() {
Current: true,
SelFgColor: gocui.ColorBlack,
SelBgColor: gocui.ColorGreen,
// extra field for view state
State: peers,
State: peers,
// corner positions
TopLeft: func(mx, my int) (int, int) {
return 0, 0
@ -69,7 +68,7 @@ func main() {
views := []*ViewController{mainView, infoView}
vm := NewViewManager(g, views)
vm := ViewManager{g: g, views: views}
g.SetManagerFunc(vm.Layout)

16
view.go
View File

@ -18,8 +18,8 @@ type ViewController struct {
SelBgColor gocui.Attribute
SelFgColor gocui.Attribute
Keybindings []Binding
Manager ViewManager
State interface{}
// extra field for view state
State interface{}
}
type ViewManager struct {
@ -27,18 +27,6 @@ type ViewManager struct {
views []*ViewController
}
func NewViewManager(g *gocui.Gui, views []*ViewController) *ViewManager {
vm := ViewManager{
g: g,
views: views,
}
// Attach a ViewManager instance to Views
for _, v := range vm.views {
v.Manager = vm
}
return &vm
}
func (m *ViewManager) Layout(g *gocui.Gui) error {
mx, my := g.Size()