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

190 Commits

Author SHA1 Message Date
Emil Ernerfeldt
002110ee3d Create struct ImmediateViewport to simplify argument lists 2023-11-14 06:26:53 +01:00
Emil Ernerfeldt
337da61c22 Easily open all viewports in test_viewports app 2023-11-13 19:22:17 +01:00
Emil Ernerfeldt
5892d057d7 Use _px suffix for things in pixel units 2023-11-12 12:52:48 +01:00
Emil Ernerfeldt
6e17040539 Merge branch 'master' into multiples_viewports 2023-11-12 10:46:41 +01:00
Emil Ernerfeldt
b27aa27e94 Add emath::Vec2b, replacing egui_plot::AxisBools (#3543)
Thanks to `impl From<bool> for Vec2b` one can now shorten some builder
calls, like:

Previous:
```rust
 egui::ScrollArea::vertical()
        .auto_shrink([false; 2])
```

New:
```rust
 egui::ScrollArea::vertical()
        .auto_shrink(false)
```
2023-11-11 21:31:36 +01:00
Konkitoman
12f3782721 Introduce ViewportInfo 2023-11-08 07:29:00 +02:00
Konkitoman
0d7c87836c Better ViewportBuilder builder patern 2023-11-08 07:04:33 +02:00
Emil Ernerfeldt
290ecca9bd Add a simple example of the viewports API 2023-11-07 15:20:35 +01:00
Emil Ernerfeldt
f300c951b3 Rename the viewport types to "immediate" and "deferred" 2023-11-07 11:50:59 +01:00
Emil Ernerfeldt
7bc5698079 Always use the latest async callback when rendering a viewport 2023-11-07 09:48:07 +01:00
Emil Ernerfeldt
a85adf59b2 Rename force_embedding -> embed_viewports 2023-11-07 09:20:31 +01:00
Emil Ernerfeldt
8aa14d2fae Allow changing titles 2023-11-06 20:14:24 +01:00
Emil Ernerfeldt
291ab1ee7b Rename viewports example to test_viewports, and hide drag-and-drop 2023-11-06 20:03:23 +01:00
Emil Ernerfeldt
73432bad84 Make the viewports example/test an explicit tree of viewports 2023-11-06 19:57:11 +01:00
Emil Ernerfeldt
a52d38312c MAIN -> ROOT 2023-11-06 19:19:37 +01:00
Emil Ernerfeldt
0ae7eebfd4 Clean up example code 2023-11-06 18:35:27 +01:00
Emil Ernerfeldt
39f13b4551 Hide close-button for child viewports by default 2023-11-06 10:51:56 +01:00
Emil Ernerfeldt
3cb8f49b46 ViewportId now wraps Id 2023-11-03 15:02:51 +01:00
Emil Ernerfeldt
47e7b9d2dc Minor naming cleanup 2023-11-03 14:09:36 +01:00
Emil Ernerfeldt
256ad734b4 More cleanup 2023-11-03 13:36:12 +01:00
Emil Ernerfeldt
1f0fc7a005 format let-else statements 2023-11-03 13:15:21 +01:00
Emil Ernerfeldt
29e1c4d101 Spelling 2023-11-03 11:43:02 +01:00
Emil Ernerfeldt
99417b45e3 Clean up viewports example slightly 2023-11-03 11:36:36 +01:00
Emil Ernerfeldt
72a7ee4606 fix typo 2023-11-01 19:05:20 +01:00
Emil Ernerfeldt
abc70ccf9c Misc code cleanup 2023-11-01 18:19:19 +01:00
Emil Ernerfeldt
9f926d4d03 Lint: vertical spacing 2023-11-01 17:13:11 +01:00
Konkitoman
b4224566ed Now all viewports repaint when pixels_per_point are changed
Added zoom shortcuts for viewports example
2023-10-20 20:52:34 +03:00
Konkitoman
239a807a8f Fix default viewport size and added a range on pixels_per_point 2023-10-20 19:03:41 +03:00
Konkitoman
fb026298fe Added pixels per point in viewports example 2023-10-20 15:39:35 +03:00
Konkitoman
701d31a887 Viewports example:
* fix typo
* fix == instead of !=
* added a spinner, to see if the redraw request are working as supposed to!
2023-10-18 15:20:21 +03:00
Konkitoman
e21ed4ff1f refactored the viewports example
I added drag and drop on every viewport, to make possible in the future to drag and drop between viewports
2023-10-09 21:21:46 +03:00
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