Files
Ely-GPUI-Components/src/theme/media.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

28 lines
649 B
Rust

use gpui::Rems;
use super::{Theme, tokens::px_to_rems};
/// Media tools' measures.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct MediaSizes {
/// A crop box's handle, square.
pub crop_handle: Rems,
/// A mark's line on a picture.
pub mark_stroke: Rems,
/// An arrow's head, from its tip.
pub arrow_head: Rems,
/// A numbered pin, round.
pub pin: Rems,
}
impl Theme {
pub fn media(&self) -> MediaSizes {
MediaSizes {
crop_handle: px_to_rems(10.0),
mark_stroke: px_to_rems(2.0),
arrow_head: px_to_rems(12.0),
pin: px_to_rems(20.0),
}
}
}