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.SetAttr(tomo.ALayout(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")) this.SetTag("outer", true) 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")) this.SetTag("sunken", true) 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")) this.SetTag("inner", true) return this }