DioxusLabs / taffy

A high performance rust-powered UI layout library
https://docs.rs/taffy
Other
2.14k stars 110 forks source link

Allow Taffy to be used with f64 values where we currently f32 #332

Open nicoburns opened 1 year ago

nicoburns commented 1 year ago

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

I haven't had a chance to review in detail, but I can answer the f64 question. For a very large scrolling area, the scroll offset would lose precision (ie not even be able to represent an integer scroll offset) around 2^24. On CPU, the speed of doing f64 arithmetic is generally the same as f32.

https://github.com/linebender/xilem/issues/37#issuecomment-1387282971

2^24 is 16,777,216 which seems very high. But I suppose that's not out of the range of a very long scroll region, and of course we also need to be able to represent decimal values.

What solution would you like?

Either:

What alternative(s) have you considered?

Accept that Taffy won't work precisely at large sizes.

Additional context

We might want to think about how this interacts with #225 (which may want to add a pointer or slotmap key value to Dimension)

alice-i-cecile commented 1 year ago

I'm nervous about swapping completely: doubling the memory usage does matter, both in games and on mobile.

nicoburns commented 1 year ago

A couple of notes on this one:

nicoburns commented 1 year ago

https://github.com/servo/servo/issues/29819

Loara commented 6 months ago

Instead to force f32 or f64 values I prefer to allow user to choose any "vector type" T that satisfies the following operations:

In this way you can use Layout also for TUI where dimensions must be integers or for "3D widgets" where instead dimensions are three-dimensional vectors.

test3211234 commented 2 months ago

@Loara What is a 3D widget in TUI? I've never heard of that.