nuit_core/compose/gesture/
gesture.rs

1use crate::{Bind, Context, GestureEvent, GestureNode, IdPath};
2
3/// A composable gesture.
4pub trait Gesture: Bind {
5    type Body: Gesture = NeverGesture;
6
7    fn body(&self) -> Self::Body {
8        panic!("Gesture does not have a body!")
9    }
10
11    fn fire(&self, event: &GestureEvent, event_path: &IdPath, context: &Context) {
12        self.bind(context);
13        self.body().fire(event, event_path, context)
14    }
15
16    fn render(&self, context: &Context) -> GestureNode {
17        self.bind(context);
18        self.body().render(context)
19    }
20}
21
22/// A gesture type that can never be constructed.
23pub enum NeverGesture {}
24
25impl Bind for NeverGesture {}
26impl Gesture for NeverGesture {}