aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/account.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/account.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/account.go')
-rw-r--r--widgets/account.go47
1 files changed, 20 insertions, 27 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 20ed3456..313a364a 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -45,45 +45,38 @@ func NewAccountView(aerc *Aerc, conf *config.AercConfig, acct *config.AccountCon
config.UI_CONTEXT_ACCOUNT: acct.Name,
})
- grid := ui.NewGrid().Rows([]ui.GridSpec{
- {ui.SIZE_WEIGHT, 1},
+ view := &AccountView{
+ acct: acct,
+ aerc: aerc,
+ conf: conf,
+ host: host,
+ logger: logger,
+ }
+
+ view.grid = ui.NewGrid().Rows([]ui.GridSpec{
+ {ui.SIZE_WEIGHT, ui.Const(1)},
}).Columns([]ui.GridSpec{
- {ui.SIZE_EXACT, acctUiConf.SidebarWidth},
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_EXACT, func() int {
+ return view.UiConfig().SidebarWidth
+ }},
+ {ui.SIZE_WEIGHT, ui.Const(1)},
})
worker, err := worker.NewWorker(acct.Source, logger)
if err != nil {
host.SetStatus(fmt.Sprintf("%s: %s", acct.Name, err)).
Color(tcell.ColorDefault, tcell.ColorRed)
- return &AccountView{
- acct: acct,
- aerc: aerc,
- grid: grid,
- host: host,
- logger: logger,
- }
+ return view
}
+ view.worker = worker
- dirlist := NewDirectoryList(conf, acct, logger, worker)
+ view.dirlist = NewDirectoryList(conf, acct, logger, worker)
if acctUiConf.SidebarWidth > 0 {
- grid.AddChild(ui.NewBordered(dirlist, ui.BORDER_RIGHT))
+ view.grid.AddChild(ui.NewBordered(view.dirlist, ui.BORDER_RIGHT))
}
- msglist := NewMessageList(conf, logger, aerc)
- grid.AddChild(msglist).At(0, 1)
-
- view := &AccountView{
- acct: acct,
- aerc: aerc,
- conf: conf,
- dirlist: dirlist,
- grid: grid,
- host: host,
- logger: logger,
- msglist: msglist,
- worker: worker,
- }
+ view.msglist = NewMessageList(conf, logger, aerc)
+ view.grid.AddChild(view.msglist).At(0, 1)
go worker.Backend.Run()