Refactor Spacing into DynamicSpacing using proc macro #20504
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Density tracking issue: #18078
Post-Merge Note: It looks like the enum variant docs aren't showing up correctly. Will work on a fix for this.
This PR refactors our spacing system to use a more flexible and maintainable approach. We've replaced the static
Spacing
enum with a dynamically generatedDynamicSpacing
enum using a proc macro.Enum variants now use a
BaseXX
format, where XX = the pixel value @ default rem size and the default UI density.For example:
CustomSpacing::Base16
would return 16px at the default UI scale & density.I'd love to find another name other than
Base
that is clear (to avoid base_10, etc confusion), let me know if you have any ideas!Changes:
derive_dynamic_spacing
proc macro to generate theDynamicSpacing
enumSpacing
to use the newDynamicSpacing
custom_spacing
function, mapping previous usages to appropriateDynamicSpacing
variantsNew usage example:
vs old usage example:
Release Notes: