package objects import "git.tebibyte.media/tomo/tomo" // Container is an object that can contain other objects. It can be used as a // primitive for building more complex layouts. It has two variants: an outer // container, and an inner container. The outer container has padding around // its edges, whereas the inner container does not. The container will have a // corresponding object role variation of either "outer" or "inner". type Container struct { tomo.ContainerBox } func newContainer (layout tomo.Layout, children ...tomo.Object) *Container { this := &Container { ContainerBox: tomo.NewContainerBox(), } this.SetLayout(layout) for _, child := range children { this.Add(child) } return this } // NewOuterContainer creates a new container that has padding around it, as well // as a solid background color. It is meant to be used as a root container for a // window, tab pane, etc. func NewOuterContainer (layout tomo.Layout, children ...tomo.Object) *Container { this := newContainer(layout, children...) this.SetRole(tomo.R("objects", "Container", "outer")) tomo.Apply(this) return this } // NewSunkenContainer creates a new container with a sunken style and padding // around it. It is meant to be used as a root container for a ScrollContainer. func NewSunkenContainer (layout tomo.Layout, children ...tomo.Object) *Container { this := newContainer(layout, children...) this.SetRole(tomo.R("objects", "Container", "sunken")) tomo.Apply(this) return this } // NewInnerContainer creates a new container that has no padding around it. func NewInnerContainer (layout tomo.Layout, children ...tomo.Object) *Container { this := newContainer(layout, children...) this.SetRole(tomo.R("objects", "Container", "inner")) tomo.Apply(this) return this }