oops i broke the public api

This commit is contained in:
charburgx 2022-12-19 04:56:28 -06:00
parent c29b80d41e
commit 5473c0f8a0
2 changed files with 21 additions and 5 deletions

View file

@ -267,15 +267,26 @@ impl PaintList {
self.0.is_empty()
}
/// Returns the index of the new [`Shape`] that can be used with `PaintList::set`.
/// Returns the index of the new [`Shape`] at index `z` that can be used with `PaintList::set`.
#[inline(always)]
pub fn add(&mut self, clip_rect: Rect, shape: Shape, z: ZOrder) -> ShapeIdx {
pub fn add_at_z(&mut self, clip_rect: Rect, shape: Shape, z: ZOrder) -> ShapeIdx {
let idx = ShapeIdx(self.0.len());
self.0.push((z, ClippedShape(clip_rect, shape)));
idx
}
pub fn extend<I: IntoIterator<Item = Shape>>(&mut self, clip_rect: Rect, shapes: I, z: ZOrder) {
/// Returns the index of the new [`Shape`] at base z-index that can be used with `PaintList::set`.
#[inline(always)]
pub fn add(&mut self, clip_rect: Rect, shape: Shape) -> ShapeIdx {
self.add_at_z(clip_rect, shape, ZOrder::base())
}
pub fn extend_at_z<I: IntoIterator<Item = Shape>>(
&mut self,
clip_rect: Rect,
shapes: I,
z: ZOrder,
) {
self.0.extend(
shapes
.into_iter()
@ -283,6 +294,10 @@ impl PaintList {
);
}
pub fn extend<I: IntoIterator<Item = Shape>>(&mut self, clip_rect: Rect, shapes: I) {
self.extend_at_z(clip_rect, shapes, ZOrder::base());
}
/// Modify an existing [`Shape`].
///
/// Sometimes you want to paint a frame behind some contents, but don't know how large the frame needs to be

View file

@ -197,12 +197,13 @@ impl Painter {
}
fn add_to_paint_list(&self, shape: Shape) -> ShapeIdx {
self.paint_list().add(self.clip_rect, shape, self.layer.z)
self.paint_list()
.add_at_z(self.clip_rect, shape, self.layer.z)
}
fn extend_paint_list(&self, shapes: impl IntoIterator<Item = Shape>) {
self.paint_list()
.extend(self.clip_rect, shapes, self.layer.z);
.extend_at_z(self.clip_rect, shapes, self.layer.z);
}
fn set_shape_in_paint_list(&self, idx: ShapeIdx, shape: Shape) {