<!--
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>
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>
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>.
* 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.
* 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.
* 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
![cross-widget-text-selection](https://github.com/emilk/egui/assets/1148717/5582b9d2-8b04-47b7-9637-f48e44064a70)
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>