1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Close #168. Modal dialogs now center onscreen properly

This commit is contained in:
Chris Cummer
2018-06-09 08:52:32 -07:00
parent cca845d4ff
commit 5e13618813
3 changed files with 36 additions and 14 deletions

View File

@@ -35,19 +35,19 @@ func NewBillboardModal(text string, closeFunc func()) *tview.Frame {
textView.SetBackgroundColor(tview.Styles.ContrastBackgroundColor)
textView.SetInputCapture(keyboardIntercept)
thing := tview.NewFrame(textView)
thing.SetRect(offscreen, offscreen, modalWidth, modalHeight)
frame := tview.NewFrame(textView)
frame.SetRect(offscreen, offscreen, modalWidth, modalHeight)
drawFunc := func(screen tcell.Screen, x, y, width, height int) (int, int, int, int) {
w, h := screen.Size()
thing.SetRect((w/2)-(width/2), (h/2)-(height/2), width, height)
frame.SetRect((w/2)-(width/2), (h/2)-(height/2), width, height)
return x, y, width, height
}
thing.SetBackgroundColor(tview.Styles.ContrastBackgroundColor)
thing.SetBorder(true)
thing.SetBorders(1, 1, 0, 0, 1, 1)
thing.SetDrawFunc(drawFunc)
frame.SetBackgroundColor(tview.Styles.ContrastBackgroundColor)
frame.SetBorder(true)
frame.SetBorders(1, 1, 0, 0, 1, 1)
frame.SetDrawFunc(drawFunc)
return thing
return frame
}