ref: ad4215a7ebb19bf5063e01bb8f3162fa95c63696 gio/ui/widget/image.go -rw-r--r-- 1.2 KiB
ui: use ints for unit conversions to pixels

The dp and sp units are approximate and mostly used for layout
dimensions that operate in whole pixels. This change alters the
Config methods to return pixels in ints instead of floats, which
results in smoother use for layout and emphasize the inexactness of
the device independent units.

Clients can still access to raw PxPrDp and PxPrSp factors from

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ui/widget: introduce Image.Scale

And use a constant 72 DPI for the default scale, to ensure consistent
image sizes across display densities.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ui/widget: preserve image aspect in Image.Layout

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ui: rename ops to have Op suffixed, not prefixed

Match Go's FooError name pattern.

While we're here, rename RedrawOp to InvalidateOp.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ui: split OpImage into OpImage and OpDraw

In preparation for an OpColor (and future OpGradient and similar).

Label and Editor no longer take an explicit source image. They
draw with the current image.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ui: switch to (more) explicit layout

The layout package switched from interfaces to functions for
composing layouts. The switch made sure that no garbage is
generated for transient layouts such as Align, Inset, Stack, Flex.

Unfortunately, that left the stateful widgets and layouts: as soon
as their layout methods are embedded in a transient layout, a
closure is generated that escapes to the heap.

To avoid garbage for both transient as well as stateful widgets,
replace the functional approach with explicit begin/end methods.

A begin method generally starts an op block and returns the adjusted
constraints. An end method takes computed dimensions, ends its op
block and returns adjusted dimensions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ui/layout,ui/text,ui/widget: shorten Widget function names to W

Signed-off-by: Elias Naur <mail@eliasnaur.com>
all: serialize ops

- Much less per-frame garbage
- Allow future preprocessing of ops while building it
- Much fewer interface calls and pointer chasing
- Allow future serialization of ops for remote rendering

- Slightly clumsier API

Signed-off-by: Elias Naur <mail@eliasnaur.com>
all: run goimports

gioui.org/ui was renamed from gioui.org/ui/ui before the release,
but the import order wasn't changed accordingly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
all: initial import

Signed-off-by: Elias Naur <mail@eliasnaur.com>