Commit Graph

2705 Commits

Author SHA1 Message Date
Emil Ernerfeldt fc3bddd0cf
Add more puffin profile scopes to `eframe` (#3330)
* Add puffin profile scopes to the startup and running of eframe

* puffin_profiler example: start puffin right away

* cargo format let-else statements

* More profile scopes

* Add some `#[inline]`

* Standardize puffin profile scope definitions

* standardize again

* Silence warning when puffin is disabled
2023-09-13 09:00:38 +02:00
Jan Procházka 2bc6814acc
Improved texture loading (#3315)
* rework loading around `Arc<Loaders>`

* use `Bytes` instead of splitting api

* remove unwraps in `texture_handle`

* make `FileLoader` optional under `file` feature

* hide http load error stack trace from UI

* implement image fit

* support more image sources

* center spinner if we know size ahead of time

* allocate final size for spinner

* improve image format guessing

* remove `ui.image`, `Image`, add `RawImage`

* deprecate `RetainedImage`

* `image2` -> `image`

* add viewer example

* update `examples/image` + remove `svg` and `download_image` exapmles

* fix lints and tests

* fix doc link

* add image controls to `images` example

* add more `From` str-like types

* add api to forget all images

* fix max size

* do not scale original size unless necessary

* fix doc link

* add more docs for `Image` and `RawImage`

* make paint_at `pub`

* update `ImageButton` to use new `Image` API

* fix double rendering

* `SizeHint::Original` -> `Scale` + remove `Option` wrapper

* Update crates/egui/src/load.rs

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

* remove special `None` value for `forget`

* Update crates/egui/src/load.rs

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

* add more examples to `ui.image` + add `include_image` macro

* Update crates/egui/src/ui.rs

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

* update `menu_image_button` to use `ImageSource`

* `OrderedFloat::get` -> `into_inner`

* derive `Eq` on `SizedTexture`

* add `id` to loaders + `is_installed` check

* move `images` to demo + simplify `images` example

* log trace when installing loaders

* fix lint

* fix doc link

* add more documentation

* more `egui_extras::loaders` docs

* Update examples/images/src/main.rs

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

* update `images` example screenshots + readme

* remove unused `rfd` from `images` example

* Update crates/egui_extras/src/loaders/ehttp_loader.rs

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

* add `must_use` on `Image` and `RawImage`

* document `loaders::install` multiple call safety

* Update crates/egui_extras/Cargo.toml

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

* reshuffle `is_loader_installed`

* make `include_image` produce `ImageSource` + update docs

* update `include_image` docs

* remove `None` mentions from loader `forget`

* inline `From` texture id + size for `SizedTexture`

* add warning about statically known path

* change image load error + use in image button

* add `.size()` to `Image`

* Update crates/egui_demo_app/Cargo.toml

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

* add explanations to image viewer ui

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-09-12 10:39:17 +02:00
Jackson Kruger dbcf15b49e
Add method to RichText making it easier to construct layout jobs (#3319)
* Slightly refactor and expose some parts of rich text to make it easier to construct layout jobs

* Cargo fmt

* Add documentation
2023-09-10 14:06:02 +02:00
Emil Ernerfeldt 62e27d623a Move README section on writing a new integration to the egui crate docs
Closes https://github.com/emilk/egui/issues/3326
2023-09-10 13:57:24 +02:00
zkldi 523aa6b8ba
feat: change to PointingHand when hovering over a button (#3312)
* feat: change to PointingHand when hovering over a button

* feat: make this a togglable option that is off by default

* fix: typo

* feat: use Option<CursorIcon> instead for the option.

* remove superfluous comment

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-09-08 09:37:03 +02:00
Emil Ernerfeldt 2338a854f9
Fix deadlock in the texture/image loaders (#3314) 2023-09-06 15:36:08 +02:00
Jan Procházka ec671e754f
Managed texture loading (#3297)
* add types from proposal

* add load methods on `egui::Context`

* implement loaders from proposal in `egui_extras`

* impl `From<Vec2>` for `SizeHint`

* re-export `SizeHint` from `egui` root

* rework `svg` example to use new managed `Image`

* split loaders into separate files + add logging

* add `log_trace`

* clean up `RetainedImage` from `svg` example

* refactor ehttp loader response to bytes mapping

* remove spammy trace

* load images even without extension

* fix lints

* remove unused imports

* use `Image2` in `download_image`

* use `visuals.error_fg_color` in `Image2` error state

* update lockfile

* use `Arc<ColorImage>` in `ImageData` + add `forget` API

* add `ui.image2`

* add byte size query api

* use iterators to sum loader byte sizes

* add static image loading

* use static image in `svg` example

* small refactor of `Image2::ui` texture loading code

* add `ImageFit` to size images properly

* remove println calls

* add bad image load to `download_image` example

* add loader file extension support tests

* fix lint errors in `loaders`

* remove unused `poll-promise` dependency

* add some docs to `Image2`

* add some docs to `egui_extras::loaders::install`

* explain `loaders::install` in examples

* fix lint

* upgrade `ehttp` to `0.3` for some crates

* Remove some unused dependencies

* Remove unnecessary context clone

* Turn on the `log` create feature of egui_extras in all examples

* rename `forget` and document it

* derive `Debug` on `SizeHint`

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

* round when converting SizeHint from vec2

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

* add `load` module docs

* docstring `add_loader` methods

* expose + document `load_include_bytes`

* cache texture handles in `DefaultTextureLoader`

* add `image2` doctest + further document `Image2`

* use `Default` for default `Image2` options

* update `image2` doc comment

* mention immediate-mode safety

* more fit calculation into inherent impl

* add hover text on spinner

* add `all-loaders` feature

* clarify `egui_extras::loaders::install` behavior

* explain how to enable image formats

* properly format `uri`

* use `thread::Builder` instead of `spawn`

* use eq op instead of `matches`

* inline `From<Arc<ColorImage>>` for `ImageData`

* allow non-`'static` bytes + `forget` in `DefaultTextureLoader`

* sort features

* change `ehttp` feature to `http`

* update `Image2` docs

* refactor loader cache type

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-09-06 10:51:51 +02:00
Emil Ernerfeldt 82704bebbf
Update MSRV to Rust 1.70.0 (#3310)
* Update to Rust 1.70

* Fix renamed clippy lint

* Use let-else more

* Code cleanup

* Remove derelict Safety comments

* Enable more clippy lints
2023-09-06 07:59:24 +02:00
Emil Ernerfeldt 707ca04c08
Add opt-in `puffin` feature to `egui-extras` (#3307)
* Add opt-in `puffin` feature to `egui-extras`

Image loading can be slow.

Related to https://github.com/emilk/egui/pull/3297

* Silence warning
2023-09-05 14:11:29 +02:00
Emil Ernerfeldt 67168be069
Improve clippy, and add more docs (#3306)
* Silence a few clippy warnings

* Use named threads

* Remove some deprecated functions

* Document Context and Ui fully

* Use `parking_lot::Mutex` in `eframe`

* Expand clippy.toml files

* build fix
2023-09-05 14:11:22 +02:00
Emil Ernerfeldt 436996b79e
Update web-time to 0.2 (#3308) 2023-09-05 14:11:07 +02:00
Emil Ernerfeldt b9f9cab914
Update webpki 0.22.0 -> 0.22.1 (#3305) 2023-09-05 13:03:37 +02:00
Emil Ernerfeldt 46ea72abe4
Add control of line height and letter spacing (#3302)
* Add `TextFormat::extra_letter_spacing`

* Add control of line height

* Add to text layout demo

* Move the text layout demo to its own window in the demo app

* Fix doclink

* Better document points vs pixels

* Better documentation and code cleanup
2023-09-05 10:45:11 +02:00
Barugon cf163cc954
Add `scroll_area::State::velocity` (#3300)
* Implement `has_momentum`

* Add doc comment

* Call it `has_velocity`

* Implement `velocity` method

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-09-05 10:44:23 +02:00
Barugon 1b8e8cb38e
`eframe::Frame::info` returns a reference (#3301)
* Get a reference to `IntegrationInfo`

* Add doc comment

* Change `info` to return a reference

* Clone integration info

* Remove `&`

* Clone integration info in another place
2023-09-05 10:43:39 +02:00
Emil Ernerfeldt e3362dafac
CI: Update to actions/checkout@v4 (#3304) 2023-09-05 10:18:38 +02:00
Emil Ernerfeldt 8c84bbfde4
Prune old egui memory data when reaching some limit (#3299)
* Add generations to serialized state

* Make IdTypeMap into a field struct

* Less code duplication

* Implement garbage collection during serialization

* Add unit-test

* Add docstring

* Build fix

* another fix
2023-09-04 21:46:57 +02:00
Emil Ernerfeldt 9e86bb8d6a
Add opt-in `puffin` feature to egui (#3298)
* Add opt-in `puffin` feature to egui

* fix web build

* Fix web for realz
2023-09-04 15:01:22 +02:00
Barugon 72adf3bde3
Remove unnecessary code (#2860) 2023-09-04 11:43:24 +02:00
v-kat 59235ff01c
Changing menu_image_button to use ImageButton builder (#3288)
Co-authored-by: Ivy <fake@email.com>
2023-09-04 11:12:43 +02:00
Emil Ernerfeldt 5f742b9aba
Improve documentation of `eframe`, especially for wasm32 (#3295)
* Improve documentation of `eframe`, especially for wasm32

* remove dead code

* fix
2023-09-04 09:55:47 +02:00
Emil Ernerfeldt 209cbeb030
Replace instant with web_time (#3296) 2023-09-04 09:37:35 +02:00
Timon ea15987ad4
Change focused widget with arrow keys (#3272)
* Allow widget focus change with keyboard arrows

* remove set id function

* docs

* Emilk feedback round 1

* Fix compile error

* undo example

* Move out functions from range to memory.rs

* remove contains range

* Use docstrings

* code cleanup

* Improve candidate logic

* More tweaks

* Less `pub`

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-08-30 10:28:21 +02:00
Emil Ernerfeldt 70bfc7e09f
Add `eframe::storage_dir` (#3286)
* Add `eframe::storage_dir`

Now you can easily tell where eframe stores its state

* egui_plot: work even without the `serde` featur flag
2023-08-29 15:22:07 +02:00
Emil Ernerfeldt a59eda7a27
egui-winit: Recognize numpad enter/plus/minus (#3285)
Numpad enter should work the same as the normal return key.

Numpad plus/minus should now work for scaling ui
(together with cmd/ctrl)
2023-08-29 14:04:12 +02:00
Emil Ernerfeldt 7b169ec13d
Break out plotting to own crate `egui_plot` (#3282)
This replaces `egui::plot` with the new crate `egui_plot`
2023-08-27 17:22:49 +02:00
Sven Niederberger 87f12d782e
Allow setting the progress bar height (#3183)
* allow setting the progress bar height

* changelog entry

* remove the changelog entry
2023-08-27 14:28:55 +02:00
Sven Niederberger c722b7fd46
Plot items: Image rotation and size in plot coordinates, polygon fill color (#3182)
* plot item improvements

* update changelog

* fix links

* revert changes to the changelog

* clean up merge
2023-08-27 14:28:10 +02:00
Emil Ernerfeldt b6f46b000b Some clippy fixes from 1.72.0 2023-08-25 07:44:25 +02:00
Antoine Beyeler 627e1b3d50
Add exception for RUSTSEC-2023-0052 to deny.toml (#3274) 2023-08-23 15:22:41 +02:00
Antoine Beyeler 2c5fc5a0a5
Added `mime` field to `DroppedFiles` (#3273) 2023-08-23 15:13:47 +02:00
Emil Ernerfeldt ec506c0a43
Use the minus character instead of "dash" (#3271)
* Use the minus character instead of "dash"

See https://github.com/rerun-io/rerun/issues/3053

* docstring

* fix
2023-08-22 15:35:27 +02:00
David M. Lary 32a63da580
Added Context::is_context_menu_open() (#3267)
I encountered a case where I needed to know if an egui context menu was
open, even if the mouse cursor was not in an egui area (full details in
discord).  I found that every resource I needed to detect that the menu
was open was either private, or pub(crate).  While it is possible to
wrap the `Response::context_menu()` in code to do state-tracking, it
becomes necessary to duplicate that code in every place you use a
context menu.

In this commit, I add `Context::is_context_menu_open()`.  Named similarly
to `Context::is_pointer_over_area()`, this method will return true if
any context menu is open.  This is possible because the context menu
uses a temp var with a fixed Id to store its state.  This method just
fetches the state, and interrogates it to see if there is a menu
present.

One helper method, `BarState::has_root()`, was added as all the fields
needed to perform the check were private to the `menu` module.

I've also updated the Context Menu demo to show the result of
`is_context_menu_open()` to verify the code functions as expected.
2023-08-22 15:35:15 +02:00
lucasmerlin 461328f54d
Fix iOS support in `eframe` (#3241)
* Fix the app only taking up half the screen size on iPad

* Fix request_repaint not working on iOS

* Always use run_and_exit on iOS since run_and_return is not supported by winit on iOS right now.

* Fix typo

* Fix eframe glow on ios

* Handle more cases
2023-08-22 14:35:18 +02:00
Brian Janssen 2c7c59820e
Expose area::State's Rect in Memory (#3161) 2023-08-16 12:52:36 +02:00
YgorSouza f0addc339c
Add tooltip_delay option (#3245)
* Add tooltip_delay option

Similar to the show_tooltips_only_when_still option, but allows the user
to configure a specific delay in seconds, and also makes the tooltip
disappear if the mouse is moved again.

Closes #3232

* Update crates/egui/src/response.rs

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

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-08-15 19:48:36 +02:00
Andreas Reich b0735775f3
Fix plot formatter not taking closures (#3260)
and fix their their comments
2023-08-15 19:46:04 +02:00
Andreas Reich b896d641c5
Improved wgpu callbacks (#3253)
* Improved wgpu callbacks

* update documentation on egui_wgpu callbacks

* make shared callback resource map pub

* make it nicer to create epaint::PaintCallback from egui_wgpu callback

* constrain ClippedPrimitive lifetime to outlive wgpu::RenderPass

* Revert callback resources to TypeMap, put finish_prepare on callback trait

* doc string fixes
2023-08-15 17:17:39 +02:00
Emil Ernerfeldt 3c4223c6b1
Support images with rounded corners (#3257)
* Add `Rect::ZERO`

* Add `Rounding::ZERO`

* Add `RectShape::new`

* Add `Image::rounding` to support images with rounded corners
2023-08-15 09:29:30 +02:00
Emil Ernerfeldt 481f44828c
Improve "Reset everything" button in demo (#3255)
Closes https://github.com/emilk/egui/issues/3254
2023-08-14 18:57:39 +02:00
dmackdev 8ee506ec37
Added remove method for CollapsingState. (#3252) 2023-08-14 18:57:07 +02:00
Kamen Yovchevski e5428a3084
Add Window::drag-to-scroll (#3118) 2023-08-14 18:44:29 +02:00
Kamen Yovchevski 043183a3a4
Add `TableBuilder::drag_to_scroll` (#3100)
* Add TableBuilder::drag_to_scroll

* Add reference to ScrollArea::drag_to_scroll
2023-08-14 18:21:42 +02:00
JohannesProgrammiert dbe55ba46a
Draw axis labels and ticks outside of plotting window (#2284)
* Always draw axis labels at plot borders

* Revert "Always draw axis labels at plot borders"

This reverts commit 9235e6603366d3b8a8189e2a5fc28c9780b7f54f.

* Add axis labels for plots

* First Draft of axis labels outside of plotting window

* plot: Tick placement of opposite axes and digit constraints

* plot: Axis label API

* plot: Update demo lib

* plot: resolve clippy warning

* Update changelog

* Remove default axis

* Fix clippy

* plot: Remove unused comments

* plot-axis: Rebase label opacity calculation on master

* plot: Resolve check.sh warnings

* plot-axis: Use 'into impl<WidgetText>' as axis label formatter

* plot-axis: Expose more conveniece functions to public API. Add axis labels to demo app

* plot-axes: Resolve ./scripts/check.sh warnings

* typo in comment

* Use `TAU` instead of the legacy `PI`

* Simpler generic syntax

* Use `Arc` to avoid some expensive clones

* Use `Margin` instead of a,b,c,d

* Add some vertical spacing

* De-duplicate color_from_contrast

* better naming

* Fix typos

* cnt -> num

* Axis are present by default, with empty names

* Add HPlacement and VPlacement

* Don't catch clicks and drags on axes

* Remove generics to minimize monomorphization code bloat

* Create helper function

* Remove changelog entry

* Simplify more

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-08-14 17:51:17 +02:00
Emil Ernerfeldt a3ae81cadb
Add option to truncate text at wrap width (#3244)
* Add option to clip text to wrap width

* Spelling

* Better naming, and report back wether the text was elided

* Improve docstrings

* Simplify

* Fix max_rows with multiple paragraphs

* Add note

* Typos

* fix doclink

* Add `Label::elide`

* Label: show full non-elided text on hover

* Add demo of `Label::elide`

* Call it `Label::truncate`

* Clarify limitations of `break_anywhere`

* Better docstrings
2023-08-14 11:22:04 +02:00
Frederic L 1023f937a6
Add option to always open hyperlink in a new browser tab (#3242)
* add option to always open hyperlink in a new browser tab

* Fix logic error
2023-08-12 14:05:49 +02:00
lucasmerlin 1036cb1f7d
Change force to be Option<f32> instead of f32 (#3240) 2023-08-12 13:50:40 +02:00
Emil Ernerfeldt 6633ecce64
Fix wrong detection of OS (#3238)
We had a bunch of `cfg!(windows)` and `cfg!(macos)` which should
have been `cfg!(target_os = "windows")`.

I wonder what the effects of this PR will be fore Windows 😬
2023-08-12 13:50:31 +02:00
Aaron Hill 98087029e0
Update to `wgpu` 0.17.0 (#3170)
* Bump `wgpu` to 0.17.0
This required bumping wasm-bindgen to 0.2.87
* cargo deny exception for `foreign-types`
* sort deny.toml
* Add fragile-send-sync-non-atomic-wasm feature to wgpu
* cargo deny: ignore children of foreign-types

---------

Co-authored-by: Andreas Reich <r_andreas2@web.de>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-08-11 17:10:10 +02:00
Emil Ernerfeldt dd417cfc1a
eframe: Better restore Window position on Mac when on secondary monitor (#3239) 2023-08-11 16:25:22 +02:00