Class GraphEdit

Namespace
Forma
Assembly
Forma.dll

Editor graph canvas with selection, node movement, zoom state and explicit connection management.

[TemplatePart("PART_GraphCanvas", typeof(Container), true)]
public sealed class GraphEdit : TemplatedControl, IAddChild<Control>, IAddChild, INotifyPropertyChanged, IDisposable
Inheritance
GraphEdit
Implements
Inherited Members

Constructors

GraphEdit()

public GraphEdit()

Fields

GraphCanvasPartName

public const string GraphCanvasPartName = "PART_GraphCanvas"

Field Value

string

Properties

AccessibilityRole

public override AccessibilityRole AccessibilityRole { get; }

Property Value

AccessibilityRole

ArrangeButton

public Button ArrangeButton { get; }

Property Value

Button

Arranger

public GraphEditArranger Arranger { get; }

Property Value

GraphEditArranger

BoxSelectionEnabled

Enables Godot-style background drag selection over graph elements.

public bool BoxSelectionEnabled { get; set; }

Property Value

bool

BoxSelectionRect

The current retained box-selection rectangle in screen coordinates.

public Rectangle BoxSelectionRect { get; }

Property Value

Rectangle

ConnectionDragTarget

The compatible target currently under the pointer during a connection drag, if any.

public GraphConnection? ConnectionDragTarget { get; }

Property Value

GraphConnection?

ConnectionLinesAntialiased

public bool ConnectionLinesAntialiased { get; set; }

Property Value

bool

ConnectionLinesCurvature

public float ConnectionLinesCurvature { get; set; }

Property Value

float

ConnectionLinesThickness

public float ConnectionLinesThickness { get; set; }

Property Value

float

Connections

public IReadOnlyList<GraphConnection> Connections { get; }

Property Value

IReadOnlyList<GraphConnection>

GridPattern

public GraphEditGridPattern GridPattern { get; set; }

Property Value

GraphEditGridPattern

GridToggleButton

public Button GridToggleButton { get; }

Property Value

Button

IsBoxSelecting

Whether a background drag selection rectangle is currently active.

public bool IsBoxSelecting { get; }

Property Value

bool

IsConnectionDragging

Whether a graph-port connection is presently being dragged.

public bool IsConnectionDragging { get; }

Property Value

bool

IsKeyboardConnecting

public bool IsKeyboardConnecting { get; }

Property Value

bool

Minimap

Built-in minimap overlay, equivalent to Godot's get_minimap().

public GraphEditMinimap Minimap { get; }

Property Value

GraphEditMinimap

MinimapEnabled

public bool MinimapEnabled { get; set; }

Property Value

bool

MinimapOpacity

public float MinimapOpacity { get; set; }

Property Value

float

MinimapSize

public Vector2 MinimapSize { get; set; }

Property Value

Vector2

MinimapToggleButton

public Button MinimapToggleButton { get; }

Property Value

Button

Panner

public ViewPanner Panner { get; }

Property Value

ViewPanner

PanningScheme

public GraphEditPanningScheme PanningScheme { get; set; }

Property Value

GraphEditPanningScheme

RightDisconnectsEnabled

public bool RightDisconnectsEnabled { get; set; }

Property Value

bool

ScrollOffset

public Vector2 ScrollOffset { get; set; }

Property Value

Vector2

ShowArrangeButton

public bool ShowArrangeButton { get; set; }

Property Value

bool

ShowGrid

public bool ShowGrid { get; set; }

Property Value

bool

ShowGridButtons

public bool ShowGridButtons { get; set; }

Property Value

bool

ShowMenu

public bool ShowMenu { get; set; }

Property Value

bool

ShowMinimapButton

public bool ShowMinimapButton { get; set; }

Property Value

bool

ShowZoomButtons

public bool ShowZoomButtons { get; set; }

Property Value

bool

ShowZoomLabel

public bool ShowZoomLabel { get; set; }

Property Value

bool

SnappingDistance

public int SnappingDistance { get; set; }

Property Value

int

SnappingDistanceScale

public float SnappingDistanceScale { get; set; }

Property Value

float

SnappingDistanceSpinBox

Built-in snapping distance editor shown with Godot's grid controls.

