Add pixel ratio config, document Style/Layout as logical/physical pixels#478
Add pixel ratio config, document Style/Layout as logical/physical pixels#478SimonSapin wants to merge 1 commit into
Conversation
…al pixels Per DioxusLabs#460 (comment) See details in doc-comment changes.
|
This looks good so far. Regarding the conversion point, I think we ought to convert when writing to
I think 1 and 2 are fine. 3 would be a problem, but it can easily be eliminated (by storing the unconverted (logical) computed y position of item in the One potential option is to convert the |
|
This is getting farther from my original motivation in #440 of showing how to use |
Objective
This PR represents the outcome of discussions around how different length units should be interpreted when parsing CSS syntax, in particular #460 (comment). The doc-comment for
set_pixel_ratioinsrc/tree/taffy_tree/tree.rsdetails the proposed design.Context
Previous discussion happened in #440 and #460
Feedback wanted
Documentation and API changes are in this first PR draft, but behavior changes (actually applying the pixel ratio) are not implemented yet. The (style) inputs and and eventual (layout) outputs are to use different units, but at what point should the conversion be done? The reduce bug risk I think intermediate computation (including some public APIs like
SizeAndBaselines,MeasureFunc, and likely others) should all pick one unit or the other but avoid dealing with both at the same time, with conversion kept in a small number of convenience functions or methods.Style. Perhaps in the same APIs that resolve percentages. A downside is that a&Taffyor&TaffyConfigparameter will need to be added to various functions and methods, and all of their call sitesLayoutvalue, or mutating them like rounding does. The latter muddies how we define the meaning of that struct, while the former breaks things ifLayoutever used as an intermediate result for further computation. Is that the case?