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

2881 Commits

Author SHA1 Message Date
Konkitoman
f001f06567 Restore from master egui_demo_app.js and egui_demo_app_bg.wasm 2023-09-26 23:42:51 +03:00
Konkitoman
38e00e2ea2 refactor eframe viewport sync rendering for glow and wgpu 2023-09-26 22:56:46 +03:00
Konkitoman
1930d69ae3 Fix the change that change from a Vec to HashMap braked web and pure_glow 2023-09-26 20:34:09 +03:00
Konkitoman
f3686e2459 now using a HashMap insted of a Vec to store repaint_after 2023-09-26 20:18:50 +03:00
Konkitoman
5c8c56c1b8 rename the events that are result of events event_result 2023-09-26 19:50:11 +03:00
Konkitoman
e5783127f4 Fix max_texture_side for the main viewport was alwats set to 0 2023-09-26 19:45:12 +03:00
Konkitoman
43ad25a4d9 Renamed gl_window to glutin_ctx in init_run_state and initializate max_texture_side, and now on any egui_winit has max_texture_side set 2023-09-26 18:59:42 +03:00
Konkitoman
6a5838c119 Now all sizes are in Vec2 insted of Pos2 2023-09-26 18:33:57 +03:00
Konkitoman
b719e1c030 eframe fix android build 2023-09-26 18:23:37 +03:00
Konkitoman
543a0a2a83 egui, egui_glow, eframe: fix all errors returned by ./scripts/check.sh 2023-09-26 00:45:33 +03:00
Konkitoman
489d8a79c8 egui: fix web app runner 2023-09-26 00:14:26 +03:00
Konkitoman
e453d667e5 egui and eframe now uses more ViewportIdPair 2023-09-26 00:05:04 +03:00
Konkitoman
28f7b863fe egui: Move comment 2023-09-25 23:27:21 +03: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
e8986b1e59 egui_extras: syntax-highlighting of .toml (#3388) 2023-09-25 17:48:22 +02:00
Emil Ernerfeldt
8bf0055bda Better handle additive colors in plots (#3387) 2023-09-25 15:45:32 +02:00
Emil Ernerfeldt
fdd493d48f Misc cleanup (#3381)
* Give credit to recent big-time contributors in the main README.md

* Better named profiling scopes

* Document everything in memory.rs

* Better doc-strings

* Add a section about dependencies to the main README.md

* Improve egui_extras docs

* fix typos
2023-09-24 09:32:31 +02: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
YgorSouza
d77c446572 Prevent text from being cleared when selected due to winit IME (#3376)
Closes #3374
2023-09-23 15:27:34 +02:00
Emil Ernerfeldt
33a0f50f6a Improve text truncation: always include elision character (#3366)
* Add Row::text

* Rename elide_at_width -> truncate_at_width

* Move text layout tests to own module

* Add test to check that elision character is always included

* Include elision character in more circumstances

* Append overflow character if we can't replace

* Always append … when eliding

* Add a secondary text to the text layout demo
2023-09-21 10:41:49 +02:00
Konkitoman
8ecd29dea7 eframe: Now WGPU implementation when creating a sync viewport will inherit the icon of his parent
And refactoring and adding some inline documentation
2023-09-20 18:56:38 +03: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
915d1b6997 Add ViewportIdPair, Viewport, ViewportOutput 2023-09-19 17:55:54 +03:00
Konkitoman
c96197db79 Merge branch 'master' of https://github.com/emilk/egui into multiples_viewports 2023-09-19 17:22:31 +03:00
Barugon
c07394b576 Only show on-screen-keyboard and IME when editing text (#3362)
* Remove calls to `set_ime_allowed`

* Allow IME if `text_cursor_pos` is `Some`

* Only call `Window::set_ime_allowed` when necessary

* allow_ime doesn't need to be atomic

* Remove unused imports

* Fix assignment
2023-09-19 14:14:42 +02:00
George Burton
08c46acba1 std::borrow::Cow<'_, str> now implements TextBuffer (#3164)
* `std::borrow::Cow<'_, str>` now implements `TextBuffer`

* Add pr number

* Remove line from CHANGELOG.md

* Add missing semicolons

* remove extra semicolon

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2023-09-18 21:38:10 +02:00
daxpedda
ad8b41cad6 Fix not taking clipping into account when calculating colum remainder (#3357) 2023-09-18 21:08:17 +02:00
Emil Ernerfeldt
6870d141d7 Add Context::style_mut (#3359) 2023-09-18 21:07:44 +02:00
Emil Ernerfeldt
dbf9b79d06 Fix typo
Closes https://github.com/emilk/egui/issues/3346
2023-09-18 17:15:51 +02:00
Sebastian Reinhard
433d1fc239 file_storage: Wrap File in BufWriter (#3353)
When exiting my application, it would freeze for around a minute waiting to finish writing ca. 40MB to file storage.
Some quick profiling revealed that it was spending all that time in `File::write`,
presumably making a large number of system calls writing tiny amounts of data at a time.
We can avoid this by buffering writes using a `BufWriter`, just like we already do with `BufReader`.

With this change, my application takes around 1-2 seconds to exit, with the majority of that time spent serializing `ron`.
I'm sure there are further potential performance improvements there, but this is already an order of magnitude or two better.

I also fixed the call to `log::warn!`, which was using incorrect formatting syntax and not including the error message.
2023-09-18 16:40:29 +02:00
Emil Ernerfeldt
8073ca6fe0 Fix problems with tabs in text (#3355)
* Move ascent out of `GlyphInfo`

* Give a function a better name

* Make tab and thin space act more like a normal space
2023-09-18 14:09:15 +02:00
Emil Ernerfeldt
fea9047abe Fix moving slider with arrow keys (#3354)
It would sometimes get stuck on the same value due to "smart-aim"
2023-09-18 13:20:45 +02:00
Emil Ernerfeldt
ceb8723c5e Bug fix: arrow keys won't move focus away from TextEdit (#3352)
* Bug fix: arrow keys won't move focus away from TextEdit

* Fix using arrow-keys to move slider

* Typo
2023-09-18 13:08:41 +02:00
aspect
9c4f55b1f4 Remove Function() invocation from eframe text_agent to bypass "unsafe-eval" restrictions in Chrome browser extensions. (#3349)
* remove Function (eval) from eframe text agent for compatibility with browser extensions.

* cargo fmt on image viewer
2023-09-17 13:25:50 +02:00
Dunfan Lu
d949eaf682 Fix typo in eframe/README.md (#3344) 2023-09-16 12:22:02 +02:00
Emil Ernerfeldt
a3dfd08d71 More image polish (#3343)
* docs

* paint_texture_at

* comment

* Fix doc-tests
2023-09-15 10:57:25 +02:00
Emil Ernerfeldt
2bbceb856b "Final" image polish (#3342)
* Improve the Image API a bit

* Improve image view demo

* Better names

* calculate -> calc
2023-09-15 10:13:50 +02: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
Emil Ernerfeldt
5e785ae00a Add syntax highlighing feature to egui_extras (#3333)
* Add syntax highlighing feature to egui_extras

Enable "syntect" feature for great syntax highlighting of any language.

If not a simple fallback is used that works fine for C++, Rust, Python

* Check --no-default-features of egui_extras on CI

* spelling

* Fix building egui_extras without additional features
2023-09-13 20:39:40 +02:00
Emil Ernerfeldt
4b5146d35d Add more profiling scopes (#3332) 2023-09-13 19:32:19 +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
1cbf333561 * Fix crash when spamming a viewport with other viewports
The crash was causated because sync viewport, when was cleaning up inactive viewports, was cleaning his parent before he got cleaned, and his parent when tring to resume was causing the crash

* Better performance because now the cleanup will be only run by the async viewports
2023-09-11 20:33:44 +03:00
Konkitoman
fc90a7e7c8 Fix cyclical reference
Removed the last fix because there is not need for it now!
2023-09-11 18:50:17 +03:00
Konkitoman
956c1c3527 Fix memory leak 2023-09-10 15:33:06 +03: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