gpui-ce 0.3.0

A community fork of Zed's GPU-accelerated UI framework
Documentation

GPUI Community Edition

GPUI is a Rust UI framework for macOS, Windows, Linux, and the web. A view builds an element tree for layout, input, and painting; entities hold the application state that views read. After changing state that a view displays, call notify so GPUI can render the windows that depend on it.

GPUI was built by Zed Industries for the Zed editor. GPUI Community Edition is a community-maintained fork for standalone applications.

To try GPUI in a new application, add these dependencies to Cargo.toml and put the program below in src/main.rs:

[dependencies]
gpui = { package = "gpui-ce", version = "0.2" }
gpui_platform = { package = "gpui_ce_platform", version = "0.1" }

These requirements select published releases. Repository documentation may describe APIs newer than those releases. If this example does not compile with the versions Cargo resolves, pin both dependencies to the same git revision as described in the project guide.

use gpui::{App, Context, QuitMode, Window, WindowOptions, div, prelude::*};

struct Hello;

impl Render for Hello {
    fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
        div().size_full().flex().items_center().justify_center().child("Hello, GPUI!")
    }
}

fn main() {
    gpui_platform::application()
        .with_quit_mode(QuitMode::LastWindowClosed)
        .run(|cx: &mut App| {
            cx.open_window(WindowOptions::default(), |_, cx| cx.new(|_| Hello))
                .unwrap();
            cx.activate(true);
        });
}

Run it with cargo run. gpui_platform selects the platform backend; the application callback creates the entity that becomes the window's root view.

Platform backends

GPUI uses Parley for text shaping, wrapping, hit testing, and font fallback on each platform. gpui_platform selects the windowing and rendering integrations. The choice affects setup and available services:

  • On macOS, windows use the native app backend and Metal rendering.
  • On Linux and FreeBSD, enable wayland, x11, or both for desktop windows.
  • On Windows, windows use Win32 and rendering uses DirectX.
  • The web build uses the browser backend; see the web guide for its font and build requirements.

The big picture

Application state lives in Entity values. A Render implementation turns an entity into a view, and the view builds an element tree for layout, input, and painting. Use a custom Element when a view needs control over those phases, such as for a virtualized list or custom drawing. The concepts pages explain how entities, views, elements, contexts, and frames connect.

Learn

Requirements

Use Rust 1.95 or newer. Desktop builds also need Xcode on macOS, development libraries for the Linux backends, or the MSVC toolchain and Windows SDK on Windows. The project setup guide lists the requirements and installation commands.

License

Apache-2.0.