Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
GraphNode
Hérite de : GraphElement < Container < Control < CanvasItem < Node < Object
Un conteneur avec des ports de connexion, représentant un nœud dans un GraphEdit.
Description
GraphNode allows to create nodes for a GraphEdit graph with customizable content based on its child controls. GraphNode is derived from Container and it is responsible for placing its children on screen. This works similar to VBoxContainer. Children, in turn, provide GraphNode with so-called slots, each of which can have a connection port on either side.
Each GraphNode 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 the input port and the right port is referred to as the output 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 parent GraphEdit will receive this information on each connect and disconnect request.
Slots can be configured in the Inspector dock once you add at least one child Control. 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 that GraphEdit uses the port's index and not the slot's index. You can use get_input_port_slot() and get_output_port_slot() to get the slot index from the port index.
Propriétés
focus_mode |
|
|
|
||
mouse_filter |
|
|
|
||
|
Méthodes
void |
_draw_port(slot_index: int, position: Vector2i, left: bool, color: Color) virtual |
void |
|
void |
clear_slot(slot_index: int) |
get_input_port_color(port_idx: int) |
|
get_input_port_position(port_idx: int) |
|
get_input_port_slot(port_idx: int) |
|
get_input_port_type(port_idx: int) |
|
get_output_port_color(port_idx: int) |
|
get_output_port_position(port_idx: int) |
|
get_output_port_slot(port_idx: int) |
|
get_output_port_type(port_idx: int) |
|
get_slot_color_left(slot_index: int) const |
|
get_slot_color_right(slot_index: int) const |
|
get_slot_custom_icon_left(slot_index: int) const |
|
get_slot_custom_icon_right(slot_index: int) const |
|
get_slot_metadata_left(slot_index: int) const |
|
get_slot_metadata_right(slot_index: int) const |
|
get_slot_type_left(slot_index: int) const |
|
get_slot_type_right(slot_index: int) const |
|
is_slot_draw_stylebox(slot_index: int) const |
|
is_slot_enabled_left(slot_index: int) const |
|
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_metadata_left(slot_index: int, value: Variant) |
void |
set_slot_metadata_right(slot_index: int, value: Variant) |
void |
set_slot_type_left(slot_index: int, type: int) |
void |
set_slot_type_right(slot_index: int, type: int) |
Propriétés du thème
|
||
|
||
|
||
Signaux
slot_sizes_changed() 🔗
Émis quand la taille de n'importe quel emplacement aurait changé.
slot_updated(slot_index: int) 🔗
Émis lorsqu’un emplacement du GraphNode est mis à jour.
Descriptions des propriétés
bool ignore_invalid_connection_type = false 🔗
Si true, vous pouvez connecter les ports avec des types différents, même si la connexion n'était pas explicitement autorisée dans le GraphEdit parent.
FocusMode slots_focus_mode = 3 🔗
Determines how connection slots can be focused.
If set to Control.FOCUS_CLICK, connections can only be made with the mouse.
If set to Control.FOCUS_ALL, slots can also be focused using the ProjectSettings.input/ui_up and ProjectSettings.input/ui_down and connected using ProjectSettings.input/ui_left and ProjectSettings.input/ui_right input actions.
If set to Control.FOCUS_ACCESSIBILITY, slot input actions are only enabled when the screen reader is active.
Le texte affiché dans la barre de titre du GraphNode.
Descriptions des méthodes
void _draw_port(slot_index: int, position: Vector2i, left: bool, color: Color) virtual 🔗
There is currently no description for this method. Please help us by contributing one!
void clear_all_slots() 🔗
Disables all slots of the GraphNode. This will remove all input/output ports from the GraphNode.
void clear_slot(slot_index: int) 🔗
Disables the slot with the given slot_index. This will remove the corresponding input and output port from the GraphNode.
Color get_input_port_color(port_idx: int) 🔗
Retourne la Color de la connexion d'entrée au port_idx donné.
Returns the number of slots with an enabled input port.
Vector2 get_input_port_position(port_idx: int) 🔗
Retourne la position du port d'entrée avec le port_idx donné.
int get_input_port_slot(port_idx: int) 🔗
Retourne l'index correspondant du port d'entrée avec le port_idx donné.
int get_input_port_type(port_idx: int) 🔗
Returns the type of the input port with the given port_idx.
Color get_output_port_color(port_idx: int) 🔗
Returns the Color of the output port with the given port_idx.
Returns the number of slots with an enabled output port.
Vector2 get_output_port_position(port_idx: int) 🔗
Returns the position of the output port with the given port_idx.
int get_output_port_slot(port_idx: int) 🔗
Returns the corresponding slot index of the output port with the given port_idx.
int get_output_port_type(port_idx: int) 🔗
Returns the type of the output port with the given port_idx.
Color get_slot_color_left(slot_index: int) const 🔗
Returns the left (input) Color of the slot with the given slot_index.
Color get_slot_color_right(slot_index: int) const 🔗
Returns the right (output) Color of the slot with the given slot_index.
Texture2D get_slot_custom_icon_left(slot_index: int) const 🔗
Returns the left (input) custom Texture2D of the slot with the given slot_index.
Texture2D get_slot_custom_icon_right(slot_index: int) const 🔗
Returns the right (output) custom Texture2D of the slot with the given slot_index.
Variant get_slot_metadata_left(slot_index: int) const 🔗
Returns the left (input) metadata of the slot with the given slot_index.
Variant get_slot_metadata_right(slot_index: int) const 🔗
Returns the right (output) metadata of the slot with the given slot_index.
int get_slot_type_left(slot_index: int) const 🔗
Returns the left (input) type of the slot with the given slot_index.
int get_slot_type_right(slot_index: int) const 🔗
Returns the right (output) type of the slot with the given slot_index.
HBoxContainer get_titlebar_hbox() 🔗
Returns the HBoxContainer used for the title bar, only containing a Label for displaying the title by default. This can be used to add custom controls to the title bar such as option or close buttons.
bool is_slot_draw_stylebox(slot_index: int) const 🔗
Returns true if the background StyleBox of the slot with the given slot_index is drawn.
bool is_slot_enabled_left(slot_index: int) const 🔗
Returns true if left (input) side of the slot with the given slot_index is enabled.
bool is_slot_enabled_right(slot_index: int) const 🔗
Returns true if right (output) side of the slot with the given slot_index is enabled.
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) 🔗
Sets properties of the slot with the given slot_index.
If enable_left_port/enable_right_port is true, a port will appear and the slot will be able to be connected from this side.
With type_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 parent GraphEdit (see GraphEdit.add_valid_connection_type()). Keep in mind that the GraphEdit has the final say in accepting the connection. Type compatibility simply allows the GraphEdit.connection_request signal to be emitted.
Ports can be further customized using color_left/color_right and custom_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. See slot.
Individual properties can also be set using one of the set_slot_* methods.
Note: This method only sets properties of the slot. To create the slot itself, add a Control-derived child to the GraphNode.
void set_slot_color_left(slot_index: int, color: Color) 🔗
Sets the Color of the left (input) side of the slot with the given slot_index to color.
void set_slot_color_right(slot_index: int, color: Color) 🔗
Sets the Color of the right (output) side of the slot with the given slot_index to color.
void set_slot_custom_icon_left(slot_index: int, custom_icon: Texture2D) 🔗
Sets the custom Texture2D of the left (input) side of the slot with the given slot_index to custom_icon.
void set_slot_custom_icon_right(slot_index: int, custom_icon: Texture2D) 🔗
Sets the custom Texture2D of the right (output) side of the slot with the given slot_index to custom_icon.
void set_slot_draw_stylebox(slot_index: int, enable: bool) 🔗
Toggles the background StyleBox of the slot with the given slot_index.
void set_slot_enabled_left(slot_index: int, enable: bool) 🔗
Toggles the left (input) side of the slot with the given slot_index. If enable is true, a port will appear on the left side and the slot will be able to be connected from this side.
void set_slot_enabled_right(slot_index: int, enable: bool) 🔗
Toggles the right (output) side of the slot with the given slot_index. If enable is true, a port will appear on the right side and the slot will be able to be connected from this side.
void set_slot_metadata_left(slot_index: int, value: Variant) 🔗
Sets the custom metadata for the left (input) side of the slot with the given slot_index to value.
void set_slot_metadata_right(slot_index: int, value: Variant) 🔗
Sets the custom metadata for the right (output) side of the slot with the given slot_index to value.
void set_slot_type_left(slot_index: int, type: int) 🔗
Sets the left (input) type of the slot with the given slot_index to type. If the value is negative, all connections will be disallowed to be created via user inputs.
void set_slot_type_right(slot_index: int, type: int) 🔗
Définit le type (de sortie) sortie de l'emplacement avec l'index slot_index donné à type. Si la valeur est négative, toutes les connexions seront refusées d'être créées via des entrées utilisateur.
Descriptions des propriétés du thème
Color resizer_color = Color(0.875, 0.875, 0.875, 1) 🔗
La couleur de modulation appliquée à l'icône de redimensionnement.
Le décalage horizontal pour les ports.
La distance verticale entre les ports.
L’icône utilisée pour représenter les ports.
The default background for the slot area of the GraphNode.
StyleBox used when the GraphNode is focused (when used with assistive apps).
The StyleBox used for the slot area when selected.
The StyleBox used for each slot of the GraphNode.
StyleBox used when the slot is focused (when used with assistive apps).
The StyleBox used for the title bar of the GraphNode.
The StyleBox used for the title bar of the GraphNode when it is selected.