mirror of
https://github.com/storytold/egui.git
synced 2026-11-20 01:22:21 +01:00
* [x] I have followed the instructions in the PR template
Adds `egui::Aligned`, a container that places its contents at a given
`Align2` within the available space of the parent `Ui`, e.g. in the
bottom-right corner.
Since the size of the contents isn't known up front, it remembers the
size from the previous pass. On the first pass the contents are added
invisibly and a new pass is requested with `request_discard`, so there
is no flicker.
```rust
egui::Aligned::new(egui::Align2::RIGHT_BOTTOM).show(ui, |ui| {
ui.label("Bottom right");
let _ = ui.button("Click me");
});
```
Like a `Panel`, `Aligned` reserves space in the parent `Ui` along its
main axis: if the contents are aligned to the end of that axis (e.g. the
bottom of a vertical `Ui`), widgets added afterwards go in the space
*before* them. So you can put something in the bottom-right corner and
keep adding widgets above it:
```rust
egui::Aligned::new(egui::Align2::RIGHT_BOTTOM).show(ui, |ui| {
let _ = ui.button("Bottom right");
});
ui.label("Placed above the button");
```
Rerun uses this to overlay the legend on a plot.
Extracted from Rerun's `re_ui::egui_ext` (where it is called `Group`).
Naming suggestions welcome.
Written by Claude (LLM).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Test apps
Some application to tests various parts of egui and eframe.
At some point it would be nice to have automatic screenshot regression tests for these.