58 lines
1.3 KiB
Rust
58 lines
1.3 KiB
Rust
/// The location of a UI element, in one of a few
|
|
/// possible coordinate systems.
|
|
///
|
|
/// Positive Y always points up,
|
|
/// positive X always points right.
|
|
#[derive(Debug, Clone)]
|
|
pub enum PositionAnchor {
|
|
/// Position of this sprite's center,
|
|
/// relative to the nw corner of the window.
|
|
NwC,
|
|
|
|
/// Position of this sprite's nw corner,
|
|
/// relative to the nw corner of the window.
|
|
NwNw,
|
|
|
|
/// Position of this sprite's ne corner,
|
|
/// relative to the nw corner of the window.
|
|
NwNe,
|
|
|
|
/// Position of this sprite's sw corner,
|
|
/// relative to the nw corner of the window.
|
|
NwSw,
|
|
|
|
/// Position of this sprite's se corner,
|
|
/// relative to the nw corner of the window.
|
|
NwSe,
|
|
|
|
/// Position of this sprite's ne corner,
|
|
/// relative to the ne corner of the window.
|
|
NeNe,
|
|
|
|
/// Position of this sprite's center,
|
|
/// relative to the center of the window.
|
|
CC,
|
|
|
|
/// Position of this sprite's NW corner,
|
|
/// relative to the center of the window.
|
|
CNw,
|
|
}
|
|
|
|
// These offsets are implemented in wgsl shaders.
|
|
|
|
impl PositionAnchor {
|
|
/// Get the uint that represents this anchor mode in shaders
|
|
pub fn to_int(&self) -> u32 {
|
|
match self {
|
|
Self::NwC => 0,
|
|
Self::NwNw => 1,
|
|
Self::NwNe => 2,
|
|
Self::NwSw => 3,
|
|
Self::NwSe => 4,
|
|
Self::NeNe => 5,
|
|
Self::CC => 6,
|
|
Self::CNw => 7,
|
|
}
|
|
}
|
|
}
|