summaryrefslogtreecommitdiffstats
path: root/native/src/widget/operation.rs
blob: 4a075da92f4ca878e6585adccd59a5e996d9792f (plain) (blame)
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
28
29
pub mod focusable;
pub mod scrollable;

pub use focusable::Focusable;
pub use scrollable::Scrollable;

use crate::widget::Id;

pub trait Operation<T> {
    fn container(
        &mut self,
        id: Option<&Id>,
        operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>),
    );

    fn focusable(&mut self, _state: &mut dyn Focusable, _id: Option<&Id>) {}

    fn scrollable(&mut self, _state: &mut dyn Scrollable, _id: Option<&Id>) {}

    fn finish(&self) -> Outcome<T> {
        Outcome::None
    }
}

pub enum Outcome<T> {
    None,
    Some(T),
    Chain(Box<dyn Operation<T>>),
}