diff --git a/src/event.rs b/src/event.rs new file mode 100644 index 0000000..981fc88 --- /dev/null +++ b/src/event.rs @@ -0,0 +1,34 @@ +use crate::key::Key; + +/// Enum defining commands that can be issued by an `Element`. +#[derive(Debug, Clone, PartialEq)] +pub enum Command { + /// Renders the element with the specified state. + Render(usize), + /// Exits the application. + Exit, + /// Updates the element with the specified state. + Event(Event), + /// Pauses execution for the specified duration in milliseconds. + Sleep(u64), +} + +/// Enum representing the possible responses from an element event. +#[derive(Debug, Clone, PartialEq)] +pub enum EventResponse { + /// Indicates that the event is complete. + Done, + /// Indicates no response. + None, + /// Issues a single command. + Command(Command), + /// Issues a list of commands. + CommandList(Vec), +} + +/// Enum representing the possible responses from an element update. +#[derive(Debug, Clone, PartialEq)] +pub enum Event { + Key(Key), + State(usize), +} diff --git a/src/test/mod.rs b/src/test/mod.rs new file mode 100644 index 0000000..1e0d296 --- /dev/null +++ b/src/test/mod.rs @@ -0,0 +1,13 @@ +use crate::{self as osui, rsx, ui::*, val, Element}; + +pub fn app() -> Box { + rsx! { + custom_component { width: val!(20), "" } + } +} + +pub fn custom_component<'a>() -> Box> { + rsx! { + button { style.clicked_background: Color::Red, "test" } + } +}