Ui::horizontal_wrapped in bottom-up layout goes down
- Dominant language
- Rust
- Stars
- 30.6k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 72
Description
**Describe the bug**
When you place a `Ui::horizontal_wrapped` inside a bottom-up layout, the wrapped elements end up going down instead of up.
Here's an excerpt of the code:
```rust
ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| {
ui.horizontal_wrapped(|ui| {
...
```
The `...` is mostly a set of buttons that I want to wrap instead of hard-breaking them into two lines.
**To Reproduce**
Steps to reproduce the behavior:
1. Create a `Ui::horizontal_wrapped` inside a bottom-up layout, as above.
2. Fiddle with the panel width to make the contents wrap.
3. Observe that the wrapped elements go down instead of up.
**Expected behavior**
Presumably, in a bottom-up layout a wrapped element would go to the line above instead of the line below.
One might argue `Ui::horizontal_wrapped` resets its layout. Even if this is the case, as best I can tell, *there is no way to achieve the behavior I want*. E.g., manually creating a `Layout` with `Layout::left_to_right(Align::Center).with_main_wrap(true)` still does not give us the ability to wrap upwards.
It appears that `Layout` needs to describe the secondary layout direction, i.e., `left_to_right` and then bottom-up on wrap.
**Screenshots**
The following short video shows the reproduction of the bug:
https://github.com/emilk/egui/assets/3129/79eb1872-da8a-46f3-adcc-f8934bce5b4e
**Desktop (please complete the following information):**
- OS: macOS
- Browser: N/A, I'm using native
- Version: 13.4
Contributor guide
Research direction
Start by tracing Ui::horizontal_wrapped and Layout::bottom_up, then reproduce the issue by resizing the panel until the contents wrap. Done means wrapped elements in a bottom-up layout move to the line above rather than below, while preserving the existing horizontal wrapping behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100