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 any Control-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¶
bool | comment | false |
Vector2 | offset | Vector2( 0, 0 ) |
Overlay | overlay | 0 |
bool | resizable | false |
bool | selected | false |
bool | show_close | false |
String | title | "" |
Methods¶
void | clear_all_slots ( ) |
void | clear_slot ( int idx ) |
Color | get_connection_input_color ( int idx ) |
int | get_connection_input_count ( ) |
Vector2 | get_connection_input_position ( int idx ) |
int | get_connection_input_type ( int idx ) |
Color | get_connection_output_color ( int idx ) |
int | get_connection_output_count ( ) |
Vector2 | get_connection_output_position ( int idx ) |
int | get_connection_output_type ( int idx ) |
Color | get_slot_color_left ( int idx ) const |
Color | get_slot_color_right ( int idx ) const |
int | get_slot_type_left ( int idx ) const |
int | get_slot_type_right ( int idx ) const |
bool | is_slot_enabled_left ( int idx ) const |
bool | is_slot_enabled_right ( int idx ) const |
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 ) |
Theme Properties¶
StyleBox | breakpoint | |
Texture | close | |
Color | close_color | Color( 0, 0, 0, 1 ) |
int | close_offset | 18 |
StyleBox | comment | |
StyleBox | commentfocus | |
StyleBox | defaultfocus | |
StyleBox | defaultframe | |
StyleBox | frame | |
Texture | port | |
int | port_offset | 3 |
StyleBox | position | |
Texture | resizer | |
Color | resizer_color | Color( 0, 0, 0, 1 ) |
StyleBox | selectedframe | |
int | separation | 1 |
Color | title_color | Color( 0, 0, 0, 1 ) |
Font | title_font | |
int | title_offset | 20 |
Signals¶
Emitted when the GraphNode is requested to be closed. Happens on clicking the close button (see show_close).
Emitted when the GraphNode is dragged.
Emitted when the GraphNode is moved.
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 (see resizable).
Enumerations¶
Property Descriptions¶
- bool comment
Default | false |
Setter | set_comment(value) |
Getter | is_comment() |
If true
, the GraphNode is a comment node.
- Vector2 offset
Default | Vector2( 0, 0 ) |
Setter | set_offset(value) |
Getter | get_offset() |
The offset of the GraphNode, relative to the scroll offset of the GraphEdit.
Note: You cannot use position directly, as GraphEdit is a Container.
- Overlay overlay
Default | 0 |
Setter | set_overlay(value) |
Getter | get_overlay() |
Sets the overlay shown above the GraphNode. See Overlay.
- bool resizable
Default | false |
Setter | set_resizable(value) |
Getter | is_resizable() |
If true
, the user can resize the GraphNode.
Note: Dragging the handle will only emit the resize_request signal, the GraphNode needs to be resized manually.
- bool selected
Default | false |
Setter | set_selected(value) |
Getter | is_selected() |
If true
, the GraphNode is selected.
- bool show_close
Default | false |
Setter | set_show_close_button(value) |
Getter | is_close_button_visible() |
If true
, the close button will be visible.
Note: Pressing it will only emit the close_request signal, the GraphNode needs to be removed manually.
- String title
Default | "" |
Setter | set_title(value) |
Getter | get_title() |
The text displayed in the GraphNode’s title bar.
Method Descriptions¶
Disables all input and output slots of the GraphNode.
- void clear_slot ( int idx )
Disables input and output slot whose index is idx
.
Returns the color of the input connection idx
.
- int get_connection_input_count ( )
Returns the number of enabled input slots (connections) to the GraphNode.
Returns the position of the input connection idx
.
Returns the type of the input connection idx
.
Returns the color of the output connection idx
.
- int get_connection_output_count ( )
Returns the number of enabled output slots (connections) of the GraphNode.
Returns the position of the output connection idx
.
Returns the type of the output connection idx
.
Returns the color set to idx
left (input) slot.
Returns the color set to idx
right (output) slot.
Returns the (integer) type of left (input) idx
slot.
Returns the (integer) type of right (output) idx
slot.
Returns true
if left (input) slot idx
is enabled, false
otherwise.
Returns true
if right (output) slot idx
is enabled, false
otherwise.
- 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 )
Sets properties of the slot with ID idx
.
If enable_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 a Control-derived child to the GraphNode.