From 5719041eb9b846c7d056952e9e14295c65a8b81a Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Sun, 28 Jan 2024 02:08:26 +0100 Subject: 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 Acked-by: Robin Jarry --- app/dialog.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'app') 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 + }, + ) +} -- cgit