diff options
author | Jeffas <dev@jeffas.io> | 2020-05-31 12:37:46 +0100 |
---|---|---|
committer | Reto Brunner <reto@labrat.space> | 2020-06-09 08:48:47 +0200 |
commit | 543510f5c146aa6e4d3344ec7d109ad7945fa106 (patch) | |
tree | 7356a64e28c2ab9123e84a76381e2cd99e82849a /widgets/msgviewer.go | |
parent | 3877b1aa719569d3666bce227e351afcbc2628af (diff) | |
download | aerc-543510f5c146aa6e4d3344ec7d109ad7945fa106.tar.gz |
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.
Diffstat (limited to 'widgets/msgviewer.go')
-rw-r--r-- | widgets/msgviewer.go | 20 |
1 files changed, 10 insertions, 10 deletions
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). |