TachyonUI 1.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 <gui_core/gui_id_manager.h>
#include <span>
#include <unordered_map>
#include <unordered_set>
#include <vector>

Go to the source code of this file.

Classes

struct  tachyon::TransitionPath
 A transition's arrow, in node.pos space, between the states as last laid out. More...

Namespaces

namespace  tachyon

Functions

ID tachyon::NodeElementID (const NodeViewState &view, ID stableID)
 The element a view last built for the node, frame or transition stableID names: its stable ID scoped to the view's canvas, so another view of the graph has its own.
float tachyon::NodeViewZoom (ConstNodeViewRef view)
 The node view's zoom (1 = 100%).
void tachyon::ZoomNodeView (NodeViewRef view, float factor, int2 pivot={})
 Zooms by factor around pivot (pixels from the canvas centre), within the view's minZoom..maxZoom.
void tachyon::SetNodeViewCenter (NodeViewRef view, float2 center, float zoom)
 Centres the view on canvas point center at zoom (clamped to minZoom..maxZoom).
void tachyon::FrameAllNodes (NodeViewRef view)
 Centres and zooms the view on all nodes.
void tachyon::FrameNodes (NodeViewRef view, std::span< const int > indices)
 Centres and zooms the view on the nodes at indices (ones out of range skipped); none leaves the view as it is.
void tachyon::FrameSelectedNodes (NodeViewRef view)
 Centres and zooms the view on the selected nodes, and in a state machine the states a selected transition joins; on all of them when none is selected (Home, the Fit button).
