DioxusLabs / DioxusLabs/taffy

Support `Display::Contents`

Open
#533 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
3.6k
Forks
222
Avg merge
10h 41m
Merged PRs (30d)
40

Description

## What problem does this solve or what need does it fill?

`Display::Contents` is useful when you want to toggle between layouts which require different tree structures without actually altering the tree structure.

Requested in https://github.com/bevyengine/bevy/issues/9731

## What solution would you like?

- Add a `Display::Contents` variant to the `Display` enum
- Alter the children iterator of the `Taffy` tree implementation to check each Node's `Display` property, an recurse into children that are set to `Display::Contents`, returning those grandchildren (and great-grandchildren, etc in the case that any of the grandchild nodes are themselves set to `Display::Contents` *instead* of the child itself.
- Process the `Display::Contents` child itself by setting it to a zero layout.
- I believe that this can be implemented entirely in the tree/storage layer (and the "dispatch" function that switches between algorithms) and the layout algorithm's themselves should not need any changes.

## What alternative(s) have you considered?

Don't support `Display::Contents` and require users of Taffy to alter their tree structure if they want to achieve a similar effect.

## Additional context

As the implementation is in the tree/storage layer, users of Taffy implementing custom tree/storage layers will have to implement this themselves. Implementing `Display::Contents` also requires the tree/storage layer to be able to access non-direct child nodes, so custom tree/storage that can only access direct children may not be to implement this.

Contributor guide

Open the contributing guide

Research direction

Start by locating the Display enum, the Taffy tree's children iterator, and the dispatch function that switches between layout algorithms. Trace how tree and storage layers expose descendants, then verify that Display::Contents descendants participate in layout while the wrapper receives a zero layout without requiring algorithm changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.