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
|
#ifndef DIAGRAM_LAYOUT_H
#define DIAGRAM_LAYOUT_H
#define EDGE_PATH_MAX_POINTS 32
typedef struct EdgePath EdgePath;
struct EdgePath {
u32 routing; // resolved routing (ORTHOGONAL, STRAIGHT, BEZIER)
u32 point_count; // for polyline (2..EDGE_PATH_MAX_POINTS)
Vec2f points[EDGE_PATH_MAX_POINTS];
// for bezier: p0, c0, c1, p1
Vec2f c0, c1;
// tangents (unit vectors pointing into endpoints)
Vec2f src_dir; // outgoing unit vector from src
Vec2f dst_dir; // incoming unit vector into dst (pointing toward dst)
Vec2f label_pos;
Vec2f src_mult_pos;
Vec2f dst_mult_pos;
Rect bounds;
};
typedef enum AlignMode {
ALIGN_LEFT,
ALIGN_CENTER_X,
ALIGN_RIGHT,
ALIGN_TOP,
ALIGN_CENTER_Y,
ALIGN_BOTTOM,
DISTRIBUTE_H,
DISTRIBUTE_V,
} AlignMode;
internal f32 diagram_member_world_y(Diagram *d, s32 node_index, s32 member_index);
internal b32 diagram_edge_route(Diagram *d, s32 edge_index, EdgePath *out);
internal s32 diagram_hit_test_node(Diagram *d, f32 wx, f32 wy);
internal s32 diagram_hit_test_edge(Diagram *d, f32 wx, f32 wy, f32 tolerance);
internal Rect diagram_bounds(Diagram *d);
internal void diagram_layout_layered(Diagram *d, b32 left_to_right);
internal void diagram_layout_force(Diagram *d, u32 iterations);
internal void diagram_layout_grid(Diagram *d);
internal void diagram_layout_sequence(Diagram *d, f32 origin_x, f32 origin_y); // lifelines in a row, messages evenly spaced
internal void diagram_clear_bends(Diagram *d, b32 only_unpinned);
internal void diagram_align_selected(Diagram *d, AlignMode mode);
#endif // DIAGRAM_LAYOUT_H
|