GraphNode

Experimental: This class may be changed or removed in future versions.

Inherits:GraphElement<Container<Control<CanvasItem<Node<Object

A container with connection ports, representing a node in aGraphEdit.

Description

GraphNode allows to create nodes for aGraphEdit graph with customizable content based on its child controls.GraphNode is derived fromContainer and it is responsible for placing its children on screen. This works similar toVBoxContainer. Children, in turn, provideGraphNode with so-called slots, each of which can have a connection port on either side.

EachGraphNode slot is defined by its index and can provide the node with up to two ports: one on the left, and one on the right. By convention the left port is also referred to as theinput port and the right port is referred to as theoutput port. Each port can be enabled and configured individually, using different type and color. The type is an arbitrary value that you can define using your own considerations. The parentGraphEdit will receive this information on each connect and disconnect request.

Slots can be configured in the Inspector dock once you add at least one childControl. The properties are grouped by each slot's index in the "Slot" section.

Note: While GraphNode is set up using slots and slot indices, connections are made between the ports which are enabled. Because of thatGraphEdit uses the port's index and not the slot's index. You can useget_input_port_slot() andget_output_port_slot() to get the slot index from the port index.

Properties

bool

ignore_invalid_connection_type

false

MouseFilter

mouse_filter

0 (overridesControl)

String

title

""

Methods

void

_draw_port(slot_index:int, position:Vector2i, left:bool, color:Color)virtual

void

clear_all_slots()

void

clear_slot(slot_index:int)

Color

get_input_port_color(port_idx:int)

int

get_input_port_count()

Vector2

get_input_port_position(port_idx:int)

int

get_input_port_slot(port_idx:int)

int

get_input_port_type(port_idx:int)

Color

get_output_port_color(port_idx:int)

int

get_output_port_count()

Vector2

get_output_port_position(port_idx:int)

int

get_output_port_slot(port_idx:int)

int

get_output_port_type(port_idx:int)

Color

get_slot_color_left(slot_index:int)const

Color

get_slot_color_right(slot_index:int)const

Texture2D

get_slot_custom_icon_left(slot_index:int)const

Texture2D

get_slot_custom_icon_right(slot_index:int)const

int

get_slot_type_left(slot_index:int)const

int

get_slot_type_right(slot_index:int)const

HBoxContainer

get_titlebar_hbox()

bool

is_slot_draw_stylebox(slot_index:int)const

bool

is_slot_enabled_left(slot_index:int)const

bool

is_slot_enabled_right(slot_index:int)const

void

set_slot(slot_index:int, enable_left_port:bool, type_left:int, color_left:Color, enable_right_port:bool, type_right:int, color_right:Color, custom_icon_left:Texture2D = null, custom_icon_right:Texture2D = null, draw_stylebox:bool = true)

void

set_slot_color_left(slot_index:int, color:Color)

void

set_slot_color_right(slot_index:int, color:Color)

void

set_slot_custom_icon_left(slot_index:int, custom_icon:Texture2D)

void

set_slot_custom_icon_right(slot_index:int, custom_icon:Texture2D)

void

set_slot_draw_stylebox(slot_index:int, enable:bool)

void

set_slot_enabled_left(slot_index:int, enable:bool)

void

set_slot_enabled_right(slot_index:int, enable:bool)

void

set_slot_type_left(slot_index:int, type:int)

void

set_slot_type_right(slot_index:int, type:int)

Theme Properties

Color

resizer_color

Color(0.875,0.875,0.875,1)

int

port_h_offset

0

int

separation

2

Texture2D

port

StyleBox

panel

StyleBox

panel_selected

StyleBox

slot

StyleBox

titlebar

StyleBox

titlebar_selected


Signals

slot_updated(slot_index:int)🔗

Emitted when any GraphNode's slot is updated.


Property Descriptions

boolignore_invalid_connection_type =false🔗

Iftrue, you can connect ports with different types, even if the connection was not explicitly allowed in the parentGraphEdit.


Stringtitle =""🔗

The text displayed in the GraphNode's title bar.


Method Descriptions

void_draw_port(slot_index:int, position:Vector2i, left:bool, color:Color)virtual🔗

There is currently no description for this method. Please help us bycontributing one!


voidclear_all_slots()🔗

Disables all slots of the GraphNode. This will remove all input/output ports from the GraphNode.


voidclear_slot(slot_index:int)🔗

Disables the slot with the givenslot_index. This will remove the corresponding input and output port from the GraphNode.


Colorget_input_port_color(port_idx:int)🔗

Returns theColor of the input port with the givenport_idx.


intget_input_port_count()🔗

Returns the number of slots with an enabled input port.


Vector2get_input_port_position(port_idx:int)🔗

Returns the position of the input port with the givenport_idx.


intget_input_port_slot(port_idx:int)🔗

Returns the corresponding slot index of the input port with the givenport_idx.


intget_input_port_type(port_idx:int)🔗

Returns the type of the input port with the givenport_idx.


Colorget_output_port_color(port_idx:int)🔗

Returns theColor of the output port with the givenport_idx.


intget_output_port_count()🔗

Returns the number of slots with an enabled output port.


Vector2get_output_port_position(port_idx:int)🔗

Returns the position of the output port with the givenport_idx.


intget_output_port_slot(port_idx:int)🔗

