summaryrefslogtreecommitdiffstats
path: root/docs/DESIGNING.md
blob: ffc3c57cf0b82a76f4ddd7fc1408f2ea422df1f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Designing Diagrams in `design-it`

`design-it` combines an infinite, Vulkan-accelerated 2D canvas with a RAD Debugger-style dockable workspace. Every view shares the same live selection: clicking a node in **Outline** highlights it on **Canvas** and opens its fields in **Inspector**; dragging or editing on **Canvas** immediately updates **Outline**, **Inspector**, **Edges**, and **Source**.

---

## 1. Workspace & Docking

The default workspace opens with:
- **Canvas** (left, 70%): Infinite 2D pan/zoom diagram surface.
- **Outline | Palette | Layers** (top-right): Structure tree, archetype/template inserter, and tag/layer visibility controls.
- **Inspector | Edges | Source | Views** (bottom-right): Editable properties & members, edge table, live DSL text, and view launcher.
- **Status** (bottom bar): Mode, messages, frame timing, quad count, active edge tool, and selection summary.

### Rearranging Panels
- **Drag a tab** onto another panel's center to join its tabs, or onto its left/right/top/bottom edge (25% zone) to split.
- **Drag the gap** between two panels to resize.
- **Middle-click a tab** to close it.
- **Open multiple Canvas views** (`:vs canvas` or `^w v` while on Canvas): every Canvas view keeps its **own independent camera** — keep a full architecture overview on one side and edit a zoomed-in subsystem on the other.
- **Panel keyboard shortcuts:**
  - `^h` `^j` `^k` `^l` (or `^w h j k l`): Focus neighboring panel.
  - `^w v` / `^w s`: Split vertical / horizontal.
  - `^w c`: Close focused tab.
  - `^w =`: Equalize split ratios.
  - `gt` / `gT`: Next / previous tab in panel.
  - `^Tab` / `^Shift-Tab`: Cycle through every tab across all panels.
  - `:view <name>`, `:vs <name>`, `:sp <name>`: Open or split any view (`canvas`, `outline`, `inspector`, `edges`, `layers`, `palette`, `source`, `views`, settings groups like `colors`/`canvas`/`appearance`, or profiler groups like `frame`/`heap`/`diagram`).
  - `:reset`: Restore the default panel layout.

---

## 2. Node Archetypes (Beyond Rigid UML)

Every node can switch archetypes at any time without losing its sections or edges (in **Inspector**, move to `kind` and press `h` / `l`).

| Kind | Badge | Visual Cue | Best Used For |
|---|---|---|---|
| `struct` | `STRUCT` | Sharp card, left accent header bar | C/C++/Rust structs, memory layouts, DTOs, PODs |
| `class` | `CLASS` | Sharp card, left accent header bar | OOP classes, controllers, managers |
| `interface` | `IFACE` | Dashed border, subtle header tint | Traits, protocols, abstract interfaces |
| `enum` | `ENUM` | Double left accent bar | Enums, tagged unions, algebraic variants |
| `module` | `MODULE` | Dashed container framing child nodes | Packages, namespaces, subsystems, processes |
| `system` | `SYSTEM` | Accent header bar | Engines, services, threads, workers, daemons |
| `storage` | `STORE` | Top slab accent bar | Databases, ring buffers, arenas, queues, caches |
| `state` | `STATE` | Rounded capsule/pill corners | FSM states, lifecycle phases, pipeline stages |
| `note` | `NOTE` | Folded corner triangle, muted fill | Architecture notes, ADRs, invariants, legends |

### Flexible Compartments (Sections & Members)
Unlike classic UML's rigid 3-box class diagram, any node can hold **0 to N custom sections** (`fields`, `methods`, `memory layout`, `ports`, `events`, `topics`, `invariants`, etc.):
1. Select a node on **Canvas** or in **Outline**.
2. Switch to **Inspector** (`^l` / `^j`, or click it).
3. Press **`A`** (or activate `+ add section`) to add a custom section.
4. Press **`a`** on any section or member row to add a member.
5. Press **`Enter`** on any member to edit it inline using the concise syntax:
   ```text
   + rect[4] : f32 (x0,y0,x1,y1) [0x00]
   ```
   - **Visibility prefix** (optional): `+` public, `-` private, `#` protected, `~` internal/package, `@` port/channel/event, `*` invariant/bullet.
   - **Name**: Left of `:`.
   - **Type / Signature** (optional): Right of `:`.
   - **Badge** (optional): Trailing `[tag]` rendered as a right-aligned pill (e.g. `[atomic]`, `[0x10]`, `[O(1)]`, `[hot]`, `[pure]`).
6. Press **`dd`** in **Inspector** to delete the highlighted member or section.
7. Click `[-]` / `[+]` on a section header (on Canvas or in Inspector) to collapse/expand it individually, or press **`c`** on Canvas to collapse/expand the whole node.

### Containers (`module`)
- Nodes with `parent` set to a `module` are visually framed inside it.
- Dragging a `module` moves all of its children together.
- Resizing or moving children automatically refits the container bounds on release.
- Clicking `[-]` on a `module` header collapses its children out of sight to declutter large diagrams.

---

## 3. Relationships, Routing & Member Pinning

### Edge Kinds
Press **`e`** on Canvas to cycle the active edge creation tool (shown in the status bar as `edge:->`), or edit any selected edge's `relationship` in **Inspector** (`h` / `l`):

