Commit Graph

32 Commits

Author SHA1 Message Date
Elias Naur 81f474f5d7 op/paint,io/system: document ImageOp lifetime
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-14 13:15:05 +02:00
Elias Naur 3fd1ccbbed io/router: fix ellipse hit function
The previous formula was simply wrong.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 12:15:54 +02:00
Elias Naur a046f15156 io/router: return boolean expressions directly
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 11:57:37 +02:00
Chris Waldon 29a9e5bc27 io/router: fix Enter/Leave during press events
This commit updates the implementation of the Enter/Leave pointer
events so that it no longer shares any state with the processing
of pointer presses and grabs. This simplifies the implementation,
though it does leave a certain amount of structural redundancy.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-05-09 08:47:01 +02:00
Chris Waldon c1f0f9b5c7 io/router: improve benchmark by trying multiple sizes
This commit improves the usefulness of the benchmark by automatically
measuring event processing times with a range of values for the complexity
of the UI.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-05-09 08:46:56 +02:00
Chris Waldon b2f1776670 io/router: fix enter/leave event tests and add more
This commit fixes a bug which concealed test failures when
the actual event sequence was empty but the expected events
were not.

Additionally, this commit adds the following tests:

- a test for when the active input
area disappears while it is still being "hovered".
- a test for when there are two nested input areas that are
being hovered

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-05-09 08:46:53 +02:00
Chris Waldon 13941c9f1b io/router: add tests for Enter/Leave pointer events
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-05-04 14:41:28 +02:00
Chris Waldon 1c113f19c6 io/router: send pointer Enter/Leave events
This commit introduces a naive system for sending events
when a pointer enters or leaves a pointer hit area.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-05-04 14:41:25 +02:00
Chris Waldon 6501ecf2a0 io/pointer: define new Enter/Leave pointer events
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-05-04 14:41:21 +02:00
Elias Naur 8d9612f9aa layout,app,io/system: move Queue from app.Window to FrameEvent
Change gioui.org/commit/0e70fbc1262920a69c60409285795b6bb8701b09
added a note that app.Window.Queue must only be used during the
processing of a FrameEvent. The change was added because a Gio
user took the existence of app.Window.Queue to mean it was always
available.

This change reduces the scope of window Queues by moving it from Window
to FrameEvent, and minimizes the risk of misuse by not offering
Window.Queue at all.

Note that the gioui.org/commit/a937a7653439333b8c6fc30c7a6039b717339766
change moved Window's Frame method (named Update) to FrameEvent for the
same reason.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-03 21:04:52 +02:00
Elias Naur 050f43d60a io/router: add pointer drag-and-move test
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 10:11:23 +01:00
Elias Naur bfb50cef5d all: remove unused fields, functions and add missing error handling
Credit to staticcheck.io.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 22:26:54 +01:00
Elias Naur 8a2837531e io/router: add pointer routing test
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 09:22:48 +01:00
Elias Naur 5a3ffad00a io/router: expand Router.Add to accept multiple events
Niver API and useful for testing.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 09:08:56 +01:00
steverusso fd5dfacb40 io/pointer: minor documentation update.
The `image.Rectangle` object should be passed to the `pointer.Rect` function.

Signed-off-by: steverusso <steverusso@protonmail.com>
2020-02-12 09:04:47 +01:00
Elias Naur 34c6a2f735 io/router: expose the event router
For integrating with external window implementations (replacing
package app), access to the event router is required. Extract it
and put it into the new package router.

Router may belong in package io/event, but can't without introducing
import cycles.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 20:41:04 +01:00
Elias Naur 2aa6071e33 io/system: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 12:38:48 +01:00
Larry Clapp 65bc7be256 app/internal/window: allow punctuation as keycode events
Allows things like "ctrl-{" and ".".

All punctuation is returned as-is, e.g. "!" is "!", not "shift-1", and
"{" is "{", not "shift-[".

Also add the Enter key as a known key (fn-return on my Mac).

Signed-off-by: Larry Clapp <larry@theclapp.org>
2019-11-24 19:41:11 +01:00
Larry Clapp f8de7545f4 several: add modifiers to mouse events and clicks
macOS only, for the os-specific bits.

Signed-off-by: Larry Clapp <larry@theclapp.org>
2019-11-18 15:38:09 +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 dc7f9bab23 io/pointer,gesture: report right and middle mouse button events
Updates gio#60

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 17:41:39 +01:00
Elias Naur de7d6b28fa io/key: add support for the Tab and Space keys
Fixes gio#62

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 11:57:36 +01:00
Elias Naur cc43588aba io/key: switch Event.Name to be a string and add function keys
Function keys don't have a natural rune representation so switch
Event.Name to be a string to fit "F1"-"F12".

Fixes gio#59

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 22:20:17 +01:00
Elias Naur c833c98fd7 io/key: add ModAlt, ModSuper
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 18:39:21 +01:00
Elias Naur d293dfe604 key: add ModCtrl, ModShortcut
ModCtrl is the physical Ctrl key, ModShortcut is the virtual
"shortcut" modifier, which is Ctrl on most platforms, Command on
Apple platforms.

Updates #59

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 18:02:26 +01:00
Elias Naur fa00b53e13 op: change signature of Ops.Write
By returning the allocated data buffer, Ops can become an interface
in a future change without forcing operations to allocate.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 23:10:35 +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 e1de1ba591 io/pointer: delete Foremost priority
It wasn't used, and it's not clear that it is useful at all in its current
form. For example, a single control with multiple handler keys (say, one for
scrolling and one for clicking) will only receive priority Foremost for one of
them.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 16:31:23 +02:00
Elias Naur 71731a613c io/key: add String methods to Modifiers and Event
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-10 11:57:13 +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