Skip to content

Consider not storing properties of disjoint layout options in the main Style struct #605

@stephanemagnenat

Description

@stephanemagnenat

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

At the moment, the Style struct contains both properties common to all layout options (e.g., margin), but also specific ones to Flexbox, Grid, etc. This feels wrong to me, as it consumes extra memory that is not needed (if I'm not mistaken, the Flexbox properties do not make sense when using a Grid layout).

What solution would you like?

The layout-specific properties could be stored inside inner structs specific to each variant of the Display enum. This would possibly allow to keep each of these inner structs in their own modules, reducing the amount of #[cfg(feature = "...")] needed inside the style top module.

What alternative(s) have you considered?

The current approach can be kept, it doesn't hurt, it just uses a bit of extra memory and makes the Style struct quite big.

Additional context

I am considering using taffy for my own GUI framework, to be open sourced one day if/when it exists enough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions