Commit graph

40 commits

Author SHA1 Message Date
Emil Ernerfeldt
be44c71e31 egui_glium: Flip vertical scroll direction on Linux
This is to address https://github.com/emilk/egui/issues/356
2021-05-08 08:35:17 +02:00
Ivo Vollrath
03721dbfd8
Basic multi touch support (issue #279) (#306)
* translate touch events from glium to egui

Unfortunately, winit does not seem to create _Touch_ events for the touch pad
on my mac.  Only _TouchpadPressure_ events are sent.

Found some issues (like
[this](https://github.com/rust-windowing/winit/issues/54)), but I am not sure
what they exactly mean:  Sometimes, touch events are mixed with
touch-to-pointer translation in the discussions.

* translate touch events from web_sys to egui

The are a few open topics:
- egui_web currently translates touch events into pointer events.
  I guess this should change, such that egui itself performs this kind of
  conversion.
- `pub fn egui_web::pos_from_touch_event` is a public function, but I
  would like to change the return type to an `Option`.  Shouldn't this
  function be private, anyway?

* introduce `TouchState` and `Gesture`

InputState.touch was introduced with type `TouchState`, just as
InputState.pointer is of type `Pointer`.

The TouchState internally relies on a collection of `Gesture`s.  This commit
provides the first rudimentary implementation of a Gesture, but has no
functionality, yet.

* add method InputState::zoom()

So far, the method always returns `None`, but it should work as soon as the
`Zoom` gesture is implemented.

* manage one `TouchState` per individual device

Although quite unlikely, it is still possible to connect more than one touch
device. (I have three touch pads connected to my MacBook in total, but
unfortunately `winit` sends touch events for none of them.)

We do not want to mix-up the touches from different devices.

* implement control loop for gesture detection

The basic idea is that each gesture can focus on detection logic and does not
have to care (too much) about managing touch state in general.

* streamline `Gesture` trait, simplifying impl's

* implement first version of Zoom gesture

* fix failing doctest

a simple `TODO` should be enough

* get rid of `Gesture`s

* Provide a Zoom/Rotate window in the demo app

For now, it works for two fingers only.  The third finger interrupts the
gesture.

Bugs:
- Pinching in the demo window also moves the window -> Pointer events must be
  ignored when touch is active
- Pinching also works when doing it outside the demo window -> it would be nice
  to return the touch info in the `Response` of the painter allocation

* fix comments and non-idiomatic code

* update touch state *each frame*

* change egui_demo to use *relative* touch data

* support more than two fingers

This commit includes an improved Demo Window for egui_demo, and a complete
re-write of the gesture detection.  The PR should be ready for review, soon.

* cleanup code and comments for review

* minor code simplifications

* oops – forgot the changelog

* resolve comment fee8ed83db (r623226656)

* accept suggestion https://github.com/emilk/egui/pull/306#discussion_r623229228

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* fix syntax error (dough!)

* remove `dbg!` (why didnt clippy see this?)

* apply suggested diffs from review

* fix conversion of physical location to Pos2

* remove redundanct type `TouchAverages`

* remove trailing space

* avoid initial translation jump in plot demo

* extend the demo so it shows off translation

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-05-06 21:01:10 +02:00
Emil Ernerfeldt
c2744a1437
Implement trackpad pinch-to-zoom for plots in egui_web (#333)
This adds a new `zoom_delta` to input.
This is hooked up to ctrl-scroll on egui_web and egui_glium.

Browsers convert trackpad pinch gestures to ctrl-scroll,
so this means you can not pinch-to-zoom plots (on trackpad).

In the future we can support multitouch pinch-to-zoom via the same
`InputState::zoom_factor()` function
2021-04-25 17:04:34 +02:00
Emil Ernerfeldt
7f0689e566 Refactor egui_glium with new EguiGlium wrapper and standalone example 2021-04-25 17:02:27 +02:00
Emil Ernerfeldt
76d5229821
CI: run cargo doc (#309)
* Deny doc errors

* Add intentional bad intradoc link to test CI

* Add cargo doc to CI

* Fix carg doc web (add wasm32 target)

* Fix intentionally broken doc-link
2021-04-15 10:35:15 +02:00
Lin Han
22cd1a8e10
Move IME candidate window following text cursor (#258)
* egui_web: enable IME support on web.

* Move candidate window following text cursor.

* Preclude too frequent agent movement.

* IME candidate window move on native app.
2021-03-30 08:48:55 +02:00
Emil Ernerfeldt
958aea922f Add a lot more CursorIcon's 2021-03-13 12:38:03 +01:00
Norbert Nemec
ee1fcf1ead
egui_glium: prevent cursor icon flickering at frame boundary on Windows (#217) (#218)
* egui_glium: prevent cursor icon flickering at frame boundary (Windows)

* fix compiler warning

* cargo fmt
2021-03-13 12:27:05 +01:00
Jay Oster
269bcdfce3
Replace clipboard with copypasta (#221)
- Fixes #146
2021-03-10 11:16:45 +01:00
Emil Ernerfeldt
44cd304cdf Add experimental screen_reader feature
Part of https://github.com/emilk/egui/issues/167
2021-03-08 20:58:01 +01:00
Emil Ernerfeldt
1c06622dbc Hold down a modifier key when clicking a link to open it in a new tab 2021-03-08 17:48:23 +01:00
Emil Ernerfeldt
5f6a468812 Add Context::set_pixels_per_point to control the scale of the UI 2021-02-21 11:23:33 +01:00
Emil Ernerfeldt
247026149c
Multiple mouse button support (#135)
Add support for primary, secondary and middle mouse buttons. Also improve ability to click things in low FPS situations.

This introduces a lot of breaking changes:

    Backends/integrations now pass mouse events via the even stream.
    Response has an interface of mostly methods instead of public members.
    input.mouse is now input.pointer and has new interface.


* Rename 'mouse' to 'pointer' everywhere (pointer = mouse or touch)

* Make Response::clicked and Response::double_clicked into methods

* Remove Response::active and add dragged() and interact_pointer_pos()

* Support multiple mouse buttons

* Make PointerState interface all methods

* Make most members of Response private
2021-01-25 18:50:19 +01:00
Emil Ernerfeldt
d0fc77fe9b [egui_glium] minor code cleanup 2021-01-17 02:31:37 +01:00
Emil Ernerfeldt
4933bb3c30 [egui_glium] Fix a bug where key releases weren't sent to Egui
Fixes https://github.com/emilk/egui/issues/102
2021-01-11 18:09:09 +01:00
Emil Ernerfeldt
69d31a5e47 [eframe] Make persistence, http and time optional features
Saves on compile times.
2021-01-04 10:25:13 +01:00
Emil Ernerfeldt
c6a5af19e6 Add all alpha-numeric keys to egui::Key
Closes https://github.com/emilk/egui/issues/91
2021-01-03 11:25:13 +01:00
Emil Ernerfeldt
8fd58dc827 [egui_glium] make GliumInputState::raw public
Closes https://github.com/emilk/egui/issues/90
2021-01-02 16:37:39 +01:00
Emil Ernerfeldt
948d8ec6ed clippy fixes 2021-01-02 16:31:45 +01:00
Emil Ernerfeldt
d229b6fc23 Enforce rust_2018_idioms in all libs 2021-01-02 12:02:26 +01:00
Emil Ernerfeldt
4e3251c300 Improve ecosystem documentation and add changelogs for epi and eframe 2021-01-02 11:59:20 +01:00
Emil Ernerfeldt
9db1b8dbf9 Add http fetch to eframe and implement it in egui_glium using ureq 2020-12-30 20:56:50 +01:00
Emil Ernerfeldt
71449fe61c Only forbid warnings in release builds 2020-12-18 22:19:56 +01:00
Daniel Collin
69dc13ed2d Allow user to check for Key::Space 2020-12-13 10:00:20 +01:00
Emil Ernerfeldt
fe0d159324 Support Cmd+A ^W ^U ^K and shift-click 2020-11-15 14:21:21 +01:00
Emil Ernerfeldt
c4ed507d63 Add modifier keys and implement moving cursors one word at a time 2020-11-14 21:01:21 +01:00
Emil Ernerfeldt
8a0bc97e8c [egui_glium] Fix paste 2020-11-13 11:04:45 +01:00
Emil Ernerfeldt
ed8a69ab2f [drag-and-drop] Add Grab and Grabbing CursorIcon:s 2020-11-02 17:40:05 +01:00
Emil Ernerfeldt
92cfbe643c Add #![forbid(unsafe_code)] and safety badge 2020-10-18 15:40:23 +02:00
Emil Ernerfeldt
a4e19d7207 [app] Add demo app slider to change scale of all of Egui 2020-10-17 23:54:46 +02:00
Emil Ernerfeldt
5cba44eaa8 Clean up various small TODOs 2020-10-01 22:40:49 +02:00
Emil Ernerfeldt
b77151fb64 remove seconds_from_midnight from core egui input
It is only used by demo app, and so does not belong to egui proper.
Instead it is now passed as part of a DemoEnvironment
2020-09-23 08:57:23 +02:00
Emil Ernerfeldt
f693a558c5 [web/glium] better text input filtering
CapsLock and function keys (F1, F2, ...) are now ignored on web.

All special keys are ignored on glium.
2020-07-30 11:58:24 +02:00
Emil Ernerfeldt
554e6e7120 [app] unify web and glium demo app 2020-07-23 19:04:23 +02:00
Emil Ernerfeldt
61cdec8fca [refactor] rename 'example' to 'demo', and add simple example_glium 2020-07-23 12:18:19 +02:00
Emil Ernerfeldt
a14bfa0e73 [glium] make it super easy to make an Egui app using glium 2020-07-22 18:46:12 +02:00
Emil Ernerfeldt
e84412dec5 [glium] break out persistence 2020-07-22 18:01:27 +02:00
Emil Ernerfeldt
4e52a960e5 [glium] refactor and simplify glium example code 2020-07-22 12:10:14 +02:00
Emil Ernerfeldt
9b9cd01c5c [glium] update to latest glium with EventLoop and vsync 2020-07-22 00:36:17 +02:00
Emil Ernerfeldt
fd5ab736bb Rename from "Emigui" to "Egui"
Shorter to type (especially in code).
2020-05-30 10:22:35 +02:00
Renamed from emigui_glium/src/lib.rs (Browse further)