bevyengine / bevyengine/bevy

Move `Val` out of `bevy_ui`

Open
#25,327 2 comments 3 reactions 0 assignees View on GitHub
A-Math A-UI C-Usability D-Straightforward S-Needs-Design X-Contentious
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?

It would be much simple if we were using `Val` units for font sizes instead of the `FontSize` type but `bevy_text` can't have a dependency on `bevy_ui`.

Similarly it might make sense to move the gradients types into `bevy_color` but again, `bevy_color` shouldn't depend on `bevy_ui`.

## What solution would you like?

Move `Val` into a crate shared by `bevy_text` and `bevy_ui`.

`bevy_math` probably would make the most sense, but `Val` isn't a purely mathematical type so it's not entirely natural for it to be there either. Perhaps might not be so offensive if it's feature gated?

I'm not determined to put it in `bevy_math`, just unsure where else it could go if not.

It could also be moved into its own crate. Could include the other UI specific responsive geometric types, call it `bevy_ui_math` or something.

## What alternative(s) have you considered?

* Keep `FontSize`. Add more duplicate responsive coords types if we need them.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the existing Val and FontSize types across the bevy_ui and bevy_text crates, then review bevy_math and bevy_color as possible shared-crate boundaries. Compare the proposed shared-crate and dedicated-crate options; done means a crate location and dependency arrangement are agreed without introducing an invalid dependency direction.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.