2023-08-10 15:52:01 -06:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-05-13 17:48:29 -06:00
|
|
|
// 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.
|
2023-08-10 15:52:01 -06:00
|
|
|
func NewOuterContainer (layout tomo.Layout, children ...tomo.Object) *Container {
|
|
|
|
this := newContainer(layout, children...)
|
2024-06-03 19:13:18 -06:00
|
|
|
this.SetRole(tomo.R("objects", "Container", "outer"))
|
|
|
|
tomo.Apply(this)
|
2023-08-10 15:52:01 -06:00
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
2024-05-13 17:48:29 -06:00
|
|
|
// 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...)
|
2024-06-03 19:13:18 -06:00
|
|
|
this.SetRole(tomo.R("objects", "Container", "sunken"))
|
|
|
|
tomo.Apply(this)
|
2024-05-13 17:48:29 -06:00
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
2023-08-10 15:52:01 -06:00
|
|
|
// NewInnerContainer creates a new container that has no padding around it.
|
|
|
|
func NewInnerContainer (layout tomo.Layout, children ...tomo.Object) *Container {
|
|
|
|
this := newContainer(layout, children...)
|
2024-06-03 19:13:18 -06:00
|
|
|
this.SetRole(tomo.R("objects", "Container", "inner"))
|
|
|
|
tomo.Apply(this)
|
2023-08-10 15:52:01 -06:00
|
|
|
return this
|
|
|
|
}
|
|
|
|
|