public SpinBox SnappingDistanceSpinBox { get; }

Property Value

SpinBox

SnappingEnabled

public bool SnappingEnabled { get; set; }

Property Value

bool

SnappingToggleButton

public Button SnappingToggleButton { get; }

Property Value

Button

Toolbar

In-canvas GraphEdit toolbar, corresponding to Godot's toolbar menu panel.

public PanelContainer Toolbar { get; }

Property Value

PanelContainer

ToolbarButtons

public HBoxContainer ToolbarButtons { get; }

Property Value

HBoxContainer

TypeNames

public IReadOnlyDictionary<int, string> TypeNames { get; }

Property Value

IReadOnlyDictionary<int, string>

Zoom

public float Zoom { get; set; }

Property Value

float

ZoomInButton

public Button ZoomInButton { get; }

Property Value

Button

ZoomLabel

public Label ZoomLabel { get; }

Property Value

Label

ZoomMax

public float ZoomMax { get; set; }

Property Value

float

ZoomMin

public float ZoomMin { get; set; }

Property Value

float

ZoomOutButton

public Button ZoomOutButton { get; }

Property Value

Button

ZoomResetButton

public Button ZoomResetButton { get; }

Property Value

Button

ZoomStep

public float ZoomStep { get; set; }

Property Value

float

Methods

AddValidConnectionType(int, int)

Registers a directional pair of port types as a valid interactive connection target.

public void AddValidConnectionType(int fromType, int toType)

Parameters

fromType int
toType int

AddValidLeftDisconnectType(int)

public void AddValidLeftDisconnectType(int type)

Parameters

type int

AddValidRightDisconnectType(int)

public void AddValidRightDisconnectType(int type)

Parameters

type int

ArrangeChildren()

protected override void ArrangeChildren()

ArrangeNodes()

public void ArrangeNodes()

AttachGraphElementToFrame(string, string)

public void AttachGraphElementToFrame(string graphElement, string parentFrame)

Parameters

graphElement string
parentFrame string

ClearConnections()

public void ClearConnections()

ConnectNode(string, int, string, int)

public bool ConnectNode(string fromNode, int fromPort, string toNode, int toPort)

Parameters

fromNode string
fromPort int
toNode string
toPort int

Returns

bool

DeselectAll()

public void DeselectAll()

DetachGraphElementFromFrame(string)

public void DetachGraphElementFromFrame(string graphElement)

Parameters

graphElement string

DisconnectNode(string, int, string, int)

public bool DisconnectNode(string fromNode, int fromPort, string toNode, int toPort)

Parameters

fromNode string
fromPort int
toNode string
toPort int

Returns

bool

EndKeyboardConnecting(GraphNode, int, int)

public void EndKeyboardConnecting(GraphNode node, int inputPort, int outputPort)

Parameters

node GraphNode
inputPort int
outputPort int

ForceConnectionDragEnd()

public void ForceConnectionDragEnd()

GetAttachedNodesOfFrame(string)

public IReadOnlyList<string> GetAttachedNodesOfFrame(string graphFrame)

Parameters

graphFrame string

Returns

IReadOnlyList<string>

GetClosestConnectionAtPoint(Vector2, float)

Returns the closest retained connection to a screen-space point, matching Godot's hit query shape.

public GraphConnection? GetClosestConnectionAtPoint(Vector2 point, float maxDistance = 4)

Parameters

point Vector2
maxDistance float

Returns

GraphConnection?

GetConnectionActivity(string, int, string, int)

public float GetConnectionActivity(string fromNode, int fromPort, string toNode, int toPort)

Parameters

fromNode string
fromPort int
toNode string
toPort int

Returns

float

GetConnectionCount(string, int)

public int GetConnectionCount(string fromNode, int fromPort)

Parameters

fromNode string
fromPort int

Returns

int

GetConnectionLine(Vector2, Vector2)

Returns the retained screen-space connection curve points for the supplied endpoints.

public IReadOnlyList<Vector2> GetConnectionLine(Vector2 from, Vector2 to)

Parameters

from Vector2
to Vector2

Returns

IReadOnlyList<Vector2>

GetConnectionLinesCurvature()

