bevyengine / bevyengine/bevy

Feathers: Allow users to specify format of slider text in a function

Open
#20,905 0 comments 0 reactions 0 assignees View on GitHub
A-UI C-Feature S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

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

https://github.com/user-attachments/assets/ecddaecc-cb64-47dd-8fb5-c5190b81ca2a

The above shows the problem on main. The slider value at whole numbers does not show decimals, making the value jump around.

https://github.com/user-attachments/assets/1f7bc838-8b71-45e5-8549-f76b8dd18bc8

If we instead hardcode the precision in the slider formatting to be 2, it looks like the above.
Better, but still problematic due to the negative sign.

(Change was done here: https://github.com/bevyengine/bevy/blob/main/crates/bevy_feathers/src/controls/slider.rs#L224)

## What solution would you like?

Allow users to choose how to deal with these situations:

Sliders (and perhaps other widgets with similar challenges) could allow users to specify a format function which takes the widget value and outputs a string.

This way users are allowed to make arbitrarily complex formatting choices on a per-widget basis.

## What alternative(s) have you considered?

Having my eyes suffer

## Additional context

Discord chatter: https://discordapp.com/channels/691052431525675048/743663673393938453/1413921549769113714

Contributor guide

Open the contributing guide

Research direction

Start with crates/bevy_feathers/src/controls/slider.rs around line 224, where the current slider text formatting is changed. Trace how the slider value reaches its displayed text and determine the widget API boundaries; done means each slider can use a caller-provided formatting function without the value display jumping or losing the requested precision.

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.