Use "in front" and "behind" instead of "below" and "above"
This commit is contained in:
parent
cb051425ff
commit
ce2d37d5d9
3 changed files with 42 additions and 32 deletions
|
@ -308,10 +308,11 @@ impl SidePanel {
|
||||||
};
|
};
|
||||||
let resize_x = side.opposite().side_x(rect);
|
let resize_x = side.opposite().side_x(rect);
|
||||||
let resize_x = ui.painter().round_to_pixel(resize_x);
|
let resize_x = ui.painter().round_to_pixel(resize_x);
|
||||||
ui.painter()
|
ui.painter().clone().with_z(layers::ZOrder::FRONT).vline(
|
||||||
.clone()
|
resize_x,
|
||||||
.with_z(layers::ZOrder::ABOVE_ALL)
|
rect.y_range(),
|
||||||
.vline(resize_x, rect.y_range(), stroke);
|
stroke,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inner_response
|
inner_response
|
||||||
|
@ -759,10 +760,11 @@ impl TopBottomPanel {
|
||||||
};
|
};
|
||||||
let resize_y = side.opposite().side_y(rect);
|
let resize_y = side.opposite().side_y(rect);
|
||||||
let resize_y = ui.painter().round_to_pixel(resize_y);
|
let resize_y = ui.painter().round_to_pixel(resize_y);
|
||||||
ui.painter()
|
ui.painter().clone().with_z(layers::ZOrder::FRONT).hline(
|
||||||
.clone()
|
rect.x_range(),
|
||||||
.with_z(layers::ZOrder::ABOVE_ALL)
|
resize_y,
|
||||||
.hline(rect.x_range(), resize_y, stroke);
|
stroke,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inner_response
|
inner_response
|
||||||
|
|
|
@ -127,27 +127,32 @@ impl AreaLayerId {
|
||||||
pub struct ZOrder(pub i32);
|
pub struct ZOrder(pub i32);
|
||||||
|
|
||||||
impl ZOrder {
|
impl ZOrder {
|
||||||
|
/// The default layer 0.
|
||||||
pub const BASE: ZOrder = ZOrder(0);
|
pub const BASE: ZOrder = ZOrder(0);
|
||||||
pub const ABOVE_ALL: ZOrder = ZOrder(i32::MAX);
|
|
||||||
pub const BELOW_ALL: ZOrder = ZOrder(i32::MIN);
|
/// In front of everything else.
|
||||||
|
pub const FRONT: ZOrder = ZOrder(i32::MAX);
|
||||||
|
|
||||||
|
/// Behind everything else.
|
||||||
|
pub const BACK: ZOrder = ZOrder(i32::MIN);
|
||||||
|
|
||||||
/// Directly above
|
/// Directly above
|
||||||
pub fn above(self) -> Self {
|
pub fn in_front(self) -> Self {
|
||||||
self.above_by(1)
|
self.in_front_by(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Directly below
|
/// Directly behind
|
||||||
pub fn below(self) -> Self {
|
pub fn behind(self) -> Self {
|
||||||
self.below_by(1)
|
self.behind_by(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Above by the number of levels given
|
/// In front of by the number of levels given
|
||||||
pub fn above_by(self, levels: i32) -> Self {
|
pub fn in_front_by(self, levels: i32) -> Self {
|
||||||
Self(self.0.saturating_add(levels))
|
Self(self.0.saturating_add(levels))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Below by the number of levels given
|
/// Behind by the number of levels given
|
||||||
pub fn below_by(self, levels: i32) -> Self {
|
pub fn behind_by(self, levels: i32) -> Self {
|
||||||
Self(self.0.saturating_sub(levels))
|
Self(self.0.saturating_sub(levels))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,6 +180,9 @@ impl std::ops::AddAssign<ZOffset> for ZOrder {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Offset within a [`ZOrder`].
|
/// Offset within a [`ZOrder`].
|
||||||
|
///
|
||||||
|
/// * Positive: more in front of.
|
||||||
|
/// * Negative: more behind.
|
||||||
pub type ZOffset = i32;
|
pub type ZOffset = i32;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -222,28 +230,28 @@ impl ZLayer {
|
||||||
Self::from_area_layer_z(self.area_layer, z)
|
Self::from_area_layer_z(self.area_layer, z)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the `ZLayer` directly above this one
|
/// Get the `ZLayer` directly in front of this one.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn above(self) -> Self {
|
pub fn in_front(self) -> Self {
|
||||||
self.with_z(self.z.above())
|
self.with_z(self.z.in_front())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the `ZLayer` above this one by `levels` levels
|
/// Get the `ZLayer` in front of this one by `levels` levels.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn above_by(self, levels: i32) -> Self {
|
pub fn in_front_by(self, levels: i32) -> Self {
|
||||||
self.with_z(self.z.above_by(levels))
|
self.with_z(self.z.in_front_by(levels))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the `ZLayer` directly below this one
|
/// Get the `ZLayer` directly behind this one.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn below(self) -> Self {
|
pub fn behind(self) -> Self {
|
||||||
self.with_z(self.z.below())
|
self.with_z(self.z.behind())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the `ZLayer` below this one by `levels` levels
|
/// Get the `ZLayer` behind this one by `levels` levels.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn below_by(self, levels: i32) -> Self {
|
pub fn behind_by(self, levels: i32) -> Self {
|
||||||
self.with_z(self.z.below_by(levels))
|
self.with_z(self.z.behind_by(levels))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `Id` of underlying area layer
|
/// `Id` of underlying area layer
|
||||||
|
|
|
@ -72,7 +72,7 @@ impl eframe::App for MyApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
let base = ZOrder::BASE;
|
let base = ZOrder::BASE;
|
||||||
let above = base.above();
|
let above = base.in_front();
|
||||||
|
|
||||||
draw_squares(ui, Vec2::new(0.0, 0.0), base, above);
|
draw_squares(ui, Vec2::new(0.0, 0.0), base, above);
|
||||||
draw_squares(ui, Vec2::new(100.0, 0.0), above, base);
|
draw_squares(ui, Vec2::new(100.0, 0.0), above, base);
|
||||||
|
|
Loading…
Reference in a new issue