public float GetConnectionLinesCurvature()

Returns

float

GetConnectionLinesThickness()

public float GetConnectionLinesThickness()

Returns

float

GetConnectionList()

public IReadOnlyList<GraphConnection> GetConnectionList()

Returns

IReadOnlyList<GraphConnection>

GetConnectionListFromNode(string)

public IReadOnlyList<GraphConnection> GetConnectionListFromNode(string node)

Parameters

node string

Returns

IReadOnlyList<GraphConnection>

GetConnectionsIntersectingWithRect(RectangleF)

Returns retained connections whose screen-space line segments intersect the supplied rectangle.

public IReadOnlyList<GraphConnection> GetConnectionsIntersectingWithRect(RectangleF rect)

Parameters

rect RectangleF

Returns

IReadOnlyList<GraphConnection>

GetElementFrame(string)

public GraphFrame GetElementFrame(string attachedGraphElement)

Parameters

attachedGraphElement string

Returns

GraphFrame

GetGridPattern()

public GraphEditGridPattern GetGridPattern()

Returns

GraphEditGridPattern

GetMenuHBox()

public HBoxContainer GetMenuHBox()

Returns

HBoxContainer

GetMinimapOpacity()

public float GetMinimapOpacity()

Returns

float

GetMinimapSize()

public Vector2 GetMinimapSize()

Returns

Vector2

GetPanningScheme()

public GraphEditPanningScheme GetPanningScheme()

Returns

GraphEditPanningScheme

GetScrollOffset()

public Vector2 GetScrollOffset()

Returns

Vector2

GetSelectedNodes()

public IReadOnlyList<GraphNode> GetSelectedNodes()

Returns

IReadOnlyList<GraphNode>

GetSnappingDistance()

public int GetSnappingDistance()

Returns

int

GetTypeNames()

public IReadOnlyDictionary<int, string> GetTypeNames()

Returns

IReadOnlyDictionary<int, string>

GetZoom()

public float GetZoom()

Returns

float

GetZoomMax()

public float GetZoomMax()

Returns

float

GetZoomMin()

public float GetZoomMin()

Returns

float

GetZoomStep()

public float GetZoomStep()

Returns

float

GraphToScreen(Vector2)

public Vector2 GraphToScreen(Vector2 graphPosition)

Parameters

graphPosition Vector2

Returns

Vector2

IsBoxSelectionEnabled()

public bool IsBoxSelectionEnabled()

Returns

bool

IsConnectionLinesAntialiased()

public bool IsConnectionLinesAntialiased()

Returns

bool

IsConnectionTargetValid(string, int, string, int)

Returns whether an output port may be used as an interactive connection source for an input port. Like Godot, equal types always match, the destination node can opt out of checking, and registered directional type pairs also match. This does not constrain ConnectNode(string, int, string, int), which is an explicit programmatic connection API in Godot as well.

public bool IsConnectionTargetValid(string fromNode, int fromPort, string toNode, int toPort)

Parameters

fromNode string
fromPort int
toNode string
toPort int

Returns

bool

IsKeyboardConnectingMode()

public bool IsKeyboardConnectingMode()

Returns

bool

IsMinimapEnabled()

public bool IsMinimapEnabled()

Returns

bool

IsNodeConnected(string, int, string, int)

public bool IsNodeConnected(string fromNode, int fromPort, string toNode, int toPort)

Parameters

fromNode string
fromPort int
toNode string
toPort int

Returns

bool

IsRightDisconnectsEnabled()

public bool IsRightDisconnectsEnabled()

Returns

bool

IsShowingArrangeButton()

public bool IsShowingArrangeButton()

Returns

bool

IsShowingGrid()

public bool IsShowingGrid()

Returns

bool

IsShowingGridButtons()

public bool IsShowingGridButtons()

Returns

bool

IsShowingMenu()

public bool IsShowingMenu()

Returns

bool

IsShowingMinimapButton()

public bool IsShowingMinimapButton()

Returns

bool

IsShowingZoomButtons()

public bool IsShowingZoomButtons()

Returns

bool

IsShowingZoomLabel()

public bool IsShowingZoomLabel()

Returns

bool

IsSnappingEnabled()

