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.
28 lines
649 B
Rust
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),
|
|
}
|
|
}
|
|
}
|