GraphNode
A container with connection ports, representing a node in a GraphEdit
.
class GraphNode
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.
This object emits the following signals:
Superclasses
class GraphElement
A container that represents a basic element that can be placed inside a
GraphEdit
control.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Types
class Signal1
Signal support.
Type members
Instance members
var slotUpdated: Signal1
Emitted when any GraphNode’s slot is updated.
var title: String
The text displayed in the GraphNode’s title bar.
func clearAllSlots(
) Disables all slots of the GraphNode. This will remove all input/output ports from the GraphNode.
func clearSlot(slotIndex: Int32
) Disables the slot with the given
slotIndex
. This will remove the corresponding input and output port from the GraphNode.func getInputPortColor(portIdx: Int32
) -> Color Returns the
Color
of the input port with the givenportIdx
.func getInputPortCount(
) -> Int32 Returns the number of slots with an enabled input port.
func getInputPortPosition(portIdx: Int32
) -> Vector2 Returns the position of the input port with the given
portIdx
.func getInputPortSlot(portIdx: Int32
) -> Int32 Returns the corresponding slot index of the input port with the given
portIdx
.func getInputPortType(portIdx: Int32
) -> Int32 Returns the type of the input port with the given
portIdx
.func getOutputPortColor(portIdx: Int32
) -> Color Returns the
Color
of the output port with the givenportIdx
.func getOutputPortCount(
) -> Int32 Returns the number of slots with an enabled output port.
func getOutputPortPosition(portIdx: Int32
) -> Vector2 Returns the position of the output port with the given
portIdx
.func getOutputPortSlot(portIdx: Int32
) -> Int32 Returns the corresponding slot index of the output port with the given
portIdx
.func getOutputPortType(portIdx: Int32
) -> Int32 Returns the type of the output port with the given
portIdx
.func getSlotColorLeft(slotIndex: Int32
) -> Color Returns the left (input)
Color
of the slot with the givenslotIndex
.func getSlotColorRight(slotIndex: Int32
) -> Color Returns the right (output)
Color
of the slot with the givenslotIndex
.func getSlotTypeLeft(slotIndex: Int32
) -> Int32 Returns the left (input) type of the slot with the given
slotIndex
.func getSlotTypeRight(slotIndex: Int32
) -> Int32 Returns the right (output) type of the slot with the given
slotIndex
.func getTitlebarHbox(
) -> HBoxContainer? Returns the
HBoxContainer
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.func isSlotDrawStylebox(slotIndex: Int32
) -> Bool Returns true if the background
StyleBox
of the slot with the givenslotIndex
is drawn.func isSlotEnabledLeft(slotIndex: Int32
) -> Bool Returns
true
if left (input) side of the slot with the givenslotIndex
is enabled.func isSlotEnabledRight(slotIndex: Int32
) -> Bool Returns
true
if right (output) side of the slot with the givenslotIndex
is enabled.func setSlot(slotIndex: Int32, enableLeftPort: Bool, typeLeft: Int32, colorLeft: Color, enableRightPort: Bool, typeRight: Int32, colorRight: Color, customIconLeft: Texture2D?, customIconRight: Texture2D?, drawStylebox: Bool
) Sets properties of the slot with the given
slotIndex
.func setSlotColorLeft(slotIndex: Int32, color: Color
) Sets the
Color
of the left (input) side of the slot with the givenslotIndex
tocolor
.func setSlotColorRight(slotIndex: Int32, color: Color
) Sets the
Color
of the right (output) side of the slot with the givenslotIndex
tocolor
.func setSlotDrawStylebox(slotIndex: Int32, enable: Bool
) Toggles the background
StyleBox
of the slot with the givenslotIndex
.func setSlotEnabledLeft(slotIndex: Int32, enable: Bool
) Toggles the left (input) side of the slot with the given
slotIndex
. Ifenable
istrue
, a port will appear on the left side and the slot will be able to be connected from this side.func setSlotEnabledRight(slotIndex: Int32, enable: Bool
) Toggles the right (output) side of the slot with the given
slotIndex
. Ifenable
istrue
, a port will appear on the right side and the slot will be able to be connected from this side.func setSlotTypeLeft(slotIndex: Int32, type: Int32
) Sets the left (input) type of the slot with the given
slotIndex
totype
. If the value is negative, all connections will be disallowed to be created via user inputs.func setSlotTypeRight(slotIndex: Int32, type: Int32
) Sets the right (output) type of the slot with the given
slotIndex
totype
. If the value is negative, all connections will be disallowed to be created via user inputs.