blob: 3ed8b469ad48d670ab7524b54514a65b4e9be7e5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package app
import (
"git.sr.ht/~rjarry/aerc/lib/ui"
)
type Dialog interface {
ui.DrawableInteractive
ContextHeight() (func(int) int, func(int) int)
}
type dialog struct {
ui.DrawableInteractive
y func(int) int
h func(int) int
}
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}
}
// 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
},
)
}
|