diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-03-22 17:00:56 +0200 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-03-22 17:00:56 +0200 |
commit | 516ea4231768a659e38ea4e46053636446ec971c (patch) | |
tree | ed1f9324b8e5f44636ec15239db8c0ffffa86bb0 | |
parent | 492a8752f1f5493915da4e2bec9516ed7557dc23 (diff) |
Use Flex as MainView base instead of Grid
-rw-r--r-- | ui/view-main.go | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/ui/view-main.go b/ui/view-main.go index f6efd8e..974ab47 100644 --- a/ui/view-main.go +++ b/ui/view-main.go @@ -36,7 +36,7 @@ import ( ) type MainView struct { - *tview.Grid + *tview.Flex roomList *tview.List roomView *tview.Pages @@ -50,13 +50,9 @@ type MainView struct { parent *GomuksUI } -func (view *MainView) addItem(p tview.Primitive, x, y, w, h int) { - view.Grid.AddItem(p, y, x, w, h, 0, 0, false) -} - func (ui *GomuksUI) NewMainView() tview.Primitive { mainView := &MainView{ - Grid: tview.NewGrid(), + Flex: tview.NewFlex(), roomList: tview.NewList(), roomView: tview.NewPages(), rooms: make(map[string]*widget.RoomView), @@ -67,17 +63,16 @@ func (ui *GomuksUI) NewMainView() tview.Primitive { parent: ui, } - mainView.SetColumns(30, 1, 0).SetRows(0) - mainView.roomList. ShowSecondaryText(false). SetSelectedBackgroundColor(tcell.ColorDarkGreen). SetSelectedTextColor(tcell.ColorWhite). SetBorderPadding(0, 0, 1, 0) - mainView.addItem(mainView.roomList, 0, 0, 1, 1) - mainView.addItem(widget.NewBorder(), 1, 0, 1, 1) - mainView.addItem(mainView.roomView, 2, 0, 1, 1) + mainView.SetDirection(tview.FlexColumn) + mainView.AddItem(mainView.roomList, 30, 0, false) + mainView.AddItem(widget.NewBorder(), 1, 0, false) + mainView.AddItem(mainView.roomView, 0, 1, true) ui.mainView = mainView @@ -231,7 +226,11 @@ func (view *MainView) SwitchRoom(roomIndex int) { return } view.currentRoomIndex = roomIndex % len(view.roomIDs) - view.roomView.SwitchToPage(view.CurrentRoomID()) + if !view.roomView.HasPage(view.CurrentRoomID()) { + debug.Print("Oh noes!", view.CurrentRoomID(), "has no page!") + } else { + view.roomView.SwitchToPage(view.CurrentRoomID()) + } view.roomList.SetCurrentItem(roomIndex) view.gmx.App().SetFocus(view) view.parent.Render() |