Crate mkgraphic

Crate mkgraphic 

Source
Expand description

§MKGraphic

A Rust port of the cycfi/elements C++ GUI framework.

MKGraphic provides a lightweight, fine-grained, resolution-independent, modular GUI library. The library is designed to be:

  • Lightweight: Elements are light-weight objects with minimal memory footprint
  • Composable: Elements can be combined and nested to create complex UIs
  • Resolution-independent: Automatically adapts to different screen densities
  • Cross-platform: Supports macOS, Windows, and Linux

§Architecture

The library is organized into several main modules:

  • support: Core types like Point, Rect, Color, and Canvas
  • element: The Element trait and base element types
  • view: Window and view management
  • host: Platform-specific implementations

§Example

use mkgraphic::prelude::*;

fn main() {
    let mut app = App::new();
    let mut window = Window::new("Hello MKGraphic", Extent::new(800.0, 600.0));

    let content = vtile![
        label("Hello, World!"),
        button("Click me!").on_click(|| println!("Clicked!")),
    ];

    window.set_content(share(content));
    window.show();
    app.run();
}

Modules§

element
Element module - the core of the UI framework.
host
Host module for platform-specific implementations.
prelude
Prelude module for convenient imports
support
Support module containing fundamental types and utilities.
view
View module for window and view management.

Macros§

grid
Macro for creating grids.
htile
Macro for creating horizontal tiles.
layer
Macro for creating layers.
vtile
Macro for creating vertical tiles.