diff options
author | Koni Marti <koni.marti@gmail.com> | 2024-01-28 02:08:26 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-01-29 22:46:08 +0100 |
commit | 5719041eb9b846c7d056952e9e14295c65a8b81a (patch) | |
tree | bb8972453befd91fdb7b615456c74509ef82868c /app | |
parent | 37b05d7e73b11610f2979abdbe821366e55ee651 (diff) | |
download | aerc-5719041eb9b846c7d056952e9e14295c65a8b81a.tar.gz |
app: define two dialog constructors
Define two new constructor functions for the popup dialog.
DefaultDialog() creates a dialog that spans half of the screen, whereas
the LargeDialog() covers three-quarter of the screen.
If a dialog widget has more specific size requirements, custom window
position and window height functions can be used with NewDialog().
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'app')
-rw-r--r-- | app/dialog.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/dialog.go b/app/dialog.go index 8ec6405a..3ed8b469 100644 --- a/app/dialog.go +++ b/app/dialog.go @@ -22,3 +22,31 @@ func (d *dialog) ContextHeight() (func(int) int, func(int) int) { func NewDialog(d ui.DrawableInteractive, y func(int) int, h func(int) int) Dialog { return &dialog{DrawableInteractive: d, y: y, h: h} } + +// DefaultDialog creates a dialog window spanning half of the screen +func DefaultDialog(d ui.DrawableInteractive) Dialog { + return NewDialog(d, + // vertical starting position in lines from the top + func(h int) int { + return h / 4 + }, + // dialog height from the starting line + func(h int) int { + return h / 2 + }, + ) +} + +// LargeDialog creates a dialog window spanning three quarter of the screen +func LargeDialog(d ui.DrawableInteractive) Dialog { + return NewDialog(d, + // vertical starting position in lines from the top + func(h int) int { + return h / 8 + }, + // dialog height from the starting line + func(h int) int { + return 3 * h / 4 + }, + ) +} |