Documentation
¶
Overview ¶
Package GraphEdit provides methods for working with GraphEdit object instances.
Index ¶
- type Advanced
- type Any
- type Connection
- type GridPattern
- type Implementation
- type Instance
- func (self Instance) AddValidConnectionType(from_type int, to_type int)
- func (self Instance) AddValidLeftDisconnectType(atype int)
- func (self Instance) AddValidRightDisconnectType(atype int)
- func (self Instance) ArrangeNodes()
- func (self Instance) AsCanvasItem() CanvasItem.Instance
- func (self Instance) AsControl() Control.Instance
- func (self Instance) AsGraphEdit() Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AttachGraphElementToFrame(element string, frame_ string)
- func (self Instance) ClearConnections()
- func (self Instance) ConnectNode(from_node string, from_port int, to_node string, to_port int) error
- func (self Instance) ConnectionLinesAntialiased() bool
- func (self Instance) ConnectionLinesCurvature() Float.X
- func (self Instance) ConnectionLinesThickness() Float.X
- func (self Instance) Connections() []map[any]any
- func (self Instance) DetachGraphElementFromFrame(element string)
- func (self Instance) DisconnectNode(from_node string, from_port int, to_node string, to_port int)
- func (self Instance) ForceConnectionDragEnd()
- func (self Instance) GetAttachedNodesOfFrame(frame_ string) []string
- func (self Instance) GetClosestConnectionAtPoint(point Vector2.XY) Connection
- func (self Instance) GetConnectionCount(from_node string, from_port int) int
- func (self Instance) GetConnectionLine(from_node Vector2.XY, to_node Vector2.XY) []Vector2.XY
- func (self Instance) GetConnectionsIntersectingWithRect(rect Rect2.PositionSize) []Connection
- func (self Instance) GetElementFrame(element string) [1]gdclass.GraphFrame
- func (self Instance) GetMenuHbox() [1]gdclass.HBoxContainer
- func (self Instance) GridPattern() gdclass.GraphEditGridPattern
- func (self Instance) IsNodeConnected(from_node string, from_port int, to_node string, to_port int) bool
- func (self Instance) IsValidConnectionType(from_type int, to_type int) bool
- func (self Instance) MinimapEnabled() bool
- func (self Instance) MinimapOpacity() Float.X
- func (self Instance) MinimapSize() Vector2.XY
- func (self Instance) OnBeginNodeMove(cb func())
- func (self Instance) OnConnectionDragEnded(cb func())
- func (self Instance) OnConnectionDragStarted(cb func(from_node string, from_port int, is_output bool))
- func (self Instance) OnConnectionFromEmpty(cb func(to_node string, to_port int, release_position Vector2.XY))
- func (self Instance) OnConnectionRequest(cb func(from_node string, from_port int, to_node string, to_port int))
- func (self Instance) OnConnectionToEmpty(cb func(from_node string, from_port int, release_position Vector2.XY))
- func (self Instance) OnCopyNodesRequest(cb func())
- func (self Instance) OnCutNodesRequest(cb func())
- func (self Instance) OnDeleteNodesRequest(cb func(nodes []string))
- func (self Instance) OnDisconnectionRequest(cb func(from_node string, from_port int, to_node string, to_port int))
- func (self Instance) OnDuplicateNodesRequest(cb func())
- func (self Instance) OnEndNodeMove(cb func())
- func (self Instance) OnFrameRectChanged(cb func(frame_ [1]gdclass.GraphFrame, new_rect Rect2.PositionSize))
- func (self Instance) OnGraphElementsLinkedToFrameRequest(cb func(elements []any, frame_ string))
- func (self Instance) OnNodeDeselected(cb func(node [1]gdclass.Node))
- func (self Instance) OnNodeSelected(cb func(node [1]gdclass.Node))
- func (self Instance) OnPasteNodesRequest(cb func())
- func (self Instance) OnPopupRequest(cb func(at_position Vector2.XY))
- func (self Instance) OnScrollOffsetChanged(cb func(offset Vector2.XY))
- func (self Instance) PanningScheme() gdclass.GraphEditPanningScheme
- func (self Instance) RemoveValidConnectionType(from_type int, to_type int)
- func (self Instance) RemoveValidLeftDisconnectType(atype int)
- func (self Instance) RemoveValidRightDisconnectType(atype int)
- func (self Instance) RightDisconnects() bool
- func (self Instance) ScrollOffset() Vector2.XY
- func (self Instance) SetConnectionActivity(from_node string, from_port int, to_node string, to_port int, amount Float.X)
- func (self Instance) SetConnectionLinesAntialiased(value bool)
- func (self Instance) SetConnectionLinesCurvature(value Float.X)
- func (self Instance) SetConnectionLinesThickness(value Float.X)
- func (self Instance) SetConnections(value []map[any]any)
- func (self Instance) SetGridPattern(value gdclass.GraphEditGridPattern)
- func (self Instance) SetMinimapEnabled(value bool)
- func (self Instance) SetMinimapOpacity(value Float.X)
- func (self Instance) SetMinimapSize(value Vector2.XY)
- func (self Instance) SetPanningScheme(value gdclass.GraphEditPanningScheme)
- func (self Instance) SetRightDisconnects(value bool)
- func (self Instance) SetScrollOffset(value Vector2.XY)
- func (self Instance) SetSelected(node [1]gdclass.Node)
- func (self Instance) SetShowArrangeButton(value bool)
- func (self Instance) SetShowGrid(value bool)
- func (self Instance) SetShowGridButtons(value bool)
- func (self Instance) SetShowMenu(value bool)
- func (self Instance) SetShowMinimapButton(value bool)
- func (self Instance) SetShowZoomButtons(value bool)
- func (self Instance) SetShowZoomLabel(value bool)
- func (self Instance) SetSnappingDistance(value int)
- func (self Instance) SetSnappingEnabled(value bool)
- func (self Instance) SetZoom(value Float.X)
- func (self Instance) SetZoomMax(value Float.X)
- func (self Instance) SetZoomMin(value Float.X)
- func (self Instance) SetZoomStep(value Float.X)
- func (self Instance) ShowArrangeButton() bool
- func (self Instance) ShowGrid() bool
- func (self Instance) ShowGridButtons() bool
- func (self Instance) ShowMenu() bool
- func (self Instance) ShowMinimapButton() bool
- func (self Instance) ShowZoomButtons() bool
- func (self Instance) ShowZoomLabel() bool
- func (self Instance) SnappingDistance() int
- func (self Instance) SnappingEnabled() bool
- func (self *Instance) UnsafePointer() unsafe.Pointer
- func (self Instance) Virtual(name string) reflect.Value
- func (self Instance) Zoom() Float.X
- func (self Instance) ZoomMax() Float.X
- func (self Instance) ZoomMin() Float.X
- func (self Instance) ZoomStep() Float.X
- type Interface
- type PanningScheme
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Connection ¶
type GridPattern ¶
type GridPattern = gdclass.GraphEditGridPattern //gd:GraphEdit.GridPattern
const ( /*Draw the grid using solid lines.*/ GridPatternLines GridPattern = 0 /*Draw the grid using dots.*/ GridPatternDots GridPattern = 1 )
type Implementation ¶
type Implementation = implementation
Implementation implements Interface with empty methods.
type Instance ¶
[GraphEdit] provides tools for creation, manipulation, and display of various graphs. Its main purpose in the engine is to power the visual programming systems, such as visual shaders, but it is also available for use in user projects. [GraphEdit] by itself is only an empty container, representing an infinite grid where [GraphNode]s can be placed. Each [GraphNode] represents a node in the graph, a single unit of data in the connected scheme. [GraphEdit], in turn, helps to control various interactions with nodes and between nodes. When the user attempts to connect, disconnect, or delete a [GraphNode], a signal is emitted in the [GraphEdit], but no action is taken by default. It is the responsibility of the programmer utilizing this control to implement the necessary logic to determine how each request should be handled. [b]Performance:[/b] It is greatly advised to enable low-processor usage mode (see [member OS.low_processor_usage_mode]) when using GraphEdits. [b]Note:[/b] Keep in mind that [method Node.get_children] will also return the connection layer node named [code]_connection_layer[/code] due to technical limitations. This behavior may change in future releases.
See [Interface] for methods that can be overridden by a [Class] that extends it.
%!(EXTRA string=GraphEdit)
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AddValidConnectionType ¶
Allows the connection between two different port types. The port type is defined individually for the left and the right port of each slot with the [method GraphNode.set_slot] method. See also [method is_valid_connection_type] and [method remove_valid_connection_type].
func (Instance) AddValidLeftDisconnectType ¶
Allows to disconnect nodes when dragging from the left port of the [GraphNode]'s slot if it has the specified type. See also [method remove_valid_left_disconnect_type].
func (Instance) AddValidRightDisconnectType ¶
Allows to disconnect nodes when dragging from the right port of the [GraphNode]'s slot if it has the specified type. See also [method remove_valid_right_disconnect_type].
func (Instance) ArrangeNodes ¶
func (self Instance) ArrangeNodes()
Rearranges selected nodes in a layout with minimum crossings between connections and uniform horizontal and vertical gap between nodes.
func (Instance) AsCanvasItem ¶
func (self Instance) AsCanvasItem() CanvasItem.Instance
func (Instance) AsGraphEdit ¶
func (Instance) AttachGraphElementToFrame ¶
Attaches the [param element] [GraphElement] to the [param frame] [GraphFrame].
func (Instance) ClearConnections ¶
func (self Instance) ClearConnections()
Removes all connections between nodes.
func (Instance) ConnectNode ¶
func (self Instance) ConnectNode(from_node string, from_port int, to_node string, to_port int) error
Create a connection between the [param from_port] of the [param from_node] [GraphNode] and the [param to_port] of the [param to_node] [GraphNode]. If the connection already exists, no connection is created. Connections with [param keep_alive] set to [code]false[/code] may be deleted automatically if invalid during a redraw.
func (Instance) ConnectionLinesAntialiased ¶
func (Instance) ConnectionLinesCurvature ¶
func (Instance) ConnectionLinesThickness ¶
func (Instance) Connections ¶
func (Instance) DetachGraphElementFromFrame ¶
Detaches the [param element] [GraphElement] from the [GraphFrame] it is currently attached to.
func (Instance) DisconnectNode ¶
Removes the connection between the [param from_port] of the [param from_node] [GraphNode] and the [param to_port] of the [param to_node] [GraphNode]. If the connection does not exist, no connection is removed.
func (Instance) ForceConnectionDragEnd ¶
func (self Instance) ForceConnectionDragEnd()
Ends the creation of the current connection. In other words, if you are dragging a connection you can use this method to abort the process and remove the line that followed your cursor. This is best used together with [signal connection_drag_started] and [signal connection_drag_ended] to add custom behavior like node addition through shortcuts. [b]Note:[/b] This method suppresses any other connection request signals apart from [signal connection_drag_ended].
func (Instance) GetAttachedNodesOfFrame ¶
Returns an array of node names that are attached to the [GraphFrame] with the given name.
func (Instance) GetClosestConnectionAtPoint ¶
func (self Instance) GetClosestConnectionAtPoint(point Vector2.XY) Connection
Returns the closest connection to the given point in screen space. If no connection is found within [param max_distance] pixels, an empty [Dictionary] is returned. A connection is represented as a [Dictionary] in the form of: [codeblock]
{ from_node: StringName, from_port: int, to_node: StringName, to_port: int, keep_alive: bool }
[/codeblock] For example, getting a connection at a given mouse position can be achieved like this: [codeblocks] [gdscript] var connection = get_closest_connection_at_point(mouse_event.get_position()) [/gdscript] [/codeblocks]
func (Instance) GetConnectionCount ¶
Returns the number of connections from [param from_port] of [param from_node].
func (Instance) GetConnectionLine ¶
Returns the points which would make up a connection between [param from_node] and [param to_node].
func (Instance) GetConnectionsIntersectingWithRect ¶
func (self Instance) GetConnectionsIntersectingWithRect(rect Rect2.PositionSize) []Connection
Returns an [Array] containing the list of connections that intersect with the given [Rect2]. A connection is represented as a [Dictionary] in the form of: [codeblock]
{ from_node: StringName, from_port: int, to_node: StringName, to_port: int, keep_alive: bool }
[/codeblock]
func (Instance) GetElementFrame ¶
func (self Instance) GetElementFrame(element string) [1]gdclass.GraphFrame
Returns the [GraphFrame] that contains the [GraphElement] with the given name.
func (Instance) GetMenuHbox ¶
func (self Instance) GetMenuHbox() [1]gdclass.HBoxContainer
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.
func (Instance) GridPattern ¶
func (self Instance) GridPattern() gdclass.GraphEditGridPattern
func (Instance) IsNodeConnected ¶
func (self Instance) IsNodeConnected(from_node string, from_port int, to_node string, to_port int) bool
Returns [code]true[/code] if the [param from_port] of the [param from_node] [GraphNode] is connected to the [param to_port] of the [param to_node] [GraphNode].
func (Instance) IsValidConnectionType ¶
Returns whether it's possible to make a connection between two different port types. The port type is defined individually for the left and the right port of each slot with the [method GraphNode.set_slot] method. See also [method add_valid_connection_type] and [method remove_valid_connection_type].
func (Instance) MinimapEnabled ¶
func (Instance) MinimapOpacity ¶
func (Instance) MinimapSize ¶
func (Instance) OnBeginNodeMove ¶
func (self Instance) OnBeginNodeMove(cb func())
func (Instance) OnConnectionDragEnded ¶
func (self Instance) OnConnectionDragEnded(cb func())
func (Instance) OnConnectionDragStarted ¶
func (Instance) OnConnectionFromEmpty ¶
func (Instance) OnConnectionRequest ¶
func (Instance) OnConnectionToEmpty ¶
func (Instance) OnCopyNodesRequest ¶
func (self Instance) OnCopyNodesRequest(cb func())
func (Instance) OnCutNodesRequest ¶
func (self Instance) OnCutNodesRequest(cb func())
func (Instance) OnDeleteNodesRequest ¶
func (Instance) OnDisconnectionRequest ¶
func (Instance) OnDuplicateNodesRequest ¶
func (self Instance) OnDuplicateNodesRequest(cb func())
func (Instance) OnEndNodeMove ¶
func (self Instance) OnEndNodeMove(cb func())
func (Instance) OnFrameRectChanged ¶
func (self Instance) OnFrameRectChanged(cb func(frame_ [1]gdclass.GraphFrame, new_rect Rect2.PositionSize))
func (Instance) OnGraphElementsLinkedToFrameRequest ¶
func (Instance) OnNodeDeselected ¶
func (Instance) OnNodeSelected ¶
func (Instance) OnPasteNodesRequest ¶
func (self Instance) OnPasteNodesRequest(cb func())
func (Instance) OnPopupRequest ¶
func (Instance) OnScrollOffsetChanged ¶
func (Instance) PanningScheme ¶
func (self Instance) PanningScheme() gdclass.GraphEditPanningScheme
func (Instance) RemoveValidConnectionType ¶
Disallows the connection between two different port types previously allowed by [method add_valid_connection_type]. The port type is defined individually for the left and the right port of each slot with the [method GraphNode.set_slot] method. See also [method is_valid_connection_type].
func (Instance) RemoveValidLeftDisconnectType ¶
Disallows to disconnect nodes when dragging from the left port of the [GraphNode]'s slot if it has the specified type. Use this to disable disconnection previously allowed with [method add_valid_left_disconnect_type].
func (Instance) RemoveValidRightDisconnectType ¶
Disallows to disconnect nodes when dragging from the right port of the [GraphNode]'s slot if it has the specified type. Use this to disable disconnection previously allowed with [method add_valid_right_disconnect_type].
func (Instance) RightDisconnects ¶
func (Instance) ScrollOffset ¶
func (Instance) SetConnectionActivity ¶
func (self Instance) SetConnectionActivity(from_node string, from_port int, to_node string, to_port int, amount Float.X)
Sets the coloration of the connection between [param from_node]'s [param from_port] and [param to_node]'s [param to_port] with the color provided in the [theme_item activity] theme property. The color is linearly interpolated between the connection color and the activity color using [param amount] as weight.
func (Instance) SetConnectionLinesAntialiased ¶
func (Instance) SetConnectionLinesCurvature ¶
func (Instance) SetConnectionLinesThickness ¶
func (Instance) SetConnections ¶
func (Instance) SetGridPattern ¶
func (self Instance) SetGridPattern(value gdclass.GraphEditGridPattern)
func (Instance) SetMinimapEnabled ¶
func (Instance) SetMinimapOpacity ¶
func (Instance) SetMinimapSize ¶
func (Instance) SetPanningScheme ¶
func (self Instance) SetPanningScheme(value gdclass.GraphEditPanningScheme)
func (Instance) SetRightDisconnects ¶
func (Instance) SetScrollOffset ¶
func (Instance) SetSelected ¶
Sets the specified [param node] as the one selected.
func (Instance) SetShowArrangeButton ¶
func (Instance) SetShowGrid ¶
func (Instance) SetShowGridButtons ¶
func (Instance) SetShowMenu ¶
func (Instance) SetShowMinimapButton ¶
func (Instance) SetShowZoomButtons ¶
func (Instance) SetShowZoomLabel ¶
func (Instance) SetSnappingDistance ¶
func (Instance) SetSnappingEnabled ¶
func (Instance) SetZoomMax ¶
func (Instance) SetZoomMin ¶
func (Instance) SetZoomStep ¶
func (Instance) ShowArrangeButton ¶
func (Instance) ShowGridButtons ¶
func (Instance) ShowMinimapButton ¶
func (Instance) ShowZoomButtons ¶
func (Instance) ShowZoomLabel ¶
func (Instance) SnappingDistance ¶
func (Instance) SnappingEnabled ¶
func (*Instance) UnsafePointer ¶
type Interface ¶
type Interface interface { //Returns whether the [param mouse_position] is in the input hot zone. //By default, a hot zone is a [Rect2] positioned such that its center is at [param in_node].[method GraphNode.get_input_port_position]([param in_port]) (For output's case, call [method GraphNode.get_output_port_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(in_node, in_port, mouse_position): // var port_size = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical")) // var port_pos = in_node.get_position() + in_node.get_input_port_position(in_port) - port_size / 2 // var rect = Rect2(port_pos, port_size) // // return rect.has_point(mouse_position) //[/codeblock] IsInInputHotzone(in_node Object.Instance, in_port int, mouse_position Vector2.XY) bool //Returns whether the [param mouse_position] 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(in_node, in_port, mouse_position): // var port_size = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical")) // var port_pos = in_node.get_position() + in_node.get_output_port_position(in_port) - port_size / 2 // var rect = Rect2(port_pos, port_size) // // return rect.has_point(mouse_position) //[/codeblock] IsInOutputHotzone(in_node Object.Instance, in_port int, mouse_position Vector2.XY) bool //Virtual method which can be overridden to customize how connections are drawn. GetConnectionLine(from_position Vector2.XY, to_position Vector2.XY) []Vector2.XY //This virtual method can be used to insert additional error detection while the user is dragging a connection over a valid port. //Return [code]true[/code] if the connection is indeed valid or return [code]false[/code] if the connection is impossible. If the connection is impossible, no snapping to the port and thus no connection request to that port will happen. //In this example a connection to same node is suppressed: //[codeblocks] //[gdscript] //func _is_node_hover_valid(from, from_port, to, to_port): // return from != to //[/gdscript] //[csharp] //public override bool _IsNodeHoverValid(StringName fromNode, int fromPort, StringName toNode, int toPort) //{ // return fromNode != toNode; //} //[/csharp] //[/codeblocks] IsNodeHoverValid(from_node string, from_port int, to_node string, to_port int) bool }
type PanningScheme ¶
type PanningScheme = gdclass.GraphEditPanningScheme //gd:GraphEdit.PanningScheme
const ( /*[kbd]Mouse Wheel[/kbd] will zoom, [kbd]Ctrl + Mouse Wheel[/kbd] will move the view.*/ ScrollZooms PanningScheme = 0 /*[kbd]Mouse Wheel[/kbd] will move the view, [kbd]Ctrl + Mouse Wheel[/kbd] will zoom.*/ ScrollPans PanningScheme = 1 )