TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_node_view_helpers.h File Reference
#include <gui_controls/gui_node_view_types.h>
#include <gui_core/gui_base_types.h>
#include <gui_core/gui_id.h>
#include <span>
#include <unordered_map>
#include <unordered_set>
#include <vector>

Go to the source code of this file.

Namespaces

namespace  tachyon

Functions

float tachyon::NodeViewZoom (const NodeView &view)
 The node view's zoom (1 = 100%).
void tachyon::ZoomNodeView (NodeView &view, float factor, int2 pivot={})
 Zooms by factor around pivot (pixels from the canvas centre), within 10%..100%.
void tachyon::SetNodeViewCenter (NodeView &view, float2 center, float zoom)
 Centres the view on canvas point center at zoom (clamped to 10%..100%).
void tachyon::FrameAllNodes (NodeView &view)
 Centres and zooms the view on all nodes (Home, the Fit button).
void tachyon::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 spare; a node larger than the view shows its top-left.
void tachyon::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 canvas's layout space (node.pos space): a dot on every grid point.
constexpr int32_t tachyon::FloorDiv (int32_t a, int32_t b)
 a / b rounded toward negative infinity.
constexpr int32_t tachyon::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.
constexpr int32_t tachyon::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.
constexpr int32_t tachyon::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.
WireRoute tachyon::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 (inPt, on tgtRect's left edge), with bends on the grid and clear of both bodies:
constexpr uint32_t tachyon::WireKey (int targetNode, int targetProp)
 Stable key for a wire, identified by its target (input) endpoint - each input carries at most one incoming wire.
constexpr PropertyEndpoint tachyon::WireInput (uint32_t wireKey)
 The input a WireKey names.
std::optional< uint32_t > tachyon::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.
void tachyon::ApplyNodeViewEdit (NodeView &view, const NodeViewEdit &edit, bool undo=false)
 Redoes edit (its to values), or with undo restores its from values.
void tachyon::CommitNodeViewEdit (NodeView &view, const NodeViewEdit &edit)
 Applies edit and reports it to view.onEdit.
NodeViewEdit tachyon::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.
NodeViewEdit tachyon::DisconnectEdit (const NodeView &view, PropertyEndpoint input)
 An edit that removes the wire into Input, with its lane overrides.
NodeViewEdit tachyon::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.
NodeViewEdit tachyon::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), with every wire into or out of them and those wires' lanes.
NodeViewEdit tachyon::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 wire then runs from its output into the new reroute, and on from it into the input.
std::unordered_map< uint32_t, WireLane > tachyon::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: k wires, in input order, get (k-1)/2 counting down by one (one wire: 0; two: 0,-1; three: 1,0,-1; four: 1,0,-1,-2), so wires running down nest instead of crossing.
WireRoute tachyon::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 that accepts it (inPt on tgtRect), else to cursor as if an input sat there.
WireRoute tachyon::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 that accepts it (outPt on srcRect), else from cursor as if an output sat there.
bool tachyon::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 canConnect delegate decides (none: allowed).
PropertyEndpoint tachyon::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 there is none.
PropertyEndpoint tachyon::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.
int tachyon::NodeAtCanvasPos (const NodeView &view, float2 canvasPos)
 The node whose {pos, lastSize} rect holds canvasPos (node.pos space), the frontmost in view.ordering when several do; -1 when none does.
void tachyon::ConnectSockets (NodeView &view, PropertyEndpoint output, PropertyEndpoint input)
 Wires output into Input without reporting to view.onEdit.
void tachyon::BringNodeToFront (std::vector< int > &ordering, int n)
 Moves n to the front (last) of a z-order list, keeping the others' order.
float2 tachyon::NodeViewScreenToCanvas (const float3x2 &viewTransform, IntRect canvasInnerRectScreen, int2 screen)
 A screen point in node.pos space, for a canvas whose padding box is canvasInnerRectScreen (screen pixels) and whose pan/zoom is viewTransform (view.transform).
float2 tachyon::NodeViewScreenToCanvas (const NodeView &view, int2 screen)
 A screen point (as events have them) in node.pos space, through the pan/zoom and place the view was last drawn with.
float2 tachyon::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 NodeViewScreenToCanvas.
std::unordered_set< ID > tachyon::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.pos space (canvas inner-rect relative, before the content transform).