fix: intersect nested clip bounds with parent layer

This commit is contained in:
Ilia Malanin 2026-07-07 10:55:41 +02:00 • committed by Ashley Wulber
parent b5b2b2fcc3
commit 371dd94a2a

View file

@ -83,13 +83,20 @@ impl<T: Layer> Stack<T> {
/// Pushes a new clipping region in the [`Stack`]; creating a new layer in the
/// process.
pub fn push_clip(&mut self, bounds: Rectangle) {
let bounds = bounds * self.transformation();
let bounds = bounds
.intersection(&self.layers[self.current].bounds())
.unwrap_or(Rectangle {
width: 0.0,
height: 0.0,
..bounds
});
self.previous.push(self.current);
self.current = self.active_count;
self.active_count += 1;
let bounds = bounds * self.transformation();
if self.current == self.layers.len() {
self.layers.push(T::with_bounds(bounds));
} else {