use embedded_graphics::primitives::Rectangle;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AppRedraw {
None,
StackMotion,
Interactive,
Full,
}
impl AppRedraw {
pub const fn merge(self, other: Self) -> Self {
match (self, other) {
(Self::Full, _) | (_, Self::Full) => Self::Full,
(Self::StackMotion, _) | (_, Self::StackMotion) => Self::StackMotion,
(Self::Interactive, _) | (_, Self::Interactive) => Self::Interactive,
_ => Self::None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AppNavigation<ViewId> {
Push(ViewId),
Pop,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct ViewResponse<ViewId> {
pub redraw: AppRedraw,
pub navigation: Option<AppNavigation<ViewId>>,
pub captured: bool,
}
impl<ViewId> ViewResponse<ViewId> {
pub const fn none() -> Self {
Self {
redraw: AppRedraw::None,
navigation: None,
captured: false,
}
}
pub const fn redraw(redraw: AppRedraw) -> Self {
Self {
redraw,
navigation: None,
captured: false,
}
}
pub fn push(view: ViewId) -> Self {
Self {
redraw: AppRedraw::None,
navigation: Some(AppNavigation::Push(view)),
captured: true,
}
}
pub const fn pop() -> Self {
Self {
redraw: AppRedraw::None,
navigation: Some(AppNavigation::Pop),
captured: true,
}
}
pub fn with_redraw(mut self, redraw: AppRedraw) -> Self {
self.redraw = self.redraw.merge(redraw);
self
}
pub const fn with_capture(mut self, captured: bool) -> Self {
self.captured = captured;
self
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct AppTouchResult {
pub redraw: AppRedraw,
pub captured: bool,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct StackMotion {
pub header: Rectangle,
pub body: Rectangle,
pub overlay: Rectangle,
}