Open nicoburns opened 1 year ago
I'm nervous about swapping completely: doubling the memory usage does matter, both in games and on mobile.
A couple of notes on this one:
f64
for computation but still store f32
. We'd need to benchmark, but I'd guess at f32
-> f64
conversion being cheap enough for this to be viable. If we turn Style
into a trait then implementors of the API could choose how much precision they wish to store.calc()
requires very large values which must therefore be boxed or similar likely requiring a usize
sized value. We could potentially work around this by using a truncated index into a Vec
/SlotMap
or similar. But SlotMap
doesn't currently support smaller keys either (https://github.com/orlp/slotmap/issues/52) so we might need to implement our own storage. Also, if we use an index we'll need to carefully manage the lifecycle of the calc expressions, as it would be easy to leak them.Instead to force f32
or f64
values I prefer to allow user to choose any "vector type" T
that satisfies the following operations:
T
types;T
type and a scalar T::Scalar
type (by default f64
).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.
@Loara What is a 3D widget in TUI? I've never heard of that.
What problem does this solve or what need does it fill?
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)