| Symbol | Kind | Visual Style | Meaning |
|---|---|---|---|
| `->` | `association` | Solid line + open chevron | Uses / references / calls |
| `..>` | `dependency` | Dashed line + open chevron | Weak / compile-time / runtime dependency |
| `-\|>` | `inheritance` | Solid line + hollow triangle | Extends / inherits from |
| `..\|>` | `implements` | Dashed line + hollow triangle | Implements interface / realizes trait |
| `*->` | `composition` | Solid + filled diamond (src) + chevron | Strong ownership / embedded lifetime |
| `o->` | `aggregation` | Solid + hollow diamond (src) + chevron | Shared collection / weak ownership |
| `==>` | `dataflow` | Thick solid accent line + filled triangle | Hot data path / stream / pipeline |
| `~>` | `async` | Dashed line + filled triangle | Async message / event / queue |
| `<->` | `bidirectional` | Solid line + chevrons at both ends | Mutual / two-way communication |
| `--` | `link` | Solid undirected line | Undirected association / coupling |

### Creating & Editing Edges
- **Mouse (fastest):** Hover a node to reveal its 4 cardinal port dots and drag from a port to any target node — OR **right-drag directly from any node** onto another node.
- **Command line:** `:connect <src_key> <dst_key> [symbol]` (check node keys in the `Source` view).
- **Double-click an edge** (or press `Enter` / `i` with an edge selected) to edit its label.
- **Routing modes:** Press **`r`** on Canvas (or `:route orthogonal|straight|bezier`) to switch the diagram default, or set `routing` per-edge in **Inspector** (`auto`, `orthogonal`, `straight`, `bezier`).
- **Multiplicities & Ports:** In **Inspector**, set `src mult` (e.g. `1`), `dst mult` (e.g. `0..*`), `source port` / `target port` (`auto`, `north`, `south`, `east`, `west`), `tag`, and custom `color`.
- **Member-row pinning:** Edges created by the C++ scanner or pinned to a member index anchor directly to that exact field row's left/right border.

---

## 4. Direct Canvas Manipulation & Auto-Layout

### Mouse Controls on Canvas
- **Scroll wheel:** Smooth zoom toward cursor (`Shift+wheel` or touchpad horizontal scroll pans horizontally).
- **Middle-drag** (or **Right-drag on empty space**): Smooth pan.
- **Left-click:** Select node or edge (`Shift+click` toggles multi-select).
- **Left-drag on empty space:** Box marquee multi-select.
- **Left-drag node(s):** Move with optional grid snap and live smart alignment guides.
- **Left-drag bottom-right corner square:** Manually resize any node or module.
- **Double-click node / edge:** Inline rename / label edit.
- **Minimap (bottom-right):** Click or drag to jump anywhere across massive canvases.

### Keyboard Controls on Canvas
| Key | Action |
|---|---|
| `h j k l` / arrows | Smooth pan (prefix with a count like `5l`) |
| `Shift` + `H J K L` | Nudge selected node by one grid step |
| `+` / `-` / `0` | Zoom in / zoom out / reset to 100% |
| `f` / `Z` | Fit entire diagram / fit current selection |
| `a` | Add a new `struct` at cursor and immediately rename |
| `e` | Cycle edge creation tool (`->`, `..>`, `-\|>`, ...) |
| `c` | Collapse / expand active node |
| `Enter` / `i` | Rename active node or edit active edge label |
| `yy` | Duplicate active node |
| `dd` / `Delete` | Delete selected node(s) or edge(s) |
| `u` / `^r` | Undo / Redo (32 snapshots) |
| `Tab` | Cycle selection and pan through nodes |
| `L` | Run hierarchical Sugiyama auto-layout |
| `r` | Cycle default routing (`orthogonal` / `straight` / `bezier`) |
| `G` / `S` / `m` | Cycle grid (`dots`/`lines`/`off`) / toggle snap / toggle minimap |
| `F` | Toggle **Focus Mode** (dims everything outside 1- or 2-hop neighborhood) |
| `/` | Fuzzy search nodes, members, types, and edge labels |
| `:` | Open command bar with live tab-completion |

### Layout & Alignment Commands
```text
:layout layered      # Sugiyama top-down hierarchy (inheritance points up)
:layout lr           # Sugiyama left-to-right (ideal for pipelines & services)
:layout force        # Fruchterman-Reingold spring layout (untangles complex graphs)
:layout grid         # Compact grid overview
:align left|right|top|bottom|cx|cy|dh|dv   # Align or distribute multi-selected nodes
```

---

## 5. Layers, Focus Mode, Themes & Performance

- **Layers / Tags:** Assign a `tag` to any node or edge in **Inspector** (e.g. `core`, `render`, `hot`, `deprecated`). Open the **Layers** tab to see node/edge counts per tag and press `Enter` to hide/show an entire layer.
- **Focus Mode (`F`):** Dims every node and edge outside the 1-hop (or 2-hop, configurable via `:set focus hops=2`) neighborhood of the selected node.
- **Themes & Settings:** Open `:view appearance`, `:view colors`, or `:view canvas`, or run:
  ```text
  :set color scheme=nord
  :set grid style=lines
  :set zoom=1.2
  ```
  Available schemes: `mono dark`, `mono light`, `amber`, `green phosphor`, `gruvbox`, `nord`, `solarized`, `high contrast`, plus per-color `#RRGGBBAA` overrides (`custom`).
- **Built-in Profiler:** Dock `:view frame`, `:view diagram`, `:view heap`, or `:view gpu` anywhere to inspect live frame CPU/GPU timings, quad counts, arena usage, and zoom LOD scaling (try `:tpl stress` to benchmark 1,000 nodes / 1,935 edges live).