package views import "git.milar.in/milarin/tui" // FrameView is a tui.Wrapper which draws its view preferably with preferred size on its tui.Anchor point type FrameView struct { tui.WrapperTmpl Anchor tui.Anchor DontClearBuffer bool } var _ tui.Wrapper = &FrameView{} func NewFrameView(view tui.View) *FrameView { v := new(FrameView) v.SetView(view) v.Anchor = tui.AnchorCenter return v } func (g *FrameView) Draw(buf *tui.ViewBuffer) { if !g.DontClearBuffer { g.ViewTmpl.Draw(buf) } w, h := g.View().Layout() w = iff(w >= 0, w, buf.Width()) h = iff(h >= 0, h, buf.Height()) g.View().Draw(tui.ConstrainBufferToAnchor(buf, g.Anchor, w, h)) } func (v *FrameView) Layout() (prefWidth, prefHeight int) { return -1, -1 }