Similar to what a previous commit did for Flex, this change simplifies
Stack to just one Layout call:
layout.Stack{}.Layout(gtx,
layout.Stacked(func() {...}),
layout.Expanded(func() {...}),
)
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The ability to invoke other operation lists belongs in the new CallOp.
While we're here, make MacroOp.Add use a pointer receiver to match the
other methods.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Overlapping layouts such as
outer := layout.Flex{}
inner := layout.Stack{}
child := inner.Rigid(gtx, ...)
outerChild := outer.Rigid(gtx, func() {
inner.Layout(gtx, child)
})
outer.Layout(gtx, outerChild)
runs but result in a wrong layout.
This change use empty StackOps to ensure that the Stack and Flex
child layout methods are called in the same scope as their Layout
methods:
outer := layout.Flex{}
inner := layout.Stack{}
outerChild := outer.Rigid(gtx, func() {
child := inner.Rigid(gtx, ...)
inner.Layout(gtx, child)
})
outer.Layout(gtx, outerChild)
Signed-off-by: Elias Naur <mail@eliasnaur.com>
With Context containing all the necessary information, separate
Init methods no longer makes much sense. Delete them and thereby
remove a source of runtime panics.
Signed-off-by: Elias Naur <mail@eliasnaur.com>