Divide by UiScale when converting UI coordinates from physical to logical#8720
Divide by UiScale when converting UI coordinates from physical to logical#8720cart merged 14 commits intobevyengine:mainfrom
UiScale when converting UI coordinates from physical to logical#8720Conversation
…rojection matrix for the UI camera.
UiScale when calculating UI logical coordinates
UiScale when calculating UI logical coordinatesUiScale when converting from physical to logical coordinates
UiScale when converting from physical to logical coordinatesUiScale when converting UI coordinates from physical to logical
|
@ickshonpe can you resolve conflicts? I think this is likely to get merged preferentially. |
Yep done. This seems like the right approach. Once users have set up their window and set I can't see where there are any tangible benefits from the extra precision using f64s for the scaling, I think that's one of the first things we should deal with after 0.11 is done. I'll make an issue. |
|
Checked all the examples and they all seem fine. Just going to fix up the |
Added an extract parameter for `UiScale`. The window's logical size is now divided by `UiScale::scale` to calculate the logical size of the UI's viewport for the border thickness resolution calculations. `viewport_debug` Doubled the physical resolution of the window for this example and set `UiScale` to `2.` so the logical size of the UI's viewport remains the same. Also simplified this example by instead of spawning and despawning the two different uinode trees on state changes, using the `Display` style property to disable the trees one at a time.
|
Updated Shouldn't be any other problems. |
Divide cursor postion by UiScale, not multiply.
Renamed `logical_viewport_size` to `ui_logical_viewport_size` to be extra explicit. Added a comment explaining why we have to divide by `UiScale` here.
cart
left a comment
There was a problem hiding this comment.
This looks good to me / seems like the right fixes.
Objective
After the UI layout is computed when the coordinates are converted back from physical coordinates to logical coordinates the
UiScaleis ignored. This results in a confusing situation where we have two different systems of logical coordinates.Example:
result:
We asked for a 100x100 UI node but the Node's size is multiplied by the value of
UiScaleto give a logical size of 400x400.Solution
Divide the output physical coordinates by
UiScaleinui_layout_systemand multiply the logical viewport size byUiScalewhen creating the projection matrix for the UI'sExtractedViewinextract_default_ui_camera_view.Changelog
UiScalewhen converting them back to logical coordinates. The logical size of Ui nodes now matches the values given to their size constraints.UiScalebefore creating the projection matrix for the UI'sExtractedViewinextract_default_ui_camera_view.ui_focus_systemthe cursor position returned fromWindowis divided byUiScale.Node::physical_sizeandNode::physical_rect.viewport_debugnow uses aUiScaleof 2. to ensure that viewport coordinates are working correctly with a non-unitUiScale.Migration Guide
Physical UI coordinates are now divided by both the
UiScaleand the window's scale factor to compute the logical sizes and positions of UI nodes.This ensures that UI Node size and position values, held by the
NodeandGlobalTransformcomponents, conform to the same logical coordinate system as the style constraints from which they are derived, irrespective of the currentscale_factorandUiScale.