public bool IsSnappingEnabled()

Returns

bool

IsValidConnectionType(int, int)

Returns whether an explicit directional type pair is registered.

public bool IsValidConnectionType(int fromType, int toType)

Parameters

fromType int
toType int

Returns

bool

IsValidLeftDisconnectType(int)

public bool IsValidLeftDisconnectType(int type)

Parameters

type int

Returns

bool

IsValidRightDisconnectType(int)

public bool IsValidRightDisconnectType(int type)

Parameters

type int

Returns

bool

RaiseElement(GraphElement)

public void RaiseElement(GraphElement element)

Parameters

element GraphElement

RemoveValidConnectionType(int, int)

Removes a directional pair of port types from the interactive connection registry.

public void RemoveValidConnectionType(int fromType, int toType)

Parameters

fromType int
toType int

RemoveValidLeftDisconnectType(int)

public void RemoveValidLeftDisconnectType(int type)

Parameters

type int

RemoveValidRightDisconnectType(int)

public void RemoveValidRightDisconnectType(int type)

Parameters

type int

ScreenToGraph(Vector2)

public Vector2 ScreenToGraph(Vector2 screenPosition)

Parameters

screenPosition Vector2

Returns

Vector2

SelectNode(GraphNode)

public void SelectNode(GraphNode node)

Parameters

node GraphNode

SetBoxSelectionEnabled(bool)

public void SetBoxSelectionEnabled(bool enable)

Parameters

enable bool

SetConnectionActivity(string, int, string, int, float)

public void SetConnectionActivity(string fromNode, int fromPort, string toNode, int toPort, float amount)

Parameters

fromNode string
fromPort int
toNode string
toPort int
amount float

SetConnectionLinesAntialiased(bool)

public void SetConnectionLinesAntialiased(bool antialiased)

Parameters

antialiased bool

SetConnectionLinesCurvature(float)

public void SetConnectionLinesCurvature(float curvature)

Parameters

curvature float

SetConnectionLinesThickness(float)

public void SetConnectionLinesThickness(float pixels)

Parameters

pixels float

SetConnections(IEnumerable<GraphConnection>)

public void SetConnections(IEnumerable<GraphConnection> connections)

Parameters

connections IEnumerable<GraphConnection>

SetGridPattern(GraphEditGridPattern)

public void SetGridPattern(GraphEditGridPattern pattern)

Parameters

pattern GraphEditGridPattern

SetMinimapEnabled(bool)

public void SetMinimapEnabled(bool enable)

Parameters

enable bool

SetMinimapOpacity(float)

public void SetMinimapOpacity(float opacity)

Parameters

opacity float

SetMinimapSize(Vector2)

public void SetMinimapSize(Vector2 size)

Parameters

size Vector2

SetPanningScheme(GraphEditPanningScheme)

public void SetPanningScheme(GraphEditPanningScheme scheme)

Parameters

scheme GraphEditPanningScheme

SetRightDisconnects(bool)

public void SetRightDisconnects(bool enable)

Parameters

enable bool

SetScrollOffset(Vector2)

public void SetScrollOffset(Vector2 offset)

Parameters

offset Vector2

SetShowArrangeButton(bool)

public void SetShowArrangeButton(bool show)

Parameters

show bool

SetShowGrid(bool)

public void SetShowGrid(bool enable)

Parameters

enable bool

SetShowGridButtons(bool)

public void SetShowGridButtons(bool show)

Parameters

show bool

SetShowMenu(bool)

public void SetShowMenu(bool show)

Parameters

show bool

SetShowMinimapButton(bool)

public void SetShowMinimapButton(bool show)

Parameters

show bool

SetShowZoomButtons(bool)

public void SetShowZoomButtons(bool show)

Parameters

show bool

SetShowZoomLabel(bool)

public void SetShowZoomLabel(bool show)

Parameters

show bool

SetSnappingDistance(int)

public void SetSnappingDistance(int pixels)

Parameters

pixels int

SetSnappingEnabled(bool)

public void SetSnappingEnabled(bool enable)

Parameters

enable bool

SetTypeNames(IDictionary<int, string>)

public void SetTypeNames(IDictionary<int, string> typeNames)

