Skip to content

Refactor compute_layout_with_measure to return LayoutOutput directly#953

Open
josephg wants to merge 1 commit into
DioxusLabs:mainfrom
josephg:compute_layout_refactor
Open

Refactor compute_layout_with_measure to return LayoutOutput directly#953
josephg wants to merge 1 commit into
DioxusLabs:mainfrom
josephg:compute_layout_refactor

Conversation

@josephg
Copy link
Copy Markdown

@josephg josephg commented May 11, 2026

Objective

Fixes #199. This PR aims to make it easier for people using TaffyTree to set the Baseline on layout nodes. Currently its only possible to do this using the lower level API (by making your own tree).

This is a breaking API change, since the signature is part of the public API.

I've also written new tests in tests/hand_written/baseline.rs.

Feedback wanted

This change takes out the implicit call to compute_leaf_layout in compute_child_layout. I've added that call back in a bunch of places - eg in TaffyTree:

    /// Updates the stored layout of the provided `node` and its children
    pub fn compute_layout(&mut self, node: NodeId, available_space: Size<AvailableSpace>) -> Result<(), TaffyError> {
        self.compute_layout_with_measure(node, available_space, |inputs, _, _, style| {
            compute_leaf_layout(inputs, style, |_, _| 0.0, |_, _| Size::ZERO)
        })
    }

I'm not super familiar with the codebase; let me know if this is a mistake.

@nicoburns
Copy link
Copy Markdown
Member

@ickshonpe Does this change make sense to you? It would allow Bevy to integrate baseline alignment into Taffy. And if you want compatibility with the old simpler API then that would involve wrapping your old-style measure function in an explicit call to compute_leaf_layout like in the PR description above.

@ickshonpe
Copy link
Copy Markdown
Contributor

It's definitely definitely something I'd like us to support better in Bevy. I'll make a quick test branch with bevy_ui using this in a little example, shouldn't be complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve support for AlignSelf::Baseline

3 participants