Commit Graph
100 Commits
Author SHA1 Message Date
Emil Ernerfeldt aef5942d0f Make egui_demo_app the default binary, so cargo run just works 2022-05-12 13:30:35 +02:00
Emil Ernerfeldt 2e4138d050 Add InputState::stable_dt (#1625)
This provides a better estimate of a typical frametime in reactive mode.

From the docstring of `stable_dt`:

Time since last frame (in seconds), but gracefully handles the first frame after sleeping in reactive mode.

In reactive mode (available in e.g. `eframe`), `egui` only updates when there is new input or something animating.
This can lead to large gaps of time (sleep), leading to large [`Self::unstable_dt`].

If `egui` requested a repaint the previous frame, then `egui` will use
`stable_dt = unstable_dt;`, but if `egui` did not not request a repaint last frame,
then `egui` will assume `unstable_dt` is too large, and will use
`stable_dt = predicted_dt;`.

This means that for the first frame after a sleep,
`stable_dt` will be a prediction of the delta-time until the next frame,
and in all other situations this will be an accurate measurement of time passed
since the previous frame.

Note that a frame can still stall for various reasons, so `stable_dt` can
still be unusually large in some situations.

When animating something, it is recommended that you use something like
`stable_dt.min(0.1)` - this will give you smooth animations when the framerate is good
(even in reactive mode), but will avoid large jumps when framerate is bad,
and will effectively slow down the animation when FPS drops below 10.
2022-05-12 11:23:53 +02:00
931e716b97 Add egui_wgpu crate (#1564)
Based on https://github.com/hasenbanck/egui_wgpu_backend

`egui-wgpu` is now an official backend for `eframe` (opt-in).

Use the `wgpu` feature flag on `eframe` and the `NativeOptions::renderer` settings to pick it.

Co-authored-by: Nils Hasenbanck <nils@hasenbanck.de>
Co-authored-by: Sven Niederberger <niederberger@embotech.com>
Co-authored-by: Sven Niederberger <73159570+s-nie@users.noreply.github.com>
2022-05-12 09:02:28 +02:00
Emil Ernerfeldt 9624de6c41 Fix dead-lock when alt-tabbing while also showing a tooltip (#1618)
Closes https://github.com/emilk/egui/issues/1609
2022-05-11 20:56:57 +02:00
Emil Ernerfeldt 7b18fab7a4 Optimize tessellation of filled circles (#1616)
When painting a scatter plot we sometimes want to paint hundreds of thousands of points (filled circles) on screen every frame.

In this PR the font texture atlas is pre-populated with some filled circled of various radii. These are then used when painting (small) filled circled, which means A LOT less triangles and vertices are generated for them.

In a new benchmark we can see a 10x speedup in circle tessellation, but the the real benefit comes in the painting of these circles: since we generate a lot less vertices, the backend painter has less to do.

In a real-life scenario with a lot of things being painted (including around 100k points) I saw tessellation go from 35ms -> 7ms and painting go from 45ms -> 1ms. This means the total frame time went from 80ms to 8ms, or a 10x speedup.
2022-05-10 19:31:19 +02:00
Emil Ernerfeldt 28efc0e1c8 emath: Implement NumExt on all integer types 2022-05-09 12:44:28 +02:00
Emil Ernerfeldt d69ce546fa Release egui_glow 0.18.1 - remove unnecessary calls to gl.get_error 2022-05-09 12:43:37 +02:00
Emil Ernerfeldt e82b87ca73 Remove calls to gl.getError in release builds (#1583)
This slows down the web version a lot, especially on some browsers

Publish new web demo
2022-05-05 23:17:33 +02:00
Emil Ernerfeldt 32b4781da2 Improve web demo for mobile (#1556)
`egui_demo_app/lib`: add "About egui" window, and improve mobile layout

This makes the app responsive, removing the side bars on mobile and turning them into drop-down menus instead.
2022-05-02 13:13:35 +02:00
Emil Ernerfeldt 078be52ff8 README.md: Fix broken links to toggle_switch.rs example code 2022-05-01 15:27:12 +02:00
Emil Ernerfeldt b30224471c Release 0.18.1 of egui & epaint - Change Shape::Callback to &mut dyn Any (#1552) 2022-05-01 11:35:29 +02:00
Emil Ernerfeldt dc26890a80 Release 0.18.0 - Shape::Callback, Table, and better text contrast 2022-04-30 20:27:27 +02:00
Emil Ernerfeldt 9394e7ea22 Publish new web demo 2022-04-30 20:23:40 +02:00
Emil Ernerfeldt f0e6332b42 Fix cargo deny (#1549)
* Make the strip demo less ugly

* revert duplicated windows dependency in Cargo.lock

* cargo update

* Remove duplicated windows dependency by reverting rfd

* And again for parking_lot_core
2022-04-30 20:18:59 +02:00
Emil Ernerfeldt d24599f3cc Revert tts version to 0.20 2022-04-30 19:23:44 +02:00
Emil Ernerfeldt 45b0a071c8 Clean up changelogs and add contributors section 2022-04-30 19:21:40 +02:00
Emil Ernerfeldt b41fb585fe Add doclinks to egui_extras::RetainedImage 2022-04-30 18:36:24 +02:00
Emil Ernerfeldt ec57683c1a Update some crates 2022-04-30 18:05:58 +02:00
Emil Ernerfeldt 00471f2887 Update cint 0.2 -> 0.3 2022-04-30 18:01:24 +02:00
Emil Ernerfeldt ed4fe43e7a Update tts 0.20 -> 0.21 2022-04-30 17:59:30 +02:00
Emil Ernerfeldt 30aeb2a94f Update webbrowser 0.6 -> 0.7 2022-04-30 17:58:12 +02:00
Emil Ernerfeldt 11e8ffa079 Reduce Plot::show code bloat by adding Plot::show_dyn 2022-04-30 17:51:07 +02:00
Emil Ernerfeldt 003dc4aac9 egui_demo_app: add link to my twitter 2022-04-30 17:50:39 +02:00
Emil Ernerfeldt 051deb293f mute warning when building for wasm 2022-04-30 17:47:30 +02:00
Emil Ernerfeldt 51f6cd9c58 Simplify plot demo code 2022-04-30 17:45:39 +02:00
Emil Ernerfeldt e5ccfedd61 Escape some strings in build_demo_web.sh 2022-04-30 17:18:31 +02:00
Emil Ernerfeldt 462ad5a7f6 egui_demo_app: fall back to dark mode if there is no system preference 2022-04-30 17:18:31 +02:00
Emil Ernerfeldt 3ace620f37 Code cleanup in eframe web backend 2022-04-30 17:18:31 +02:00
Emil Ernerfeldt 9b9c5005d3 CI and check.sh: run cargo doc for all crates 2022-04-30 15:51:46 +02:00
Emil Ernerfeldt 603e5bc5fb Add Rect::lerp 2022-04-30 15:50:12 +02:00
Emil Ernerfeldt b137f16472 Make members of Response public, but hide documentation
Discourage their direct use, but allow it
2022-04-30 15:49:50 +02:00
Emil Ernerfeldt c869f67066 Simplify file_dialog example 2022-04-30 15:49:22 +02:00
Emil Ernerfeldt 8a2470b45e example hello_world: remove frame.set_window_size
it doesn't work very well
2022-04-30 15:47:55 +02:00
Emil Ernerfeldt afd27ca664 Simplify eframe web panic handler code 2022-04-30 15:47:34 +02:00
Emil Ernerfeldt 1983d19614 eframe: fix wrong clear color on native 2022-04-30 15:42:35 +02:00
Emil Ernerfeldt da2ce58127 egui_demo_app: don't do a transparent native window
It doesn't work great on Mac
2022-04-30 15:42:18 +02:00
Emil Ernerfeldt e1bcaeebe5 App::clear_color: give egui::Visuals as argument 2022-04-30 15:41:43 +02:00
Emil ErnerfeldtandDaniel Buch Hansen 8303523ccf Precompute rounded vertices (#1547)
Co-authored-by: Daniel Buch Hansen <boogiewasthere@gmail.com>
2022-04-30 13:14:33 +02:00
Emil Ernerfeldt 3a83a600bb Add a custom 3D demo using glow to egui_demo_app (#1546) 2022-04-30 12:58:29 +02:00
Emil Ernerfeldt bb421c7e8a Remove egui_web and epi (#1545)
* Remove integration name (it is always eframe)

* Remove egui_web crate

* Move egui_web/CHANGELOG.md into eframe/CHANGELOG.md

* Remove all mentions of egui_web

* Remove epi crate and absorb into eframe

* egui_glow: only use puffin on native

* Remove WASM doc from CI (we don't generate it anyways!)

* Remove eframe::epi and improve eframe docs
2022-04-30 10:44:35 +02:00
Emil Ernerfeldt 18d529203a Publish new web demo to fix source links following PR #1540
https://github.com/emilk/egui/pull/1540
2022-04-29 08:23:56 +02:00
Emil Ernerfeldt ed002acc68 Refactor: move things into eframe (#1542)
* Move all epi-related code from egui_glow into eframe

* Move epi stuff from egui-winit into eframe

* Remove mention of epi in egui

* Remove mention of epi in egui_glium

* Remove trait epi::NativeTexture

* Remove confusing mentions of epi

* Refactor egui_web: break up into smaller files

* Clean up feature flags further, and update changelogs

* Clean up check.sh

* Small cleanup of egui_web/Cargo.toml

* Fix dependencies for pure_glow example

* Fix clippy false positive
2022-04-29 08:17:49 +02:00
Emil Ernerfeldt 881f9b4161 Deprecate `CollapsingHeader::selectable/selected
Better to use the more powerful CollapsingState::show_header
2022-04-28 20:06:55 +02:00
Emil Ernerfeldt 355d70d2b9 Move code from egui_demo_lib to egui_demo_app (#1540)
Also clean up feature names and dependencies
2022-04-28 11:23:34 +02:00
Emil Ernerfeldt 39917bec26 Collapsing header with custom header (#1538)
* Returns openness in CollapsingResponse
* Make CollapsingState a building block for custom collapsing headers
* Add a demo of the custom collapsing header
* Revert to much simpler tree demo
* Add CollapsingState::is_open and CollapsingState::set_open
2022-04-28 11:09:44 +02:00
Emil Ernerfeldt 8e266760e2 Silence warnings about unused profiling macros in egui-winit 2022-04-27 10:15:32 +02:00
Emil Ernerfeldt 1133f3a42b Improve look of color button and show_color slightly 2022-04-27 10:06:42 +02:00
Emil Ernerfeldt 06802cb0a0 Add Rounding::at_least and Rounding::at_most 2022-04-27 10:05:09 +02:00
Emil Ernerfeldt e3b77e320a Fix broken doclink 2022-04-27 09:59:05 +02:00
Emil Ernerfeldt 2fd20308e5 Add Ui::toggle_value 2022-04-26 21:36:22 +02:00
Emil Ernerfeldt 4d2eb5b71e Don't export macros that should only be pub(crate) 2022-04-25 22:01:32 +02:00
Emil Ernerfeldt 95c0174331 Change canvas frame margin two points 2022-04-25 16:58:24 +02:00
Emil Ernerfeldt 0862712595 Add Vec2::dot 2022-04-25 11:26:54 +02:00
Emil Ernerfeldt c70c72ef61 eframe: make sure we wait for FileStorage to complete the save
Closes https://github.com/emilk/egui/pull/1520
2022-04-20 21:54:31 +02:00
Emil Ernerfeldt f789159a4a Don't persist Grid sizes
A) there are potentially a lot of Grids, using up a lot of space
(and therefore serialization time).

B) if the code changes, the grid should also change,
and not remember old sizes
2022-04-19 21:28:45 +02:00
Emil Ernerfeldt 558891c146 eframe native: persist app state in background thread
Gives smoother frame rate
2022-04-19 21:26:35 +02:00
Emil Ernerfeldt 1dee439ab1 Added CursorIcons for resizing columns, rows and 8 cardinal directions 2022-04-19 16:56:27 +02:00
Emil Ernerfeldt 4231a5303b Clean up custom plot axis demo 2022-04-19 11:43:22 +02:00
Emil Ernerfeldt e82ea0c4b4 Plot: estimate bounds for generator functions 2022-04-19 11:43:04 +02:00
Emil Ernerfeldt cde5f95fc9 code cleanup: replace some for_each with normal for-loops 2022-04-19 11:42:05 +02:00
Emil Ernerfeldt 676ff047e9 Add Ui::scroll_with_delta, and improve scroll docs 2022-04-19 10:46:24 +02:00
Emil Ernerfeldt 5414e8a7fb Rename Painter::sub_region to Painter::with_clip_rect 2022-04-19 10:00:34 +02:00
Emil Ernerfeldt 2d2022fb72 Add Link widget (#1506)
This looks like a Hyperlink, but doesn't do anything when clicked.
Or rather: it lets the user decide what happens on click.

Closes https://github.com/emilk/egui/issues/1152
2022-04-16 22:55:15 +02:00
Emil Ernerfeldt 2b861f86e8 egui_web: Ignore input of "GroupNext"
Closes https://github.com/emilk/egui/issues/510
2022-04-16 10:38:25 +02:00
Emil Ernerfeldt 2355828d41 Remove epaint::mutex::Arc type alias 2022-04-15 15:18:21 +02:00
Emil Ernerfeldt 5a78213421 Enable depth buffer in WebGL backend (#1499)
This is useful when embedding 3D into eframe using egui::PaintCallback
2022-04-15 12:41:42 +02:00
Emil Ernerfeldt f3e31391e0 Pass clip rectangle to PaintCallback 2022-04-15 10:31:33 +02:00
Emil Ernerfeldt a7b6334784 Misc doc improvements 2022-04-13 22:14:34 +02:00
Emil Ernerfeldt 2ae93c40ab Move examples out of eframe/examples into examples/ (#1486)
* Move examples out of eframe/examples into examples/

Give each example a `Cargo.toml` and `src/main.rs`.
This makes it easier for people to use as templates.

* Update README.md with more deps needed on vanilla Ubuntu
* Install libgtk-3-dev on CI, hoping that will fix something
2022-04-13 16:13:24 +02:00
Emil Ernerfeldt 170b21b63e Add opt-in support for the 'puffin' profiler in eframe (#1483) 2022-04-13 11:06:13 +02:00
Emil Ernerfeldt 973c3f22d1 Revert "Update tts to 0.21.1" (#1482)
This reverts commit de038b9546.
2022-04-12 21:40:57 +02:00
Emil Ernerfeldt 08b208586a egui-winit: if clipboard fails to start, fall back to local clipboard 2022-04-12 11:39:35 +02:00
Emil Ernerfeldt d364dfac66 Add Rect::distance_to_pos 2022-04-12 11:33:48 +02:00
Emil Ernerfeldt 038b3cf2e2 Add Painter::hline and Painter::vline 2022-04-12 10:54:38 +02:00
Emil Ernerfeldt 701ae3cb46 egui_extras::Table: fix bugs in the virtual scrolling 2022-04-11 17:54:57 +02:00
Emil Ernerfeldt 56b127f209 Simplify table demo 2022-04-11 17:25:44 +02:00
Emil Ernerfeldt de038b9546 Update tts to 0.21.1 2022-04-11 16:36:25 +02:00
Emil Ernerfeldt efc0b992e0 egui_extras: fix bug when restoring persisted table widths 2022-04-11 14:27:32 +02:00
Emil Ernerfeldt e97241861e egui_extras Table/Strip: less aggressive cell clipping 2022-04-11 10:55:52 +02:00
Emil Ernerfeldt 917f9e1768 Refactor and simplify feature flags 2022-04-11 10:53:16 +02:00
Emil Ernerfeldt 426b933d2f egui_extras: add cell_layout option to set the layout of all cells 2022-04-11 10:29:34 +02:00
Emil Ernerfeldt 0e0eedfdda Add ui.horizontal_centered 2022-04-11 10:28:45 +02:00
Emil Ernerfeldt 772ef84242 egui_extras Table/Strip: fix some spacing bugs 2022-04-11 10:19:07 +02:00
Emil Ernerfeldt c88e1f8b29 egui_extras: improve Table/Strip docs, and only panic in debug builds 2022-04-11 10:17:36 +02:00
Emil Ernerfeldt 65d16695ae Replace copypasta with arboard (#1475)
* Replace copypasta with arboard

Closes https://github.com/emilk/egui/issues/1474

* Clean up deny.toml
2022-04-10 16:41:07 +02:00
Emil Ernerfeldt 9b37c82d46 Update three-d to 0.11 2022-04-10 10:00:57 +02:00
Emil Ernerfeldt 29d214912f Improve explanation of immediate mode
Closes https://github.com/emilk/egui/issues/1465
2022-04-10 09:43:23 +02:00
Emil Ernerfeldt c2ab0404b7 Fix crash in text layout (#1468)
Fix text layout bug added in https://github.com/emilk/egui/pull/1291
2022-04-09 22:43:40 +02:00
Emil Ernerfeldt cf0338d48f Rust 1.60.0 + refactor cargo features (#1467)
* Update to rust 1.60.0
* Rename the feature `convert_bytemuck` to `bytemuck`
* Rename the feature `serialize` to `serde`.
* Make use of the "weak dependency" cargo feature
* Set rust-version = "1.60" for all crates
* egui_glow: clipboard, links, persistence & winit are now opt-in features
2022-04-09 13:54:47 +02:00
Emil Ernerfeldt bdfc512b01 Add docstring example for TableBody::rows 2022-04-09 13:34:55 +02:00
Emil Ernerfeldt cd0fb1f3d9 Simplify table demo 2022-04-09 13:18:57 +02:00
Emil Ernerfeldt 8cf196a34b Use proper shebang for all bash scripts: #!/usr/bin/env bash 2022-04-07 17:34:34 +02:00
Emil Ernerfeldt 7cd285ecbc misc clippy fixes from 1.60.0 2022-04-07 17:03:19 +02:00
Emil Ernerfeldt 68d5806b41 Add a text blending test to the color test 2022-04-05 14:23:30 +02:00
Emil ErnerfeldtandMichael Völkl a9ae8c3e2c Smaller checkboxes and radiobutton without a label (#1456)
Co-authored-by: Michael Völkl <michaelvoelkl@zoho.com>
2022-04-05 09:16:58 +02:00
Emil Ernerfeldt bd25526a4f check.sh: fail on rustdoc failure
Same as https://github.com/emilk/egui/pull/1454
2022-04-05 08:07:57 +02:00
Emil Ernerfeldt c3b6d1bab9 Warn about Id clashes for Grid, Plot, ScrollArea, Table (#1452)
Id clashes can cause subtle bugs.

egui already warns when the same Id is used to interact with different
parts of the screen.

This adds warnings about id clashes for some widgets that store state:
Grid, Plot, ScrollArea, Table.

The PR also adds `Context::check_for_id_clash` so users who create
their own widgets can add the same type of check.
2022-04-04 13:13:34 +02:00
Emil Ernerfeldt 2d30bd751c emath: add Rect::signed_distance_to_pos and Vec2::abs 2022-04-04 11:24:08 +02:00
Emil Ernerfeldt 5d19f381f9 Fix TexEdit clipping half the cursor when in the first column
Closes https://github.com/emilk/egui/issues/1449
2022-04-04 09:20:19 +02:00
Emil Ernerfeldt dfd6a91cb0 Fix doclinks 2022-04-03 20:38:51 +02:00