9#include <unordered_map>
10#include <unordered_set>
45 color4f dotColor,
float dotSize,
int2 originOffset = {},
46 IntRect clipCurrent = {});
53 constexpr int32_t
FloorDiv(int32_t a, int32_t b)
55 int32_t q = a / b, r = a % b;
56 if (r != 0 && ((r < 0) != (b < 0))) --q;
60 constexpr int32_t
GridLineLE(int32_t v, int32_t origin, int32_t grid)
62 return origin +
FloorDiv(v - origin, grid) * grid;
65 constexpr int32_t
GridLineGE(int32_t v, int32_t origin, int32_t grid)
68 return (d == v) ? d : d + grid;
74 return ((v - d) * 2 <= grid) ? d : d + grid;
89 int32_t grid,
int2 gridOrigin,
94 constexpr uint32_t
WireKey(
int targetNode,
int targetProp)
96 return ((uint32_t)targetNode << 16) | (uint32_t)(uint16_t)targetProp;
102 return { int(wireKey >> 16), int(wireKey & 0xFFFFu) };
107 std::optional<uint32_t>
WireAt(std::span<const DrawnWire> wires,
int2 p,
float tolerance);
151 PropertyEndpoint pendingIn = {});
157 std::optional<int2> inPt,
IntRect tgtRect,
163 std::optional<int2> outPt,
IntRect srcRect,
211 std::span<const NodeModel> nodes,
214 int2 marqueeStartScreen,
215 int2 marqueeCurrentScreen);
Passed to custom-draw callbacks (ElementStorage::AddCustomDraw / AddCustomDrawAfter): geometry lookup...
Definition gui_custom_draw_context.h:43
bool ConnectionAllowed(const NodeView &view, PropertyEndpoint out, PropertyEndpoint in)
Whether a wire from output out to input in is allowed: never a same-node loop, otherwise the view's c...
constexpr PropertyEndpoint WireInput(uint32_t wireKey)
The input a WireKey names.
Definition gui_node_view_helpers.h:100
float2 NodeViewScreenToCanvas(const float3x2 &viewTransform, IntRect canvasInnerRectScreen, int2 screen)
A screen point in node.pos space, for a canvas whose padding box is canvasInnerRectScreen (screen pix...
float2 NodeViewCanvasToScreen(const NodeView &view, float2 canvasPos)
A point in node.pos space on the screen, where the view last drew it: the other way round from NodeVi...
void RenderCanvasGrid(CustomDrawContext &ctx, int32_t baseGridSize, color4f dotColor, float dotSize, int2 originOffset={}, IntRect clipCurrent={})
Infinite background dot grid for a pan/zoom canvas, drawn from a CustomDrawContext callback in the ca...
void ConnectSockets(NodeView &view, PropertyEndpoint output, PropertyEndpoint input)
Wires output into input without reporting to view.onEdit.
float NodeViewZoom(const NodeView &view)
The node view's zoom (1 = 100%).
std::unordered_map< uint32_t, WireLane > ComputeWireLaneOffsets(const NodeView &view, PropertyEndpoint pendingOut={}, PropertyEndpoint pendingIn={})
Default lane offsets (grid steps) for wires between the same two nodes, so their lanes don't coincide...
void SetNodeViewCenter(NodeView &view, float2 center, float zoom)
Centres the view on canvas point center at zoom (clamped to 10%..100%).
std::unordered_set< ID > ComputeNodesInMarquee(std::span< const NodeModel > nodes, IntRect canvasInnerRectScreen, const float3x2 &viewTransform, int2 marqueeStartScreen, int2 marqueeCurrentScreen)
Stable IDs of nodes whose {pos, lastSize} rect lies fully inside the marquee, compared in node....
constexpr int32_t GridLineNearest(int32_t v, int32_t origin, int32_t grid)
The grid line (origin + k x grid) nearest v, ties going down; grid must be > 0.
Definition gui_node_view_helpers.h:71
int NodeAtCanvasPos(const NodeView &view, float2 canvasPos)
The node whose {pos, lastSize} rect holds canvasPos (node.pos space), the frontmost in view....
constexpr int32_t FloorDiv(int32_t a, int32_t b)
a / b rounded toward negative infinity.
Definition gui_node_view_helpers.h:53
NodeViewEdit DisconnectEdit(const NodeView &view, PropertyEndpoint input)
An edit that removes the wire into input, with its lane overrides.
void BringNodeToFront(std::vector< int > &ordering, int n)
Moves n to the front (last) of a z-order list, keeping the others' order.
PropertyEndpoint FirstInputAccepting(const NodeView &view, PropertyEndpoint output, int nodeIdx)
The first input of node nodeIdx, top to bottom, that a wire from output may connect to; invalid when ...
PropertyEndpoint FirstOutputAccepting(const NodeView &view, PropertyEndpoint input, int nodeIdx)
The first output of node nodeIdx, top to bottom, that may feed input; invalid when there is none.
void CommitNodeViewEdit(NodeView &view, const NodeViewEdit &edit)
Applies edit and reports it to view.onEdit.
void ApplyNodeViewEdit(NodeView &view, const NodeViewEdit &edit, bool undo=false)
Redoes edit (its to values), or with undo restores its from values.
NodeViewEdit RerouteWireEdit(const NodeView &view, uint32_t wireKey, ID stableID, int2 pos)
An edit that puts a reroute (NodeModel::reroute) on the wire wireKey (the WireKey of its input): the ...
void FrameAllNodes(NodeView &view)
Centres and zooms the view on all nodes (Home, the Fit button).
NodeViewEdit ConnectEdit(const NodeView &view, PropertyEndpoint output, PropertyEndpoint input)
An edit that wires output into input; the input's old wire goes, the output keeps its others.
WireRoute BuildWireRoute(int2 outPt, int2 inPt, IntRect srcRect, IntRect tgtRect, int32_t grid, int2 gridOrigin, const WireRouteOverrides &overrides={})
Orthogonal route for a wire from an output socket (outPt, on srcRect's right edge) to an input socket...
void ScrollNodeIntoView(NodeView &view, int nodeIdx, int32_t margin)
Pans the view, at the same zoom, by as little as brings node nodeIdx inside it with margin pixels to ...
WireRoute BuildPendingWireRoute(int2 outPt, IntRect srcRect, int2 cursor, std::optional< int2 > inPt, IntRect tgtRect, int32_t grid, int2 gridOrigin, WireLane lane={})
A wire being dragged from an output: routed as the connection it would make when it is over an input ...
void ZoomNodeView(NodeView &view, float factor, int2 pivot={})
Zooms by factor around pivot (pixels from the canvas centre), within 10%..100%.
NodeViewEdit AddNodeEdit(const NodeView &view, NodeModel node, int index=-1)
An edit that adds node at index (-1, or past the end: last), drawn in front of the others.
std::optional< uint32_t > WireAt(std::span< const DrawnWire > wires, int2 p, float tolerance)
The wire within tolerance of point p (the closest when several are); none when no wire is.
NodeViewEdit RemoveNodesEdit(const NodeView &view, std::span< const int > indices)
An edit that removes the nodes at indices (in any order; ones out of range and repeats are skipped),...
constexpr uint32_t WireKey(int targetNode, int targetProp)
Stable key for a wire, identified by its target (input) endpoint - each input carries at most one inc...
Definition gui_node_view_helpers.h:94
WireRoute BuildPendingWireRouteToInput(int2 inPt, IntRect tgtRect, int2 cursor, std::optional< int2 > outPt, IntRect srcRect, int32_t grid, int2 gridOrigin, WireLane lane={})
A wire being dragged from an input: routed as the connection it would make when it is over an output ...
constexpr int32_t GridLineGE(int32_t v, int32_t origin, int32_t grid)
The grid line (origin + k x grid) at or above v; grid must be > 0.
Definition gui_node_view_helpers.h:65
constexpr int32_t GridLineLE(int32_t v, int32_t origin, int32_t grid)
The grid line (origin + k x grid) at or below v; grid must be > 0.
Definition gui_node_view_helpers.h:60
Definition gui_logging.h:24
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
Definition gui_base_types.h:407
Definition gui_renderer.h:32
One node of a node view.
Definition gui_node_view_types.h:66
One thing the user did in a node view, as values before and after, so a host can keep the undo histor...
Definition gui_node_view_types.h:159
All state of one node-view widget; no global state.
Definition gui_node_view_types.h:215
A property on a node. Default-constructed is invalid: in a socket it means "present,...
Definition gui_node_view_types.h:27
A wire's place among the wires between the same two nodes, so their default lanes nest instead of coi...
Definition gui_node_view_types.h:110
User-pinned lanes of one wire (unset = default), in the route's space.
Definition gui_node_view_types.h:121
Polyline plus its draggable interior segments (never the end stubs).
Definition gui_node_view_types.h:141
Definition gui_base_types.h:395
Definition gui_base_types.h:121
2D affine transform matrix (2 rows x 3 columns): x' = r0.x*x + r0.y*y + r0.z y' = r1....
Definition gui_base_types.h:219
Integer 2D vector.
Definition gui_base_types.h:19