GraphEdit is an area capable of showing various GraphNodes. It manages connection events between them.
GraphEdit manages the showing of GraphNodes it contains, as well as connections and disconnections between them. Signals are sent for each of these two events. Disconnection between GraphNode slots is disabled by default.
It is greatly advised to enable low-processor usage mode (see [member OS.low_processor_usage_mode]) when using GraphEdits.
Virtual method which can be overridden to customize how connections are drawn.
Returns whether the [code]mouse_position[/code] is in the input hot zone.
By default, a hot zone is a [Rect2] positioned such that its center is at [code]graph_node[/code].[method GraphNode.get_connection_input_position]([code]slot_index[/code]) (For output's case, call [method GraphNode.get_connection_output_position] instead). The hot zone's width is twice the Theme Property [code]port_grab_distance_horizontal[/code], and its height is twice the [code]port_grab_distance_vertical[/code].
Below is a sample code to help get started:
[codeblock]
func _is_in_input_hotzone(graph_node, slot_index, mouse_position):
var slot_size : Vector2 = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical"))
var slot_pos : Vector2 = graph_node.get_position() + graph_node.get_connection_input_position(slot_index) - slot_size / 2
var rect = Rect2(slot_pos, slot_size)
return rect.has_point(mouse_position)
[/codeblock]
Returns whether the [code]mouse_position[/code] is in the output hot zone. For more information on hot zones, see [method _is_in_input_hotzone].
Below is a sample code to help get started:
[codeblock]
func _is_in_output_hotzone(graph_node, slot_index, mouse_position):
var slot_size : Vector2 = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical"))
var slot_pos : Vector2 = graph_node.get_position() + graph_node.get_connection_output_position(slot_index) - slot_size / 2
var rect = Rect2(slot_pos, slot_size)
return rect.has_point(mouse_position)
[/codeblock]
Makes possible the connection between two different slot types. The type is defined with the [method GraphNode.set_slot] method.
Makes possible to disconnect nodes when dragging from the slot at the left if it has the specified type.
Makes possible to disconnect nodes when dragging from the slot at the right if it has the specified type.
Rearranges selected nodes in a layout with minimum crossings between connections and uniform horizontal and vertical gap between nodes.
Removes all connections between nodes.
Create a connection between the [code]from_port[/code] slot of the [code]from[/code] GraphNode and the [code]to_port[/code] slot of the [code]to[/code] GraphNode. If the connection already exists, no connection is created.
Removes the connection between the [code]from_port[/code] slot of the [code]from[/code] GraphNode and the [code]to_port[/code] slot of the [code]to[/code] GraphNode. If the connection does not exist, no connection is removed.
Returns the points which would make up a connection between [code]from[/code] and [code]to[/code].
Returns an Array containing the list of connections. A connection consists in a structure of the form [code]{ from_port: 0, from: "GraphNode name 0", to_port: 1, to: "GraphNode name 1" }[/code].
Gets the [HBoxContainer] that contains the zooming and grid snap controls in the top left of the graph. You can use this method to reposition the toolbar or to add your own custom controls to it.
[b]Warning:[/b] This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their [member CanvasItem.visible] property.
Returns [code]true[/code] if the [code]from_port[/code] slot of the [code]from[/code] GraphNode is connected to the [code]to_port[/code] slot of the [code]to[/code] GraphNode.
Returns whether it's possible to connect slots of the specified types.
Makes it not possible to connect between two different slot types. The type is defined with the [method GraphNode.set_slot] method.
Removes the possibility to disconnect nodes when dragging from the slot at the left if it has the specified type.
Removes the possibility to disconnect nodes when dragging from the slot at the right if it has the specified type.
Sets the coloration of the connection between [code]from[/code]'s [code]from_port[/code] and [code]to[/code]'s [code]to_port[/code] with the color provided in the [theme_item activity] theme property.
Sets the specified [code]node[/code] as the one selected.
If [code]true[/code], the lines between nodes will use antialiasing.
The thickness of the lines between the nodes.
If [code]true[/code], the minimap is visible.
The opacity of the minimap rectangle.
The size of the minimap rectangle. The map itself is based on the size of the grid area and is scaled to fit this rectangle.
If [code]true[/code], enables disconnection of existing connections in the GraphEdit by dragging the right end.
The scroll offset.
If [code]true[/code], makes a label with the current zoom level visible. The zoom value is displayed in percents.
The snapping distance in pixels.
If [code]true[/code], enables snapping.
The current zoom value.
The upper zoom limit.
The lower zoom limit.
The step of each zoom level.
Emitted at the beginning of a GraphNode movement.
Emitted when user dragging connection from input port into empty space of the graph.
Emitted to the GraphEdit when the connection between the [code]from_slot[/code] slot of the [code]from[/code] GraphNode and the [code]to_slot[/code] slot of the [code]to[/code] GraphNode is attempted to be created.
Emitted when user dragging connection from output port into empty space of the graph.
Emitted when the user presses [kbd]Ctrl + C[/kbd].
Emitted when a GraphNode is attempted to be removed from the GraphEdit.
Emitted to the GraphEdit when the connection between [code]from_slot[/code] slot of [code]from[/code] GraphNode and [code]to_slot[/code] slot of [code]to[/code] GraphNode is attempted to be removed.
Emitted when a GraphNode is attempted to be duplicated in the GraphEdit.
Emitted at the end of a GraphNode movement.
Emitted when a GraphNode is selected.
Emitted when the user presses [kbd]Ctrl + V[/kbd].
Emitted when a popup is requested. Happens on right-clicking in the GraphEdit. [code]position[/code] is the position of the mouse pointer when the signal is sent.
Emitted when the scroll offset is changed by the user. It will not be emitted when changed in code.
Color of major grid lines.
Color of minor grid lines.
The fill color of the selection rectangle.
The outline color of the selection rectangle.
The horizontal range within which a port can be grabbed (on both sides).
The vertical range within which a port can be grabbed (on both sides).
The icon for the zoom out button.
The icon for the zoom in button.
The icon for the zoom reset button.
The icon for the snap toggle button.
The background drawn under the grid.