* 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.
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`.
<!--
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
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 ?
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
* 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>
This lets users specify the spacing of the grid lines and the axis
labels, as well as when these start to fade out.
New:
* `AxisHints::new_x/new_y` (replaces `::default()`)
* `AxisHints::label_spacing`
* `Plot::grid_spacing`
Previously the `Frame` API only supported picking colors once, and then
adding widgets.
But what if you want to add widgets first, and THEN pick the colors for
the frame? Now you can!
```rs
let frame = Frame::default().inner_margin(4.0).begin(ui);
{
frame.content_ui.label("Inside the frame");
frame.content_ui.label("This too");
}
let response = frame.allocate_space(ui);
if response.hovered() {
frame.frame.stroke = Stroke::new(2.0, Color32::WHITE);
}
frame.paint(ui);
```
If a widgets sense both clicks and drags, we don't know wether or not a
mouse press on it will be a short click or a long drag.
With this PR, `response.dragged` and `response.drag_started` isn't true
until we know it is a drag and not a click.
If the widget ONLY senses drags, then we know as soon as someone presses
on it that it is a drag.
If it is sensitive to both clicks and drags, we don't know until the
mouse moves a bit, or stays pressed down long enough.
This PR also ensures that `response.clicked` and is only true for
widgets that senses clicks.
This can be useful for creating simple plugins for egui.
The state can be stored in the egui data store, or by the user.
An example plugin for painting debug text on screen is provided.
This adds smooth scrolling in egui. This makes scrolling in a
`ScrollArea` using a notched mouse wheel a lot nicer.
`InputState::scroll_delta` has been replaced by
`InputState::raw_scroll_delta` and `InputState::smooth_scroll_delta`.
Addition for <https://github.com/emilk/egui/pull/3847>
In previous one i only fixed crash occurring with Wgpu backend. This
fixes crash with Glow backend as well.
I only tested this change with android so most things i changed are
behind ```#[cfg(target_os = "android")]```.
Both fixes are dirty thought. As
<https://github.com/emilk/egui/pull/3172> says that "The root viewport
is the original viewport, and cannot be closed without closing the
application.". So they break rules i guess? But i can't think about
better solution for now.
Closes <https://github.com/emilk/egui/issues/3861>.
* Closes https://github.com/emilk/egui/issues/3816

Turn off with `style.interaction.multi_widget_text_select`.
There is an API for this in `LabelSelectionState`, but it's pretty
bare-bones.
This became really hairy implementation-wise, but it works decently
well.
# Limitations
* Drag-select to scroll doesn't work
* A selection disappears if you scroll past one of its end-points
* Only the text of labels and links are selectable
## TODO
* [x] An option to turn it off
* [x] An API for querying about the selected text, and to deselect it.
* [x] Scrolling past selection behaves weird
* [x] Shift-click to select a range
This makes all `wgpu` features opt-in for `egui-wgpu` users.
For `eframe`, I opted to enable some `wgpu` features so users can still
use `eframe` without having to also opt-in to extra ewgpu features
(eframe is batteries-included).
Setting `desired_maximum_frame_latency` to a low value should
theoretically lead to lower latency in winit apps using `egui-wgpu`
(e.g. in `eframe` with `wgpu` backend).
* Replaces https://github.com/emilk/egui/pull/3714
* See also https://github.com/gfx-rs/wgpu/pull/4899
----
It seems like `desired_maximum_frame_latency` has no effect on my Mac. I
lowered my monitor refresh-rate to 30Hz to test, and can see no
difference between `desired_maximum_frame_latency` of `0` or `3`.
Before when experimenting with changing the global `DESIRED_NUM_FRAMES`
in `wgpu` I saw a huge difference, so I wonder what has changed.
I verified that `set_maximum_drawable_count` is being called with either
`1` or `2`, but I perceive no difference between the two.
This PR adds the following APIs, which I found to be missing while
working on https://github.com/rerun-io/rerun/pull/4879:
- `Response::decidedly_dragged()`: tests if the corresponding widget is
being decidedly dragged
- `Memory::dragged_id()`: returns the ID of the dragged widget, if any
The `egui_winit::State` contains both the `clipboard` and `allow_ime`,
but these are both private fields. In our implementation we use
`egui_winit` to do most of the lifting, but it would come really in
handy if we could access these values.
Instead of making the fields `pub` we opted for separate get/set
functions, that way calling side can't freely replace any of the values
fully and it's more in line with the style of the rest of the codebase.
---------
Co-authored-by: Marijn Suijten <marijn@traverseresearch.nl>
Co-authored-by: Marijn Suijten <marijns95@gmail.com>
* Closes https://github.com/emilk/egui/issues/3841⚠️ Breaking change!
This defines `response.hovered()` to never be true if any other widget
is being dragged.
If you want to detect if a widget is being hovered while another widget
is being dragged, use the new `response.contains_pointer` instead. This
is necessaert for things like drag-and-drop targets.
Overall, this removes special-casing of non-interactive widgets.
<!--
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!
-->
Added Viewport reinitialization and Window recreation for Android on
resume event.
Closes <https://github.com/emilk/egui/issues/3674>.
https://github.com/emilk/egui/assets/95014675/7bc51ea5-3f63-4422-b5a0-ce8291612982
How text editing behaves depends on what OS we are running on.
`target_os` is a compile-time check, but `ctx.os()` is a runtime check,
that works also on web.
<!--
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 breaking change seems to have snuck in during #3649. Previously it
would never consume these, today it consumes them unconditionally, and
with this change it'll ~~only consume them if egui wants text input~~
never consume them.
This is a blocker for updating our application, sadly :(