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>
With the simplification of MacroOp, it is now possible to simplify
the Flex API to just a single Layout method, similar to List:
layout.Flex{}.Layout(gtx,
layout.Rigid(func() { ... }),
layout.Flexed(0.5, 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>
While here, unexport the Queue and Config fields. The NewContext
cosntructor is shorter, and there is no reason to expose the fields
to accidental mutation.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Put List.{first|offset|beforeEnd} into a new exported Position slot, and
also export each individually.
Have to put BeforeEnd into the Position slot to support ScrollToEnd
lists.
Signed-off-by: Larry Clapp <larry@theclapp.org>
Remembering the order of the corners in the RoundRect is difficult,
which suggest that RoundRect should be a struct with named fields.
Do that, and make Rect the special case where corner radii are all
zero.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Package app is the only package that depends on native libraries and
Cgo. Minimize its API, thereby minimizing Gio clients' dependency on
it. In the future, a headless, testing or remote "Window" should be
very easy to replace app.Window.
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>
Taking a constraint in Reset smells too much of a layout operation,
whereas a size is simpler and only serves to set the context constraints
to something sensible.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Package ui is now only about units except for the Config.Now method.
Remove Now and rename Config to Converter. Add layout.Config to
replace the old ui.Config.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Packages that provide support for external events such as pointer, key and
system are only the beginning. Future packages are expected for clipboard
access, drag and drop, gps positions and so on.
To keep the number of top-level packages under control, move such I/O packages
to the new `io` directory.
The `system` package name was the previous solution to keeping the number of
top-level packages under control: I named it `system` instead of the narrower
`profile` because I expected to put all the less common events into it, turning
`system` into a "package util" smell.
With `io`, package system can be renamed to `profile`.
Signed-off-by: Elias Naur <mail@eliasnaur.com>