Skip to content

Sliders: replace Into<f64> with AsPrimitive<f64> - #3260

Merged
hecrj merged 3 commits into
iced-rs:masterfrom
tritoke:tritoke/slider-as-primitive
Jun 1, 2026
Merged

Sliders: replace Into<f64> with AsPrimitive<f64>#3260
hecrj merged 3 commits into
iced-rs:masterfrom
tritoke:tritoke/slider-as-primitive

Conversation

@tritoke

@tritoke tritoke commented Feb 22, 2026

Copy link
Copy Markdown
Contributor

This change is intended to allow the Slider and VerticalSlider structs to work with larger integer types such as u64 and usize.

I had a use case for this on a personal project and @edwloef suggested the change on the discord so I've put up this PR for it.

@hecrj
hecrj force-pushed the tritoke/slider-as-primitive branch from 4fe0960 to b1eeaed Compare March 11, 2026 18:20
@hecrj hecrj added this to the 0.15 milestone Mar 11, 2026
@hecrj hecrj added improvement An internal improvement widget change labels Mar 11, 2026

@hecrj hecrj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@hecrj
hecrj enabled auto-merge March 11, 2026 18:21
@hecrj

hecrj commented Mar 11, 2026

Copy link
Copy Markdown
Member

Although on second thought, I'm not sure we want to pretend that slider can work with all ranges of u64 and usize.

@tritoke

tritoke commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

Although on second thought, I'm not sure we want to pretend that slider can work with all ranges of u64 and usize.

Yeah this was a thought I had as well, I think it might be worth mentioning in the docs that it uses conversions to/from f64 internally so it can represent up to 52(iirc) bits losslessly and the rest is imprecise? From what I can tell if you have multiple ways to control the same value the slider will not overwrite it's value if you have another way to change it. In my case I have a +/- 1 button and. a text entry box which is based on the true value.

I'm not around tonight but I'm happy to add this to the relevant docs if you think it's a good idea.

auto-merge was automatically disabled March 30, 2026 20:56

Head branch was pushed to by a user without write access

@tritoke
tritoke force-pushed the tritoke/slider-as-primitive branch 2 times, most recently from 6af2f1d to 3cb23f3 Compare March 30, 2026 21:27
@tritoke

tritoke commented Mar 30, 2026

Copy link
Copy Markdown
Contributor Author

Took me a hot minute to get round to this but I've added a note to the docs for both mentioning the limitiation and the fact that if you are using any large u? to their limits f64 is not what is stopping you from achieving precision, its the fact you are using a slider lol. Happy to amend the wording ofc

tritoke and others added 2 commits June 1, 2026 13:36
This change is intended to allow the Slider and VerticalSlider structs
to work with larger integer types such as u64 and usize.
@hecrj
hecrj force-pushed the tritoke/slider-as-primitive branch from 3cb23f3 to e323eda Compare June 1, 2026 05:37
@hecrj
hecrj enabled auto-merge June 1, 2026 05:40
@hecrj
hecrj merged commit d52b980 into iced-rs:master Jun 1, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change improvement An internal improvement widget

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants