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

16
view.go
View File

@ -18,8 +18,8 @@ type ViewController struct {
SelBgColor gocui.Attribute SelBgColor gocui.Attribute
SelFgColor gocui.Attribute SelFgColor gocui.Attribute
Keybindings []Binding Keybindings []Binding
Manager ViewManager // extra field for view state
State interface{} State interface{}
} }
type ViewManager struct { type ViewManager struct {
@ -27,18 +27,6 @@ type ViewManager struct {
views []*ViewController 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 { func (m *ViewManager) Layout(g *gocui.Gui) error {
mx, my := g.Size() mx, my := g.Size()