mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-27 04:38:49 +00:00
craft-ui: a levelled unit runs half a pixel past its measured width
At its level a unit ran bounded at exactly the width its Count probe measured, so content that took that width could wrap on a rounding. It runs at that width plus measure_tolerance, as other bounded re-runs of measured content do.
This commit is contained in:
@@ -9,6 +9,7 @@ use crate::runtime::layout_memory;
|
||||
use crate::runtime::measure;
|
||||
use crate::runtime::memory::sub;
|
||||
use crate::runtime::pass_state;
|
||||
use craft_behavior::layout_memory::measure_tolerance;
|
||||
use craft_behavior::{Axis, ColumnWidth, Flow, GridCursor, GridMeasure};
|
||||
use egui::{Id, IdMap, Rect, Ui, Vec2};
|
||||
use std::borrow::Cow;
|
||||
@@ -453,6 +454,9 @@ pub fn levelled_unit(ui: &mut Ui, key: Id, levels: usize, mut show: impl FnMut(&
|
||||
Some(width) => {
|
||||
let rtl = Env::of(ui).direction.is_rtl();
|
||||
let bounded = own_room.derive_local(|scoped| scoped.unbounded.0 = false);
|
||||
// Half a pixel past the width the level measured at, as a bounded re-run of a measured body is given:
|
||||
// content that took exactly that width lays out the same here, never wrapping on a rounding.
|
||||
let width = width + measure_tolerance(crate::runtime::egui::scale::pixels_per_point(&ctx));
|
||||
let rect = Flow::new(ui.available_rect_before_wrap(), rtl).span(0.0, width);
|
||||
child::block(ui, Some(rect), child::column_layout(rtl), |ui| {
|
||||
let installed = Env::install_for(ui, bounded);
|
||||
|
||||
Reference in New Issue
Block a user