Commit Graph

40 Commits

Author SHA1 Message Date
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
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 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
Pierre Curto 9c16954bef gesture: add Hover type
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-19 15:59:25 +02:00
Pierre Curto e11ac9784c gesture: add the Pressed method to Drag
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-10-06 08:21:55 +02:00
Pierre Curto 7463910191 gesture: fix typos in comments, remove unused type
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-09-19 11:04:02 +02:00
pierre 5e1a662b94 io/pointer: support nested scrollables
Fixes #185.

Signed-off-by: pierre <pierre.curto@gmail.com>
2021-03-31 09:57:13 +02:00
Elias Naur ffb26b0e17 io/pointer: rename button names to reflect their meaning, not placement
For example, ButtonLeft may be the right-most button for a left-handed user.
Rename the button names to match their intended use.

This is an API change. Use the following commands to update your
projects:

    $ gofmt -r 'pointer.ButtonLeft -> pointer.ButtonPrimary' -w .
    $ gofmt -r 'pointer.ButtonRight -> pointer.ButtonSecondary' -w .
    $ gofmt -r 'pointer.ButtonMiddle -> pointer.ButtonTertiary' -w .

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-03-03 11:08:41 +01:00
Larry Clapp 34273940a0 widget,widget/material: add selection to the editor
- Allow dragging to be on both horizontal and vertical axes at once.
- Split Editor.caret.pos into caret.start and caret.stop. caret.start is
  the old caret.pos, and is both the position of the caret, and also the
  start of selected text. caret.end is the end of the selected text.
  Start can be after end, e.g. after after Shift-DownArrow.
- Update caret.end after a mouse drag, and various shifted keys
  (Shift-UpArrow, Shift-DownArrow, etc).
- Change Shortcut-C to copy only the selected text, not the whole editor
  text.
- Add Shortcut-X to copy and delete selected text, and Shortcut-A to
  select all text.
- The various Insert/Delete/etc functions now overwrite or delete the
  selection, as appropriate.
- Change MoveCaret to accept a distance for selection end, as well.
  Change SetCaret to accept a selection end offset.
- Add SelectionLen to get the selection length, Selection to get
  selection offsets, SelectedText to get the selected text, and
  ClearSelection to clear the selection.
- Add a rudimentary selection unit test, and extend the deleteWord unit
  test with some text selection cases.
- Add SelectionColor to material.EditorStyle, which defaults to
  Theme.Palette.ContrastBg.

Signed-off-by: Larry Clapp <larry@theclapp.org>
2021-01-24 09:44:52 +01:00
Elias Naur 4f45d9a567 io/router: rename Router.Add to the more specific Queue
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-01-22 16:36:14 +01:00
Egon Elbre 93ebd51531 gesture,widget: add hovered property
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-01-18 10:56:52 +01:00
Egon Elbre 0b2a2d6c2e {gesture,widget}: expose Dragging
Knowing whether a widget is being interacted with allows to implement
bi-directional updates without feedbacks.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-12-11 16:44:22 +01:00
Elias Naur 6ab43aba3e all: implement staticcheck suggestions
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-07-19 10:47:17 +02:00
Gordon Klaus 5368743478 widget,widget/material: add Float and Slider
Signed-off-by: Gordon Klaus <gordon.klaus@gmail.com>
2020-06-22 12:17:35 +02:00
Elias Naur b9f6543cf5 gesture: always drag scroll on Android
Mice drags scroll on Android by convention. Further, ChromeOS converts
two-finger touchpad scroll gestures to press-drag with Source == Mouse.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-19 20:05:01 +02:00
Elias Naur 596e321610 all: make unit.Converter concrete and rename to Metric
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>
2020-06-17 11:47:14 +02:00
Elias Naur 5e37a64ff1 gesture: remove Click.State and cancel Click gesture on outside Release
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-09 00:12:05 +02:00
Elias Naur ce56464923 widget,gesture: fade out cancelled inkwells
While here, adjust inkwell sizes to match gtx.Constraints.Min.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-08 23:50:00 +02:00
Elias Naur 0444caa9e3 gesture,widget: drop press markers on gesture cancel
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-08 21:44:57 +02:00
Elias Naur 65d4707e3e io/pointer,io/router,gesture: add pointer.Foremost priority
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>
2020-06-05 10:46:19 +02:00
Gordon Klaus 1a070a36b6 io/pointer: add Drag event type
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>
2020-06-03 20:04:16 +02:00
Gordon Klaus 9d2a6c48d8 io/pointer: add InputOp.Types to specify which types of events to receive
Signed-off-by: Gordon Klaus <gordon.klaus@gmail.com>
2020-06-03 15:29:12 +02:00
Gordon Klaus e188d0e6ff io/pointer,gesture,app/internal/window: add pointer.Scroll event type
Signed-off-by: Gordon Klaus <gordon.klaus@gmail.com>
2020-06-03 10:08:22 +02:00
Elias Naur 3b28c5d067 io/router: simplify pointer event routing
- 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>
2020-06-01 00:04:34 +02:00
Elias Naur 03db2817ac all: rename io/event.Key to Tag
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>
2020-05-17 19:48:12 +02:00
Elias Naur f2fee00bab Revert "gesture: only report TypePress for Click gestures if pointer is grabbed"
This reverts commit 062e2bc54b.

Reason: delays the press too much for the common case of an embedding List.
2020-05-16 12:09:18 +02:00
Elias Naur 062e2bc54b gesture: only report TypePress for Click gestures if pointer is grabbed
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 16:50:07 +02:00
Elias Naur ca0af08ff2 gesture: use Enter/Leave events instead of Moves
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 16:32:37 +02:00
Pierre.Curto 4db3cb2afb gesture: support multiple click actions
Double click or tap actions are common in user interfaces and this
commit adds support for it in the gesture package.
ClickEvent has now a new field NumClicks that contains the number of
successive clicks that occurred within 200ms.

Fixes gio#101

Signed-off-by: Pierre.Curto <pierre.curto@gmail.com>
2020-05-02 19:07:59 +02:00
Elias Naur 22f964548b gesture: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-27 21:29:11 +02:00
Elias Naur b39e4227c2 gesture,internal/fling: fix rounding
The code tried to extract a rounded whole number of pixels while preserving the
fraction. However, it failed to converge for the value 0.5, rounded to 1,
leaving -0.5, rounded to -1, leaving 0.5 and so on.

Drop the cleverness and truncate the values instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-20 18:30:01 +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 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 2a9361db65 Revert "gesture: add Active methods to gestures"
This reverts commit d829e56194.

We're not using the activity of gestures to track whether widgets
should behave as disabled or enabled anymore.
2019-11-02 14:49:33 +01:00
Elias Naur d829e56194 gesture: add Active methods to gestures
Active reports whether events are being processed. If not, widgets
can draw themselves as inactive.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:04:34 +02:00
Elias Naur 3784ece6dd all: rename package ui to unit
Package ui is now only about units except for the Config.Now method.
Remove Now and rename Config to Converter. Add layout.Config to
replace the old ui.Config.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 16:55:47 +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
Elias Naur 22cd88df9f all: rename the gioui.org/ui module to gioui.org
The "ui" is redundant and stutters.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 12:37:06 +02:00