ContainerCore and ContainerCoreControl WIP

This commit is contained in:
Sasha Koshka 2023-03-02 18:59:08 -05:00
parent e9e6e4fbe7
commit 38baa97e76
2 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,55 @@
package core
import "image"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
// ContainerCore is a struct that can be embedded into an object to allow it to
// have one or more children. It also implements Flexible and Focusable and
// provides the standard behavior for selecting multiple children, and
// propagating user input events to them.
type ContainerCore struct {
bounds image.Rectangle
layout layouts.Layout
children []layouts.LayoutEntry
drags [10]elements.MouseTarget
warping bool
focused bool
focusable bool
flexible bool
}
func NewContainerCore (
layout layouts.Layout,
onFocusChange func (),
onLayoutChange func (),
) (
core *ContainerCore,
control ContainerCoreControl,
) {
core = &ContainerCore {
layout: layout,
}
control = ContainerCoreControl {
core: core,
}
return
}
// TODO fulfill interfaces here. accessors and mutators need to be in the
// container core control, because elements will have different ways of adopting
// and disowning child elements.
type ContainerCoreControl struct {
core *ContainerCore
}
// Resize sets the size of the control, and
func (control ContainerCoreControl) Resize (bounds image.Rectangle) {
// TODO do a layout
// TODO call onLayoutChange
}
func (control ContainerCoreControl) Adopt (element elements.Element, expand bool) {
}

View File

@ -12,6 +12,8 @@ type LayoutEntry struct {
}
// TODO: have layouts take in artist.Inset for margin and padding
// TODO: create a layout that only displays the first element and full screen.
// basically a blank layout for containers that only ever have one element.
// Layout is capable of arranging elements within a container. It is also able
// to determine the minimum amount of room it needs to do so.