Say region and placement, not extent
The split box was named `region` and `placement` on 2026-09-17; `frame` came back as a length and survived, `extent` did not. It stayed as the name for both halves, distinguished only by prose: `draw_at` bound the caller's `part` to a parameter called `extent`, and `ActiveData` held two `UiRegion`s that `draw_at` wrote `part: extent` from. The box a parent asks a widget in is now the region, and where its drawing ends up is its placement. `Painter`'s four holds accumulators become the one `LayoutHolds` they were assembled into, which also drops the name mapping between them. The cold dump of 400 depth-5 trees is byte-identical across the change.
This commit is contained in:
1 parent
84dad211f5
commit
5642f2010a
13 files changed
+212
-227
No files matched your search
+84
-94
@@ -1,10 +1,10 @@
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
use crate::layout_diagnostics::{self as diag, Counter, ReuseOutcome, TimerKind};
|
||||
use crate::ui::painter::{declared_lens, frame_and_extent, placed_extent};
|
||||
use crate::ui::painter::{declared_lens, frame_and_region, placement};
|
||||
use crate::{
|
||||
ActiveData, Axis, DrawLayers, Holds, IdLike, LayoutHolds, LayoutLen, Len, MaskIdx, MoveIdx,
|
||||
Moves, Painter, Part, PixelRegion, Place, PxVec2, Rel, Size, StrongWidget, UiRegion, UiRsc,
|
||||
UiSpan, UiVec2, Weight, WidgetId, Widgets,
|
||||
ActiveData, Axis, DrawLayers, IdLike, LayoutHolds, LayoutLen, Len, MaskIdx, MoveIdx, Moves,
|
||||
Painter, Part, PixelRegion, Place, PxVec2, Rel, Size, StrongWidget, UiRegion, UiRsc, UiSpan,
|
||||
UiVec2, Weight, WidgetId, Widgets,
|
||||
util::{HashMap, Vec2},
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ pub(super) struct DrawInfo {
|
||||
pub frame: UiVec2,
|
||||
/// The box the widget is asked in, in its parent region node's
|
||||
/// coordinates.
|
||||
pub part: UiRegion,
|
||||
pub region: UiRegion,
|
||||
/// Where the widget is put, and where it was asked, as parts of the
|
||||
/// parent's box. See [`Place`]. The two are one ask's place until the
|
||||
/// parent puts the answer somewhere else.
|
||||
@@ -52,7 +52,7 @@ impl DrawInfo {
|
||||
/// drawing is in, and what else one ask of a child is decided from.
|
||||
pub(super) struct Placing {
|
||||
pub id: WidgetId,
|
||||
pub extent: UiRegion,
|
||||
pub region: UiRegion,
|
||||
pub frame: UiVec2,
|
||||
pub window: PxVec2,
|
||||
pub depth: usize,
|
||||
@@ -125,8 +125,8 @@ impl UiRenderState {
|
||||
// it will ask either again.
|
||||
let answer = active
|
||||
.answer
|
||||
.is_some_and(|(_, holds)| holds.contains(size, active.frame, active.part));
|
||||
answer && active.holds.contains(size, active.frame, active.part)
|
||||
.is_some_and(|(_, holds)| holds.contains(size, active.frame, active.region));
|
||||
answer && active.holds.contains(size, active.frame, active.region)
|
||||
});
|
||||
if !stands {
|
||||
widgets.needs_redraw.insert(root);
|
||||
@@ -135,7 +135,7 @@ impl UiRenderState {
|
||||
|
||||
/// The root is asked about in the output. Its own rules narrow both its
|
||||
/// frame and box; nothing above it chose a different one.
|
||||
fn root_info(&self, frame: UiVec2, extent: UiRegion) -> DrawInfo {
|
||||
fn root_info(&self, frame: UiVec2, region: UiRegion) -> DrawInfo {
|
||||
let px = frame.to_px(self.output_size);
|
||||
DrawInfo {
|
||||
layer: 0,
|
||||
@@ -145,7 +145,7 @@ impl UiRenderState {
|
||||
region_node: false,
|
||||
mask: MaskIdx::NONE,
|
||||
frame,
|
||||
part: extent,
|
||||
region,
|
||||
placed: [Place::Within(Part::All); 2],
|
||||
asked: [Place::Within(Part::All); 2],
|
||||
narrow: [None; 2],
|
||||
@@ -196,8 +196,8 @@ impl UiRenderState {
|
||||
let _layout = diag::timer(TimerKind::FullLayout);
|
||||
self.clear(rsc);
|
||||
if let Some(id) = root {
|
||||
let (frame, extent) = Self::root_layout(id.id(), rsc.widgets());
|
||||
let info = self.root_info(frame, extent);
|
||||
let (frame, region) = Self::root_layout(id.id(), rsc.widgets());
|
||||
let info = self.root_info(frame, region);
|
||||
self.draw_inner(id.id(), info, None, rsc);
|
||||
}
|
||||
}
|
||||
@@ -206,7 +206,7 @@ impl UiRenderState {
|
||||
/// rules. Nothing above it narrowed anything or chose where it goes, so
|
||||
/// its declaration is the whole of what decides either.
|
||||
fn root_layout(id: WidgetId, widgets: &Widgets) -> (UiVec2, UiRegion) {
|
||||
frame_and_extent(
|
||||
frame_and_region(
|
||||
UiRegion::FULL,
|
||||
UiVec2::FULL_SIZE,
|
||||
[Place::Within(Part::All); 2],
|
||||
@@ -227,11 +227,11 @@ impl UiRenderState {
|
||||
.as_ref()
|
||||
.or_else(|| self.active.get(&id))
|
||||
.and_then(|a| a.parent);
|
||||
let part = info.part;
|
||||
let region = info.region;
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
{
|
||||
diag::bump(Counter::DrawRequests);
|
||||
diag::draw_request(id, info.parent, part, info.px, info.region_node);
|
||||
diag::draw_request(id, info.parent, region, info.px, info.region_node);
|
||||
}
|
||||
let align = rsc.widgets().alignment(id);
|
||||
let declared = declared_lens(rsc.widgets(), id);
|
||||
@@ -245,23 +245,24 @@ impl UiRenderState {
|
||||
// an answer is kept only with the drawing that gave it, and both
|
||||
// have to hold for the box asked about.
|
||||
let reused = (!stale)
|
||||
.then(|| self.retained_answer(id, part, info))
|
||||
.then(|| self.retained_answer(id, region, info))
|
||||
.flatten()
|
||||
.and_then(|answer| {
|
||||
let extent = placed_extent(part, answer.0, declared, info.fill(), align);
|
||||
self.try_reuse(id, part, extent, info, rsc).map(|()| answer)
|
||||
let placed = placement(region, answer.0, declared, info.fill(), align);
|
||||
self.try_reuse(id, region, placed, info, rsc)
|
||||
.map(|()| answer)
|
||||
});
|
||||
let answer = reused.unwrap_or_else(|| {
|
||||
if old.is_none() {
|
||||
old = self.remove(id, false, rsc);
|
||||
}
|
||||
let answer = self.draw_at(id, part, info, old.take(), rsc);
|
||||
let answer = self.draw_at(id, region, info, old.take(), rsc);
|
||||
// Where the drawing goes: the part its parent gave it, with the
|
||||
// answer placed inside that part on any axis the parent left
|
||||
// open.
|
||||
let extent = placed_extent(part, answer.0, declared, info.fill(), align);
|
||||
if extent != part {
|
||||
self.relocate(id, extent, info, rsc);
|
||||
let placed = placement(region, answer.0, declared, info.fill(), align);
|
||||
if placed != region {
|
||||
self.relocate(id, placed, info, rsc);
|
||||
}
|
||||
answer
|
||||
});
|
||||
@@ -276,7 +277,7 @@ impl UiRenderState {
|
||||
active.re_asked = info.re_asked;
|
||||
active.answer = Some(answer);
|
||||
active.asked = info.asked;
|
||||
active.part = part;
|
||||
active.region = region;
|
||||
active.placed = info.placed;
|
||||
active.own_align = align;
|
||||
// The previous parent must stop owning the subtree before it can
|
||||
@@ -291,27 +292,27 @@ impl UiRenderState {
|
||||
(answer.0, answer.1, drawing_holds)
|
||||
}
|
||||
|
||||
/// Calls a widget's `draw` and keeps what it drew in `extent` of `frame`.
|
||||
/// Calls a widget's `draw` and keeps what it drew in `region` of `frame`.
|
||||
fn draw_at(
|
||||
&mut self,
|
||||
id: WidgetId,
|
||||
extent: UiRegion,
|
||||
region: UiRegion,
|
||||
info: DrawInfo,
|
||||
old: Option<ActiveData>,
|
||||
rsc: &mut dyn UiRsc,
|
||||
) -> (Size, LayoutHolds) {
|
||||
let frame = info.frame;
|
||||
let (move_idx, extent, retired_move) = match info.region_node {
|
||||
let (move_idx, region, retired_move) = match info.region_node {
|
||||
// A node entry is only a translation. Its local box keeps the
|
||||
// same window-unit length as the box in its parent's node.
|
||||
true => (
|
||||
self.move_slot(id, info.parent_move, translation(extent)),
|
||||
local_region(extent),
|
||||
self.move_slot(id, info.parent_move, translation(region)),
|
||||
local_region(region),
|
||||
None,
|
||||
),
|
||||
// Keep the old entry alive until every descendant has migrated.
|
||||
// Reusing its index sooner could make an old parent look current.
|
||||
false => (info.parent_move, extent, self.slots.remove(&id)),
|
||||
false => (info.parent_move, region, self.slots.remove(&id)),
|
||||
};
|
||||
let mask_slot = old
|
||||
.as_ref()
|
||||
@@ -324,8 +325,7 @@ impl UiRenderState {
|
||||
let mut painter = Painter {
|
||||
state: self,
|
||||
frame,
|
||||
extent,
|
||||
extent_len: [None; 2],
|
||||
region,
|
||||
window,
|
||||
mask: info.mask,
|
||||
layer: info.layer,
|
||||
@@ -337,10 +337,8 @@ impl UiRenderState {
|
||||
mask_slot,
|
||||
children: Vec::new(),
|
||||
size_deps: Vec::new(),
|
||||
window_own: [Holds::ANY; 2],
|
||||
frame_own_len: [None; 2],
|
||||
own: LayoutHolds::ANY,
|
||||
under: Vec::new(),
|
||||
extent_own: [Holds::ANY; 2],
|
||||
answer_under: LayoutHolds::ANY,
|
||||
depth: info.depth,
|
||||
move_idx,
|
||||
@@ -362,20 +360,17 @@ impl UiRenderState {
|
||||
state: _,
|
||||
rsc: _,
|
||||
frame: _,
|
||||
extent: _,
|
||||
region: _,
|
||||
window: _,
|
||||
mask,
|
||||
textures,
|
||||
primitives,
|
||||
mask_region,
|
||||
mask_slot,
|
||||
extent_own,
|
||||
extent_len,
|
||||
own,
|
||||
answer_under,
|
||||
children,
|
||||
size_deps,
|
||||
window_own,
|
||||
frame_own_len,
|
||||
under,
|
||||
move_idx,
|
||||
layer,
|
||||
@@ -418,7 +413,7 @@ impl UiRenderState {
|
||||
mask == info.mask
|
||||
|| AXES
|
||||
.into_iter()
|
||||
.all(|axis| within_box(size, extent, self.output_size, axis)),
|
||||
.all(|axis| within_box(size, region, self.output_size, axis)),
|
||||
"'{}' ({id:?}) clips to {px:?} and reports {size}",
|
||||
rsc.widgets().label(id),
|
||||
);
|
||||
@@ -444,21 +439,16 @@ impl UiRenderState {
|
||||
.is_some_and(|len| len.rel != Rel::ZERO);
|
||||
match fraction {
|
||||
true => Some(info.frame.axis(axis)),
|
||||
false => frame_own_len[axis as usize],
|
||||
false => own.frame_len[axis as usize],
|
||||
}
|
||||
});
|
||||
let own_holds = LayoutHolds {
|
||||
window: window_own,
|
||||
frame_len,
|
||||
extent: extent_own,
|
||||
extent_len,
|
||||
};
|
||||
let own_holds = LayoutHolds { frame_len, ..own };
|
||||
let answer_holds = own_holds.and(answer_under);
|
||||
let holds = under
|
||||
.into_iter()
|
||||
.fold(answer_holds, |holds, (_, child)| holds.and(child));
|
||||
debug_assert!(
|
||||
holds.contains(self.output_size, info.frame, extent),
|
||||
holds.contains(self.output_size, info.frame, region),
|
||||
"'{}' ({id:?}) drew in {px:?}, outside the ranges it reported: {holds:?}",
|
||||
rsc.widgets().label(id),
|
||||
);
|
||||
@@ -477,7 +467,7 @@ impl UiRenderState {
|
||||
region_node: false,
|
||||
mask,
|
||||
frame: UiVec2::FULL_SIZE,
|
||||
part: UiRegion::FULL,
|
||||
region: UiRegion::FULL,
|
||||
placed: [Place::Within(Part::All); 2],
|
||||
asked: [Place::Within(Part::All); 2],
|
||||
narrow: [None; 2],
|
||||
@@ -492,12 +482,12 @@ impl UiRenderState {
|
||||
|
||||
let active = ActiveData {
|
||||
id,
|
||||
extent,
|
||||
placement: region,
|
||||
frame: info.frame,
|
||||
narrow: info.narrow,
|
||||
placed: info.placed,
|
||||
asked: info.asked,
|
||||
part: extent,
|
||||
region,
|
||||
// Whoever asked writes the answer.
|
||||
answer: None,
|
||||
re_asked: info.re_asked,
|
||||
@@ -551,7 +541,7 @@ impl UiRenderState {
|
||||
fn retained_answer(
|
||||
&self,
|
||||
id: WidgetId,
|
||||
part: UiRegion,
|
||||
region: UiRegion,
|
||||
info: DrawInfo,
|
||||
) -> Option<(Size, LayoutHolds)> {
|
||||
let active = self.active.get(&id)?;
|
||||
@@ -565,17 +555,17 @@ impl UiRenderState {
|
||||
let answer = active.answer?;
|
||||
answer
|
||||
.1
|
||||
.contains(self.output_size, info.frame, part)
|
||||
.contains(self.output_size, info.frame, region)
|
||||
.then_some(answer)
|
||||
}
|
||||
|
||||
/// Keeps the retained drawing if its contract holds for `part`, the box
|
||||
/// asked about, and puts it at `extent`, where the answer places it.
|
||||
/// asked about, and puts it at `placed`, where the answer places it.
|
||||
fn try_reuse(
|
||||
&mut self,
|
||||
id: WidgetId,
|
||||
part: UiRegion,
|
||||
extent: UiRegion,
|
||||
region: UiRegion,
|
||||
placed: UiRegion,
|
||||
info: DrawInfo,
|
||||
rsc: &mut dyn UiRsc,
|
||||
) -> Option<()> {
|
||||
@@ -630,7 +620,7 @@ impl UiRenderState {
|
||||
// In pixels, because the box is a fraction of the window and that
|
||||
// may be what changed -- an unchanged fraction of a window half the
|
||||
// size is half the widget.
|
||||
if !active.holds.contains(self.output_size, info.frame, part) {
|
||||
if !active.holds.contains(self.output_size, info.frame, region) {
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
{
|
||||
// Which of the three said no, so a frame that redraws more
|
||||
@@ -639,7 +629,7 @@ impl UiRenderState {
|
||||
let holds = active.holds;
|
||||
for axis in AXES {
|
||||
let n = axis as usize;
|
||||
if holds.extent_len[n].is_some_and(|pinned| pinned != part.axis(axis).len()) {
|
||||
if holds.region_len[n].is_some_and(|pinned| pinned != region.axis(axis).len()) {
|
||||
diag::bump(Counter::OutsidePinnedLen);
|
||||
}
|
||||
if !holds.window[n].contains(self.output_size.axis(axis))
|
||||
@@ -647,10 +637,10 @@ impl UiRenderState {
|
||||
{
|
||||
diag::bump(Counter::OutsideFrame);
|
||||
}
|
||||
if !holds.extent[n]
|
||||
.contains(part.axis(axis).len().to_px(self.output_size.axis(axis)))
|
||||
if !holds.region[n]
|
||||
.contains(region.axis(axis).len().to_px(self.output_size.axis(axis)))
|
||||
{
|
||||
diag::bump(Counter::OutsideExtent);
|
||||
diag::bump(Counter::OutsideRegion);
|
||||
}
|
||||
}
|
||||
diag::bump(Counter::ReuseOutside);
|
||||
@@ -658,14 +648,14 @@ impl UiRenderState {
|
||||
}
|
||||
return None;
|
||||
}
|
||||
self.relocate(id, extent, info, rsc);
|
||||
self.relocate(id, placed, info, rsc);
|
||||
Some(())
|
||||
}
|
||||
|
||||
/// Puts a retained drawing where its parent now has it, without drawing:
|
||||
/// a widget with a node of its own writes that node's translation, and
|
||||
/// one without re-expresses its own drawing and everything inside it.
|
||||
fn relocate(&mut self, id: WidgetId, extent: UiRegion, info: DrawInfo, rsc: &mut dyn UiRsc) {
|
||||
fn relocate(&mut self, id: WidgetId, placed: UiRegion, info: DrawInfo, rsc: &mut dyn UiRsc) {
|
||||
let active = &self.active[&id];
|
||||
debug_assert!(
|
||||
!rsc.widgets().needs_redraw.contains(&id),
|
||||
@@ -674,13 +664,13 @@ impl UiRenderState {
|
||||
);
|
||||
let has_region_node = active.move_idx != active.parent_move;
|
||||
let local = match has_region_node {
|
||||
true => local_region(extent),
|
||||
false => extent,
|
||||
true => local_region(placed),
|
||||
false => placed,
|
||||
};
|
||||
let moved = active.extent != local;
|
||||
let moved = active.placement != local;
|
||||
let slot = active.move_idx;
|
||||
if has_region_node {
|
||||
self.moves.set(slot, translation(extent));
|
||||
self.moves.set(slot, translation(placed));
|
||||
}
|
||||
if moved {
|
||||
self.reposition(id, local, info, rsc);
|
||||
@@ -728,9 +718,9 @@ impl UiRenderState {
|
||||
rsc: &mut dyn UiRsc,
|
||||
) {
|
||||
let active = &self.active[&child];
|
||||
let (frame, part) = Self::ask_again(active, at, place);
|
||||
let extent = placed_extent(
|
||||
part,
|
||||
let (frame, region) = Self::ask_again(active, at, place);
|
||||
let placed = placement(
|
||||
region,
|
||||
active.measured().unwrap_or(active.size),
|
||||
active.declared,
|
||||
place.map(Place::fills),
|
||||
@@ -744,14 +734,14 @@ impl UiRenderState {
|
||||
region_node: active.move_idx != active.parent_move,
|
||||
mask: at.mask,
|
||||
frame,
|
||||
part,
|
||||
region,
|
||||
placed: place,
|
||||
asked: active.asked,
|
||||
narrow: active.narrow,
|
||||
re_asked: active.re_asked,
|
||||
px: frame.to_px(at.window),
|
||||
};
|
||||
self.relocate(child, extent, info, rsc);
|
||||
self.relocate(child, placed, info, rsc);
|
||||
}
|
||||
|
||||
/// The frame and the box a widget already drawn is given at `place` of
|
||||
@@ -759,8 +749,8 @@ impl UiRenderState {
|
||||
/// it declared are its own record's, so both are resolved against that
|
||||
/// parent's frame again exactly as the first ask resolved them.
|
||||
fn ask_again(active: &ActiveData, at: &Placing, place: [Place; 2]) -> (UiVec2, UiRegion) {
|
||||
frame_and_extent(
|
||||
at.extent,
|
||||
frame_and_region(
|
||||
at.region,
|
||||
at.frame,
|
||||
place,
|
||||
active.narrow,
|
||||
@@ -773,19 +763,19 @@ impl UiRenderState {
|
||||
/// is placed as a part of that box, so each one's new box is its retained
|
||||
/// part re-added to the new start -- and a child whose own box then did
|
||||
/// not change is not touched at all.
|
||||
fn reposition(&mut self, id: WidgetId, extent: UiRegion, info: DrawInfo, rsc: &mut dyn UiRsc) {
|
||||
fn reposition(&mut self, id: WidgetId, placed: UiRegion, info: DrawInfo, rsc: &mut dyn UiRsc) {
|
||||
let active = self.active.get_mut(&id).unwrap();
|
||||
active.extent = extent;
|
||||
active.placement = placed;
|
||||
for primitive in &active.primitives {
|
||||
let handle = &primitive.handle;
|
||||
*self.layers[handle.layer].region_mut(handle) = primitive.region.within(&extent);
|
||||
*self.layers[handle.layer].region_mut(handle) = primitive.region.within(&placed);
|
||||
}
|
||||
if let Some(mask_region) = active.mask_region {
|
||||
rsc.ui_mut().masks.get_mut(active.mask).region = mask_region.within(&extent);
|
||||
rsc.ui_mut().masks.get_mut(active.mask).region = mask_region.within(&placed);
|
||||
}
|
||||
let at = Placing {
|
||||
id,
|
||||
extent,
|
||||
region: placed,
|
||||
frame: info.frame,
|
||||
window: self.output_size,
|
||||
depth: info.depth,
|
||||
@@ -890,12 +880,12 @@ impl UiRenderState {
|
||||
id,
|
||||
ActiveData {
|
||||
id,
|
||||
extent: UiRegion::FULL,
|
||||
placement: UiRegion::FULL,
|
||||
frame: UiVec2::FULL_SIZE,
|
||||
narrow: [None; 2],
|
||||
placed: [Place::Within(Part::All); 2],
|
||||
asked: [Place::Within(Part::All); 2],
|
||||
part: UiRegion::FULL,
|
||||
region: UiRegion::FULL,
|
||||
answer: None,
|
||||
re_asked: false,
|
||||
size,
|
||||
@@ -1080,7 +1070,7 @@ impl UiRenderState {
|
||||
let active = self.active.get(&id.id())?;
|
||||
active.drawn.then(|| {
|
||||
self.moves
|
||||
.resolve(active.move_idx, active.extent)
|
||||
.resolve(active.move_idx, active.placement)
|
||||
.to_px(self.output_size)
|
||||
})
|
||||
}
|
||||
@@ -1122,10 +1112,10 @@ impl UiRenderState {
|
||||
// box is its own to work out again against the output. Every other
|
||||
// widget was given one.
|
||||
let Some(parent) = active.parent else {
|
||||
let (frame, extent) = Self::root_layout(id, rsc.widgets());
|
||||
let (frame, region) = Self::root_layout(id, rsc.widgets());
|
||||
let info = DrawInfo {
|
||||
mask: active.parent_mask,
|
||||
..self.root_info(frame, extent)
|
||||
..self.root_info(frame, region)
|
||||
};
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
diag::bump(Counter::LocalRedraws);
|
||||
@@ -1139,8 +1129,8 @@ impl UiRenderState {
|
||||
// draw ran in and what its children's parts are of. Where the
|
||||
// parent's answer put its own drawing is not a question anybody
|
||||
// asked, and nothing is asked in it here either.
|
||||
let parent_at = self.placing_of(parent, self.active[&parent].part);
|
||||
let (frame, part) = Self::ask_again(active, &parent_at, active.asked);
|
||||
let parent_at = self.placing_of(parent, self.active[&parent].region);
|
||||
let (frame, region) = Self::ask_again(active, &parent_at, active.asked);
|
||||
let info = DrawInfo {
|
||||
layer: active.layer,
|
||||
parent: active.parent,
|
||||
@@ -1149,7 +1139,7 @@ impl UiRenderState {
|
||||
region_node: rsc.widgets().is_region_node(id),
|
||||
mask: active.parent_mask,
|
||||
frame,
|
||||
part,
|
||||
region,
|
||||
placed: active.asked,
|
||||
asked: active.asked,
|
||||
narrow: active.narrow,
|
||||
@@ -1171,7 +1161,7 @@ impl UiRenderState {
|
||||
active.answer = was_answer;
|
||||
}
|
||||
if active.holds.covers(was_holds)
|
||||
&& was_holds.contains(self.output_size, active.frame, active.extent)
|
||||
&& was_holds.contains(self.output_size, active.frame, active.placement)
|
||||
{
|
||||
active.holds = was_holds;
|
||||
}
|
||||
@@ -1188,20 +1178,20 @@ impl UiRenderState {
|
||||
// The answer stands, so where the parent put it stands: the
|
||||
// fresh drawing goes back there -- the same place, of the box
|
||||
// the parent's answer chose rather than the one it was asked in.
|
||||
let at = self.placing_of(parent, self.active[&parent].extent);
|
||||
let at = self.placing_of(parent, self.active[&parent].placement);
|
||||
self.place_in(id, &at, was_place, rsc);
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
/// A drawn widget as the thing its children are placed within, with
|
||||
/// `extent` as the box their parts are of: the box it was asked in for
|
||||
/// `region` as the box their parts are of: the box it was asked in for
|
||||
/// asking one of them again, the box its answer chose for placing one.
|
||||
fn placing_of(&self, id: WidgetId, extent: UiRegion) -> Placing {
|
||||
fn placing_of(&self, id: WidgetId, region: UiRegion) -> Placing {
|
||||
let active = &self.active[&id];
|
||||
Placing {
|
||||
id,
|
||||
extent,
|
||||
region,
|
||||
frame: active.frame,
|
||||
window: self.output_size,
|
||||
depth: active.depth,
|
||||
@@ -1215,11 +1205,11 @@ impl UiRenderState {
|
||||
/// Both are lengths of the window, so the comparison is in its pixels. A
|
||||
/// share is a length only to whoever divides one, so it is not a claim about
|
||||
/// this box and cannot exceed it.
|
||||
fn within_box(size: Size, extent: UiRegion, window: PxVec2, axis: Axis) -> bool {
|
||||
fn within_box(size: Size, region: UiRegion, window: PxVec2, axis: Axis) -> bool {
|
||||
let len = size.axis(axis);
|
||||
let window = window.axis(axis);
|
||||
len.leftover != Weight::ZERO
|
||||
|| Len::from_parts(len.rel, len.px).to_px(window) <= extent.axis(axis).len().to_px(window)
|
||||
|| Len::from_parts(len.rel, len.px).to_px(window) <= region.axis(axis).len().to_px(window)
|
||||
}
|
||||
|
||||
/// A box in a fresh region node keeps its window-unit length and starts at
|
||||
|
||||
Reference in new issue
Block a user