rat_widget/calendar/
event.rs

1use rat_event::{ConsumedEvent, Outcome};
2
3/// Result of event handling.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
5pub enum CalOutcome {
6    /// The given event has not been used at all.
7    Continue,
8    /// The event has been recognized, but there is no state change.
9    /// Further processing for this event may stop.
10    Unchanged,
11    /// The event has been recognized and there is some state change
12    /// due to it. Further processing for this event may stop.
13    /// Rendering the ui is advised.
14    Changed,
15    /// The selection has changed.
16    Selected,
17}
18
19impl ConsumedEvent for CalOutcome {
20    fn is_consumed(&self) -> bool {
21        *self != CalOutcome::Continue
22    }
23}
24
25impl From<Outcome> for CalOutcome {
26    fn from(value: Outcome) -> Self {
27        match value {
28            Outcome::Continue => CalOutcome::Continue,
29            Outcome::Unchanged => CalOutcome::Unchanged,
30            Outcome::Changed => CalOutcome::Changed,
31        }
32    }
33}
34
35impl From<CalOutcome> for Outcome {
36    fn from(value: CalOutcome) -> Self {
37        match value {
38            CalOutcome::Continue => Outcome::Continue,
39            CalOutcome::Unchanged => Outcome::Unchanged,
40            CalOutcome::Changed => Outcome::Changed,
41            CalOutcome::Selected => Outcome::Changed,
42        }
43    }
44}