Commit Graph

3427 Commits

Author SHA1 Message Date
Emil Ernerfeldt 58bc67e02f
Fix compilation of `egui_extras` without `serde` feature (#5014)
* Closes https://github.com/emilk/egui/issues/4771
2024-08-27 11:38:33 +02:00
Emil Ernerfeldt bd7d71e7fd Remove dead code
Closes https://github.com/emilk/egui/issues/4867
2024-08-27 11:33:18 +02:00
Douglas Dwyer 73bb4cedb4
Prevent `ScrollArea` contents from exceeding the container size (#5006)
When a `ScrollArea` is added to a `Ui` or its contents change
dynamically, the contents will briefly escape the container. This occurs
because `ScrollArea` internally maintains `content_is_too_large` flags,
from which it determines when to clip. The `content_is_too_large` flags
are calculated after painting, so they always lag one frame behind. This
can lead to flickering.

To fix this, I have changed the `ScrollArea` so that it always clips
scrollable content. I believe that this should fix things without
negatively impacting other behavior. To see this, consider how
`ScrollArea` calculates the `content_is_too_large` flag:

```rust
// This calculates a new inner rect, after painting, from the initial clip rect
let inner_rect = {
  // At this point this is the available size for the inner rect.
  let mut inner_size = inner_rect.size();
  
  for d in 0..2 {
      inner_size[d] = match (scroll_enabled[d], auto_shrink[d]) {
          (true, true) => inner_size[d].min(content_size[d]), // shrink scroll area if content is small
          (true, false) => inner_size[d], // let scroll area be larger than content; fill with blank space
          (false, true) => content_size[d], // Follow the content (expand/contract to fit it).
          (false, false) => inner_size[d].max(content_size[d]), // Expand to fit content
      };
  }
  
  Rect::from_min_size(inner_rect.min, inner_size)
};

let outer_rect = Rect::from_min_size(inner_rect.min, inner_rect.size() + current_bar_use);

let content_is_too_large = Vec2b::new(
  scroll_enabled[0] && inner_rect.width() < content_size.x,
  scroll_enabled[1] && inner_rect.height() < content_size.y,
);
```
If `scroll_enabled[d] == true`, then the actual `inner_rect` (which is
calculated after painting contents) will always be smaller than the
original `inner_rect`. Hence, it is safe to unconditionally clip the
contents to `inner_rect` whenever `scroll_enabled[d] == true`.

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

* Closes <https://github.com/emilk/egui/issues/4742>
* [x] I have followed the instructions in the PR template
2024-08-27 10:22:32 +02:00
Hrafn Orri Hrafnkelsson 0f8614d69e
Avoid some `Id` clashes by seeding auto-ids with child id (#4840)
I was having trouble with id collisions and was not able to resolve it
using `push_id` and `child_ui_with_id_source`.

When investigating the issue I found
https://github.com/emilk/egui/pull/2262 which matched the issues I had
so I forked egui and implemented the changes from that PR for the latest
version.

It solved the issue for me.

I did not notice any regressions in my project or the egui web viewer.

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-08-27 09:43:57 +02:00
Michaël Monayron 82814c4fff
Fix virtual keyboard on (mobile) web (#4855)
Hello,

I have made several corrections to stabilize the virtual keyboard on
Android and IOS (Chrome and Safari).

I don't know if these corrections can have a negative impact in certain
situations, but at the moment they don't cause me any problems.
I'll be happy to answer any questions you may have about these fixes.
These fixes correct several issues with the display of the virtual
keyboard, particularly since update 0.28, which can be reproduced on the
egui demo site.
We hope to be able to help you.

Thanks a lot for your work, I'm having a lot of fun with egui :)
2024-08-27 09:42:35 +02:00
Emil Ernerfeldt a9a6e0c2f2
Remove the need for setting `web_sys_unstable_apis` (#5000)
* No longer required since https://github.com/emilk/egui/pull/4980

And despite some outdated comments, wgpu/WebGPU doesn't need it either
2024-08-26 16:31:38 +02:00
rustbasic 47c0aeb7b9
Add `Label::halign` (#4975)
Function to specify `Align` to `Label`

There are cases where you want to display `Label` on the left or right
regardless of other `Layout` specifications.

Before : Note the part showing the rust source code.

![20240818-1](https://github.com/user-attachments/assets/a08f7594-1ec1-4c6a-b96d-1a5f735d02c1)

After : Note the part showing the rust source code.

![20240818-2](https://github.com/user-attachments/assets/807ff9cf-f8cd-4415-9c78-b62869d1696d)

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-08-26 15:38:00 +02:00
Nicolas 5a1ab9b2b8
Add `Slider::max_decimals_opt` (#4953)
As mentioned in #4950 I added `max_decimals_opt` to the Slider

* Closes <https://github.com/emilk/egui/issues/4950>
* [x] I have followed the instructions in the PR template
* [x] I ran the script in `scripts/check.sh`
2024-08-26 15:36:50 +02:00
VinTarZ 9f2f5f7292
Fix eframe centering on multiple monitor systems (#4919)
On multiple-monitor systems, eframe was incorrectly selecting first ones
dimensions for centering

Would also appretiate releasing 0.28.2 with fix included on crates.io
2024-08-26 15:36:30 +02:00
Emil Ernerfeldt 0513c05768
Fix CI (#5005) 2024-08-26 15:35:44 +02:00
rustbasic b84a1e2a29
Add additional cases and the egui inspectors to the `test_ui_stack` example (#4992)
Improvement: test_ui_stack

---------

Co-authored-by: Antoine Beyeler <49431240+abey79@users.noreply.github.com>
2024-08-26 15:32:27 +02:00
rustbasic 555ea9f7aa
Refactor: use `if let` instead of `for` on `Option`s (#4934)
This is recommended by `rust-analyzer`

It might be a good idea to fix this to appease `rust-analyzer`.
2024-08-26 15:31:26 +02:00
Nicolas 560b2989a7
Update `web-sys` & `wasm-bindgen` (#4980)
This PR updates web-sys & wasm to the newest version.

(this was already part of the POC #4954 )

* Closes <https://github.com/emilk/egui/issues/4961>
* Closes <https://github.com/emilk/egui/issues/4958>
* [x] I have followed the instructions in the PR template
2024-08-26 11:38:30 +02:00
frederik-uni e9522cf765
Ignore viewport size/position on iOS (#4922)
I disabled some code that changes the viewport of iOS devices. 
* [X] I have followed the instructions in the PR template
2024-08-26 11:34:39 +02:00
rustbasic ba80038f3d
`egui_extras`: Fix file mime from path (wrong feature name) (#4933)
Fix: features "mime_guess" to "file"

typo: 1

Is this what you intended?
If you intended to add `mime_guess` to `cargo.toml`, please drop it.
2024-08-26 11:24:08 +02:00
YgorSouza a0c4e28b65
Fix `Id` clash in `Frame` styling widget (#4967)
As we have two Margin widgets in the same UI and this widget has a Grid
with a hardcoded Id, we have to force a different Id to one of them to
avoid clashes.

* Closes <https://github.com/emilk/egui/issues/4965>
* [x] I have followed the instructions in the PR template
2024-08-26 11:19:51 +02:00
Oscar Gustafsson cc3a09187d
Deprecate `ahash` re-exports (#4979)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->
* Closes <https://github.com/emilk/egui/issues/3482>
* [x] I have followed the instructions in the PR template

Regarding the statement in #3482,
https://docs.rs/egui/latest/egui/layers/struct.GraphicLayers.html#method.drain
accepts a HashMap, but not sure if that is enough to keep the re-export.
2024-08-26 10:41:16 +02:00
lucasmerlin c9e00e50ad
Fix iOS build, and add iOS step to CI (#4898)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

This PR
- adds a pipeline to check the ios build
- removes the iOS WaitUntil workaround, which doesn't seem to be
necessary anymore after the winit update (and caused the build for iOS
to fail again because of a missing self
- ~removes a iOS workaround for window size which doesn't seem necessary
anymore~
Turns out it was still needed (but you need to actually restart the app
for the issue to show up, so I didn't catch it first)
- fixes some cargo check errors in run.rs

I've done all these changes in a single PR because otherwise the
pipeline doesn't run but I can also split them in separate PRs if that
makes it easier to review
2024-08-26 09:48:12 +02:00
Zoxc f996b9050e
Request focus on a `TextEdit` when clicked (#4991)
This request focus on a TextEdit when clicked, so that touch events on
Android can now focus it.

This looks like a reasonable fix for
https://github.com/emilk/egui/issues/4941.
2024-08-26 09:45:56 +02:00
rustbasic fd0ce5fb65
Add `TextWrapMode` in `Style ui` (#4994)
Add `TextWrapMode` in `Style ui`

I think this would be useful for debugging.
2024-08-26 09:41:54 +02:00
pm100 0c528fb862
Fix crash when changing viewport settings (#4862)
* Fixes #3959

There are two bugs racing each other here, which is why it sometimes
crashes and sometimes the app just silently exists

Bug 1
When the window is recreated a Destroyed event arrives (due to the Drop
of the old window). The code that receives this event does not look to
see if its the main viewport or a secondary one and unconditionally
closes the app. The code path for other platforms is slightly different
and does check.

I have moved the code that handles the destroy to be in the same place
and have the same behavior as the other platforms.

Bug 2

At recreate time the window and winit entries of the viewport are set to
None (forcin g them to be recreated). But the surface is still bound to
the old window, this causes the next context switch to fail. So I simply
added a viewport.gl_surface = None too,


This is my first egui PR so I hope I have not broken anything. If
nothing else I understand a little better how egui works.
2024-08-26 08:55:34 +02:00
Emil Ernerfeldt 5a196f6604
Create a `UiBuilder` for building `Ui`s (#4969)
* Part of https://github.com/emilk/egui/issues/4634

The goals is to create fewer, more powerful entry points.


### Added
* `egui::UiBuilder`
* `Ui::allocate_new_ui`
* `Ui::new_child`

### Breaking changes
* `Ui::new` now takes a `UiBuilder`
* Deprecated
	* `ui.add_visible_ui`
	* `ui.allocate_ui_at_rect`
	* `ui.child_ui`
	* `ui.child_ui_with_id_source`
	* `ui.push_stack_info`
2024-08-26 08:51:18 +02:00
pm100 06f88e12b0
Add close_button option to test_viewports (#4907)
This make the test excercise the window recreation logic, that resulted
in several bugs - see #4862

Adds a check box that turns the close button on and off for child
windows
2024-08-26 08:49:25 +02:00
Andreas Reich 9a1e358a14
Update to wgpu 22.1 (#4964)
Updates to wgpu 22.1, removing a workaround that was needed for wgpu
22.0
2024-08-16 13:29:40 +02:00
Arthur Brussee 1f6ae49a5f
Unpin & upgrade winit to 0.30.5 (#4939)
This updates winit to 0.30.5. 

https://github.com/emilk/egui/pull/4849 Had to pin the version to
0.30.2, as a Winit patch changed the behavior of selecting a theme.
Winit 0.30.5 reverts this, so we could stick with `window.theme()`, but
the newly added `ActiveEventLoop::system_theme` is more like what egui
wants anyway, as individual windows can have theme overrides.

Also bump `smithay-clipboard` to prevent some now duplicate
dependencies.
2024-08-09 09:15:14 +02:00
Tau Gärtli 2dac4a4fc6
Follow the System Theme in egui (#4860)
* Some initial progress towards #4490

This PR just moves `Theme` and the "follow system theme" settings to
egui and adds `RawInput.system_theme`.
A follow-up PR can then introduce the two separate `dark_mode_style` and
`light_mode_style` fields on `Options`.


<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->


* [x] I have followed the instructions in the PR template


### Breaking changes

The options `follow_system_theme` and `default_theme` has been moved
from `eframe` into `egui::Options`, settable with `ctx.options_mut`

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-08-06 20:17:51 +02:00
PrimmR ed0254288a
Update `Button` to correctly align contained image (#4891)
Similar to #4889

Updated the `ui` method of the `Button` widget so that the alignment
given by the layout is applied to the image contained in the button (if
one exists).

Currently, only the text inside the button has alignment applied to it,
and only when it is not accompanied by an image or shortcut text. Images
within buttons are always aligned to the centre left, no matter the
alignment of the containing `Ui`. This update now also applies this
alignment to an image when it has no accompanying text, which makes
buttons with an image and no text more consistent with the appearance of
ones with text and no image.

I've also made an additional change so that the vertical alignment is
now also respected when displaying some combination of image and text,
but the original horizontal alignment remains the same, so that the
image always appears left of the text. Any shortcut text now also
follows vertical alignment, but is always horizontally aligned to the
right.

Here are some comparisons of the difference between how buttons look
with different alignments, before and after this change:

### Before

![Before](https://github.com/user-attachments/assets/b5086ccb-765d-42e6-88a5-8fa427544568)

### After

![After](https://github.com/user-attachments/assets/ecf6c6aa-b1b9-4b45-be44-8c71665df5c3)

* [x] I have followed the instructions in the PR template
2024-08-05 11:19:20 +02:00
rustbasic 76fe6c855b
Fix: Backspace not working after IME input (#4912)
Fix: Changed the handling method of `Ime::Preedit(_, None)`

Fix: backspace fail after ime input

* Related #4358
* Related #4430 
* Related #4436
* Related #4794 
* Related #4896
* Closes #4908 

Issues: backspace fail after ime input
* #4908 (Chinese)

Changed the handling method of `Ime::Preedit(_, None)`
2024-08-05 11:09:51 +02:00
Tau Gärtli 71dbc48818
Fix missing `winit` feature in `egui_glow` (#4916)
Since #4849, running `./scripts/check.sh` fails with:
```
...

error[E0277]: the trait bound `ActiveEventLoop: raw_window_handle::borrowed::HasDisplayHandle` is not satisfied
  --> crates/egui_glow/src/winit.rs:43:13
   |
43 |             event_loop,
   |             ^^^^^^^^^^ the trait `raw_window_handle::borrowed::HasDisplayHandle` is not implemented for `ActiveEventLoop`
   |
   = help: the following other types implement trait `raw_window_handle::borrowed::HasDisplayHandle`:
             raw_window_handle::borrowed::DisplayHandle<'a>
             &H
             &mut H
   = note: required for the cast from `&ActiveEventLoop` to `&dyn raw_window_handle::borrowed::HasDisplayHandle`
```

This PR adds the missing `rwh_06` to the winit dependency (in
egui-glow).

* [x] I have followed the instructions in the PR template
2024-08-05 11:06:42 +02:00
Emil Ernerfeldt d856f7b3a5 Fix typos 2024-07-31 18:49:08 +02:00
Emil Ernerfeldt 8dc2ba2fe9 Refactor: add `TitleBar::new` in `window.rs` 2024-07-31 18:44:05 +02:00
Ardocrat dfbc7f0d19
Fix iOS compilation of eframe (#4851)
Fixed changed the name of function `WinitApp::get_window_winit_id` to
`WinitApp::window_id_from_viewport_id` and missed `egui::ViewportId`
import.
2024-07-31 10:18:18 +02:00
lucasmerlin c5bea3113e
Make `scroll_to_*` animations configurable (#4305)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to add commits to your PR.
* Remember to run `cargo fmt` and `cargo cranky`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

* Closes #4295

I based this on #4303, I'll rebase once that one gets merged.
2024-07-31 09:54:29 +02:00
Alex Pinkus ae7672e336
Move default fonts to new crate `epaint_default_fonts` (#4853)
This allows license checking tools to omit the OFL and UFL licenses when
`default_fonts` are turned off.

There was some discussion of versioning on the original issue; I have
chosen to label this version as `0.28.1` to match the other crates.
Happy to adjust the version as needed.

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

* Closes <https://github.com/emilk/egui/issues/2321>
* [X] I have followed the instructions in the PR template

---------

Co-authored-by: Alex Pinkus <pinkus@amazon.com>
2024-07-31 09:50:02 +02:00
Arthur Brussee 6f2f006885
Upgrade winit to 0.30.2 (#4849)
* Closes https://github.com/emilk/egui/issues/1918
* Closes https://github.com/emilk/egui/issues/4437
* Closes https://github.com/emilk/egui/issues/4709
* [x] I have followed the instructions in the PR template

Hiya,

I need new winit for a specific fix for a android_native_actvity. There
are already two PRs, but both don't seem to have a lot of movement, or
are entirely complete:

https://github.com/emilk/egui/pull/4466
Seems to have gone stale & is missing some bits.

https://github.com/emilk/egui/pull/4702
Also seems stale (if less so), and is missing a refactor to
run_on_demand. I also *think* the accesskit integration has a mistake
and can't be enabled. I've marked them as a co-author on this as I
started from this branch. (I think! Haven't done that on git before...).

Sorry for the wall of text but just dumping some details / thoughts
here:

- There's an issue with creating child windows in winit 0.30.1 and up on
macOS. The multiple_viewports, "create immediate viewport" example
crashes on anything later 0.30.1, with a stack overflow in unsafe code.
I've create [a winit
issue](https://github.com/rust-windowing/winit/issues/3800), it *might*
already be fixed in 0.31.0 but I can't test as 0.31 will likely require
another refactoring. For now I have just pinned things to 0.30.0 exatly.

- Winit has deprecated run_on_demand, instead requiring the
ApplicationHandler interface. In 0.31.0 run_on_demand is removed. I've
refactored both the integration and the WinitApp trait to follow this
pattern. I've left user_events a bit more opaque, as it seems 0.31.0 is
doing a rework of UserEvents too.

- I've used the new lazy init approach for access kit from this branch
https://github.com/mwcampbell/egui/tree/accesskit-new-lazy-init and
marked Matt as co-author, thanks Matt!

- There was very similair but not quite the same code for run_and_return
and run_and_exit. I've merged them, but looking at the github issues
graveyard it seems vey finnicky. I *hope* this is more robust than
before but it's a bit scary.

- when receiving new_events this also used to check the redraw timing
dictionary. That doesn't seem necesarry so left this out, but that is a
slight behaviour change?

- I have reeneabled serial_windows on macOS. I wondered whether it was
fixed after this PR and does seem to be! However, even before this PR it
seems to work, so maybe winit has sorted things out before that...
Windows also works fine now without the extra hack.

- I've done a very basic test of AccessKit on Windows and screen reader
seems ok but I'm really not knowleadgable enough to say whether it's all
good or not.

- I've tested cargo tests & all examples on Windows & macOS, and ran a
basic Android app. Still, testing native platforms is wel... hard so if
anyone can test linux / iOs / older mac versions / windows 10 would
probably be a good idea!

- For consistencys sake I've made all event like functions in WinitApp
return a `Result<EventResult>`. There's quite a bit of Ok-wrapping now,
maybe too annoying? Not sure.

Thank you for having a look!

# Tested on
* [x] macOS
* [x] Windows
* [x] Wayland (thanks [SiebenCorgie](https://github.com/SiebenCorgie))
* [x] X11 (thanks
[crumblingstatue](https://github.com/crumblingstatue)!,
[SiebenCorgie](https://github.com/SiebenCorgie))


# TODO
* [x] Fix "follow system theme" not working on initial startup (winit
issue, pinning to 0.30.2 for now).
* [x] Fix `request_repaint_after`

---------

Co-authored-by: mwcampbell <mattcampbell@pobox.com>
Co-authored-by: j-axa <josef.axa@gmail.com>
Co-authored-by: DataTriny <datatriny@gmail.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-07-31 09:43:16 +02:00
PrimmR 37b1e1504d
Fix: hint text follows the alignment set on the `TextEdit` (#4889)
Updated the `show_content` method of the `TextEdit` widget so that the
requested text alignment (if any) is also applied to the hint text.

Currently, hint text is always aligned to the top left of the widget,
which may be inconsistent with the actual location of text entered by
the user. I think it's more intuitive for the hint text to be positioned
as if the user had entered the same text themselves.

Here are some comparisons of the difference between how the hint text
and the entered text looks, before and after this change:

### Previous Behaviour

![Prev](https://github.com/user-attachments/assets/8cd7858f-833e-4946-84f1-ff1ede60c64d)


### Updated Behaviour

![Update](https://github.com/user-attachments/assets/2596dd44-d6f9-4376-9012-5b074fc2cdea)

* [x] I have followed the instructions in the PR template
2024-07-30 21:03:52 +02:00
Tyler Stevens 7736192722
Clarified `eframe::run_simple_native()` persistence (#4846)
* [x] I have followed the instructions in the PR template

Clarified that `eframe::run_simple_native()` does in fact save some
state (if persistence is enabled) but does not allow user to save state.
2024-07-30 21:01:10 +02:00
Onè 057033ef34
Fix typos in egui docstrings (#4869)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

* [x] I have followed the instructions in the PR template (less the
self-review using the script as it's only a single word change).
2024-07-30 21:00:47 +02:00
rustbasic 378df03910
Clamp margin values in `Margin::ui` (#4873)
limit margin value in `settings.ui()`.

Issues: If the `window margin` of `settings.ui()` becomes -10.0 or less,
a panic occurs.
2024-07-30 20:11:33 +02:00
Andreas Reich 64d5f948e4
Workaround for wgpu crash when surface is dropped last (#4876)
* Fixes https://github.com/emilk/egui/issues/4874
* Details see https://github.com/gfx-rs/wgpu/pull/6052
2024-07-26 10:10:23 +02:00
Salman Abuhaimed 34db001db1
Force canvas/text input focus on touch for iOS web browsers (#4848) 2024-07-23 18:16:51 +02:00
Simon Niedermayr 56df31ab48
upgrade to wgpu 22.0.0 (#4847)
wgpu changelog: https://github.com/gfx-rs/wgpu/releases/tag/v22.0.0

---------

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2024-07-19 10:05:56 +02:00
frederik-uni b2d74eaef6
Return `ScrollAreaOutput` from `Table::body` (#4829)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

added return ScrollAreaOutput.

This can be used to monitor the scroll progress of a table(usage
example: custom scroll progress bar or lazy loading table)

* [X] I have followed the instructions in the PR template
2024-07-15 20:49:41 +02:00
Xavier Lau 1741f0a51c
Make sure SVGs are crisp (#4823)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

* Closes https://github.com/emilk/egui/issues/3453
* [x] I have followed the instructions in the PR template

I'm fairly new to egui.

I read the code, but I didn't follow the approach mentioned in
https://github.com/emilk/egui/issues/3453#issuecomment-2208255433.

I believe this is an easier way to achieve that, though I'm not certain
if it's the best method.

<img width="760" alt="image"
src="https://github.com/user-attachments/assets/4b3c561f-1c24-446b-9581-a2f4e9858480">

I get really nice svg with this patch.

@emilk Can you please take a look? I really need this!
2024-07-15 20:49:29 +02:00
zk 27e648a335
Add `Rect::scale_from_center` (#4673)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

I find myself wanting this API quite a lot, and I imagine it'll probably
be useful for others.

# What?

This PR adds `Rect::scale` and `Rect::scale2` functions, which work a
lot like `expand`, but instead multiply by a scale.

i.e.
```rs
rect.scale(2.0); // rect is 2x as big, still in same center
rect.scale2(vec2(1.5, 2.0)); // rect is 1.5x as big on x axis, 2.0x as big on y axis. still in same center
```

# Why?

Before this you either had to write this yourself or use a `expand` in a
cumbersome way:
```rs
rect.expand2(vec2(rect.width() * scale.x / 2.0, rect.height() * scale.y / 2.0));
```

I find myself wanting to scale things up by a factor frequently enough,
and it seems like a useful addition to have a multiply-based variant of
`expand`.

I realise this is pretty minor, but it seems useful enough to me!

---------

Co-authored-by: zkldi <20380519+zkldi@users.noreply.github.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-07-15 19:54:35 +02:00
Jan Procházka 0d89e31e3e
Use canvas directly (#4780) 2024-07-15 18:59:15 +02:00
Emil Ernerfeldt cb9f30482f
Move `egui_plot` to its own repo (#4828)
* Part of https://github.com/emilk/egui/issues/4705

`egui_plot` can now be found at https://github.com/emilk/egui_plot
2024-07-15 18:45:19 +02:00
Emil Ernerfeldt 1384410cb4
Revert "Don't specify a patch version of rust in rust-toolchain" (#4827)
Fix Android CI
2024-07-15 15:14:31 +02:00
Emil Ernerfeldt 8d2df5491e
Remove some debug asserts (#4826)
* Closes https://github.com/emilk/egui/issues/4825
2024-07-15 11:20:22 +02:00
v0x0g 1bee7bfefa
Add `Ui::columns_const()` (#4764)
# Changes

- Adds a new function `egui::Ui::columns_const()`, which is the same as
`egui::Ui::columns()` except that it uses a `const` parameter for the
column count.
- Backed by an array `[Ui; NUM_COL] instead of a `Vec<Ui>`, so fewer
allocations
- Inner closure takes in an array reference, instead of a slice
reference. This makes it possible to use pattern destructuring on the
columns, as shown in the example, and makes it more ergonomic to use

# Example

```rust
// ORIGINAL
ui.columns(2, |cols| {
    cols[0].label("one");
    cols[1].label("two");
});


// NEW
ui.columns_const(|[a,b]| {
    a.label("one");
    b.label("two");
});

```

# Checks

- [X] `cargo fmt`
- [X] `cargo clippy`
- [X] `./scripts/check.sh`
- [X] Docs
- [ ] Review
2024-07-15 11:19:34 +02:00