Commit graph

1295 commits

Author SHA1 Message Date
Emil Ernerfeldt
2cb94b98ef Add plot legends and on_disabled_hover_text to CHANGELOG.md 2021-05-07 10:35:55 +02:00
Sven Niederberger
838f3e4ff2
Add plot legends (#349)
* add plot legends

* don't show crosshairs when hovering over legend

* add a toggle for the legend

* changes based on review

* improve legend behavior when curves share names
2021-05-07 10:32:17 +02:00
Emil Ernerfeldt
d862ff66ac Add Image::sense to let an image respond to clicks and drags 2021-05-06 22:10:05 +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
0d71017ad4 clippy fixes for rust 1.52 2021-05-06 20:49:22 +02:00
Emil Ernerfeldt
29668b5128 Minor documentation improvements 2021-05-02 22:02:26 +02:00
Emil Ernerfeldt
1394205f52 Document and demonstrate how to expand a TextEdit to fill a Ui 2021-05-02 21:57:51 +02:00
Emil Ernerfeldt
66122e4c9a Decrease indentation with shift-tab 2021-05-02 20:09:11 +02:00
Emil Ernerfeldt
bf8ce774cc Don't draw bidi control characters
Closes https://github.com/emilk/egui/issues/336
2021-05-02 19:50:06 +02:00
Emil Ernerfeldt
7da9928548 Clean up new code editor code 2021-05-02 19:28:02 +02:00
Emil Ernerfeldt
10b60d5361
Run clippy on all targets and all features (#347)
* Run clippy on all targets and all features

* check.sh: print each step

* impl ToString -related clippy fix
2021-05-02 19:26:57 +02:00
Cristian Dinu
35c7b09285
Tab identation for multiline text edit (#246)
Lock focus on multiline text edit, and insert tabs on tab char

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-05-02 18:56:28 +02:00
ilya sheprut
101eed0d67
memory: add Send + Sync reqirement, fix #337 (#341)
* memory: add `Send + Sync` reqirement, fix #337

* Update egui/src/memory.rs

Co-authored-by: Lucien Greathouse <me@lpghatguy.com>

Co-authored-by: Lucien Greathouse <me@lpghatguy.com>
2021-04-30 10:03:45 +02:00
David Pedersen
02a62d1986
Replace impl Into<String> with impl ToString (#302)
* Replace `impl Into<String>` with `impl ToString`

This is something I ran into today. Types that implement
`std::fmt::Display` cannot be passed to functions that take `impl
Into<String>`. You have to call `display_thing.to_string()`. Its a small
thing but would be fixed by instead taking `impl ToString`.

Afaik `impl ToString` is a superset of `impl Into<String>`, unless users
manually implement `Into<String> for T` (or `From<T> for String`) for
their own types. However I think its more common to implement `Display`
as that works with `println` and friends. The main difference is that
`Display::fmt` can return errors but thats also quite rare in my
experience.

I did some testing in a [playground] and seems to work.

[playground]: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1111e071f6ae416ae2688d58d2e9b575

* Silence warnings
2021-04-29 19:49:49 +02:00
crumblingstatue
e991a1c310
Fix typo in README.md (#340) 2021-04-29 19:31:24 +02:00
Emil Ernerfeldt
6f01577d5f Tab only selects labels if the screen_reader option is turned on. 2021-04-25 18:20: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
Sven Niederberger
a505d01090
Plot refactor (#331)
* drag and zoom support for plots

* update doctest

* use impl ToString

* revert back to Into<String> until #302 is solved

* Apply suggestions from code review

Co-authored-by: ilya sheprut <optitel223@gmail.com>

* use persistence feature for PlotMemory

* * split plot into multiple files
* add curve from function
* move more functionality into ScreenTransform struct

* changes from code review in base branch

* let user specify a range for generated functions

* rename file

* minor changes

* improve generator functionality

* improve callback and add parametric callback

* minor changes

* add documentation

* fix merge issues

* changes based on review

* rename folder

* make plot.rs the mod.rs file

* remove mod.rs

* rename file

* namespace changes

* fix doctest

* Update egui/src/widgets/plot/items.rs

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

Co-authored-by: ilya sheprut <optitel223@gmail.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-04-24 14:26:54 +02:00
Emil Ernerfeldt
b69bc2c06a egui_web: Scroll faster when scrolling with mouse wheel
Closes https://github.com/emilk/egui/issues/159
2021-04-24 11:08:29 +02:00
Emil Ernerfeldt
0f112db550 Reduce binary size with more inlining and less monomorphization
5%=150kB savings on egui_demo_app wasm
2021-04-24 09:54:11 +02:00
Emil Ernerfeldt
f38f68318d build_demo_web.sh: add --open as an option 2021-04-24 09:41:57 +02:00
Emil Ernerfeldt
6b24dbc997 Move easy_mark from egui deo egui_demo_lib 2021-04-24 01:18:08 +02:00
Emil Ernerfeldt
641e9c2d26 egui_glium: sleep a bit when not focused
This is to stop using all of the CPU when in minimized in
continious mode.

Fixes https://github.com/emilk/egui/issues/325
2021-04-22 20:12:49 +02:00
Emil Ernerfeldt
fb6f49024f Add Response::on_disabled_hover_text to show tooltip for disabled widgets
Closes https://github.com/emilk/egui/issues/323
2021-04-22 19:48:05 +02:00
Emil Ernerfeldt
07da54ad08 Refactor Ui::next_auto_id_source 2021-04-21 22:19:51 +02:00
Emil Ernerfeldt
a59c8ac2c3 DragValue: only show extra decimal with shift down if currently dragged 2021-04-21 22:14:30 +02:00
Emil Ernerfeldt
d2b669e1cd Changelog: Add line about storing state in Memory 2021-04-21 22:03:05 +02:00
Emil Ernerfeldt
6e9abfc9c0 Changelog: Add plot improvements 2021-04-21 22:02:51 +02:00
Sven Niederberger
012542d066
Drag and zoom support for plots (#317)
* drag and zoom support for plots

* update doctest

* use impl ToString

* revert back to Into<String> until #302 is solved

* Apply suggestions from code review

Co-authored-by: ilya sheprut <optitel223@gmail.com>

* use persistence feature for PlotMemory

* rename shift -> translate

* remove automatic bounds

* removed unused methods

* Into<String> -> ToString

* Apply suggestions from code review

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

* avoid potential invalid bounds bug

* use new is_valid method

* improve auto bounds behavior as suggested

* use NOTHING to initialize min_auto_bounds

Co-authored-by: ilya sheprut <optitel223@gmail.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-04-21 21:50:27 +02:00
Emil Ernerfeldt
cb14e8571f Add Vec2::LEFT,RIGHT,UP,DOWN and Vec2::angle 2021-04-20 23:04:04 +02:00
Emil Ernerfeldt
58ebb217dc Tesselator: ignore zero-sized clip rects
Improves https://github.com/emilk/egui/issues/328
2021-04-20 10:05:47 +02:00
Emil Ernerfeldt
1681769329 Add #[inline(always)] here and there 2021-04-19 23:11:42 +02:00
Emil Ernerfeldt
0f1df90d90 Tesselator: ignore non-positive clip rectangles
Closes https://github.com/emilk/egui/issues/328
2021-04-19 23:00:30 +02:00
Joel Nises
72d0d71d66
made drag and drop support selectable on Windows for the eframe glium integration (#324)
* made drag and drop support selectable on windows

to avoid issues with crates that use multi-threaded COM apis

* fixed formatting and clippy issues
2021-04-19 22:49:28 +02:00
Emil Ernerfeldt
23d292a974 faster debug builds on mac 2021-04-18 23:15:07 +02:00
Emil Ernerfeldt
fbd0e35017 Clippy fixes for benchmark 2021-04-18 23:14:35 +02:00
Emil Ernerfeldt
0351662763 Fix bug with the layout of wide DragValue:s 2021-04-18 23:10:12 +02:00
Emil Ernerfeldt
c07f439b28 Add benchmark of ui.label
This is to help evaluate the impact of
https://github.com/emilk/egui/pull/302
2021-04-18 10:24:31 +02:00
ilya sheprut
c69ecfe421
Memory usage example in the widget gallery (#307)
* init example

* add comments

* fix grammar in comments

* fix CI

* change example from view_edit to password

* rename file

* fix CI
2021-04-18 10:13:08 +02:00
Emil Ernerfeldt
580d27e0d3
Add anchors to windows and areas (#310)
This is so that you can put a window in e.g. the top right corner
or the center of the screen.
2021-04-18 10:01:41 +02:00
Emil Ernerfeldt
5667e7eb51 Add docstring to ui.with_layout 2021-04-15 22:23:15 +02:00
Emil Ernerfeldt
f07bdf0433 Add more instructions to PR template 2021-04-15 22:21:48 +02:00
Emil Ernerfeldt
231c075867 Add #[inline(always)] to a few things 2021-04-15 10:37:31 +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
Emil Ernerfeldt
b187d1c576 Make Memory::has_focus public (again) 2021-04-15 10:31:24 +02:00
ilya sheprut
d6de19b507
Mention macroquad backend in the readme (#308) 2021-04-15 10:20:04 +02:00
Emil Ernerfeldt
2aa05f00e1 check.sh: cargo doc all features 2021-04-15 09:48:30 +02:00
Emil Ernerfeldt
e1adb9c091 Fix broken markdown in docstring 2021-04-15 09:48:06 +02:00
Emil Ernerfeldt
96a2732735 Add Response::request_focus and surrender_focus 2021-04-15 09:45:12 +02:00