GraphEdit

    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 ) when using GraphEdits.

    Properties

    void

    add_valid_connection_type ( from_type, int to_type )

    void

    ( int type )

    void

    ( int type )

    void

    ( )

    Error

    ( String from, from_port, String to, to_port )

    void

    disconnect_node ( from, int from_port, to, int to_port )

    get_connection_list ( ) const

    get_zoom_hbox ( )

    is_node_connected ( from, int from_port, to, int to_port )

    is_valid_connection_type ( from_type, int to_type ) const

    void

    ( int from_type, to_type )

    void

    remove_valid_left_disconnect_type ( type )

    void

    remove_valid_right_disconnect_type ( type )

    void

    set_connection_activity ( from, int from_port, to, int to_port, amount )

    void

    set_selected ( node )

    Theme Properties

    activity

    Color( 1, 1, 1, 1 )

    grid_major

    Color( 1, 1, 1, 0.2 )

    grid_minor

    Color( 1, 1, 1, 0.05 )

    Color( 1, 1, 1, 0.3 )

    Color

    Color( 1, 1, 1, 0.8 )

    int

    160

    int

    80

    int

    24

    int

    26

    Texture

    Texture

    Texture

    Texture

    Texture

    StyleBox

    • _begin_node_move ( )

    Emitted at the beginning of a GraphNode movement.


    • _end_node_move ( )

    Emitted at the end of a GraphNode movement.


    • connection_from_empty ( to, int to_slot, release_position )

    Emitted when user dragging connection from input port into empty space of the graph.


    • connection_request ( String from, from_slot, String to, to_slot )

    Emitted to the GraphEdit when the connection between the from_slot slot of the from GraphNode and the to_slot slot of the GraphNode is attempted to be created.


    • connection_to_empty ( String from, from_slot, Vector2 release_position )

    Emitted when user dragging connection from output port into empty space of the graph.


    • copy_nodes_request ( )

    Emitted when the user presses Ctrl + C.


    • delete_nodes_request ( nodes )

    Emitted when a GraphNode is attempted to be removed from the GraphEdit. Provides a list of node names to be removed (all selected nodes, excluding nodes without closing button).


    • disconnection_request ( String from, from_slot, String to, to_slot )

    Emitted to the GraphEdit when the connection between from_slot slot of from GraphNode and to_slot slot of to GraphNode is attempted to be removed.


    • duplicate_nodes_request ( )

    Emitted when a GraphNode is attempted to be duplicated in the GraphEdit.


    • node_selected ( Node node )

    Emitted when a GraphNode is selected.


    • node_unselected ( node )

    • paste_nodes_request ( )

    Emitted when the user presses Ctrl + V.


    Emitted when a popup is requested. Happens on right-clicking in the GraphEdit. position is the position of the mouse pointer when the signal is sent.


    • scroll_offset_changed ( Vector2 ofs )

    Emitted when the scroll offset is changed by the user. It will not be emitted when changed in code.

    Property Descriptions

    • bool minimap_enabled

    Default

    true

    Setter

    set_minimap_enabled(value)

    Getter

    is_minimap_enabled()

    If true, the minimap is visible.


    • minimap_opacity

    Default

    0.65

    Setter

    set_minimap_opacity(value)

    Getter

    get_minimap_opacity()

    The opacity of the minimap rectangle.


    Default

    Vector2( 240, 160 )

    Setter

    set_minimap_size(value)

    Getter

    get_minimap_size()

    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.


    • right_disconnects

    Default

    false

    Setter

    set_right_disconnects(value)

    Getter

    is_right_disconnects_enabled()

    If true, enables disconnection of existing connections in the GraphEdit by dragging the right end.


    Default

    Vector2( 0, 0 )

    Setter

    set_scroll_ofs(value)

    Getter

    get_scroll_ofs()

    The scroll offset.


    • show_zoom_label

    If true, makes a label with the current zoom level visible. The zoom value is displayed in percents.


    • int snap_distance

    20

    Setter

    set_snap(value)

    Getter

    get_snap()

    The snapping distance in pixels.


    • use_snap

    Default

    true

    Setter

    set_use_snap(value)

    Getter

    is_using_snap()

    If true, enables snapping.


    Default

    1.0

    Setter

    set_zoom(value)

    Getter

    get_zoom()

    The current zoom value.


    • zoom_max

    Default

    2.0736

    Setter

    set_zoom_max(value)

    Getter

    get_zoom_max()

    The upper zoom limit.


    Default

    0.232568

    Setter

    set_zoom_min(value)

    Getter

    get_zoom_min()

    The lower zoom limit.


    • zoom_step

    Default

    1.2

    Setter

    set_zoom_step(value)

    Getter

    get_zoom_step()

    The step of each zoom level.

    • void add_valid_connection_type ( from_type, int to_type )

    Makes possible the connection between two different slot types. The type is defined with the method.


    • void add_valid_left_disconnect_type ( int type )

    Makes possible to disconnect nodes when dragging from the slot at the left if it has the specified type.


    • void add_valid_right_disconnect_type ( type )

    Makes possible to disconnect nodes when dragging from the slot at the right if it has the specified type.


    • void clear_connections ( )

    Removes all connections between nodes.


    • Error connect_node ( from, int from_port, to, int to_port )

    Create a connection between the from_port slot of the from GraphNode and the slot of the to GraphNode. If the connection already exists, no connection is created.


    • void disconnect_node ( from, int from_port, to, int to_port )

    Removes the connection between the from_port slot of the from GraphNode and the to_port slot of the to GraphNode. If the connection does not exist, no connection is removed.


    • get_connection_list ( ) const

    Returns an Array containing the list of connections. A connection consists in a structure of the form { from_port: 0, from: "GraphNode name 0", to_port: 1, to: "GraphNode name 1" }.


    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.

    Warning: 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 property.


    • bool is_node_connected ( from, int from_port, to, int to_port )

    Returns true if the from_port slot of the from GraphNode is connected to the to_port slot of the to GraphNode.


    • is_valid_connection_type ( int from_type, to_type ) const

    Returns whether it’s possible to connect slots of the specified types.


    • void remove_valid_connection_type ( int from_type, to_type )

    Makes it not possible to connect between two different slot types. The type is defined with the GraphNode.set_slot method.


    • void remove_valid_left_disconnect_type ( type )

    Removes the possibility to disconnect nodes when dragging from the slot at the left if it has the specified type.


    • void remove_valid_right_disconnect_type ( int type )

    Removes the possibility to disconnect nodes when dragging from the slot at the right if it has the specified type.


    • void set_connection_activity ( from, int from_port, to, int to_port, amount )

    Sets the coloration of the connection between from‘s from_port and to‘s to_port with the color provided in the activity theme property.


    • void set_selected ( Node node )

    Sets the specified node as the one selected.

    Theme Property Descriptions

    Default

    Color( 1, 1, 1, 1 )


    • grid_major

    Color of major grid lines.


    Default

    Color( 1, 1, 1, 0.05 )

    Color of minor grid lines.


    • selection_fill

    Default

    Color( 1, 1, 1, 0.3 )

    The fill color of the selection rectangle.


    Default

    Color( 1, 1, 1, 0.8 )

    The outline color of the selection rectangle.


    • bezier_len_neg

    Default

    160


    • int bezier_len_pos

    Default

    80


    • port_grab_distance_horizontal

    Default

    24

    The horizontal range within which a port can be grabbed (on both sides).


    • int port_grab_distance_vertical

    Default

    The vertical range within which a port can be grabbed (on both sides).


    • minimap

    The icon for the zoom out button.


    • more

    The icon for the zoom in button.


    The icon for the zoom reset button.



    • bg

    The background drawn under the grid.