ViewKit provides the same Rust and C UI runtime on mochiOS, Linux, and Windows.
The repository is self-contained for desktop builds: Linux and Windows use the
shared winit/softbuffer backend and fonts installed on the host system.
Linux supports both Wayland and X11.
Add ViewKit directly from its Git repository:
[dependencies]
viewkit = { git = "https://github.com/mochiOS/ViewKit.git" }Then create an application:
use viewkit::prelude::*;
struct Hello;
impl App for Hello {
type Body = Text;
fn new() -> Self {
Self
}
fn window(&self) -> WindowOptions {
WindowOptions::new("Hello ViewKit").size(640.0, 400.0)
}
fn body(&self, _context: &ViewContext) -> Self::Body {
Text::new("Hello from ViewKit")
}
}
fn main() -> Result<(), ViewKitError> {
viewkit::run::<Hello>()
}Run it normally on Linux or Windows:
cargo runcargo build --release
cargo run --example buttonGenerating the C header additionally requires cbindgen:
cargo install --force cbindgen
./scripts/generate.shmochiOS has no system font service, so its build supplies font files explicitly
through VIEWKIT_UI_FONT_PATH and VIEWKIT_MONOSPACE_FONT_PATH. Desktop users do
not need these variables or the surrounding mochiOS source tree.
Please see the LICENSE file.