You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pure refactor, extracted from #139. No behavior change.
The layout pass never looks at a pane's contents. All it needs from
`Behavior` are a few numbers, so this gathers them up front into a
`LayoutContext`:
```rust
pub(crate) struct LayoutContext<'a> {
pub gap_width: f32,
pub tab_bar_height: f32,
pub grid_auto_column_count: &'a dyn Fn(usize, Rect, f32) -> usize,
pub tab_auto_selected: &'a Cell<bool>,
}
```
Two consequences:
* Every layout signature loses both its `style` and `behavior` arguments
— `Tiles::layout_tile` goes from 5 parameters to 3.
* The layout code no longer mentions `Pane` at all, so it can lay out a
`Tiles<T>` for any `T`, not only the one the `Behavior` was written for.
#139 needs exactly that.
### Drive-by fix
`Tabs::layout` called `Behavior::on_edit(TabSelected)` from deep inside
the layout recursion. It now reports the auto-selection up through the
`LayoutContext` and the single caller emits the event. Same event, same
conditions — but laying out a tree is no longer a way to trigger
user-visible callbacks, which matters once anything wants to lay out a
tree speculatively.
### Breaking
⚠️ `Linear::layout` is no longer `pub`, matching the other containers.
It took `&mut Tiles` and a `&mut dyn Behavior`, so it was not callable
in practice.
### Testing
`cargo fmt --check`, `cargo clippy --all-features --all-targets` and
`cargo test --all-features` all clean. No new tests: this is intended to
be behavior-preserving, and the existing `test_grid_with_chaos_monkey`
exercises the layout paths.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
0 commit comments