/panoramix

A prototype implementation of reactive UI in rust

Primary LanguageRustMIT LicenseMIT

Panoramix

crates.io docs.rs license chat

Note: The development of Panoramix is currently (as of December 2022) on hold as I work on masonry. I do intend to resume eventually.

Panoramix is an experimental GUI framework for the Rust programming language.

The framework is data-driven and declarative, drawing some inspiration from React, and implemented on top of the Druid toolkit (hence the name).

It aims to use simple, idiomatic Rust: Panoramix doesn't use unsafe code, cells, mutexes, or DSL macros.

Getting started

Here is our "hello world" example:

use panoramix::elements::{Button, Label};
use panoramix::{component, Column, CompCtx, Element, NoEvent, RootHandler};

#[component]
fn HelloBox(ctx: &CompCtx, _props: ()) -> impl Element<Event = NoEvent> {
    let md = ctx.use_metadata::<NoEvent, ()>();
    Column!(
        Label::new("Hello world!"),
        Button::new("Say hello").on_click(md, |_, _| {
            println!("Hello world");
        })
    )
}

fn main() -> Result<(), panoramix::PlatformError> {
    RootHandler::new(HelloBox).with_tracing(true).launch()
}

See the documentation for details, and the Writing a new component tutorial.

Contributing

Issues and PRs are welcome.

PRs that add "basic block" widgets in particular will be appreciated.

See CONTRIBUTING.md for the rules to follow when making a PR. Issues don't have a mandatory format, but if you submit one, please follow common-sense rules: be polite, be professional, have a plan to kill everyone you meet, and if you have a problem, please include detailed steps to reproduce.

See ARCHITECTURE.md for a high-level presentation of the project code.

To ask questions and discuss development work, go to Druid's Zulip chat, in the #panoramix channel.

Usage

In your Cargo.toml, add the following:

panoramix = "0.1.0"

If you want the bleeding-edge version, add the following instead:

panoramix = { git = "https://github.com/PoignardAzur/panoramix.git" }

Note for Linux users: Panoramix is built on top of Druid, using the GTK backend, which requires a dev version of GTK3. See GTK installation page for install info.

Eg on Ubuntu-based distributions, you should run sudo apt install libgtk-3-dev.

Roadmap

The short term roadmap is:

  • Streamline styling options, especially for common low-effort use cases.
  • Implement two-way bindings.
  • Refactor event handling.
  • Finish doc.
  • Improve performance.
  • Write benchmarks.

On the longer timescale, there are two broad goals:

  • Achieve feature parity with React.
  • Use Panoramix to build a debugging framework, similar to chrome-devtools. TODO - Write blog posts about this.

See ROADMAP.md for details.

Authors

This crate has been almost entirely written by Olivier FAURE. Any other contributor will be added to AUTHORS.md.

This project has been possible thanks to the extremely clean and approchable work of Raph Levien and Colin Rofls, as well as some mentoring on their part, and general interaction with the Druid community. In particular, Panoramix is inspired from Crochet.