1 package gel
2 3 import (
4 l "github.com/p9c/gio/layout"
5 )
6 7 type Inset struct {
8 *Window
9 in l.Inset
10 w l.Widget
11 }
12 13 // Inset creates a padded empty space around a widget
14 func (w *Window) Inset(pad float32, embed l.Widget) (out *Inset) {
15 out = &Inset{
16 Window: w,
17 in: l.UniformInset(w.TextSize.Scale(pad)),
18 w: embed,
19 }
20 return
21 }
22 23 // Embed sets the widget that will be inside the inset
24 func (in *Inset) Embed(w l.Widget) *Inset {
25 in.w = w
26 return in
27 }
28 29 // Fn lays out the given widget with the configured context and padding
30 func (in *Inset) Fn(c l.Context) l.Dimensions {
31 return in.in.Layout(c, in.w)
32 }
33