aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/compose.go
diff options
context:
space:
mode:
authorJeffas <dev@jeffas.io>2020-05-31 12:37:46 +0100
committerReto Brunner <reto@labrat.space>2020-06-09 08:48:47 +0200
commit543510f5c146aa6e4d3344ec7d109ad7945fa106 (patch)
tree7356a64e28c2ab9123e84a76381e2cd99e82849a /widgets/compose.go
parent3877b1aa719569d3666bce227e351afcbc2628af (diff)
downloadaerc-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/compose.go')
-rw-r--r--widgets/compose.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/widgets/compose.go b/widgets/compose.go
index 01b8dd80..b68c406f 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -673,13 +673,15 @@ func (c *Composer) updateGrid() {
)
if c.grid == nil {
- c.grid = ui.NewGrid().Columns([]ui.GridSpec{{ui.SIZE_WEIGHT, 1}})
+ c.grid = ui.NewGrid().Columns([]ui.GridSpec{
+ {ui.SIZE_WEIGHT, ui.Const(1)},
+ })
}
c.grid.Rows([]ui.GridSpec{
- {ui.SIZE_EXACT, height},
- {ui.SIZE_EXACT, 1},
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_EXACT, ui.Const(height)},
+ {ui.SIZE_EXACT, ui.Const(1)},
+ {ui.SIZE_WEIGHT, ui.Const(1)},
})
if c.header != nil {
@@ -768,15 +770,18 @@ type reviewMessage struct {
}
func newReviewMessage(composer *Composer, err error) *reviewMessage {
- spec := []ui.GridSpec{{ui.SIZE_EXACT, 2}, {ui.SIZE_EXACT, 1}}
+ spec := []ui.GridSpec{
+ {ui.SIZE_EXACT, ui.Const(2)},
+ {ui.SIZE_EXACT, ui.Const(1)},
+ }
for i := 0; i < len(composer.attachments)-1; i++ {
- spec = append(spec, ui.GridSpec{ui.SIZE_EXACT, 1})
+ spec = append(spec, ui.GridSpec{ui.SIZE_EXACT, ui.Const(1)})
}
// make the last element fill remaining space
- spec = append(spec, ui.GridSpec{ui.SIZE_WEIGHT, 1})
+ spec = append(spec, ui.GridSpec{ui.SIZE_WEIGHT, ui.Const(1)})
grid := ui.NewGrid().Rows(spec).Columns([]ui.GridSpec{
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_WEIGHT, ui.Const(1)},
})
if err != nil {