aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/aerc.go7
-rw-r--r--app/dialog.go52
2 files changed, 39 insertions, 20 deletions
diff --git a/app/aerc.go b/app/aerc.go
index 97604b17..7418e979 100644
--- a/app/aerc.go
+++ b/app/aerc.go
@@ -188,10 +188,11 @@ func (aerc *Aerc) Draw(ctx *ui.Context) {
if aerc.dialog != nil {
if w, h := ctx.Width(), ctx.Height(); w > 8 && h > 4 {
if d, ok := aerc.dialog.(Dialog); ok {
- start, height := d.ContextHeight()
+ xstart, width := d.ContextWidth()
+ ystart, height := d.ContextHeight()
aerc.dialog.Draw(
- ctx.Subcontext(4, start(h),
- w-8, height(h)))
+ ctx.Subcontext(xstart(w), ystart(h),
+ width(w), height(h)))
} else {
aerc.dialog.Draw(ctx.Subcontext(4, h/2-2, w-8, 4))
}
diff --git a/app/dialog.go b/app/dialog.go
index 3ed8b469..fba0fd7b 100644
--- a/app/dialog.go
+++ b/app/dialog.go
@@ -6,47 +6,65 @@ import (
type Dialog interface {
ui.DrawableInteractive
+ ContextWidth() (func(int) int, func(int) int)
ContextHeight() (func(int) int, func(int) int)
}
type dialog struct {
ui.DrawableInteractive
+ x func(int) int
y func(int) int
+ w func(int) int
h func(int) int
}
+func (d *dialog) ContextWidth() (func(int) int, func(int) int) {
+ return d.x, d.w
+}
+
func (d *dialog) ContextHeight() (func(int) int, func(int) int) {
return d.y, d.h
}
-func NewDialog(d ui.DrawableInteractive, y func(int) int, h func(int) int) Dialog {
- return &dialog{DrawableInteractive: d, y: y, h: h}
+func NewDialog(
+ d ui.DrawableInteractive,
+ x func(int) int, y func(int) int,
+ w func(int) int, h func(int) int,
+) Dialog {
+ return &dialog{DrawableInteractive: d, x: x, y: y, w: w, h: h}
}
// DefaultDialog creates a dialog window spanning half of the screen
func DefaultDialog(d ui.DrawableInteractive) Dialog {
+ position := SelectedAccountUiConfig().DialogPosition
+ width := SelectedAccountUiConfig().DialogWidth
+ height := SelectedAccountUiConfig().DialogHeight
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
+ // horizontal starting position in columns from the left
+ func(w int) int {
+ return (w * (100 - width)) / 200
},
- )
-}
-
-// 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
+ switch position {
+ case "center":
+ return (h * (100 - height)) / 200
+ case "bottom":
+ return h - (h * height / 100)
+ default:
+ return 1
+ }
+ },
+ // dialog width from the starting column
+ func(w int) int {
+ return w * width / 100
},
// dialog height from the starting line
func(h int) int {
- return 3 * h / 4
+ if position == "bottom" {
+ return h*height/100 - 1
+ }
+ return h * height / 100
},
)
}