Commit Graph

2276 Commits

Author SHA1 Message Date
Elias Naur ac97b9d6e1 widget: [API] add content widget argument to Editor.Layout
To make the semantic relation between the editor and its content clear,
the editor clip operation must cover the content. This change adds an
explicit widget argument to editor, and lays it out inside the clip
rect.

This is an API change. Users of Editor.Layout must provide a content
widget.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
Elias Naur 665e23693f widget: [API] add child widget argument to Clickable.Layout
To make the semantic relation between the clickable area and its
content clear, it will be important for the clickable clip operation
to cover all of the clickable content.

API change: users of widget.Clickable must now pass the clickable
content to Layout.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
Elias Naur a894bd6c9c widget: add missing license headers
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
Elias Naur e5c040be1b widget/material: fix click area offset for Switch
The click area was mistakenly offset by half the track width, but it
really should be offset by half the thumb diameter.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-11-30 14:34:15 +01:00
Pierre Curto 227c5a132b op/clip: don't panic when Path is used without an initial MoveTo
A Path initialized with Begin should be ready to use with its pen at (0,
0). Make it so.

Updates gio#311

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-26 22:34:25 +01:00
Pierre Curto 74490b4dfc internal/stroke: separate more the circle special case in ArcTransform
Avoid calculations not relevant for a circle.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-26 22:31:23 +01:00
Pierre Curto 321512d8a5 internal/stroke: tidy up ArcTransform
Fix comments and rename variables to avoid confusing
de facto ellipse constant names.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-26 22:31:19 +01:00
Pierre Curto ebb7f40e9d app: implement Window.Close for Wayland
This is a followup from a question sent to the mailing list.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-26 22:28:47 +01:00
Pierre Curto 858e9930c4 io/router: cleanup
Remove unused function and func argument.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-26 22:27:10 +01:00
Pierre Curto 218a9588d6 io/router, internal/ops: minor refactoring
Rename the assertEventSequence helper to assertEventPointerTypeSequence.
Fix typos.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-26 22:26:38 +01:00
Pierre Curto 5fd4ecb011 clip: add Path method to Ellipse
Useful when drawing ellipses with Stroke.
Also, this makes it consistent with the other clip operations.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-26 22:23:03 +01:00
Elias Naur cf9832ffcb gpu/internal/vulkan: support novulkan tag, FreeBSD
The novulkan tag didn't completely disable the Vulkan backend, and
the backend wouldn't register on FreeBSD. This change fixes both
issues.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-11-26 22:02:41 +01:00
Jon Egil Strand e82438e53d io/router: fix spelling
Signed-off-by: Jon Egil Strand <jon.egil.strand@gmail.com>
2021-11-26 21:56:02 +01:00
Pierre Curto a699f771c6 app: add Maximize and Center methods support for macOS and X11
Commit 9835cd59 added support for the Window.Maximize and
Window.Center methods for Windows only.
This patch also adds support for macOS and X11.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-16 18:41:22 +01:00
Inkeliz f4c82adeff app/internal/windows: don't crash on app.Fullscreen on windows/386
Before this patch, use of `app.Fullscreen` would result in "Failed to
find SetWindowLongPtrW procedure in user32.dll" when running on 32 bit
Windows.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-11-16 16:31:13 +01:00
Pierre Curto 6bfd980044 op/clip: don't panic on zero-sized Ellipse
When the rectangle used in an Ellipse has no width
or height, the path would panic with "path not closed".
Use an empty rectangle path in that case instead.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-16 15:50:53 +01:00
Inkeliz 40bc2e1f88 app: [iOS] implement ViewEvent
ViewEvent exposes native window handle for platform specific uses. This
change implements ViewEvent for iOS.

Fixes gio#305

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-11-13 10:36:44 +01:00
Pierre Curto 9d05f35341 op/paint: fix subimage rendering by ImageOp
This change is a follow-up to bcf3ff77ff, fixing the two renderers to
properly render images with non-zero origins.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-11 10:13:26 +01:00
Pierre Curto 86c4947ccd gpu: remove unused field
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-10 21:20:00 +01:00
Pierre Curto bcf3ff77ff op/paint: remove unnecessary check in ImageOp
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-10 17:31:50 +01:00
Jan Kåre Vatne 9835cd5996 app: add Window.Maximize and Center, add Windows implementation
Signed-off-by: Jan Kare Vatne <jkvatne@online.no>
2021-11-10 17:03:23 +01:00
Pierre Curto dce453e130 gpu: remove redundant panics when handling ops
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-10 16:44:39 +01:00
Elias Naur 6b7e6c85f4 cmd: update gioui.org dependency
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-11-10 16:01:16 +01:00
Elias Naur b0b4013cdb .builds: run tests in Vulkan mode
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-11-10 15:44:28 +01:00
Elias Naur 8613d81a94 gpu/headless: accept the lavapipe Vulkan driver
On headless setups such as sr.ht CI machines, lavapipe is the only
available Vulkan driver. This change accepts the lavapipe software
driver for headless contexts, so that CI won't fall back to OpenGL.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-11-10 15:39:37 +01:00
Elias Naur 303b819539 io/router: don't panic for nil op.Ops arguements to Router.Frame
Fixes gio#306

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-11-10 15:24:22 +01:00
Elias Naur 5ddd572a41 gpu: don't panic for nil op.Ops argument to GPU.Frame
Updates gio#306

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-11-10 15:24:22 +01:00
Pierre Curto 3f25a49c75 clip: add Path method to Rect
Useful when drawing non-rounded rectangles with Stroke.
Also, this makes it consistent with RRect and Circle which
also have a Path method.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-07 11:02:52 +01:00
Elias Naur 3e0b72304a all: replace deprecated pointer.Rect with clip.Rect
Converted with

