bevyengine / bevyengine/bevy

Always resolvable `Val` alternative with no `Auto` variant

Open
#9,688 3 comments 1 reaction 0 assignees View on GitHub
A-UI C-Usability
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

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

Val's Auto variant doesn't make sense for certain Style fields, such as the gap properties. In those cases internally `Auto` just gets mapped to Taffy's LengthPercentage::Points(0.)

This might not seem that significant but it's been bothering me intensely the last year. It's never ideal to have multiple representations mapping to the same underlying value like this.

## What solution would you like?

My proposal is PR #8096 which I submitted a while ago. It needs an update to support the recent changes to `Val`, and the macro that implements some of the helper functions could be improved maybe. There wouldn't be any major changes though, so reviews won't be wasted.

Making `Margin`, `Padding` and `Border` into separate types might be controversial. I'm not bothered if we have a generic `UiRect` or `UiRect` (with `Val` edge values) and `NumRect` (with `Num`s) instead. The only important change is adding the always resolvable type.

## What alternative(s) have you considered?

There are some discussions at: https://github.com/bevyengine/bevy/pull/7656, https://github.com/bevyengine/bevy/pull/7969, https://github.com/bevyengine/bevy/pull/7710, https://github.com/bevyengine/bevy/pull/7569.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing PR #8096 against the current Val changes, then read the discussions in PRs #7656, #7969, #7710, and #7569. Done means the relevant Style fields use an always-resolvable type without an Auto variant, with the chosen Margin, Padding, Border, or UiRect design agreed and implemented.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.