oblivion-desktop/
├── src/
│ └── main.rs # Application entry point
├── docs/ # Documentation
├── Dockerfile # Container definition
├── Cargo.toml # Rust dependencies
├── build.sh # Build script
├── test.sh # Test script
└── run.sh # Run script
The Oblivion SDK provides SwiftUI-like components for building UIs.
use oblivion_ui::components::{Window, VStack, Button, Label};
use oblivion_ui::state::State;
use oblivion_ui::rendering::SDLEngine;
use oblivion_ui::themes::Theme;
fn main() -> Result<(), String> {
// Create reactive state
let counter = State::new(0);
// Create window
let mut window = Window::new("My App".to_string(), 800, 600);
// Create layout
let mut vstack = VStack::new(10.0).padding(20.0);
// Add components
let label = Label::new(counter.binding().map(|x| x.to_string()));
vstack.add_child(Box::new(label));
let button = Button::new("Increment".to_string())
.on_click(move || {
counter.set(counter.get() + 1);
});
vstack.add_child(Box::new(button));
// Set up window
window.add_child(Box::new(vstack));
// Run application
let theme = Theme::default();
let mut engine = SDLEngine::new("My App", 800, 600)?;
engine.run(Box::new(window), &theme)
}let count = State::new(0);
// Update state
count.set(count.get() + 1);let shared_state = State::new("Hello".to_string());
let binding = shared_state.binding();
// Use binding in multiple components- Window: Root container
- VStack: Vertical stack
- HStack: Horizontal stack
- Grid: 2D grid layout
- Panel: Container with border/padding
- Button: Clickable button
- Label: Text display
- Toggle: On/off switch
- Input: Text input field
Components handle events through the on_click, on_toggle, etc. methods:
let button = Button::new("Click me".to_string())
.on_click(|| {
println!("Button clicked!");
});Customize appearance with themes:
let theme = Theme {
primary_color: (255, 0, 0),
background_color: (255, 255, 255),
text_color: (0, 0, 0),
font_size: 14,
};Create custom components by implementing the Component trait:
use oblivion_ui::components::Component;
use oblivion_ui::rendering::Renderer;
use oblivion_ui::themes::Theme;
pub struct MyComponent {
// fields
}
impl Component for MyComponent {
fn render(&self, renderer: &mut dyn Renderer, theme: &Theme) {
// Custom rendering logic
}
fn handle_event(&mut self, event: &Event) {
// Event handling
}
}./build.shcargo build --release./test.shFor ARM64:
rustup target add aarch64-unknown-linux-gnu
cargo build --target aarch64-unknown-linux-gnu- Use
println!for simple debugging - SDL2 provides error messages on failure
- Check the console output for runtime errors
- Keep components small and focused
- Use reactive state for dynamic UIs
- Handle errors gracefully
- Test on multiple screen sizes
- Follow Rust naming conventions