I keep forgetting to commit stuff
This commit is contained in:
39
container.go
Normal file
39
container.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package objects
|
||||
|
||||
import "git.tebibyte.media/tomo/tomo"
|
||||
import "git.tebibyte.media/tomo/tomo/theme"
|
||||
|
||||
// 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.
|
||||
func NewOuterContainer (layout tomo.Layout, children ...tomo.Object) *Container {
|
||||
this := newContainer(layout, children...)
|
||||
theme.Apply(this, theme.R("objects", "Container", "outer"))
|
||||
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...)
|
||||
theme.Apply(this, theme.R("objects", "Container", "inner"))
|
||||
return this
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user