1 package gel
2 3 import l "github.com/p9c/gio/layout"
4 5 type Stack struct {
6 *l.Stack
7 children []l.StackChild
8 }
9 10 // Stack starts a chain of widgets to compose into a stack
11 func (w *Window) Stack() (out *Stack) {
12 out = &Stack{
13 Stack: &l.Stack{},
14 }
15 return
16 }
17 18 func (s *Stack) Alignment(alignment l.Direction) *Stack {
19 s.Stack.Alignment = alignment
20 return s
21 }
22 23 // functions to chain widgets to stack (first is lowest last highest)
24 25 // Stacked appends a widget to the stack, the stack's dimensions will be
26 // computed from the largest widget in the stack
27 func (s *Stack) Stacked(w l.Widget) (out *Stack) {
28 s.children = append(s.children, l.Stacked(w))
29 return s
30 }
31 32 // Expanded lays out a widget with the same max constraints as the stack
33 func (s *Stack) Expanded(w l.Widget) (out *Stack) {
34 s.children = append(s.children, l.Expanded(w))
35 return s
36 }
37 38 // Fn runs the ops queue configured in the stack
39 func (s *Stack) Fn(c l.Context) l.Dimensions {
40 return s.Stack.Layout(c, s.children...)
41 }
42