Call the record's boxes what they are
The offer names are from the protocol before this one, where a widget was drawn twice and the record had to say which drawing was the question. It is asked once now, so offer_part is the part it was asked in, offer_place the place it was asked at, and place where its drawing was put: part, asked and placed. LayoutHolds::frame is a range on the window since the frame became a length of one, and the frame's own entry is the frame_len pin beside it, so it is window; Painter::frame_own goes with it. answers_at had one caller and said less than the line that replaces it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
adbedaf264
commit
a30971e4c5
6 files changed
+67
-71
No files matched your search
+37
-33
@@ -28,9 +28,9 @@ pub(super) struct DrawInfo {
|
||||
pub part: 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 places the answer somewhere else.
|
||||
pub place: [Place; 2],
|
||||
pub offer_place: [Place; 2],
|
||||
/// parent puts the answer somewhere else.
|
||||
pub placed: [Place; 2],
|
||||
pub asked: [Place; 2],
|
||||
/// A frame the parent decided for it on each axis, as a length of the
|
||||
/// window, which the widget's own declaration is a fraction of.
|
||||
pub narrow: [Option<Len>; 2],
|
||||
@@ -44,7 +44,7 @@ impl DrawInfo {
|
||||
/// The axes where the part is the drawing's box outright, which are the
|
||||
/// axes the answer is not placed inside it again.
|
||||
fn fill(&self) -> [bool; 2] {
|
||||
self.place.map(Place::fills)
|
||||
self.placed.map(Place::fills)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,9 +120,13 @@ impl UiRenderState {
|
||||
let Some(root) = self.old_root else { return };
|
||||
let stands = self.active.get(&root).is_some_and(|active| {
|
||||
// Nothing above the root chose anything, so the box it was first
|
||||
// asked about is the whole of its frame.
|
||||
active.answers_at(size, active.offer_part)
|
||||
&& active.holds.contains(size, active.frame, active.offer_part)
|
||||
// asked about is the whole of its frame. Both its answer and its
|
||||
// drawing have to stand in the new window, since nothing above
|
||||
// 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)
|
||||
});
|
||||
if !stands {
|
||||
widgets.needs_redraw.insert(root);
|
||||
@@ -142,8 +146,8 @@ impl UiRenderState {
|
||||
mask: MaskIdx::NONE,
|
||||
frame,
|
||||
part: extent,
|
||||
place: [Place::Within(Part::All); 2],
|
||||
offer_place: [Place::Within(Part::All); 2],
|
||||
placed: [Place::Within(Part::All); 2],
|
||||
asked: [Place::Within(Part::All); 2],
|
||||
narrow: [None; 2],
|
||||
re_asked: false,
|
||||
px,
|
||||
@@ -267,9 +271,9 @@ impl UiRenderState {
|
||||
active.narrow = info.narrow;
|
||||
active.re_asked = info.re_asked;
|
||||
active.answer = Some(answer);
|
||||
active.offer_place = info.offer_place;
|
||||
active.offer_part = part;
|
||||
active.place = info.place;
|
||||
active.asked = info.asked;
|
||||
active.part = part;
|
||||
active.placed = info.placed;
|
||||
active.own_align = align;
|
||||
// A subtree can be reused whole under a different parent -- same box,
|
||||
// same layer, same region node -- and nothing in the drawing says it
|
||||
@@ -328,7 +332,7 @@ impl UiRenderState {
|
||||
mask_region: None,
|
||||
children: Vec::new(),
|
||||
size_deps: Vec::new(),
|
||||
frame_own: [Holds::ANY; 2],
|
||||
window_own: [Holds::ANY; 2],
|
||||
frame_own_len: [None; 2],
|
||||
under: Vec::new(),
|
||||
extent_own: [Holds::ANY; 2],
|
||||
@@ -364,7 +368,7 @@ impl UiRenderState {
|
||||
answer_under,
|
||||
children,
|
||||
size_deps,
|
||||
frame_own,
|
||||
window_own,
|
||||
frame_own_len,
|
||||
under,
|
||||
move_idx,
|
||||
@@ -435,7 +439,7 @@ impl UiRenderState {
|
||||
}
|
||||
});
|
||||
let own_holds = LayoutHolds {
|
||||
frame: frame_own,
|
||||
window: window_own,
|
||||
frame_len,
|
||||
extent: extent_own,
|
||||
extent_len,
|
||||
@@ -465,8 +469,8 @@ impl UiRenderState {
|
||||
mask,
|
||||
frame: UiVec2::FULL_SIZE,
|
||||
part: UiRegion::FULL,
|
||||
place: [Place::Within(Part::All); 2],
|
||||
offer_place: [Place::Within(Part::All); 2],
|
||||
placed: [Place::Within(Part::All); 2],
|
||||
asked: [Place::Within(Part::All); 2],
|
||||
narrow: [None; 2],
|
||||
re_asked: false,
|
||||
px,
|
||||
@@ -482,9 +486,9 @@ impl UiRenderState {
|
||||
extent,
|
||||
frame: info.frame,
|
||||
narrow: info.narrow,
|
||||
place: info.place,
|
||||
offer_place: info.offer_place,
|
||||
offer_part: extent,
|
||||
placed: info.placed,
|
||||
asked: info.asked,
|
||||
part: extent,
|
||||
// Whoever asked writes the answer.
|
||||
answer: None,
|
||||
re_asked: info.re_asked,
|
||||
@@ -626,7 +630,7 @@ impl UiRenderState {
|
||||
if holds.extent_len[n].is_some_and(|pinned| pinned != part.axis(axis).len()) {
|
||||
diag::bump(Counter::OutsidePinnedLen);
|
||||
}
|
||||
if !holds.frame[n].contains(self.output_size.axis(axis))
|
||||
if !holds.window[n].contains(self.output_size.axis(axis))
|
||||
|| holds.frame_len[n].is_some_and(|pinned| pinned != info.frame.axis(axis))
|
||||
{
|
||||
diag::bump(Counter::OutsideFrame);
|
||||
@@ -672,7 +676,7 @@ impl UiRenderState {
|
||||
self.redepth(id, info.depth);
|
||||
let active = self.active.get_mut(&id).unwrap();
|
||||
active.frame = info.frame;
|
||||
active.place = info.place;
|
||||
active.placed = info.placed;
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
{
|
||||
match (moved, has_region_node) {
|
||||
@@ -697,7 +701,7 @@ impl UiRenderState {
|
||||
|
||||
/// Places one child of `at.id` where that widget's own box now has it.
|
||||
fn place_child(&mut self, child: WidgetId, at: &Placing, rsc: &mut dyn UiRsc) {
|
||||
let place = self.active[&child].place;
|
||||
let place = self.active[&child].placed;
|
||||
self.place_in(child, at, place, rsc);
|
||||
}
|
||||
|
||||
@@ -729,8 +733,8 @@ impl UiRenderState {
|
||||
mask: at.mask,
|
||||
frame,
|
||||
part,
|
||||
place,
|
||||
offer_place: active.offer_place,
|
||||
placed: place,
|
||||
asked: active.asked,
|
||||
narrow: active.narrow,
|
||||
re_asked: active.re_asked,
|
||||
px: frame.to_px(at.window),
|
||||
@@ -874,9 +878,9 @@ impl UiRenderState {
|
||||
extent: UiRegion::FULL,
|
||||
frame: UiVec2::FULL_SIZE,
|
||||
narrow: [None; 2],
|
||||
place: [Place::Within(Part::All); 2],
|
||||
offer_place: [Place::Within(Part::All); 2],
|
||||
offer_part: UiRegion::FULL,
|
||||
placed: [Place::Within(Part::All); 2],
|
||||
asked: [Place::Within(Part::All); 2],
|
||||
part: UiRegion::FULL,
|
||||
answer: None,
|
||||
re_asked: false,
|
||||
size,
|
||||
@@ -1113,14 +1117,14 @@ impl UiRenderState {
|
||||
self.draw_inner(id, info, old, rsc);
|
||||
return true;
|
||||
};
|
||||
let (was_answer, was_holds, was_place) = (active.answer, active.holds, active.place);
|
||||
let (was_answer, was_holds, was_place) = (active.answer, active.holds, active.placed);
|
||||
// The question its parent asked, asked again: the same place of the
|
||||
// box the parent was asked in, which is the box the parent's own
|
||||
// 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 asked = self.placing_of(parent, self.active[&parent].offer_part);
|
||||
let (frame, part) = Self::ask_again(active, &asked, active.offer_place);
|
||||
let parent_at = self.placing_of(parent, self.active[&parent].part);
|
||||
let (frame, part) = Self::ask_again(active, &parent_at, active.asked);
|
||||
let info = DrawInfo {
|
||||
layer: active.layer,
|
||||
parent: active.parent,
|
||||
@@ -1130,8 +1134,8 @@ impl UiRenderState {
|
||||
mask: active.parent_mask,
|
||||
frame,
|
||||
part,
|
||||
place: active.offer_place,
|
||||
offer_place: active.offer_place,
|
||||
placed: active.asked,
|
||||
asked: active.asked,
|
||||
narrow: active.narrow,
|
||||
re_asked: false,
|
||||
px: frame.to_px(self.output_size),
|
||||
|
||||
Reference in new issue
Block a user