diff --git a/.cargo/config.toml b/embedded/.cargo/config.toml similarity index 100% rename from .cargo/config.toml rename to embedded/.cargo/config.toml diff --git a/Cargo.toml b/embedded/Cargo.toml similarity index 100% rename from Cargo.toml rename to embedded/Cargo.toml diff --git a/README.md b/embedded/README.md similarity index 100% rename from README.md rename to embedded/README.md diff --git a/build.rs b/embedded/build.rs similarity index 100% rename from build.rs rename to embedded/build.rs diff --git a/memory.x b/embedded/memory.x similarity index 100% rename from memory.x rename to embedded/memory.x diff --git a/rust-toolchain.toml b/embedded/rust-toolchain.toml similarity index 100% rename from rust-toolchain.toml rename to embedded/rust-toolchain.toml diff --git a/src/main.rs b/embedded/src/main.rs similarity index 100% rename from src/main.rs rename to embedded/src/main.rs diff --git a/gui b/gui new file mode 160000 index 0000000..12afc17 --- /dev/null +++ b/gui @@ -0,0 +1 @@ +Subproject commit 12afc17f90756988b9011240e6884fa0e3fb48ef diff --git a/simulator/Cargo.toml b/simulator/Cargo.toml new file mode 100644 index 0000000..a08949e --- /dev/null +++ b/simulator/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "gui-test" +version = "0.1.0" +edition = "2021" + +[dependencies] +embedded-graphics = "0.8.1" +embedded-graphics-simulator = "0.7.0" +embedded-layout = "0.4.1" +heapless = "0.8.0" +profont = "0.7.0" +gui = { path = "../gui/" } diff --git a/simulator/src/main.rs b/simulator/src/main.rs new file mode 100644 index 0000000..ae2c4d3 --- /dev/null +++ b/simulator/src/main.rs @@ -0,0 +1,43 @@ +use embedded_graphics::{geometry::Size, pixelcolor::Rgb565}; +use embedded_graphics_simulator::{ + sdl2::Keycode, OutputSettingsBuilder, SimulatorDisplay, SimulatorEvent, Window, +}; + +use gui::*; + +fn main() -> Result<(), core::convert::Infallible> { + let display = SimulatorDisplay::::new(Size::new(240, 320)); + + let output_settings = OutputSettingsBuilder::new().scale(1).build(); + let mut window = Window::new("Hello World", &output_settings); + + let mut gui = Gui::new(display); + + 'running: loop { + gui.draw()?; + window.update(gui.display_ref()); + + for event in window.events() { + match event { + SimulatorEvent::Quit => break 'running, + SimulatorEvent::KeyDown { keycode, .. } => { + let action: GuiAction = match keycode { + Keycode::Left => GuiAction::Left, + Keycode::Right => GuiAction::Right, + Keycode::Up => GuiAction::Up, + Keycode::Down => GuiAction::Down, + Keycode::Return => GuiAction::Select, + Keycode::Backspace => GuiAction::Back, + _ => continue, + }; + + gui = gui.action(action); + gui.fill_black()?; + } + _ => {} + } + } + } + + Ok(()) +}