Files
Ely-GPUI-Components/examples/gallery/pages/canvas/mod.rs
T
ZacharyZhang-NYandClaude Opus 5.5 f3822a8d98 Canvas · Graphs and boards: node graph, flow chart, mind map, whiteboard
NodeGraph joins Nodes by wires between typed Ports: a title drags a
node, a drag out of an output lands on an input of the same kind, an
input takes one wire, and a press on a wired input lifts its wire.
Links join shapes on the plane and follow them, straight or at right
angles, with an arrow and words; the Connector tool draws them and the
Note tool drops a sticky note. A double press with Select writes on a
shape. FlowChart draws Steps as ellipses, boxes and diamonds with their
words. MindMap lays topics out from a root, half to each side, and asks
the owner to add, remove and rename by key. Whiteboard keeps its own
tool, view and selection over a board it hands back after each change.
Painting moves to canvas::paint; a press on the tool layer goes through
canvas::press, and the layer focuses itself and asks to delete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 08:22:54 -04:00

58 lines
1.6 KiB
Rust

use gpui::{AnyElement, App, Window, div, prelude::*};
mod boards;
mod graphs;
mod looks;
mod panels;
mod plane;
mod tools;
use super::Page;
use crate::script::Step;
pub const PAGE: Page = Page {
number: 32,
slug: "canvas",
title: "Canvas & Design",
summary: "An endless plane to lay work on, the tools and panels around it, and graphs of nodes.",
render,
script: SCRIPT,
};
const SCRIPT: &[Step] = &[
Step::DownAt("canvas-plane", 420.0, 300.0),
Step::DragTo("canvas-plane", 300.0, 240.0),
Step::UpAt("canvas-plane", 300.0, 240.0),
Step::Wait(200),
Step::Shot("panned"),
Step::DownAt("canvas-tools", 150.0, 110.0),
Step::DragTo("canvas-tools", 170.0, 112.0),
Step::DragTo("canvas-tools", 187.0, 112.0),
Step::Wait(200),
Step::Shot("snapping"),
Step::UpAt("canvas-tools", 187.0, 112.0),
Step::Wait(200),
Step::DownAt("canvas-palette", 83.0, 16.0),
Step::UpAt("canvas-palette", 83.0, 16.0),
Step::Wait(150),
Step::DownAt("canvas-tools", 60.0, 230.0),
Step::DragTo("canvas-tools", 200.0, 300.0),
Step::UpAt("canvas-tools", 200.0, 300.0),
Step::Wait(250),
Step::Shot("drawn"),
];
fn render(window: &mut Window, cx: &mut App) -> AnyElement {
div()
.child(plane::plane(window, cx))
.child(tools::tools(window, cx))
.child(panels::arrange(window, cx))
.child(looks::styles(window, cx))
.child(looks::rules(window, cx))
.child(graphs::nodes(window, cx))
.child(boards::flow(window, cx))
.child(boards::mind(window, cx))
.child(graphs::board(window, cx))
.into_any_element()
}