Commit Graph

2299 Commits

Author SHA1 Message Date
Elias Naur 170d24bdcd widget/material: replace deprecated clip.Circle with clip.Ellipse
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-20 16:22:39 +01:00
Elias Naur 533f85cf8e gpu/internal/vulkan: don't destroy nil vkDescriptorPool
Most drivers seem to tolerate vkDestroyDescriptorPool with a nil
pool, but NVIDIA's (rightly) doesn't. Fix that.

References: https://todo.sr.ht/~eliasnaur/gio/323
References: https://todo.sr.ht/~eliasnaur/gio/314
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-19 14:19:37 +01:00
Christophe Meessen a34e239c04 text,widget,opentype: change text.Face.Shape to return a clip.PathSpec
With this change, the Shape function returns a clip.PathSpec
instead of a clip.Outline op. It is then possible to create
a clip.Outline or clip.Stroke op to fill the text path or
draw its stroke.

Signed-off-by: Christophe Meessen <meessen@cppm.in2p3.fr>
2021-12-19 13:30:45 +01:00
Pierre Curto 3db11cbaad io/router: make transfer targets hovering easier to detect
In commit 929e4dc12, the rules to send pointer.{Enter,Leave}
events were relaxed. Unfortunately, to be able to make use
of them was not straight forward as it required the transfer
target op to use the same handle as the hover one.
This patch eases this by allowing any handle for the target
as well as not requiring the hover op to be defined on the same
clip op as the target (then requiring a PassOp though), making
it much easier to use.

Also added a test for pointer.Enter events not being generated
if the target type does not match the source one.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-19 13:22:11 +01:00
Pierre Curto af63c089f6 gpu/headless: make Screenshot take an input image to tranfer into
When extracting headless.Window's content via screenshots,
it can be useful to keep reusing the same image for output,
as well as specify which area of the Window is to be
extracted.
The updated Screenshot method does this by using the supplied
image.

API change: users must pass an existing image to Window.Screenshot.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-15 16:05:19 +01:00
Elias Naur 0c7b0b1d0b gpu,gpu/headless: plug a resource leak when taking screenshots
Ever since commit 8ff654628, the headless implementation has used two
GPU backend (not renderer) instances, one for the renderer and one for
creating the offscreen texture to render into. This arrangment leaks
resources because the backends only clear temporary storage at
BeginFrame, which is not called when reading pixel data from renders.

This change adds an internal constructor, gpu.NewWithDevice, to allow
headless.Window to share its device with the renderer, fixing the leak.
It also makes the code simpler (took me a while to debug this issue); in
fact I'm surprised it even works.

This is not a great fix: it adds an exported yet internal constructor,
and the ownership transfer of the device is surprising enough to warrant
two comments.

Fixes gio#322

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-14 20:53:00 +01:00
Jeff Williams f5c9d2725c app: X11 clipboard: write to primary selection
This change is to augment the X11 clipboard write behaviour.
When writing to the clipboard both the primary and clipboard
selections are published so that non-GIO applications that read
the primary selection (i.e. such as terminal emulators using
middle-mouse clicks) can read the data from a GIO app.

Signed-off-by: Jeff Williams <kanobe@gmail.com>
2021-12-14 11:49:07 +01:00
Pierre Curto 929e4dc120 io/router: deliver enter/leave events to transfer participants
When a drag and drop gesture is ongoing, let the potential target
handlers receive enter/leave events so that they can react to them (e.g.
highlight themselves when the dragged item is over them).

Fixes #321.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-14 11:43:23 +01:00
Pierre Curto c8ca36b1e6 gesture: add comment to Scroll.Add
Provide a reference to the documentation of io/pointer.InputOp.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-14 10:53:51 +01:00
Pierre Curto 294ecfbe9d io/router: avoid extra work when dealing with EnterLeave events
When computing the set of Enter/Leave events to be
delivered to handlers, skip non mouse pointers
right away instead of processing hit events.

Also, remove use of pointer to slice use in opHit.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-10 06:25:48 +01:00
Pierre Curto 038ec2cc3f widget: fix handling of disabled context in Draggable
While here, add an example on how to use the Draggable
widget.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-10 06:25:43 +01:00
Pierre Curto 27e38154a0 io/transfer: fix package description formatting
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-10 06:25:35 +01:00
Inkeliz 2a32ece084 app: [iOS] replace ViewEvent.View with add ViewController field
For mixing native UI with Gio UI, the UIViewController is sometimes
needed, not just the UIView. This change replace the View field of
ViewEvent with ViewController.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-12-10 06:16:26 +01:00
Pierre Curto 03016f0c69 widget: add drag and drop support
This patch adds internal Drag and Drop support to app.Windows.

The new package io/transfer adds the ability to
define draggable and droppable targets, which
are leveraged by the new widget.Draggable type.

The API is generic and could handle future use
cases, such as external Drag and Drop.

Updates gio#153

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-07 12:45:53 +01:00
Pierre Curto 2d75181b51 layout: fix dimensions of empty list
When the Min constraints are set but the list
has no item to display, use those as the list
returned dimensions.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-07 12:18:28 +01:00
Pierre Curto 872b4ba41b op/clip: fix Path open state
If a Move/MoveTo did not move the pen, the Path
was still set as open.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-02 11:50:01 +01:00
Elias Naur e6e69812af app: expose semantic information to Android platforms
Previous changes added semantic API and semantic information to Gio
widgets. This change maps the information to Android accessibility
classes so that TalkBack can traverse and interact with Gio programs.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:57:04 +01:00
Elias Naur 6b1ca4ca7e widget: add semantic descriptions
Some semantic information is automatically extracted, but some must be
provided by UI components. This change enriches the generic and material
widgets with such information.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:57:04 +01:00
Elias Naur 8a90074d04 io/semantic: add package for adding semantic descriptions to UI components
Software such as screen readers require semantic descriptions of user
interfaces to effectively present and interact with them. Package
semantic, combined with the existing package clip provide the operations
for Gio programs to describe themselves.

This change implements the semantic package and the routing changes for
accessing semantic trees; follow-ups add semantic information to widgets
and implement mapping semantic tree to platform representations.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
Elias Naur 48a96305c8 io/router: move transform state tracking from pointerCollector to Router
We're going to need transform tracking for the upcoming meta ops.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
Elias Naur 529baed88b widget/material: [API] add description argument to Switch constructor
Switch needs a semantic description, but doesn't have a text label
attached. This change adds a description argument to the constructor.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
Elias Naur 763fca1f29 widget/material: [API] add description argument to IconButton
Icons have no inherent semantic meaning such as a label, so this change
adds another argument to the IconButton constructor for the client to
provide a description.

This is an API change, because it seems best to force every client to
provide semantic descriptions for icon buttons.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
Elias Naur d82be97a71 widget: [API] add content widget parameter to Enum.Layout
To make the semantic relation between the enum widget and its content,
the content must be laid out inside the enum clip rect.

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

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
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