haunted

Crates.iohaunted
lib.rshaunted
version0.0.1
created_at2025-06-20 12:14:05.548084+00
updated_at2025-06-20 12:14:05.548084+00
descriptionA haunted GPU-accelerated UI framework
homepage
repositoryhttps://github.com/raphamorim/boo
max_upload_size
id1719508
size64,380
Raphael Amorim (raphamorim)

documentation

README

Haunted

A GPU-accelerated UI framework for Rust, inspired by SwiftUI and built with native Cocoa, Metal, and Swash.

Features

  • Native Cocoa Integration: Direct NSWindow/NSView creation without winit
  • GPU Rendering: Direct Metal integration for high-performance graphics
  • Declarative UI: SwiftUI-inspired API with composable views
  • Text Rendering: Advanced text rendering with Swash
  • Pure Rust: Built entirely in Rust with objc bindings

Quick Start

Add to your Cargo.toml:

[dependencies]
haunted = "0.1"

Create a simple app:

use haunted::{App, ui::*};
use glam::Vec4;

struct MyView;

impl View for MyView {
    fn build(&self) -> Vec<Element> {
        VStack::new(10.0)
            .child(Box::new(Text::new(
                "Hello, Haunted!",
                24.0,
                Vec4::new(1.0, 1.0, 1.0, 1.0),
            )))
            .child(Box::new(Rectangle::new(
                200.0,
                100.0,
                Vec4::new(0.2, 0.6, 1.0, 1.0),
            )))
            .build()
    }
}

fn main() {
    let app = App::new(Box::new(MyView));
    app.run();
}

Architecture

  • App: Main application struct handling the Cocoa event loop
  • HauntedWindow: Custom NSWindow wrapper with Metal integration
  • Renderer: Metal-based GPU renderer with custom shaders
  • TextRenderer: Swash-powered text rasterization
  • UI Components: VStack, HStack, Rectangle, Text

Native Cocoa Integration

Haunted bypasses winit entirely and uses direct Objective-C bindings for:

  • Custom NSWindow and NSView subclasses
  • Native event handling (mouse, keyboard, window events)
  • Direct Metal layer integration
  • Manual NSRunLoop management

This approach provides maximum control and performance while maintaining a pure Rust API.

Examples

Run the basic example:

cargo run --example basic

Requirements

  • macOS (Cocoa/Metal support required)
  • Rust 1.70+

License

MIT

Commit count: 0

cargo fmt