gofmt -w -r 'pointer.Rect(r) -> clip.Rect(r)' .
gofmt -w -r 'pointer.Ellipse(r) -> clip.Ellipse(layout.FRect(r))' .

combined with 'goimports -w .' to clean up imports.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-11-03 14:12:31 +01:00
Elias Naur 29cea1db49 io/pointer,io/router: replace AreaOp with clip.Op
Pointer hit areas and paint clip areas are separate concepts, but
similar enough to warrant merging. This change replaces pointer hit
areas with clip areas, so Gio is left with just one area concept (in
package op/clip).

The reason for separating the concepts in the original Gio release was
because of my being unsure general path/stroke hit areas would ever be
implemented, let alone efficient.

This change represents a change of mind, in the sense that it's better
to have an incomplete API than two separate area concepts.

Leave the deprecated pointer.Rect, pointer.Ellipse for temporary
backwards compatibility.

This is an API change. Most existing programs should continue to build
with this change, but may have to adjust to having all clip.Ops participate
in InputOp hit areas.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-11-03 14:12:31 +01:00
Elias Naur 28fc08a508 op/clip: introduce axis-aligned Ellipse shape
And deprecate (but not yet remove) Circle.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-11-03 14:12:31 +01:00
Elias Naur 1d0769ae89 app: use tabs consistently in GioView.java
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-11-03 14:12:31 +01:00
Chris Waldon c5831de955 widget/material: fix List anchoring with zero minimum constraints
This comment and associated code were designed to guard against
the scrollbar failing to anchor to the proper edge of the content
when the layout.Direction was used with a zero minimum constraint.

However, they were in the wrong place to actually achieve the
desired behavior. This change simply moves the constraints
change to before the invocation of layout.Direction's Layout
method. This fixes the scrollbar appearing on the wrong edge of
content when the content is laid out with a zero minimum constraint.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2021-11-03 08:57:10 +01:00
Pierre Curto ef36ce3953 widget/material: remove unnecessary Offset in ProgressCircle
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-03 08:56:45 +01:00
Elias Naur 1eab4b84a6 gpu,internal/ops: move gpu.clipOp to ops.ClipOp
We're about to use clip.Ops for pointer areas; this change makes the
decoding accessible from the router package.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-26 12:13:11 +02:00
Elias Naur 9548dbe901 internal/ops: rename StateOP to StateOp
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-26 12:13:11 +02:00
Elias Naur 8cafbd309f io/pointer,io/router: make PassOp apply to InputOps, not areas
We're about to make clip.Ops act as pointer areas, in which case we'd
like to contain the effect of PassOp to just pointer InputOps.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-26 12:13:11 +02:00
Elias Naur 563eb60382 op: remove op.Save
op.Save, op.SaveStack were compatibility stop-gaps.

API change. Most op.Save/Loads can safely be removed altogether, or
replaced with

trans := op.Offset(f32.Pt(0, 0).Push(gtx.Ops)
...
trans.Pop()
cl := clip.Rect(image.Rect(-1e6, -1e6, 1e6, 1e6)).Push(gtx.Ops)
...
cl.Pop()

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-26 12:13:11 +02:00
Elias Naur e14e33b87e op/clip: remove Op.Add
The Add method was a compatibility stop-gap.

API change. Use clip.Op.Push and Pop the return value to explicitly mark
the region affected by the clip operation.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-26 12:13:11 +02:00
Elias Naur 9cf7cc75f4 widget/material: fix slider thumb offset
Change 936c266b03 converted a
transformation pop incorrectly. This change corrects that.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-26 12:13:11 +02:00
Elias Naur 382eabc0a8 io/pointer: fix PassOp documentation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-25 19:47:55 +02:00
Elias Naur a0c756c557 gesture: add license identifier to gesture_test.go
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-25 17:10:26 +02:00
Inkeliz dd3edf3c23 cmd/gogio: [android] add adaptive icon
This change adds basic support for adaptive icons:

https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-10-25 10:03:09 +02:00
Pierre Curto 241e566053 io/router: remove unnecessary panics while routing key ops
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-24 08:31:31 +02:00
Elias Naur da0e1bd439 go.*: update gioui.org/shader dependency
Fixes flipped images in the compute renderer on Metal.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-23 10:10:27 +02:00
Elias Naur 1672c88d9e go.*: update gio-shader version
Fixes the compute renderer on iPhone 6.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-22 16:03:11 +02:00
Elias Naur e4b96cb779 io/router: avoid a decode round for key ops
Like a previous change for pointer ops, process key ops during the
router decode of ops. This is a performance optimization and preparation
for processing future accessibility ops without without another decode
loop.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-22 15:17:05 +02:00
Elias Naur 60846d112b io/router: introduce pointerCollector to avoid an ops decode
The router package decodes the entire ops list thrice: once for pointer
ops, once for key ops, once for other ops. This change removes one
decode round by merging other ops and pointer ops decoding.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-21 18:16:12 +02:00
Elias Naur a4626d9304 io/router: make the zero value collectState the reset state
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-10-20 11:31:00 +02:00
Pierre Curto 6b0e00b9aa io/pointer: change Type to uint
This is to allow for future new Types.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-20 10:09:58 +02:00