Commit Graph

48 Commits

Author SHA1 Message Date
Elias Naur 18cddc0300 layout: include Expanded sizes in Stack size calculation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-16 13:20:50 +01:00
Elias Naur 7814da47a0 layout: simplify Stack API
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>
2019-12-12 00:45:36 +01:00
Elias Naur f60a5c7ac3 layout: simplify Flex API to a single Layout call
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>
2019-12-12 00:45:36 +01:00
Elias Naur edc81ea0bb op: remove operation list argument from MacroOp.Add
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>
2019-12-12 00:45:36 +01:00
Elias Naur 65dc6797eb layout: don't allow overlapping Flex and Stack layouts
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>
2019-12-02 18:54:35 +01:00
Elias Naur 3701e2eb1d layout: move examples to example_test.go
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 17:46:40 +01:00
Elias Naur c0beeb5e77 layout: update documentation for NewContext
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 13:21:35 +01:00
Elias Naur 11506a974e layout: add NewContext, make zero value Contexts useful
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>
2019-12-02 13:13:15 +01:00
Elias Naur bbdedfa4a7 layout: move Context to its own file
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 12:43:42 +01:00
Elias Naur 75d4eaff0e layout: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 12:41:52 +01:00
Larry Clapp ce76c2e996 layout: make list scroll position settable
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>
2019-11-26 17:53:29 +01:00
Elias Naur 16cc51ee8a io/pointer: unify area ops into a single AreaOp
Make Rect and Ellipse constructors of AreaOp.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-18 15:03:11 +01:00
Elias Naur 7299d1c875 op/clip: replace Rect and RoundRect with Rect type
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>
2019-11-18 14:33:28 +01:00
Elias Naur 65c783179d clip: change Rect argument to f32.Rectangle
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 19:42:19 +01:00
Elias Naur e864ac3fc3 op/clip: split clip operations into its own package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 19:07:00 +01:00
Elias Naur c4ac40e609 layout: remove Format
Move Format to eliasnaur.com/giox/layout because it's not clear it
belongs in the Gio standard library.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-23 10:53:59 +02:00
Elias Naur afcff9c8b5 layout: fix comment
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-21 10:38:58 +02:00
Elias Naur dafb180176 layout: fix ambiguous parsing of stack and flex arguments
Fixed gio#44

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-21 01:04:31 +02:00
Elias Naur 79d505623a layout: parse empty names and let higher levels generate errors
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-21 01:04:31 +02:00
Elias Naur c07b520157 layout: rename formatState to formatter
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-21 01:04:31 +02:00
Elias Naur 32d51dd9e6 layout: fix spelling of "northeast"
Fixes gio#45

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-21 01:04:19 +02:00
Elias Naur 5c0f1ed954 layout: update tests
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-17 14:22:24 +02:00
Elias Naur 862061b363 layout: rename "exp" layout variants to "max"; add "min" variants
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-17 13:55:30 +02:00
Elias Naur d7694ae95f layout: add "exp" format layout for expanding both constraints
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-16 20:51:20 +02:00
Elias Naur 759900902a layout: fix Flex baseline
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-16 20:35:24 +02:00
Elias Naur b1643e5e2a layout: skip Flex and Stack Layout when scanning format string
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-16 20:29:17 +02:00
Elias Naur f442512888 layout: more doc fixes for layout.Format
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-16 18:00:57 +02:00
Elias Naur 80b1af3024 layout: fix godoc.org rendering of layout.Format docs
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-16 17:59:04 +02:00
Elias Naur c76490956d layout: add support for layout format strings
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-16 17:44:13 +02:00
Elias Naur 7f07933eb3 layout: unexport Context.Layout and make it a function
Layout wasn't used outside package layout, so let's not export it.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-16 11:08:52 +02:00
Elias Naur e2d0b3cfca layout: invert baseline to measure positive distance from bottom
With an inverted baseline, the zero value results in the widget
baseline aligned to its bottom.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-16 00:49:52 +02:00
Elias Naur 8e3d03f2c4 layout: correct Align baseline
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-16 00:49:52 +02:00
Elias Naur 4bbad66947 layout: adjust only max constraints on Inset
Only adjust minimums, and insets, if necessary.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-16 00:49:52 +02:00
Elias Naur 45ccbbe571 layout: expand Flex children
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-15 23:33:31 +02:00
Elias Naur fd1fa85998 layout: allow Expand children to fill the available area
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-15 23:33:31 +02:00
Elias Naur 2990ceda69 layout: relax constraints in Stack.Rigid
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-15 17:59:23 +02:00
Elias Naur 6e44d355cc layout: enforce constraints in Context.Layout
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-15 17:59:23 +02:00
Elias Naur 0783d1939e stack: fix comment
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-15 15:53:43 +02:00
Elias Naur 36d1cd90f2 app,io/system: extract system events to separate package
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>
2019-10-14 16:20:20 +02:00
Elias Naur 529fd4d307 layout: rename Flex.Flexible to just Flex
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-06 09:20:04 +02:00
Elias Naur 8d82a3eaa6 layout: delete Init methods from Flex and Stack
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>
2019-10-06 09:17:41 +02:00
Elias Naur e031308172 layout: take a size, not constraints in Context.Reset
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>
2019-10-02 15:35:05 +02:00
Elias Naur 3784ece6dd all: rename package ui to unit
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>
2019-09-30 16:55:47 +02:00
Elias Naur beaec661d2 op/paint: move paint package below the op package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 16:55:47 +02:00
Elias Naur 8cf35a1f97 op: add package op for operations
Extract operation types from package ui into package op.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 16:55:47 +02:00
Elias Naur e7a97bf176 io/event: move event types from package ui to its own package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 15:18:08 +02:00
Elias Naur 7a259e68f7 io: give event packages a common prefix
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>
2019-09-30 14:50:55 +02:00
Elias Naur 22cd88df9f all: rename the gioui.org/ui module to gioui.org
The "ui" is redundant and stutters.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 12:37:06 +02:00