Commit graph

1286 commits

Author SHA1 Message Date
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
Emil Ernerfeldt
daf2e13238 demo: Use new id_data to store the show/hide password toggle 2021-04-12 22:37:39 +02:00
ilya sheprut
186362a4b8
Arbitrary data in Memory using Any, fix #255 (#257)
* init work

* implement deferred deserialization

* many improvements
* rename `DataElement` -> `AnyMapElement`
* make `data` in `Memory` as public field of type with public interface
* make interface more rich
* transform most unwraps to proper error handling
* make `AnyMap` store by `TypeId`, so now individual type can be counted and reset

* improve storing TypeId between different rust versions

* rewrite system widgets to use AnyMap

* refactor everything
* replace `serde_json` -> `ron`
* move `any_map` to module
* separate `AnyMap` into `AnyMapId` and `serializable::AnyMapId` in order to not require `serde` traits in methods
* add `AnyMap` and `serializable::AnyMap` that stores elements just by type, without `Id`
* write documentation
* change tooltips and color picker to use `Memory::data_temp`

* fix bugs and docs

* Apply suggestions from code review

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

* rename `AnyMap` → `TypeMap`

* rename `AnyMapId` → `AnyMap`, add generic <Key> to it

* rename files `id_map` → `any_map`

* move out usages from `serializable` mod

* rename `ToDeserialize` → `Serialized`

* fix bug with counting

* add tests, and...
* rename `reset` → `remove`
* add function `remove_by_type`
* format code

* improve code
* make identical interface for serialized and simple maps
* make serialized maps serialized fully, without features by moving this into `Memory` struct with `#[cfg(feature = "persistence")]` under fields
* move `serialized::TypeId` into `AnyMapElement` struct

* fix pipeline and add one more test

* update docs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-04-12 21:53:32 +02:00
Emil Ernerfeldt
4ecf304335 Fix touch screen defocus bug
Fixes https://github.com/emilk/egui/issues/288
2021-04-12 21:41:07 +02:00
Emil Ernerfeldt
5d50fa1350 Add Label::sense so you can make clickable labels
relates to https://github.com/emilk/egui/issues/292
2021-04-12 21:26:13 +02:00
follower
3c0c729af8
Add links to the changelogs for other crates. (#293)
(Tested via the GH web interface.)
2021-04-12 20:57:49 +02:00
Lin Han
20bf09560e
IME: Handle composition events to show suggestion on web (#278)
* Handle composition message to show suggestion.

* CI check

* Apply suggestions from code review

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

* Some minor changes

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-04-12 20:57:14 +02:00
follower
0353f40dd5
Typo fix: "occational" -> "occasional" (#286) 2021-04-08 22:22:58 +02:00
Cristian Dinu
50a56d41ee
DragValue improvements (#274)
* Display ResizeHorizontal cursor on hover

* Adapt the URL open command to the platform

With this new version we use $OSTYPE bash env var to query what OS
are we running on.

- On Linux, ex: Fedora, we use `xdg-open`
- On Windows, ex: msys, we use `start`
- For other other variants we try to use `open`

We should update this script when we notice that `open` is not
available on a particular platform.

(cherry picked from commit b3aa4982f683d961c21fd18e9ffc1fdf5fba0783)

* Add slow speed mode for `DragValue`

The slow speed mode is disabled by default. It can be activated
or deactivated using `DragValue::slow_speed()`.

When active the `Shift` key can be used to have a better control
over the value, `DragValue::speed` / 10.0 increments.

* Display `ResizeHorizontal` cursor while dragging too

* Apply review suggestion

Shorter and in line with the rest of the code base

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

* Add `Modifiers::shift_only` for better code clarity

* Make slow speed always enabled

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-04-08 22:20:52 +02:00
Emil Ernerfeldt
b30cb3313a
Try to allow turning off default_fonts for all libs (#266) 2021-04-07 20:14:44 +02:00