Skip to main content

blockworx/
state.rs

1use blockworx_doc::id::PinId;
2use blockworx_geom::Vec2;
3
4use crate::edit::naming::Authoring;
5use crate::shape::pin::PinSide;
6
7#[derive(Clone, Copy, Debug)]
8pub enum RenderMode {
9    Normal,
10    /// Not drawn at all — used to omit a shape while an in-place editor stands in
11    /// for it (a text box being edited).
12    Hidden,
13    Moving {
14        delta: Vec2,
15    },
16    Resizing {
17        mode: ResizeMode,
18        delta: Vec2,
19    },
20    Selected {
21        /// Whether this shape's add-prompts are on offer. A locked interface
22        /// and a read-only session both withhold them, and the shape draws
23        /// the same either way (see [`Authoring`]).
24        authoring: Authoring,
25    },
26    PinDragged {
27        pin: PinId,
28        delta: f32,
29        side: PinSide,
30        /// The grid slot the pin would snap to if released now (a faded preview
31        /// is drawn there), or `None` when the drop would be invalid.
32        candidate: Option<u32>,
33    },
34    TitleDragged {
35        delta: Vec2,
36    },
37    TypeDragged {
38        delta: Vec2,
39    },
40}
41
42#[derive(Clone, Copy, PartialEq, Eq, Debug)]
43pub enum ResizeMode {
44    LeftTop,
45    RightTop,
46    LeftBottom,
47    RightBottom,
48}