...interface{} requires constructing a slice, which is slow.
This cuts about 100ns from RRect and Border benchmark.
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
Update key.State documentation and add State.String while here. Also
update Event.String to include State.
Signed-off-by: Raffaele Sena <raff367@gmail.com>
Implement key state for the following platforms:
js, wayland, windows, x11.
Unsupported platforms will continue to function as before, sending
key.Press for all key events.
Signed-off-by: Josiah Niedrauer <josiah@niedrauer.com>
Encode TransformOp as an Affince2D matrix instead and use that in gpu and io transform handling.
There are no changes to user facing API and so far only the offset part of the matrix is used.
This patch is a step towards full affine transformations.
Signed-off-by: Viktor <viktor.ogeman@gmail.com>
An interface for scaling dp and sp is overkill, at least for all
current uses. Make it a concrete struct type, and rename it to the
shorter and more precise Metric.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Then, make layout.Context.Now a field, copied from FrameEvent.Now.
API change:
gofmt -r 'gtx.Now() -> gtx.Now'
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Fixes a problem where a touch Release would signal gesture.Click
that it had left just before click would complete.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
There may be unrelated events in the queue, so it's not appropriate
to clear the queue just because an input Cancel event occurs.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Replace the pointer.Scroll special case with a new priority that
indicates the foremost handler, checked in gesture.Scroll.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This eliminates needless redraws for handlers that care about drag events and not move events, like gesture.Scroll.
Signed-off-by: Gordon Klaus <gordon.klaus@gmail.com>
The funcs replace stack.Push and macro.Record, which become private.
This makes stack and macro faster to write, in particular for stacks
where you can just write the following line to save and restore the
state :
defer op.Push(ops).Pop()
This usage requires Push to return a pointer (since Pop has a pointer
receiver), or else the code doesn't compile.
For consistancy, I tried to do the same for op.Record, but this implied
to turn all the MacroOp fields into pointers, and this caused some
panics. As a result, op.Record doesn't return a pointer.
An other side effect pointed by Larry Clapp: StackOp and MacroOp are not
re-usable any more, you have to allocate a new one for each usage, using
the described funcs above.
Signed-off-by: Thomas Bruyelle <thomas.bruyelle@gmail.com>
- Drop pointer.Event.Hit in favour of Enter/Leave events.
- Track enter/leaves for each pointer.ID (updates #122). Add test.
- Resolve grabs once.
- Get rid of scratch slice.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Key had an unfortunate association with keyboard input.
This is an API change. The following rewrites were run to fixup
Gio code:
$ gofmt -r 'pointer.InputOp{Key:a} -> pointer.InputOp{Tag:a}' -w .
$ gofmt -r 'pointer.InputOp{Key:a, Grab:b} -> pointer.InputOp{Tag:a, Grab:b}' -w .
$ gofmt -r 'key.InputOp{Key:a} -> key.InputOp{Tag:a}' -w .
$ gofmt -r 'key.InputOp{Key:a, Focus:b} -> key.InputOp{Tag:a, Focus:b}' -w .
$ gofmt -r 'event.Key -> event.Tag' -w .
Signed-off-by: Elias Naur <mail@eliasnaur.com>
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>
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>
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>
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>
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>
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>
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>