void tachyon::ScrollNodeIntoView (NodeViewRef 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:
WireRoute tachyon::BuildCurvedWireRoute (int2 outPt, int2 inPt, int32_t reach)
 A curved wire from outPt to inPt, leaving the output to the right and entering the input from the left.
float2 tachyon::WireCurvePoint (int2 p0, int2 p1, int2 p2, int2 p3, float t)
 The point at t (0 to 1) along the curve the renderer draws for a line with points p0, p1, p2, p3: two quadratic Beziers, p0-p1-m and m-p2-p3, where m is halfway between p1 and p2.
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 (NodeViewRef view, const NodeViewEdit &edit, bool undo=false)
 Redoes edit (its to values), or with undo restores its from values.
void tachyon::CommitNodeViewEdit (NodeViewRef view, const NodeViewEdit &edit)
 Applies edit and reports it to view.graph.onEdit.
void tachyon::ReleaseNodeViewEditIDs (IDManager &ids, const NodeViewEdit &edit, bool undone)
 Releases the static IDs of the nodes, frames and transitions only the side of edit not in effect holds: done, what its undo would bring back; undone, what its redo would add.
NodeViewEdit tachyon::ConnectEdit (ConstNodeViewRef 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 (ConstNodeViewRef view, PropertyEndpoint input)
 An edit that removes the wire into Input, with its lane overrides.
NodeViewEdit tachyon::AddNodeEdit (ConstNodeViewRef 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 (ConstNodeViewRef 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 (ConstNodeViewRef 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.
NodeViewEdit tachyon::RemoveRerouteEdit (ConstNodeViewRef view, int node)
 An edit that takes the reroute at node out, with its wire running on as it did through it: every input it fed then takes from the output that fed it (or nothing, when nothing did).
NodeViewEdit tachyon::AddFrameEdit (ConstNodeViewRef view, NodeFrame frame, int index=-1)
 An edit that adds frame at index (-1, or past the end: last, in front of the other frames, still behind every node).
NodeViewEdit tachyon::RemoveFramesEdit (ConstNodeViewRef view, std::span< const int > indices)
 An edit that removes the frames at indices (in any order; ones out of range and repeats are skipped).
NodeFrame tachyon::FrameAroundNodes (ConstNodeViewRef view, std::span< const int > indices)
 A frame round the nodes at indices, as the view last laid them out: a grid cell of room on each side, and the title bar above them.
NodeViewEdit tachyon::GroupSelectionEdit (ConstNodeViewRef view, NodeFrame frame)
 An edit that puts the selected nodes and frames in frame: its place and size are set round them as FrameAroundNodes sets them (a collapsed frame counts at its open size), and it goes behind the selected frames so they stay in front of it.
std::vector< int > tachyon::NodesInFrame (ConstNodeViewRef view, int frame)
 The nodes (indices) frame frame holds, which move with it: those lying wholly inside it as the view last laid them out, or, collapsed, those it held when it collapsed.
NodeViewEdit tachyon::CollapseFrameEdit (ConstNodeViewRef view, int frame, bool collapse)
 An edit that collapses frame frame (or expands it), noting what it holds as it collapses (NodeFrame::members).
int tachyon::FrameTitleAtCanvasPos (ConstNodeViewRef view, float2 canvasPos)
 The frame whose title bar holds canvasPos (node.pos space), the frontmost when several do; -1 when none does.
void tachyon::RenameFrame (NodeViewRef view, int frame)
 Starts renaming frame frame as a double-click on its title does: a field over the title bar, with the focus in it, from the next RenderNodeView.
std::unordered_map< uint32_t, WireLane > tachyon::ComputeWireLaneOffsets (ConstNodeViewRef 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 (ConstNodeViewRef 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 (ConstNodeViewRef 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 (ConstNodeViewRef 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 (ConstNodeViewRef view, float2 canvasPos)
 The node whose {pos, lastSize} rect holds canvasPos (node.pos space), the frontmost in view.graph.ordering when several do; -1 when none does.
void tachyon::ConnectSockets (NodeViewRef view, PropertyEndpoint output, PropertyEndpoint input)
 Wires output into Input without reporting to view.graph.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.state.transform).
float2 tachyon::NodeViewScreenToCanvas (ConstNodeViewRef 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 (ConstNodeViewRef view, float2 canvasPos)
 A point in node.pos space on the screen, where the view last drew it: the other way round from NodeViewScreenToCanvas.
float2 tachyon::NodeViewScreenToNodePos (ConstNodeViewRef view, int2 screen)
 A screen point in node.pos space, where the nodes' boxes are (NodeViewScreenToCanvas less the canvas's border and padding, as last laid out).
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).

State machines (NodeViewKind::StateMachine)

NodeViewEdit tachyon::AddTransitionEdit (ConstNodeViewRef view, StateTransition transition, int index=-1)
NodeViewEdit tachyon::RemoveTransitionsEdit (ConstNodeViewRef view, std::span< const ID > transitions)
 An edit that removes the transitions with these stableIDs (unknown ones are skipped).
NodeViewEdit tachyon::SetInitialStateEdit (ConstNodeViewRef view, ID state)
 An edit that makes state (a stableID; Invalid: none) the initial state.
int tachyon::TransitionIndex (ConstNodeViewRef view, ID stableID)
 Index of the transition with stableID in view.graph.transitions; -1 when there's none.
int tachyon::NodeIndex (ConstNodeViewRef view, ID stableID)
 Index of the node with stableID in view.graph.nodes; -1 when there's none.
void tachyon::RenameTransition (NodeViewRef view, int transition)
 Starts relabelling transition transition as a double-click on it does: a field on its arrow, with the focus in it, from the next RenderNodeView.
void tachyon::StartTransition (NodeViewRef view, int node)
 Starts a transition from state node without a drag: it follows the pointer until a click on a state (the same one too) adds it; a click elsewhere or Escape drops it.
TransitionPath tachyon::StateTransitionPath (ConstNodeViewRef view, const StateTransition &transition, int32_t gap, int32_t loopSize)
 The arrow of transition: a straight line between the two states' edges, aimed from centre to centre; when the states are joined both ways, each arrow runs gap pixels to its own side, so the pair sits side by side.
int2 tachyon::TransitionLabelCentre (const TransitionPath &path, int2 size, int32_t margin)
 Where the middle of a label size big goes on path: half way along it and beside it, margin clear of the line, on the arrow's right as it runs, so the two of a pair both ways sit on opposite sides; over the top of a loop.
std::optional< ID > tachyon::TransitionAt (ConstNodeViewRef view, float2 canvasPos, float tolerance, int32_t gap, int32_t loopSize)
 The transition whose arrow passes within tolerance of canvasPos (node.pos space), the closest when several do, or whose label (view.state.transitionLabelBoxes) holds it; none when there's no such transition.