1 package gel
2 3 import l "github.com/p9c/gio/layout"
4 5 type Direction struct {
6 l.Direction
7 w l.Widget
8 }
9 10 // Direction creates a directional layout that sets its contents to align according to the configured direction (8
11 // cardinal directions and centered)
12 func (w *Window) Direction() (out *Direction) {
13 out = &Direction{}
14 return
15 }
16 17 // direction setters
18 19 // NW sets the relevant direction for the Direction layout
20 func (d *Direction) NW() (out *Direction) {
21 d.Direction = l.NW
22 return d
23 }
24 25 // N sets the relevant direction for the Direction layout
26 func (d *Direction) N() (out *Direction) {
27 d.Direction = l.N
28 return d
29 }
30 31 // NE sets the relevant direction for the Direction layout
32 func (d *Direction) NE() (out *Direction) {
33 d.Direction = l.NE
34 return d
35 }
36 37 // E sets the relevant direction for the Direction layout
38 func (d *Direction) E() (out *Direction) {
39 d.Direction = l.E
40 return d
41 }
42 43 // SE sets the relevant direction for the Direction layout
44 func (d *Direction) SE() (out *Direction) {
45 d.Direction = l.SE
46 return d
47 }
48 49 // S sets the relevant direction for the Direction layout
50 func (d *Direction) S() (out *Direction) {
51 d.Direction = l.S
52 return d
53 }
54 55 // SW sets the relevant direction for the Direction layout
56 func (d *Direction) SW() (out *Direction) {
57 d.Direction = l.SW
58 return d
59 }
60 61 // W sets the relevant direction for the Direction layout
62 func (d *Direction) W() (out *Direction) {
63 d.Direction = l.W
64 return d
65 }
66 67 // Center sets the relevant direction for the Direction layout
68 func (d *Direction) Center() (out *Direction) {
69 d.Direction = l.Center
70 return d
71 }
72 73 func (d *Direction) Embed(w l.Widget) *Direction {
74 d.w = w
75 return d
76 }
77 78 // Fn the given widget given the context and direction
79 func (d *Direction) Fn(c l.Context) l.Dimensions {
80 return d.Direction.Layout(c, d.w)
81 }
82