aboutsummaryrefslogtreecommitdiffstats
path: root/app/dialog.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2024-01-28 02:08:26 +0100
committerRobin Jarry <robin@jarry.cc>2024-01-29 22:46:08 +0100
commit5719041eb9b846c7d056952e9e14295c65a8b81a (patch)
treebb8972453befd91fdb7b615456c74509ef82868c /app/dialog.go
parent37b05d7e73b11610f2979abdbe821366e55ee651 (diff)
downloadaerc-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/dialog.go')
-rw-r--r--app/dialog.go28
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
+ },
+ )
+}