Files
Ely-GPUI-Components/examples/gallery/pages/media/mod.rs
T
ZacharyZhang-NY 5cd7ee0ea8 T26b Media: crop and annotate
ImageCropper crops a picture by a box in shares of it: a press holds a
corner, a side or the body (crop::grip_at), a drag through gpui's drag
moves them (crop::dragged), kept inside the picture with a least side;
with an aspect only the corners size it and the box keeps its shape; the
arrows move it. The picture sits inset by half a handle, the focus border
outside it, so handles on its edge stay whole and it keeps its shape.
ImageUpload (T06e) takes pictures only, from a drop or the dialog
(forms::taken, DropZone::kinds), decodes the file for its shape, and with
no crop yet reports the largest centered box of its aspect once. The
annotator draws boxes, arrows, lines and numbered pins in chart colors
through forms::pen; Select chooses a mark, Delete removes it, and Cmd-Z
and Shift-Cmd-Z undo and redo through forms::History. theme.media() holds
their sizes.
2026-09-26 16:16:29 -04:00

67 lines
1.9 KiB
Rust

mod edit;
mod images;
use gpui::{AnyElement, App, IntoElement, ParentElement, Window, div};
use super::Page;
use crate::script::Step;
pub const PAGE: Page = Page {
number: 26,
slug: "media",
title: "Media",
summary: "Pictures, video and sound: looking closely, cropping and marking up, playing, and the controls and devices around them.",
render,
script: SCRIPT,
};
const SCRIPT: &[Step] = &[
Step::DownAt("media-viewer", 320.0, 240.0),
Step::UpAt("media-viewer", 320.0, 240.0),
Step::Key("="),
Step::Key("="),
Step::Wait(300),
Step::Shot("zoomed"),
Step::Key("r"),
Step::Wait(500),
Step::Shot("turned"),
Step::DownAt("media-thumbs", 237.0, 50.0),
Step::UpAt("media-thumbs", 237.0, 50.0),
Step::Wait(500),
Step::Shot("lightbox"),
Step::Key("escape"),
Step::Wait(300),
Step::DownAt("media-cropper", 458.0, 317.0),
Step::DragTo("media-cropper", 400.0, 280.0),
Step::UpAt("media-cropper", 400.0, 280.0),
Step::Wait(200),
Step::Shot("cropped"),
Step::DownAt("media-annotator", 500.0, 80.0),
Step::UpAt("media-annotator", 500.0, 80.0),
Step::Key("v"),
Step::DownAt("media-annotator", 168.0, 310.0),
Step::UpAt("media-annotator", 168.0, 310.0),
Step::Wait(200),
Step::Shot("chosen"),
Step::Key("b"),
Step::DownAt("media-annotator", 60.0, 90.0),
Step::DragTo("media-annotator", 200.0, 200.0),
Step::UpAt("media-annotator", 200.0, 200.0),
Step::Wait(200),
Step::Shot("marked"),
Step::DownAt("media-upload", 388.0, 307.0),
Step::UpAt("media-upload", 388.0, 307.0),
Step::Wait(300),
Step::Shot("emptied"),
];
fn render(window: &mut Window, cx: &mut App) -> AnyElement {
div()
.child(images::viewer(cx))
.child(images::thumbnails(window, cx))
.child(edit::cropper(window, cx))
.child(edit::upload(window, cx))
.child(edit::annotator(window, cx))
.into_any_element()
}