Use Flex as MainView base instead of Grid
This commit is contained in:
parent
492a8752f1
commit
516ea42317
@ -36,7 +36,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MainView struct {
|
type MainView struct {
|
||||||
*tview.Grid
|
*tview.Flex
|
||||||
|
|
||||||
roomList *tview.List
|
roomList *tview.List
|
||||||
roomView *tview.Pages
|
roomView *tview.Pages
|
||||||
@ -50,13 +50,9 @@ type MainView struct {
|
|||||||
parent *GomuksUI
|
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 {
|
func (ui *GomuksUI) NewMainView() tview.Primitive {
|
||||||
mainView := &MainView{
|
mainView := &MainView{
|
||||||
Grid: tview.NewGrid(),
|
Flex: tview.NewFlex(),
|
||||||
roomList: tview.NewList(),
|
roomList: tview.NewList(),
|
||||||
roomView: tview.NewPages(),
|
roomView: tview.NewPages(),
|
||||||
rooms: make(map[string]*widget.RoomView),
|
rooms: make(map[string]*widget.RoomView),
|
||||||
@ -67,17 +63,16 @@ func (ui *GomuksUI) NewMainView() tview.Primitive {
|
|||||||
parent: ui,
|
parent: ui,
|
||||||
}
|
}
|
||||||
|
|
||||||
mainView.SetColumns(30, 1, 0).SetRows(0)
|
|
||||||
|
|
||||||
mainView.roomList.
|
mainView.roomList.
|
||||||
ShowSecondaryText(false).
|
ShowSecondaryText(false).
|
||||||
SetSelectedBackgroundColor(tcell.ColorDarkGreen).
|
SetSelectedBackgroundColor(tcell.ColorDarkGreen).
|
||||||
SetSelectedTextColor(tcell.ColorWhite).
|
SetSelectedTextColor(tcell.ColorWhite).
|
||||||
SetBorderPadding(0, 0, 1, 0)
|
SetBorderPadding(0, 0, 1, 0)
|
||||||
|
|
||||||
mainView.addItem(mainView.roomList, 0, 0, 1, 1)
|
mainView.SetDirection(tview.FlexColumn)
|
||||||
mainView.addItem(widget.NewBorder(), 1, 0, 1, 1)
|
mainView.AddItem(mainView.roomList, 30, 0, false)
|
||||||
mainView.addItem(mainView.roomView, 2, 0, 1, 1)
|
mainView.AddItem(widget.NewBorder(), 1, 0, false)
|
||||||
|
mainView.AddItem(mainView.roomView, 0, 1, true)
|
||||||
|
|
||||||
ui.mainView = mainView
|
ui.mainView = mainView
|
||||||
|
|
||||||
@ -231,7 +226,11 @@ func (view *MainView) SwitchRoom(roomIndex int) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
view.currentRoomIndex = roomIndex % len(view.roomIDs)
|
view.currentRoomIndex = roomIndex % len(view.roomIDs)
|
||||||
|
if !view.roomView.HasPage(view.CurrentRoomID()) {
|
||||||
|
debug.Print("Oh noes!", view.CurrentRoomID(), "has no page!")
|
||||||
|
} else {
|
||||||
view.roomView.SwitchToPage(view.CurrentRoomID())
|
view.roomView.SwitchToPage(view.CurrentRoomID())
|
||||||
|
}
|
||||||
view.roomList.SetCurrentItem(roomIndex)
|
view.roomList.SetCurrentItem(roomIndex)
|
||||||
view.gmx.App().SetFocus(view)
|
view.gmx.App().SetFocus(view)
|
||||||
view.parent.Render()
|
view.parent.Render()
|
||||||
|
Loading…
Reference in New Issue
Block a user