Make consts pub

This commit is contained in:
Emil Ernerfeldt 2023-01-26 15:00:40 +01:00
parent 9ad5356cfa
commit 8fac6df249
2 changed files with 6 additions and 24 deletions

View file

@ -124,27 +124,9 @@ impl AreaLayerId {
pub struct ZOrder(pub i32); pub struct ZOrder(pub i32);
impl ZOrder { impl ZOrder {
const BASE: ZOrder = ZOrder(0); pub const BASE: ZOrder = ZOrder(0);
const ABOVE_ALL: ZOrder = ZOrder(i32::MAX); pub const ABOVE_ALL: ZOrder = ZOrder(i32::MAX);
const BELOW_ALL: ZOrder = ZOrder(i32::MIN); pub const BELOW_ALL: ZOrder = ZOrder(i32::MIN);
/// Base z-order, corresponding to a level of 0
#[inline(always)]
pub fn base() -> Self {
Self::BASE
}
/// Maximal z-order - nothing on the same area layer can render above this
#[inline(always)]
pub fn above_all() -> Self {
Self::ABOVE_ALL
}
/// Minimal z-order - nothing on the same area layer can render below this
#[inline(always)]
pub fn below_all() -> Self {
Self::BELOW_ALL
}
/// Directly above /// Directly above
pub fn above(self) -> Self { pub fn above(self) -> Self {
@ -278,7 +260,7 @@ impl PaintList {
/// Returns the index of the new [`Shape`] at base z-index that can be used with `PaintList::set`. /// Returns the index of the new [`Shape`] at base z-index that can be used with `PaintList::set`.
#[inline(always)] #[inline(always)]
pub fn add(&mut self, clip_rect: Rect, shape: Shape) -> ShapeIdx { pub fn add(&mut self, clip_rect: Rect, shape: Shape) -> ShapeIdx {
self.add_at_z(clip_rect, shape, ZOrder::base()) self.add_at_z(clip_rect, shape, ZOrder::BASE)
} }
pub fn extend_at_z<I: IntoIterator<Item = Shape>>( pub fn extend_at_z<I: IntoIterator<Item = Shape>>(
@ -295,7 +277,7 @@ impl PaintList {
} }
pub fn extend<I: IntoIterator<Item = Shape>>(&mut self, clip_rect: Rect, shapes: I) { pub fn extend<I: IntoIterator<Item = Shape>>(&mut self, clip_rect: Rect, shapes: I) {
self.extend_at_z(clip_rect, shapes, ZOrder::base()); self.extend_at_z(clip_rect, shapes, ZOrder::BASE);
} }
/// Modify an existing [`Shape`]. /// Modify an existing [`Shape`].

View file

@ -71,7 +71,7 @@ impl eframe::App for MyApp {
}); });
} }
let base = ZOrder::base(); let base = ZOrder::BASE;
let above = base.above(); let above = base.above();
draw_squares(ui, Vec2::new(0.0, 0.0), base, above); draw_squares(ui, Vec2::new(0.0, 0.0), base, above);