blockworx/document_ng/label.rs
1#[derive(Copy, Clone, PartialEq, Eq, Default, Debug)]
2pub enum LabelSide {
3 Top,
4 Center,
5 #[default]
6 Bottom,
7}
8
9/// A user-editable text label attached to a block. The block's title (the source
10/// of truth for its name) and its type label are both `BlockLabel`s; the only
11/// difference is how each is anchored when drawn.
12#[derive(Clone, PartialEq, Default, Debug)]
13pub struct BlockLabel {
14 pub name: String,
15 /// Whether this label is hidden (not drawn). Kept beside `name` since it
16 /// governs it. The flag lives on `BlockLabel` so a title-visibility toggle
17 /// can reuse it later.
18 pub hidden: bool,
19 pub side: LabelSide,
20 pub offset: f32,
21}
22
23impl BlockLabel {
24 /// Empty label parked in the upper-left corner. Used as the default for a
25 /// block's type label, which is left-anchored (see `block_type_position`).
26 pub fn upper_left() -> Self {
27 Self {
28 name: String::new(),
29 hidden: false,
30 side: LabelSide::Top,
31 offset: 0.0,
32 }
33 }
34}