ori_core/
rebuild.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//! Rebuild trait and derive macro.

pub use ori_macro::Rebuild;

use crate::context::RebuildCx;

/// A convenience trait for rebuilding a [`View`](crate::view::View).
///
/// When derived this will detect changes in the fields of the struct and
/// request a rebuild, layout or draw when necessary. This is done by
/// specifying the `#[rebuild(...)]` attribute on the fields of the struct.
/// Valid values are `layout` and `draw`.
///
/// # Example
/// ``` ignore
/// #[derive(Rebuild)]
/// struct MyView {
///     #[rebuild(layout)]
///     size: f32,
///     #[rebuild(draw)]
///     color: Color,
/// }
/// ```
pub trait Rebuild {
    /// Rebuild the view.
    fn rebuild(&self, cx: &mut RebuildCx, old: &Self);
}