GraphNode¶
Inherits:Container<Control<CanvasItem<Node<Object
A GraphNode is a container with potentially several input and output slots allowing connections between GraphNodes. Slots can have different, incompatible types.
Description¶
A GraphNode is a container. Each GraphNode can have several input and output slots, sometimes referred to as ports, allowing connections between GraphNodes. To add a slot to GraphNode, add anyControl-derived child node to it.
After adding at least one child to GraphNode new sections will be automatically created in the Inspector called 'Slot'. When 'Slot' is expanded you will see list with index number for each slot. You can click on each of them to expand further.
In the Inspector you can enable (show) or disable (hide) slots. By default, all slots are disabled so you may not see any slots on your GraphNode initially. You can assign a type to each slot. Only slots of the same type will be able to connect to each other. You can also assign colors to slots. A tuple of input and output slots is defined for each GUI element included in the GraphNode. Input connections are on the left and output connections are on the right side of GraphNode. Only enabled slots are counted as connections.
Properties¶
| ||
| ||
| ||
| ||
| ||
| ||
|
Methods¶
void | |
void | clear_slot(int idx) |
void | set_slot(int idx,bool enable_left,int type_left,Color color_left,bool enable_right,int type_right,Color color_right,Texture custom_left=null,Texture custom_right=null) |
void | set_slot_color_left(int idx,Color color_left) |
void | set_slot_color_right(int idx,Color color_right) |
void | set_slot_enabled_left(int idx,bool enable_left) |
void | set_slot_enabled_right(int idx,bool enable_right) |
void | set_slot_type_left(int idx,int type_left) |
void | set_slot_type_right(int idx,int type_right) |
Theme Properties¶
| ||
| ||
| ||
| ||
| ||
| ||
| ||
Signals¶
close_request()
Emitted when the GraphNode is requested to be closed. Happens on clicking the close button (seeshow_close).
Emitted when the GraphNode is dragged.
offset_changed()
Emitted when the GraphNode is moved.
raise_request()
Emitted when the GraphNode is requested to be displayed over other ones. Happens on focusing (clicking into) the GraphNode.
resize_request(Vector2 new_minsize)
Emitted when the GraphNode is requested to be resized. Happens on dragging the resizer handle (seeresizable).
slot_updated(int idx)
Emitted when any GraphNode's slot is updated.
Enumerations¶
enumOverlay:
OVERLAY_DISABLED =0 --- No overlay is shown.
OVERLAY_BREAKPOINT =1 --- Show overlay set in the
breakpointtheme property.OVERLAY_POSITION =2 --- Show overlay set in the
positiontheme property.
Property Descriptions¶
boolcomment
Default |
|
Setter | set_comment(value) |
Getter | is_comment() |
Iftrue, the GraphNode is a comment node.
Vector2offset
Default |
|
Setter | set_offset(value) |
Getter | get_offset() |
The offset of the GraphNode, relative to the scroll offset of theGraphEdit.
Note: You cannot use position directly, asGraphEdit is aContainer.
Overlayoverlay
Default |
|
Setter | set_overlay(value) |
Getter | get_overlay() |
Sets the overlay shown above the GraphNode. SeeOverlay.
boolresizable
Default |
|
Setter | set_resizable(value) |
Getter | is_resizable() |
Iftrue, the user can resize the GraphNode.
Note: Dragging the handle will only emit theresize_request signal, the GraphNode needs to be resized manually.
boolselected
Default |
|
Setter | set_selected(value) |
Getter | is_selected() |
Iftrue, the GraphNode is selected.
boolshow_close
Default |
|
Setter | set_show_close_button(value) |
Getter | is_close_button_visible() |
Iftrue, the close button will be visible.
Note: Pressing it will only emit theclose_request signal, the GraphNode needs to be removed manually.
Stringtitle
Default |
|
Setter | set_title(value) |
Getter | get_title() |
The text displayed in the GraphNode's title bar.
Method Descriptions¶
voidclear_all_slots()
Disables all input and output slots of the GraphNode.
voidclear_slot(int idx)
Disables input and output slot whose index isidx.
Returns theColor of the input connectionidx.
intget_connection_input_count()
Returns the number of enabled input slots (connections) to the GraphNode.
Returns the position of the input connectionidx.
Returns the type of the input connectionidx.
Returns theColor of the output connectionidx.
intget_connection_output_count()
Returns the number of enabled output slots (connections) of the GraphNode.
Returns the position of the output connectionidx.
Returns the type of the output connectionidx.
Returns the left (input)Color of the slotidx.
Returns the right (output)Color of the slotidx.
Returns the left (input) type of the slotidx.
Returns the right (output) type of the slotidx.
Returnstrue if left (input) side of the slotidx is enabled.
Returnstrue if right (output) side of the slotidx is enabled.
voidset_slot(int idx,bool enable_left,int type_left,Color color_left,bool enable_right,int type_right,Color color_right,Texture custom_left=null,Texture custom_right=null)
Sets properties of the slot with IDidx.
Ifenable_left/right, a port will appear and the slot will be able to be connected from this side.
type_left/right is an arbitrary type of the port. Only ports with the same type values can be connected.
color_left/right is the tint of the port's icon on this side.
custom_left/right is a custom texture for this side's port.
Note: This method only sets properties of the slot. To create the slot, add aControl-derived child to the GraphNode.
Individual properties can be set using one of theset_slot_* methods. You must enable at least one side of the slot to do so.
Sets theColor of the left (input) side of the slotidx tocolor_left.
Sets theColor of the right (output) side of the slotidx tocolor_right.
Toggles the left (input) side of the slotidx. Ifenable_left istrue, a port will appear on the left side and the slot will be able to be connected from this side.
Toggles the right (output) side of the slotidx. Ifenable_right istrue, a port will appear on the right side and the slot will be able to be connected from this side.
Sets the left (input) type of the slotidx totype_left.
Sets the right (output) type of the slotidx totype_right.
Theme Property Descriptions¶
Colorclose_color
Default |
|
The color modulation applied to the close button icon.
Colorresizer_color
Default |
|
The color modulation applied to the resizer icon.
Colortitle_color
Default |
|
Color of the title text.
intclose_offset
Default |
|
The vertical offset of the close button.
intport_offset
Default |
|
Horizontal offset for the ports.
intseparation
Default |
|
The vertical distance between ports.
inttitle_offset
Default |
|
Vertical offset of the title text.
Fonttitle_font
Font used for the title text.
Textureclose
The icon for the close button, visible whenshow_close is enabled.
Textureport
The icon used for representing ports.
Textureresizer
The icon used for resizer, visible whenresizable is enabled.
StyleBoxbreakpoint
The background used whenoverlay is set toOVERLAY_BREAKPOINT.
StyleBoxcomment
TheStyleBox used whencomment is enabled.
StyleBoxcommentfocus
TheStyleBox used whencomment is enabled and theGraphNode is focused.
StyleBoxdefaultfocus
StyleBoxdefaultframe
StyleBoxframe
The default background forGraphNode.
StyleBoxposition
The background used whenoverlay is set toOVERLAY_POSITION.
StyleBoxselectedframe
The background used when theGraphNode is selected.