pub struct Layer<K> {
pub key: K,
pub frame: Rectangle,
pub offset: Point,
}Expand description
One render layer used by stack-style presentation.
Fields§
§key: KStable layer key.
frame: RectangleBase frame for the layer.
offset: PointTranslation offset applied during animation.
Implementations§
Source§impl<K> Layer<K>
impl<K> Layer<K>
Sourcepub const fn new(key: K, frame: Rectangle, offset: Point) -> Self
pub const fn new(key: K, frame: Rectangle, offset: Point) -> Self
Creates a layer.
Examples found in repository?
src/stack_view.rs (line 95)
80 pub fn root(frame: Rectangle, title: Localized<'a>) -> Self {
81 let header_height = HEADER_HEIGHT.min(frame.size.height.saturating_sub(1));
82 let header = Rectangle::new(frame.top_left, Size::new(frame.size.width, header_height));
83 let body = Rectangle::new(
84 frame.top_left + Point::new(0, header_height as i32),
85 Size::new(
86 frame.size.width,
87 frame.size.height.saturating_sub(header_height),
88 ),
89 );
90 Self {
91 frame,
92 header,
93 body,
94 layers: StackLayers {
95 base: Layer::new((), body, Point::zero()),
96 overlay: None,
97 },
98 back_button: None,
99 back_title: None,
100 active_title: HeaderTitle {
101 title,
102 center: header.center(),
103 },
104 secondary_title: None,
105 }
106 }More examples
src/stack.rs (line 174)
172 pub fn layers(&self, frame: Rectangle) -> StackLayers<K> {
173 let width = frame.size.width as i32;
174 let idle = Layer::new(self.top(), frame, Point::zero());
175
176 match self.transition {
177 None => StackLayers {
178 base: idle,
179 overlay: None,
180 },
181 Some(Transition::Push {
182 from,
183 to,
184 animation,
185 }) => {
186 let progress = animation.progress_permille();
187 let base = Layer::new(from, frame, Point::zero());
188 let overlay = Layer::new(to, frame, Point::new(lerp_i32(width, 0, progress), 0));
189 StackLayers {
190 base,
191 overlay: Some(overlay),
192 }
193 }
194 Some(Transition::Pop {
195 from,
196 to,
197 animation,
198 }) => {
199 let progress = animation.progress_permille();
200 let base = Layer::new(to, frame, Point::zero());
201 let overlay = Layer::new(from, frame, Point::new(lerp_i32(0, width, progress), 0));
202 StackLayers {
203 base,
204 overlay: Some(overlay),
205 }
206 }
207 }
208 }Sourcepub fn translated_frame(&self) -> Rectangle
pub fn translated_frame(&self) -> Rectangle
Returns the translated frame after applying the current offset.
Examples found in repository?
More examples
Trait Implementations§
impl<K: Copy> Copy for Layer<K>
impl<K: Eq> Eq for Layer<K>
impl<K> StructuralPartialEq for Layer<K>
Auto Trait Implementations§
impl<K> Freeze for Layer<K>where
K: Freeze,
impl<K> RefUnwindSafe for Layer<K>where
K: RefUnwindSafe,
impl<K> Send for Layer<K>where
K: Send,
impl<K> Sync for Layer<K>where
K: Sync,
impl<K> Unpin for Layer<K>where
K: Unpin,
impl<K> UnsafeUnpin for Layer<K>where
K: UnsafeUnpin,
impl<K> UnwindSafe for Layer<K>where
K: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.