Merge pull request #1290 from iced-rs/fix/mesh-layer-order
Fix `canvas::Frame` issuing a new layer for `Mesh2D` in `with_clip`
This commit is contained in:
commit
4aece6b776
2 changed files with 32 additions and 16 deletions
|
|
@ -265,12 +265,30 @@ impl Frame {
|
||||||
|
|
||||||
f(&mut frame);
|
f(&mut frame);
|
||||||
|
|
||||||
self.primitives.push(Primitive::Clip {
|
let primitives = frame.into_primitives();
|
||||||
bounds: region,
|
|
||||||
content: Box::new(Primitive::Translate {
|
let (text, meshes) = primitives
|
||||||
translation: Vector::new(region.x, region.y),
|
.into_iter()
|
||||||
content: Box::new(frame.into_geometry().into_primitive()),
|
.partition(|primitive| matches!(primitive, Primitive::Text { .. }));
|
||||||
}),
|
|
||||||
|
let translation = Vector::new(region.x, region.y);
|
||||||
|
|
||||||
|
self.primitives.push(Primitive::Group {
|
||||||
|
primitives: vec![
|
||||||
|
Primitive::Translate {
|
||||||
|
translation,
|
||||||
|
content: Box::new(Primitive::Group { primitives: meshes }),
|
||||||
|
},
|
||||||
|
Primitive::Translate {
|
||||||
|
translation,
|
||||||
|
content: Box::new(Primitive::Clip {
|
||||||
|
bounds: region,
|
||||||
|
content: Box::new(Primitive::Group {
|
||||||
|
primitives: text,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -308,7 +326,13 @@ impl Frame {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Produces the [`Geometry`] representing everything drawn on the [`Frame`].
|
/// Produces the [`Geometry`] representing everything drawn on the [`Frame`].
|
||||||
pub fn into_geometry(mut self) -> Geometry {
|
pub fn into_geometry(self) -> Geometry {
|
||||||
|
Geometry::from_primitive(Primitive::Group {
|
||||||
|
primitives: self.into_primitives(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn into_primitives(mut self) -> Vec<Primitive> {
|
||||||
if !self.buffers.indices.is_empty() {
|
if !self.buffers.indices.is_empty() {
|
||||||
self.primitives.push(Primitive::Mesh2D {
|
self.primitives.push(Primitive::Mesh2D {
|
||||||
buffers: triangle::Mesh2D {
|
buffers: triangle::Mesh2D {
|
||||||
|
|
@ -319,9 +343,7 @@ impl Frame {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Geometry::from_primitive(Primitive::Group {
|
self.primitives
|
||||||
primitives: self.primitives,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,3 @@ impl Geometry {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Geometry> for Primitive {
|
|
||||||
fn from(geometry: Geometry) -> Primitive {
|
|
||||||
geometry.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue