34 lines
639 B
Go
34 lines
639 B
Go
package gel
|
|
|
|
import (
|
|
l "gioui.org/layout"
|
|
"gioui.org/unit"
|
|
)
|
|
|
|
type Inset struct {
|
|
*Window
|
|
in l.Inset
|
|
w l.Widget
|
|
}
|
|
|
|
// Inset creates a padded empty space around a widget
|
|
func (w *Window) Inset(pad float32, embed l.Widget) (out *Inset) {
|
|
out = &Inset{
|
|
Window: w,
|
|
in: l.UniformInset(unit.Dp(float32(w.TextSize) * pad)),
|
|
w: embed,
|
|
}
|
|
return
|
|
}
|
|
|
|
// Embed sets the widget that will be inside the inset
|
|
func (in *Inset) Embed(w l.Widget) *Inset {
|
|
in.w = w
|
|
return in
|
|
}
|
|
|
|
// Fn lays out the given widget with the configured context and padding
|
|
func (in *Inset) Fn(c l.Context) l.Dimensions {
|
|
return in.in.Layout(c, in.w)
|
|
}
|