From 2b602a65864f8791f59af7eaaf9baa1dbb9ea97b Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Mon, 25 Sep 2023 23:16:27 +0100 Subject: [PATCH 1/8] Text bounds are computed by the layout algorithm and measure func so that given whatever the constraints are text will only wrap after it's used the maximum amount of available horizontal space. However then when the layout size is returned, before the Node size is set the layout coordinates are rounded, sometimes changing the size of the Node. This means that the text may no longer fit the horizontal available space and wrap onto a new line. But since the layout algorithm hasn't alloted any vertical space for this new line, the text on this new line dissappears. The commit adds a flag `no_rounding` to `ContentSize` that tells the layout algorithm not to round the size of the node, avoiding this problem. Rounding is used eliminate pixel wide gaps between nodes that should be touching edge to edge, but this isn't necessary for text nodes as they don't have solid edges. --- crates/bevy_ui/src/layout/mod.rs | 33 +++++++++++++++++++------------ crates/bevy_ui/src/measurement.rs | 18 +++++++++++++++++ crates/bevy_ui/src/widget/text.rs | 4 ++-- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index 90603577b1d65..363d83718774c 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -8,7 +8,7 @@ use bevy_ecs::{ event::EventReader, query::{With, Without}, removal_detection::RemovedComponents, - system::{Query, Res, ResMut, Resource}, + system::{Query, Res, ResMut, Resource, ParamSet}, world::Ref, }; use bevy_hierarchy::{Children, Parent}; @@ -245,12 +245,14 @@ pub fn ui_layout_system( mut ui_surface: ResMut, root_node_query: Query, Without)>, style_query: Query<(Entity, Ref