Commit Graph

3006 Commits

Author SHA1 Message Date
Magnus Larsen 21f08afcbb
egui_glow: Only disable sRGB framebuffer on supported platforms (#3994)
This solves a GL_INVALID_ENUM error common on Windows (occurs on my
Windows 10 machine with a GTX 1070 Ti).

<!--
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!
-->

ARB_framebuffer_SRGB is entirely unsupported on WebGL, hence why latest
egui (master branch) doesn't try to disable SRGB framebuffers on wasm32
and this PR's code doesn't even check for ARB_framebuffer_sRGB on
wasm32.

*  For <servo/servo#30782>
2024-02-08 08:54:14 +01:00
Varphone Wong 377f86efb5
egui: Fixed window title bar incorrect handling spacing (#3995)
Currently, the window title bar does not correctly handle the
`item_spacing` and `window_margin`.

* Video snapshot on changing the `item_spacing` and `window_margin`
(master)


[egui-demo-app-incorrect.webm](https://github.com/emilk/egui/assets/1274171/a4e32d43-69b5-44be-a4c3-97b0533147ca)

* Video snapshot on changing the `item_spacing` and `window_margin`
(feature/fix-window-title-bar)


[egui-demo-app-fixed.webm](https://github.com/emilk/egui/assets/1274171/42bbc210-a1f3-4e0a-ab71-d068e58e0e35)
2024-02-07 08:52:46 +01:00
Richard Hozák b35a7dd7de
Add scroll bar visibility option to Table widget (#3981)
There was no way to customize this as ScrollArea gets created inside
Table widget, this exposes the functionality, so scroll bars on tables
can be customized.

<!--
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.
* 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!
-->
2024-02-06 13:28:20 +01:00
AnotherNathan ee7fb47798
add with_taskbar to viewport builder (#3958)
Allows removing the taskbar icon of a viewport.

This can be useful when making an overlay type viewport (window is
always on top).
2024-02-06 13:27:34 +01:00
rustbasic 68eb3db648
Fix high CPU usage on Windows when app is minimized (#3985)
patch #3982
2024-02-06 13:24:49 +01:00
Emil Ernerfeldt 45e9e8df00 PR template: remind contributors to pick good PR titles 2024-02-06 09:22:14 +01:00
Emil Ernerfeldt 8ddd33fc89
README.md: put demo images next to each other 2024-02-06 08:13:37 +01:00
Emil Ernerfeldt 56bf8b79f3 Release 0.26.0 - Text selection in labels 2024-02-05 17:28:10 +01:00
Emil Ernerfeldt b36b3d69a8 Fix markdown formatting of link in docstring 2024-02-05 17:21:12 +01:00
Emil Ernerfeldt 579e84ec93 generate_changelog.py: add option to write it to the changelogs 2024-02-05 16:59:25 +01:00
Emil Ernerfeldt 74f00f9017 Turn repaint_on_widget_change off by default 2024-02-05 15:48:11 +01:00
Emil Ernerfeldt 217e066626
Make `egui_wgpu::renderer` a private module (#3979)
All its contents is exported to the top-level
2024-02-05 15:12:59 +01:00
Emil Ernerfeldt 1858167296
Fix calling request_repaint_after every frame causing immediate repaint (#3978)
* Closes https://github.com/emilk/egui/pull/3925
* Closes #3109
2024-02-05 14:45:49 +01:00
Emil Ernerfeldt d018265587
Wait with showing tooltip until mouse has been still for 300ms (#3977)
You can change this with `style.interaction.tooltip_delay§
2024-02-05 14:35:45 +01:00
Emil Ernerfeldt 28d3c8e2b5 Improve README.md 2024-02-05 14:11:54 +01:00
Emil Ernerfeldt b522200804 Update example screenshots 2024-02-05 13:01:10 +01:00
Emil Ernerfeldt d02491425c
Put all egui crates as workspace crates (#3976)
Second attempty
2024-02-05 12:59:49 +01:00
Emil Ernerfeldt bcebfecb84
Use more workspace dependencies (#3975) 2024-02-05 12:43:58 +01:00
Emil Ernerfeldt a5f3881d59
Add `Spacing::menu_width` (#3973)
Let users pick default menu width
2024-02-05 11:53:24 +01:00
StratusFearMe21 7a6d80cc8c
Pass `ScreenDescriptor` to `egui_wgpu::CallbackTrait::prepare` (#3960)
<!--
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.
* 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!
-->

`glyphon` requires the screen resolution during the `prepare` stage, and
passing that to the callback's `prepare` function seems pretty trivial.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-02-05 11:17:21 +01:00
Dan Lock a5973e5cac
Add `TextureOptions::wrap_mode` (#3954)
Exposes support in both glow and wgpu for texture wrap modes

This would be breaking for manual creations of TextureOptions but would
work with the current TextureOptions::NEAREST and LINEAR without change,
keeping those clamp to edge

I wasn't sure how best to expose the options to the user and added
consts for LINEAR_REPEAT LINEAR_MIRRORED_REPEAT NEAREST_REPEAT
NEAREST_MIRRORED_REPEAT

This does not include wrap mode clamp to border as it worked fine with
glow but with wgpu it panics due to Features
Features(ADDRESS_MODE_CLAMP_TO_BORDER) are required but not enabled on
the device, and I thought it was probably best not to try to enable that
feature, but happy to include that functionality also if that is okay to
be toggled


![image](https://github.com/emilk/egui/assets/5075747/bba71f61-a105-4e5b-b8ce-1083621eb3de)

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-02-05 09:37:05 +01:00
njust a41a04d635
Override text color with stroke selection color for selected cells (#3968)
Closes #3967 


![image](https://github.com/emilk/egui/assets/2380253/4aaa55bd-e6dc-4780-a9b1-14d537d10116)
2024-02-05 09:17:22 +01:00
YgorSouza bfdfb8894d
Fix typos in `crates/egui/src/context.rs` (#3966) 2024-02-05 09:12:01 +01:00
Ivan a6a9501d12
Fix `StripBuilder` not allocating its used space (#3957)
At crates\egui_extras\src\layout.rs :

Allocate allocation_rect instead of max_rect.
Go back from this:
```
let response = self.ui.allocate_rect(max_rect, self.sense);
let response = response.with_new_rect(allocation_rect);
return (used_rect, response)
```

to this:
```
let response = self.ui.allocate_rect(allocation_rect, self.sense);
return (used_rect, response)
```

In order to allocate the

Closes <https://github.com/emilk/egui/issues/3956>.
2024-02-05 08:34:46 +01:00
YgorSouza 1636b6af08
Fix clip rect for plot items (#3955)
Closes <https://github.com/emilk/egui/issues/3865>.
2024-02-05 08:24:49 +01:00
Emil Ernerfeldt 114f820170
`Context::repaint_causes`: `file:line` of what caused a repaint (#3949)
* Basic version of https://github.com/emilk/egui/issues/3931

This adds `Context::repaint_causes` which returns a `Vec<RepaintCause>`,
containing the `file:line` of the call to `ctx.request_repaint()`.

If your application is stuck forever repainting, this could be a useful
tool to diagnose it.
2024-02-02 16:06:37 +01:00
Emil Ernerfeldt c5352cf6c1 Remove profile scope from `tessellate_shape` 2024-02-02 15:53:01 +01:00
Emil Ernerfeldt 60e272f192
Make `egui_plot::PlotItem` a public trait (#3943) 2024-02-02 14:38:35 +01:00
Emil Ernerfeldt 8f2c8664e7
Emilk/revert workspace deps (#3942)
* Closes https://github.com/emilk/egui/issues/3941

Workspace dependencies can be annoying.

If you don't set them to `default-features=false`, then you cannot opt
out of their default features anywhere else, and get warnings if you
try.

So you set `default-features=false`, and then you need to manually opt
in to the default features everywhere else.
Or, as in my case, don't.

I don't have the energy to do this tonight, so I'll just revert.
2024-02-01 21:29:48 +01:00
Emil Ernerfeldt 00cd671ad8 Use workspace dependencies for the egui crates 2024-02-01 20:25:31 +01:00
Emil Ernerfeldt 948db61a8a
Update to puffin 0.19 (#3940)
…and some other smaller crate updates
2024-02-01 20:15:11 +01:00
Emil Ernerfeldt dda9f79838 Remove `version` field for path-dependencies 2024-02-01 20:11:40 +01:00
Emil Ernerfeldt 520b28ce22
Don't make labels focusable by default (#3937)
* Closes https://github.com/emilk/egui/issues/3910
2024-02-01 18:08:36 +01:00
Emil Ernerfeldt 67b796faee
Misc cleanup (#3935)
* Improve docstring
* Nicer welcome gif in README
* Misc cleanup
2024-02-01 17:09:35 +01:00
Emil Ernerfeldt 1db291721f
Parallell tessellation (#3934)
* Part of https://github.com/emilk/egui/issues/1485

This adds a `rayon` feature to `epaint` and `egui` to parallelize
tessellation of large shapes, such as high-resolution plot lines.
2024-02-01 16:27:59 +01:00
Emil Ernerfeldt 8860930ec8
Niche-optimize `Id` so that `Option<Id>` is the same size as `Id` (#3932)
This is an optimization for places that use `Option<Id>`
2024-02-01 12:18:36 +01:00
Emil Ernerfeldt 3a1244f672
Auto-repaint when widgets move or changes id. (#3930)
With this PR, if a widget moves or repaints, egui will automatically
repaint.

Usually this is what you want: if something is moving we should repaint
until it stops moving.

However, this could potentially create false positives in some rare
circumstances, so there is an option to turn it off with
`Options::repaint_on_widget_change`.
2024-02-01 11:33:23 +01:00
YgorSouza d72f92c41d
Add `x11` and `wayland` features to egui-wgpu and egui_glow (#3909)
This allows them to build correctly on Linux by passing one or both of
the features alongside `winit`.

Closes #3492
Closes #2286
2024-01-30 16:55:55 +01:00
Andreas Reich ca513ce241
Plot items now have optional id which is returned in the plot's response when hovered (#3920)
This allows users to check which item the user interacts with in the
plot.



https://github.com/emilk/egui/assets/1220815/1a174b38-8414-49be-a802-d187cd93d154

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-01-30 15:55:56 +01:00
StratusFearMe21 945a69d2f2
Add opacity factor to `TextShape` (#3916)
<!--
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.
* 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!
-->

This PR simply allows you to override the opacity of a Galley when you
draw it on screen. Last year I opened #3548 and some changes were
requested to the PR, but unfortunately school got really busy and I
wasn't able to apply them. This PR supersedes #3548 and applys the
changes requested in that PR

Closes #3548
2024-01-30 15:55:18 +01:00
Emil Ernerfeldt 527f4bfdf6
Expand plot axes thickness to fit their labels (#3921)
Expand the plot axis thickness as the contained plot axis labels get
wider.

This fixes a problem where the plot labels would otherwise get clipped.


![plot-axis-expansion](https://github.com/emilk/egui/assets/1148717/4500a26e-4a11-401d-9e8e-2d98d02ef3b7)
2024-01-30 12:45:27 +01:00
Aufar Zakiev 01597fe1a1
`Response.context_menu` now returns the response of the context menu, if open (#3904)
Hi everyone! It's a great pleasure to work with such a library. It feels
like a breath of fresh air!

**Problem:**

The current implementation of `context_menu` consumes `self` and returns
it. However, the underlying `menu::context_menu` requires only a
reference to `self`, so it is safe to change the `context_menu`
signature.

**Fix:**

1. Change signature to take a ref to `self`. 
2. Return the `Option<InnerResponse<()>>` from the underlying method
call

**Pros:**

1. No `let response =  response.context_menu(|| {...})` pattern
2. Better consistency with other `show`-like methods, as it is in the
`Window::show`
3. Less ownership gymnastics

**Cons:**
1. Breaking change
2. Smth else what I don't see ?

**Additional info:**
- This method is also addressed in [this
PR](https://github.com/emilk/egui/pull/857).
- `check.sh` fails only on `cargo check --quiet -p eframe
--no-default-features --features wgpu` with `"The platform you're
compiling for is not supported by winit"` error, should it be launched
at all ?
2024-01-29 23:07:16 +01:00
Emil Ernerfeldt 8562150e33
Change default plot line thickness from 1.0 to 1.5 (#3918) 2024-01-29 19:23:27 +01:00
Emil Ernerfeldt ab39420c29
Much more accurate `cpu_usage` timing (#3913)
`frame.info.cpu_usage` now includes time for tessellation and rendering,
but excludes vsync and context switching.
2024-01-29 19:12:16 +01:00
Emil Ernerfeldt 6a94f4f5f0
Fix input lag in drag-to-select o labels (#3917)
Introduced in the recent drag-vs-click stuff
2024-01-29 18:06:32 +01:00
Emil Ernerfeldt 21253d844e
Postpone call to get_current_texture (#3914)
This should help slightly with CPU/GPU parallelism when vsync is on.

I also return the time spent on vsync, which can help users figure out
how much CPU wall-time was used on non-vsync stuff
2024-01-29 18:06:21 +01:00
Emil Ernerfeldt 1d1b07c6b2
Turn off text wrapping by default in combo-box popups (#3912)
This trips up a lot of users
2024-01-29 16:09:54 +01:00
YgorSouza 13b59fb0d4
Fix typos (#3899) 2024-01-29 11:16:10 +01:00
Emil Ernerfeldt abd028bad3
Add drag-and-drop APIs with payloads storage (#3887)
* Closes https://github.com/emilk/egui/issues/3882

This adds several methods to make drag-and-drop more ergonomic in egui.

In particular, egui can now keep track of _what_ is being dragged for
you (the _payload_).

Low-level:
* `egui::DragAndDrop` hold the payload during a drag

Mid-level:
* `Response::dnd_set_drag_payload` sets it for drag-sources
* `Response::dnd_hover_payload` and `Response::dnd_release_payload`
reads it for drop-targets

High-level:
* `ui.dnd_drag_source`: make a widget draggable
* `ui.dnd_drop_zone`: a container where things can be dropped

The drag-and-drop demo is now a lot simpler:


https://github.com/emilk/egui/blob/emilk/drag-and-drop/crates/egui_demo_lib/src/demo/drag_and_drop.rs

---------

Co-authored-by: Antoine Beyeler <abeyeler@ab-ware.com>
2024-01-29 11:14:18 +01:00
Andreas Reich 40ed503ebd
Re-try adapter creation if creation with WebGPU enabled fails and WebGL was enabled. (#3895)
* Filed this in relation to the changes here
https://github.com/gfx-rs/wgpu/issues/5142
* Fixes https://github.com/rerun-io/rerun/issues/4915

Draft until fully confirmed this works on Linux Chrome
2024-01-29 11:04:05 +01:00