Returns the corresponding slot index of the output port with the givenport_idx.


intget_output_port_type(port_idx:int)🔗

Returns the type of the output port with the givenport_idx.


Colorget_slot_color_left(slot_index:int)const🔗

Returns the left (input)Color of the slot with the givenslot_index.


Colorget_slot_color_right(slot_index:int)const🔗

Returns the right (output)Color of the slot with the givenslot_index.


Texture2Dget_slot_custom_icon_left(slot_index:int)const🔗

Returns the left (input) customTexture2D of the slot with the givenslot_index.


Texture2Dget_slot_custom_icon_right(slot_index:int)const🔗

Returns the right (output) customTexture2D of the slot with the givenslot_index.


intget_slot_type_left(slot_index:int)const🔗

Returns the left (input) type of the slot with the givenslot_index.


intget_slot_type_right(slot_index:int)const🔗

Returns the right (output) type of the slot with the givenslot_index.


HBoxContainerget_titlebar_hbox()🔗

Returns theHBoxContainer used for the title bar, only containing aLabel for displaying the title by default. This can be used to add custom controls to the title bar such as option or close buttons.


boolis_slot_draw_stylebox(slot_index:int)const🔗

Returnstrue if the backgroundStyleBox of the slot with the givenslot_index is drawn.


boolis_slot_enabled_left(slot_index:int)const🔗

Returnstrue if left (input) side of the slot with the givenslot_index is enabled.


boolis_slot_enabled_right(slot_index:int)const🔗

Returnstrue if right (output) side of the slot with the givenslot_index is enabled.


voidset_slot(slot_index:int, enable_left_port:bool, type_left:int, color_left:Color, enable_right_port:bool, type_right:int, color_right:Color, custom_icon_left:Texture2D = null, custom_icon_right:Texture2D = null, draw_stylebox:bool = true)🔗

Sets properties of the slot with the givenslot_index.

Ifenable_left_port/enable_right_port istrue, a port will appear and the slot will be able to be connected from this side.

Withtype_left/type_right an arbitrary type can be assigned to each port. Two ports can be connected if they share the same type, or if the connection between their types is allowed in the parentGraphEdit (seeGraphEdit.add_valid_connection_type()). Keep in mind that theGraphEdit has the final say in accepting the connection. Type compatibility simply allows theGraphEdit.connection_request signal to be emitted.

Ports can be further customized usingcolor_left/color_right andcustom_icon_left/custom_icon_right. The color parameter adds a tint to the icon. The custom icon can be used to override the default port dot.

Additionally,draw_stylebox can be used to enable or disable drawing of the background stylebox for each slot. Seeslot.

Individual properties can also be set using one of theset_slot_* methods.

Note: This method only sets properties of the slot. To create the slot itself, add aControl-derived child to the GraphNode.


voidset_slot_color_left(slot_index:int, color:Color)🔗

Sets theColor of the left (input) side of the slot with the givenslot_index tocolor.


voidset_slot_color_right(slot_index:int, color:Color)🔗

Sets theColor of the right (output) side of the slot with the givenslot_index tocolor.


voidset_slot_custom_icon_left(slot_index:int, custom_icon:Texture2D)🔗

Sets the customTexture2D of the left (input) side of the slot with the givenslot_index tocustom_icon.


voidset_slot_custom_icon_right(slot_index:int, custom_icon:Texture2D)🔗

Sets the customTexture2D of the right (output) side of the slot with the givenslot_index tocustom_icon.


voidset_slot_draw_stylebox(slot_index:int, enable:bool)🔗

Toggles the backgroundStyleBox of the slot with the givenslot_index.


voidset_slot_enabled_left(slot_index:int, enable:bool)🔗

Toggles the left (input) side of the slot with the givenslot_index. Ifenable istrue, a port will appear on the left side and the slot will be able to be connected from this side.


voidset_slot_enabled_right(slot_index:int, enable:bool)🔗

Toggles the right (output) side of the slot with the givenslot_index. Ifenable istrue, a port will appear on the right side and the slot will be able to be connected from this side.


voidset_slot_type_left(slot_index:int, type:int)🔗

Sets the left (input) type of the slot with the givenslot_index totype. If the value is negative, all connections will be disallowed to be created via user inputs.


voidset_slot_type_right(slot_index:int, type:int)🔗

Sets the right (output) type of the slot with the givenslot_index totype. If the value is negative, all connections will be disallowed to be created via user inputs.


Theme Property Descriptions

Colorresizer_color =Color(0.875,0.875,0.875,1)🔗

The color modulation applied to the resizer icon.


intport_h_offset =0🔗

Horizontal offset for the ports.


intseparation =2🔗

The vertical distance between ports.


Texture2Dport🔗

The icon used for representing ports.


StyleBoxpanel🔗

The default background for the slot area of theGraphNode.


StyleBoxpanel_selected🔗

TheStyleBox used for the slot area when selected.


StyleBoxslot🔗

TheStyleBox used for each slot of theGraphNode.


StyleBoxtitlebar🔗

TheStyleBox used for the title bar of theGraphNode.


StyleBoxtitlebar_selected🔗

TheStyleBox used for the title bar of theGraphNode when it is selected.


User-contributed notes

Please read theUser-contributed notes policy before submitting a comment.