Port example 03

This commit is contained in:
2026-03-21 23:37:12 -04:00
parent bc287f615d
commit 0d8bc38113
4 changed files with 570 additions and 1 deletions

View File

@@ -2135,7 +2135,11 @@ fn push_clip_state(stack: &mut Vec<ActiveClip>, active: &mut ActiveClip, region:
active.rounded = Some((region.rect, region.radius));
}
active.rect = if active.rect_active {
intersect_rects(active.rect, Some(region.rect))
if active.rect.is_none() {
None
} else {
intersect_rects(active.rect, Some(region.rect))
}
} else {
Some(region.rect)
};
@@ -2397,4 +2401,47 @@ mod tests {
.is_none()
);
}
#[test]
fn deeper_nested_clip_cannot_revive_empty_parent_clip() {
let mut clip_stack = Vec::new();
let mut active_clip = ActiveClip::default();
push_clip_state(
&mut clip_stack,
&mut active_clip,
ClipRegion {
rect: Rect::new(0.0, 0.0, 100.0, 100.0),
radius: 0.0,
},
);
push_clip_state(
&mut clip_stack,
&mut active_clip,
ClipRegion {
rect: Rect::new(150.0, 150.0, 50.0, 50.0),
radius: 12.0,
},
);
push_clip_state(
&mut clip_stack,
&mut active_clip,
ClipRegion {
rect: Rect::new(160.0, 160.0, 24.0, 12.0),
radius: 8.0,
},
);
assert!(active_clip.rect_active);
assert_eq!(active_clip.rect, None);
assert!(
build_text_vertices(
Point::new(162.0, 162.0),
UiSize::new(16.0, 8.0),
UiSize::new(400.0, 400.0),
active_clip,
)
.is_none()
);
}
}