Parameters

typeNames IDictionary<int, string>

SetZoom(float)

Sets zoom while keeping the graph coordinate under the viewport center fixed.

public void SetZoom(float zoom)

Parameters

zoom float

SetZoomCustom(float, Vector2)

Sets zoom while preserving the graph point under a local viewport coordinate.

public void SetZoomCustom(float zoom, Vector2 center)

Parameters

zoom float
center Vector2

SetZoomMax(float)

public void SetZoomMax(float zoomMax)

Parameters

zoomMax float

SetZoomMin(float)

public void SetZoomMin(float zoomMin)

Parameters

zoomMin float

SetZoomStep(float)

public void SetZoomStep(float zoomStep)

Parameters

zoomStep float

SnapPosition(Vector2)

Rounds a graph coordinate to the active Godot grid spacing.

public Vector2 SnapPosition(Vector2 graphPosition)

Parameters

graphPosition Vector2

Returns

Vector2

StartKeyboardConnecting(GraphNode, int, int)

public void StartKeyboardConnecting(GraphNode node, int inputPort, int outputPort)

Parameters

node GraphNode
inputPort int
outputPort int

TryBeginConnectionDrag(GraphNode, Point)

Begins an interactive connection drag when position is over one of node's ports.

public bool TryBeginConnectionDrag(GraphNode node, Point position)

Parameters

node GraphNode
position Point

Returns

bool

UpdateGraphFrame(GraphFrame)

Recomputes an autoshrink frame around its attached elements.

public void UpdateGraphFrame(GraphFrame frame)

Parameters

frame GraphFrame

ZoomIn()

public void ZoomIn()

ZoomOut()

public void ZoomOut()

ZoomReset()

public void ZoomReset()

Events

ConnectionDragEnded

public event Action<GraphEdit> ConnectionDragEnded

Event Type

Action<GraphEdit>

ConnectionDragStarted

public event Action<GraphEdit, string, int, bool> ConnectionDragStarted

Event Type

Action<GraphEdit, string, int, bool>

ConnectionFromEmpty

public event Action<GraphEdit, string, int, Vector2> ConnectionFromEmpty

Event Type

Action<GraphEdit, string, int, Vector2>

ConnectionRequest

public event Action<GraphEdit, GraphConnection> ConnectionRequest

Event Type

Action<GraphEdit, GraphConnection>

ConnectionToEmpty

public event Action<GraphEdit, string, int, Vector2> ConnectionToEmpty

Event Type

Action<GraphEdit, string, int, Vector2>

CopyNodesRequest

public event Action<GraphEdit> CopyNodesRequest

Event Type

Action<GraphEdit>

CutNodesRequest

public event Action<GraphEdit> CutNodesRequest

Event Type

Action<GraphEdit>

DeleteNodesRequest

public event Action<GraphEdit, IReadOnlyList<string>> DeleteNodesRequest

Event Type

Action<GraphEdit, IReadOnlyList<string>>

DisconnectionRequest

public event Action<GraphEdit, GraphConnection> DisconnectionRequest

Event Type

Action<GraphEdit, GraphConnection>

DuplicateNodesRequest

public event Action<GraphEdit> DuplicateNodesRequest

Event Type

Action<GraphEdit>

GraphElementsLinkedToFrameRequest

Requests application-owned attachment of dropped graph elements to a frame.

public event Action<GraphEdit, IReadOnlyList<string>, string> GraphElementsLinkedToFrameRequest

Event Type

Action<GraphEdit, IReadOnlyList<string>, string>

NodeSelected

public event Action<GraphEdit, GraphNode> NodeSelected

Event Type

Action<GraphEdit, GraphNode>

NodesArranged

public event Action<GraphEdit> NodesArranged

Event Type

Action<GraphEdit>

PasteNodesRequest

public event Action<GraphEdit> PasteNodesRequest

Event Type

Action<GraphEdit>

ScrollOffsetChanged

public event Action<GraphEdit, Vector2> ScrollOffsetChanged

Event Type

Action<GraphEdit, Vector2>

ZoomChanged

public event Action<GraphEdit, float> ZoomChanged

Event Type

Action<GraphEdit, float>