1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-27 15:13:12 -04:00
Commit Graph

159 Commits

Author SHA1 Message Date
Konkitoman
7caa042b92 Merge branch 'master' of https://github.com/emilk/egui into multiples_viewports 2023-09-30 09:39:45 +03:00
Emil Ernerfeldt
9a947e5547 Final image API doc tweaks 2023-09-27 16:40:26 +02:00
Emil Ernerfeldt
cfbad1f865 Update example screenshots 2023-09-27 15:34:39 +02:00
Emil Ernerfeldt
dff52eddfd README.md: new images, better text (#3392)
* Update images in README.md

* Add ferris image to hello_world example

* Clean up and improve README.md, with top-level link to Rerun

* Move sections around
2023-09-26 21:17:43 +02:00
Konkitoman
f4c5378ad3 Merge branch 'master' of https://github.com/emilk/egui into multiples_viewports 2023-09-25 23:15:51 +03:00
Emil Ernerfeldt
99a1b5b62e Add Context::open_url and Context::copy_text (#3380)
* Add Context::open_url

* Add `Context::copy_text`

* Fix doctest

* Fix another doctest
2023-09-24 09:31:21 +02:00
Konkitoman
22c128bc8b Fix warning in viewports example 2023-09-19 20:42:31 +03:00
Konkitoman
e2d406d2e4 * InputState::{inner_pos, inner_size} compacted to InputState::inner_rect
* InputState::{outer_pos, outer_size} compacted to InputState::outer_rect
* RawInput::{inner_pos, inner_size} compected to RawInput::inner_rect
* RawInput::{outer_pos, outer_size} compected to RawInput::outer_rect
* Context::{viewport_inner_pos, viewport_inner_size} compacted to Context::inner_rect
* Context::{viewport_outer_pos, viewport_outer_size} compected to Context::outer_rect
2023-09-19 19:48:00 +03:00
Konkitoman
ddff550b91 Remove get_* 2023-09-19 19:20:49 +03:00
Konkitoman
c96197db79 Merge branch 'master' of https://github.com/emilk/egui into multiples_viewports 2023-09-19 17:22:31 +03:00
Emil Ernerfeldt
d7d222d3f6 Polish image API (#3338)
* Imoprove docs for callback shapes

* Improve docs for loader traits

* Use snake_case for feature `all_loaders`

* Make loaders publix

* Slightly better error message on image load failure

* Improve image loading error messages

* Use `bytes://` schema for included bytes loader

* Try user loaders first

* Move `image_loading_spinners` to `Visuals`

* Unify and simplify code

* Make the main text of `Button` optional

This largely makes ImageButton obsolete

* Fix docstrings

* Better docs

* typos

* Use the more explicit `egui_extras::install_image_loaders`

* Simplify `Image::paint_at` function
2023-09-14 16:33:10 +02:00
Emil Ernerfeldt
e367c20779 egui_extras: always depend on log crate (#3336)
* egui_extras: always depend on `log` crate

* syntax_highlighting fix: "serde" is always on

* Add "serde" flag to egui when using egui_extras
2023-09-14 11:20:34 +02:00
Jan Procházka
67a3fcae38 Final polish for new image loading (#3328)
* add egui logo to widget gallery

* improve "no image loaders" error message

* rework static URIs to accept `Cow<'static>`

* remove `RetainedImage` from `http_app` in `egui_demo_app`

* hide `RetainedImage` from docs

* use `ui.image`/`Image` over `RawImage`

* remove last remanant of `RawImage`

* remove unused doc link

* add style option to disable image spinners

* use `Into<Image>` instead of `Into<ImageSource>` to allow configuring the underlying image

* propagate `image_options` through `ImageButton`

* calculate image size properly in `Button`

* properly calculate size in `ImageButton`

* Update crates/egui/src/widgets/image.rs

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

* improve no image loaders error message

* add `size()` helper to `TexturePoll`

* try get size from poll in `Button`

* add `paint_at` to `Spinner`

* use `Spinner::paint_at` and hover on image button response

* `show_spinner` -> `show_loading_spinner`

* avoid `allocate_ui` in `Image` when painting spinner

* make icon smaller + remove old texture

* add `load_and_calculate_size` + expose `paint_image_at`

* update `egui_plot` to paint image in the right place

* Add helpers for painting an ImageSource directly

* Use max_size=INF as default

* Use new API in WidgetGallery

* Make egui_demo_app work by default

* Remove Option from scale

* Refactor ImageSize

* Fix docstring

* Small refactor

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-09-13 16:27:08 +02:00
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
Konkitoman
fb80880ff8 * Fix posibile deadlock when sending a viewport command from a sync viewport
* Improve viewports example
2023-09-06 16:30:20 +03:00
Konkitoman
83f82601e8 * Fix warnings
* Refactor eframe wgpu
2023-09-06 15:18:18 +03:00
Konkitoman
fea6ed7878 Merge branch 'master' of https://github.com/emilk/egui into multiples_viewports 2023-09-06 13:35:02 +03: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
Konkitoman
155d48abd1 Added __screenshot feature for eframe in viewports example 2023-09-05 13:09:17 +03:00
Konkitoman
4eb32c6ccf Simplify 2023-09-01 12:09:01 +03:00
Konkitoman
661120dc1d Simplify 2023-09-01 11:52:00 +03:00
Konkitoman
52a63cabf9 Make viewports example simpler 2023-09-01 11:17:54 +03:00
Konkitoman
78a0ae879e This PR has a smaller scope, and this are some reverts
Will no longer change egui::Window!
2023-08-31 19:37:01 +03:00
Konkitoman
a21cb80f56 Merge branch 'master' of https://github.com/emilk/egui into multiples_viewports 2023-08-29 10:00:14 +03: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
Konkitoman
4d01644b33 * Fix example hello_world_par
* Added warning for glow eframe when creating `Context::create_viewport_sync` in other thread, or cannot be rendered!
* Fix clippy warning
2023-08-25 11:22:18 +03:00
Konkitoman
6c91562c7b Now viewport pos and size are stored in InputState::{viewport_inner_pos, viewport_outer_pos, viewport_inner_size, viewport_outer_size}
This fixes a lot of problems
2023-08-24 09:14:48 +03:00
Konkitoman
9c73c2f4b1 Revert "Now in screen_rect min is the viewport position and max is the viewport size"
This reverts commit 4bbdab1788.
2023-08-24 07:55:56 +03:00
Antoine Beyeler
2c5fc5a0a5 Added mime field to DroppedFiles (#3273) 2023-08-23 15:13:47 +02:00
Konkitoman
3cf9c1c4b1 Make example more complex 2023-08-23 08:11:31 +03:00
Konkitoman
ab59bf8c88 Now viewports will be identified by there id a normal egui::Id
Before viewports was identified by there title
2023-08-22 10:34:43 +03:00
Konkitoman
2949874287 Update egui::Context::create_viewport documentation and update viewports example 2023-08-22 10:22:21 +03:00
Konkitoman
013f01dbcb * Now: is_desktop can only be set at the creation with egui::Context::new insted of default!
* Removed: egui::Context::is_desktop, egui::Context::set_desktop
* Added: egui::Context::force_embedding, egui::Context::set_force_embedding
2023-08-22 09:39:41 +03:00
Konkitoman
bc04696842 Merge branch 'master' of https://github.com/emilk/egui into multiples_viewports 2023-08-17 21:59:11 +03: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
Konkitoman
18575d5931 Fix all warnings 2023-08-15 04:04:52 +03:00
Konkitoman
191ee82c3e Merge branch 'master' of https://github.com/emilk/egui into multiples_viewports 2023-08-15 02:17:12 +03:00
Konkitoman
08f207a0a8 Fix some warnings 2023-08-14 17:59:26 +03:00
Konkitoman
4bbdab1788 Now in screen_rect min is the viewport position and max is the viewport size 2023-08-12 20:36:41 +03:00
Emil Ernerfeldt
08fb447fb5 Increase MSRV to 1.67 (#3234)
* Bump MSRV to 1.67

* clippy fixes

* cargo clippy: inline format args

* Add `clippy::uninlined_format_args` to cranky lints

* Fix clippy on wasm

* More clippy fixes
2023-08-11 13:54:02 +02:00
hacknus
871041c4e7 Added an example to save plot to image (#2769)
* implement save_plot

* fix for check.sh

* clippy

* add save_plot to Cargo.lock

* adapted for PR #2676 (removes unsafe code)

* add some comments

* implemented the comments from emilk

* update comments in code

* rustfmt

* remove picked_path

* add more comments

* removed unused import

* use `inner.response.rect` as the plot position

* remove plot_location from MyApp members

* sort entries

* Update examples/save_plot/src/main.rs

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

* use env_logger instead of tracing subscriber

* use env_logger instead of tracing subscriber and combine if let

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-08-10 12:35:11 +02:00
Konkitoman
48646ef521 Update viewports example, and added documentation for Window::default_embedded 2023-08-09 20:16:35 +03:00
Konkitoman
a88a5cdf83 Fix some warnings 2023-08-09 19:15:35 +03:00
Konkitoman
86ef11c521 Now viewport_id always will be in a ViewportId you cannot create a ViewportId you can only get the main one everywere or get the current viewport id with Context::get_viewport_id 2023-08-09 18:33:59 +03:00
Konkitoman
1a7c4700fd Now embedded is stored on window, and fix crash when we set a window size to 0 2023-08-08 21:18:03 +03:00
Konkitoman
c68908a6a8 Add embedd button on window is only a button with character - or ^ 2023-08-08 17:19:54 +03:00
Konkitoman
d45fc14a13 Move viewports stuff to crates/egui/src/viewports.rs 2023-08-07 19:02:18 +03:00
Konkitoman
860160ed05 Some work on wgpu implementation 2023-08-06 09:21:44 +03:00