From 543510f5c146aa6e4d3344ec7d109ad7945fa106 Mon Sep 17 00:00:00 2001 From: Jeffas Date: Sun, 31 May 2020 12:37:46 +0100 Subject: Make grid sizes dynamic The grid used static sizes which meant that changing settings didn't have an effect on elements of the ui, notably the sidebar width. This patch makes the `Size` parameter of a cell a function which returns the `int`, allowing for dynamic sizes. A `Const` function is also included for ease of use for static sizes. --- widgets/msgviewer.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'widgets/msgviewer.go') diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go index ce85970..f06b787 100644 --- a/widgets/msgviewer.go +++ b/widgets/msgviewer.go @@ -69,7 +69,7 @@ func NewMessageViewer(acct *AccountView, ) rows := []ui.GridSpec{ - {ui.SIZE_EXACT, headerHeight}, + {ui.SIZE_EXACT, ui.Const(headerHeight)}, } if msg.PGPDetails() != nil { @@ -77,16 +77,16 @@ func NewMessageViewer(acct *AccountView, if msg.PGPDetails().IsSigned && msg.PGPDetails().IsEncrypted { height = 2 } - rows = append(rows, ui.GridSpec{ui.SIZE_EXACT, height}) + rows = append(rows, ui.GridSpec{ui.SIZE_EXACT, ui.Const(height)}) } rows = append(rows, []ui.GridSpec{ - {ui.SIZE_EXACT, 1}, - {ui.SIZE_WEIGHT, 1}, + {ui.SIZE_EXACT, ui.Const(1)}, + {ui.SIZE_WEIGHT, ui.Const(1)}, }...) grid := ui.NewGrid().Rows(rows).Columns([]ui.GridSpec{ - {ui.SIZE_WEIGHT, 1}, + {ui.SIZE_WEIGHT, ui.Const(1)}, }) switcher := &PartSwitcher{} @@ -373,7 +373,7 @@ func (ps *PartSwitcher) MouseEvent(localX int, localY int, event tcell.Event) { if localY < y && ps.parts[ps.selected].term != nil { ps.parts[ps.selected].term.MouseEvent(localX, localY, event) } - for i, _ := range ps.parts { + for i := range ps.parts { if localY != y+i { continue } @@ -511,11 +511,11 @@ func NewPartViewer(acct *AccountView, conf *config.AercConfig, } grid := ui.NewGrid().Rows([]ui.GridSpec{ - {ui.SIZE_EXACT, 3}, // Message - {ui.SIZE_EXACT, 1}, // Selector - {ui.SIZE_WEIGHT, 1}, + {ui.SIZE_EXACT, ui.Const(3)}, // Message + {ui.SIZE_EXACT, ui.Const(1)}, // Selector + {ui.SIZE_WEIGHT, ui.Const(1)}, }).Columns([]ui.GridSpec{ - {ui.SIZE_WEIGHT, 1}, + {ui.SIZE_WEIGHT, ui.Const(1)}, }) selecter := NewSelecter([]string{"Save message", "Pipe to command"}, 0). -- cgit 1.4.1-2-gfad0