We plan to store input data for creating automated tests, hence the need
for more serde derives on input related structs.
---------
Co-authored-by: Georg Weisert <georg.weisert@freshx.de>
⚠️ Removes `Context::translate_layer`, replacing it with a sticky
`set_transform_layer`
Adds the capability to scale layers.
Allows interaction with scaled and transformed widgets inside
transformed layers.
I've also added a demo of how to have zooming and panning in a window
(see the video below).
This probably closes#1811. Having a panning and zooming container would
just be creating a new
`Area` with a new id, and applying zooming and panning with
`ctx.transform_layer`.
I've run the github workflow scripts in my repository, so hopefully the
formatting and `cargo cranky` is satisfied.
I'm not sure if all call sites where transforms would be relevant have
been handled. This might also be missing are transforming clipping
rects, but I'm not sure where / how to accomplish that. In the demo, the
clipping rect is transformed to match, which seems to work.
https://github.com/emilk/egui/assets/70821802/77e7e743-cdfe-402f-86e3-7744b3ee7b0f
---------
Co-authored-by: tweoss <fchua@puffer5.stanford.edu>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* 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
Part 1 of 2 of adding a better API for egui_plot's auto-bounds feature.
In this PR:
- change the `Plot` builder struct field to `default_auto_bounds` (was
`auto_bounds`)
- change the `Plot` state field to `auto_bounds` (was `bounds_modified`)
- minor improvements to `Vec2b`
* Part of https://github.com/emilk/egui/issues/3556
## In short
You now almost never need to use `eframe::Frame` - instead use
`ui.input(|i| i.viewport())` for information about the current viewport
(native window), and use `ctx.send_viewport_cmd` to modify it.
## In detail
This PR removes most commands from `eframe::Frame`, and replaces them
with `ViewportCommand`.
So `frame.close()` becomes
`ctx.send_viewport_cmd(ViewportCommand::Close)`, etc.
`frame.info().window_info` is now also gone, replaced with `ui.input(|i|
i.viewport())`.
`frame.info().native_pixels_per_point` is replaced with `ui.input(|i|
i.raw.native_pixels_per_point)`.
`RawInput` now contains one `ViewportInfo` for each viewport.
Screenshots are taken with
`ctx.send_viewport_cmd(ViewportCommand::Screenshots)` and are returned
in `egui::Event` which you can check with:
``` ust
ui.input(|i| {
for event in &i.raw.events {
if let egui::Event::Screenshot { viewport_id, image } = event {
// handle it here
}
}
});
```
### Motivation
You no longer need to pass around the `&eframe::Frame` everywhere.
This also opens the door for other integrations to use the same API of
`ViewportCommand`s.
<!--
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!
-->
Closes <https://github.com/emilk/egui/issues/3474>.
Thanks to `impl From<bool> for Vec2b` one can now shorten some builder
calls, like:
Previous:
```rust
egui::ScrollArea::vertical()
.auto_shrink([false; 2])
```
New:
```rust
egui::ScrollArea::vertical()
.auto_shrink(false)
```
* Functions that take Stroke were updated to take Into<Stroke> to make
them consistent with other Into<Stroke> parameters.
* Vec2 implements DivAssign<f32>, to make it consistent with already
implementing MulAssign<f32> and Div<f32>.
* Vec2::angled() uses sin_cos() rather than an individual sin() and
cos() call for an immeasurable but hypothetical performance improvement.
* Disable the lock_reentry_single_thread() mutex test. Lock()ing twice
on the same thread is not guaranteed to panic.
* Closes <https://github.com/emilk/egui/issues/3419>.
* Move scroll bar spacing settings to a `struct ScrollSpacing`
* Add a demo for changing scroll bar appearance
* Add setting for ScrollBarVisibility in demo
* Add `#[inline]` to a `ScrollArea` builder methods
* Refactor how scroll bar show/hide is computed
* Add support for floating scroll bars
* Tweak color and opacity of the scroll handle
* Allow allocating a fixed size even for floating scroll bars
* Add three pre-sets of scroll bars: solid, thin, floating
* Use floating scroll bars as the default
* Fix id-clash with bidir scroll areas
* Improve demo
* Fix doclink
* Remove reset button from demo
* Fix doclinks
* Fix visual artifact with thin rounded rectangles
* Fix doclink
* typos
* 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
* Allow widget focus change with keyboard arrows
* remove set id function
* docs
* Emilk feedback round 1
* Fix compile error
* undo example
* Move out functions from range to memory.rs
* remove contains range
* Use docstrings
* code cleanup
* Improve candidate logic
* More tweaks
* Less `pub`
---------
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* Fix the "ever-growing height" problem of Strip and Table Demos
Problem
-------
The height of "Table Demo" or "Strip Demo" floating window grows
when the demo app is interacted with. If 'Continuous' mode is enabled
in 'Backend' settings, the window grows irrespectively of user interaction.
Observations
------------
I noticed that [`area_content_ui.min_rect().max.y`][1] is increasing
monotonically with speed 0.5 px/frame.
I also noticed that commenting out `ui.add(crate::egui_github_link_file!());`
[statement][2] in `table_demo.rs` makes the problem disappear.
The "Fix"
---------
I added 0.5 to the height of the row with GitHub link.
This solved the problem.
Closes#3029.
Warning
-------
I failed to find the root cause of the problem.
I don't understand why this change makes the problem disappear.
[1]: 9478e50d01/crates/egui/src/containers/window.rs (L403)
[2]: 9478e50d01/crates/egui_demo_lib/src/demo/table_demo.rs (L114)
* Document `Rect::size`
Other changes:
- `area.rs`: Use existing API.
- `table_demo.rs`: Remove unnecessary call.