ailloli_ui_runtime/scene/dirty.rs
1//! Paint-only dirtiness marker for scene work.
2
3/// Whether scene painting is pending.
4///
5/// This one-bit value is independent of retained element dirtiness and does not
6/// schedule work by itself.
7///
8/// # Examples
9///
10/// ```
11/// use ailloli_ui_runtime::scene::DirtyFlags;
12/// assert_eq!(DirtyFlags::default(), DirtyFlags::clean());
13/// ```
14#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
15pub struct DirtyFlags {
16 /// `true` when the scene should be repainted.
17 pub paint: bool,
18}
19
20/// Provides the operations defined for DirtyFlags.
21impl DirtyFlags {
22 /// Returns flags with painting not pending.
23 ///
24 /// # Examples
25 ///
26 /// ```
27 /// use ailloli_ui_runtime::scene::DirtyFlags;
28 /// assert!(!DirtyFlags::clean().paint);
29 /// ```
30 pub const fn clean() -> Self {
31 Self { paint: false }
32 }
33
34 /// Returns flags with painting pending.
35 ///
36 /// # Examples
37 ///
38 /// ```
39 /// use ailloli_ui_runtime::scene::DirtyFlags;
40 /// assert!(DirtyFlags::paint().paint);
41 /// ```
42 pub const fn paint() -> Self {
43 Self { paint: true }
44 }
45}