UIGraph.h file
Graph: nodes joined by wires, panned and zoomed. Node scripts, material and animation graphs.
ui.Graph(view, { .OnMove = moved, .OnConnect = connect, .OnDisconnect = cut, .OnDelete = remove, .Menu = addNodeMenu }, [&] { for (const Node& node : nodes) { ui.Key(node.ID); ui.GraphNode(node.ID, { .X = node.X, .Y = node.Y, .Title = node.Title }, [&] { for (const Pin& pin : node.Pins) { ui.Key(pin.ID); if (auto row = ui.Row({ .Gap = 6, .Align = GGAlign::Center })) { ui.Pin(pin.ID, { .Side = pin.Side, .Color = pin.Color }); ui.Label(pin.Name); } } }); } for (const Link& link : links) ui.GraphLink(link.From, link.To); });
Nodes are ordinary UI: any element can go inside one. The graph owns none of the data. It reports what the user did (a move, a new wire, a delete) and the owner changes its data, so each gesture is one undo step in the owner's history. Pan, zoom and selection are written to the view as they happen.
Pointer: left drag on the background selects with a box (Shift adds, Ctrl removes); a click on a node selects it (Shift adds, Ctrl toggles) and dragging moves the selection; dragging from a pin draws a wire; Alt+click on a pin cuts its wires; Ctrl+drag from a pin picks its wires up and drops them on another pin, or cuts them on empty space. Right or middle drag pans, the wheel zooms about the pointer, a right click opens Menu. Keys are GGGraphKeys actions.
Namespaces
- namespace GGUI
- namespace GGUI::GGGraphKeys
- The graph's keys, rebindable.
Classes
- struct GGUI::GGGraphView
- Where a graph is looking and what is selected. Owned by the graph's owner, which keeps it for as long as the graph is shown, and written by the graph.
- struct GGUI::GGGraphLink
- A wire: from an Out pin to an In pin.
- struct GGUI::GraphMoveEvent
- The selection was dragged by DX, DY graph units. Reported once, at release.
- struct GGUI::GraphConnectEvent
- New wires. Replaces: wires picked up with Ctrl+drag, which these take the place of.
- struct GGUI::GraphLinksEvent
- Wires cut.
- struct GGUI::GraphNodesEvent
- Nodes to delete, duplicate or copy.
- struct GGUI::GraphPointEvent
- A paste, at a graph point.
- struct GGUI::GraphProps
- Properties of ui.Graph: what its gestures report, and how it looks.
- struct GGUI::GraphNodeProps
- Properties of ui.GraphNode.
- struct GGUI::PinProps
- Properties of ui.Pin.
- struct GGUI::GraphLinkProps
- Properties of ui.GraphLink.