diff options
author | Yuri Sizov <yuris@humnom.net> | 2021-12-29 20:27:44 +0300 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2021-12-29 20:27:44 +0300 |
commit | 7d37f76241c7b2a946a581c5624214409f38448e (patch) | |
tree | 178fc26162f6d2d2a300059e2d1ac83ef01955b9 /scene/gui | |
parent | 9f058674acebf9a7a0704cdbc26dc9f6d853b16e (diff) |
Use GDVIRTUAL* macros when binding virtual methods in exposed classes
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/graph_edit.cpp | 14 | ||||
-rw-r--r-- | scene/gui/graph_edit.h | 2 |
2 files changed, 10 insertions, 6 deletions
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index a008ed7180..ba63acd2dc 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -772,8 +772,9 @@ bool GraphEdit::_check_clickable_control(Control *p_control, const Vector2 &pos) } bool GraphEdit::is_in_input_hotzone(GraphNode *p_graph_node, int p_slot_index, const Vector2 &p_mouse_pos, const Vector2i &p_port_size) { - if (get_script_instance() && get_script_instance()->has_method("_is_in_input_hotzone")) { - return get_script_instance()->call("_is_in_input_hotzone", p_graph_node, p_slot_index, p_mouse_pos); + bool success; + if (GDVIRTUAL_CALL(_is_in_input_hotzone, p_graph_node, p_slot_index, p_mouse_pos, success)) { + return success; } else { Vector2 pos = p_graph_node->get_connection_input_position(p_slot_index) + p_graph_node->get_position(); return is_in_port_hotzone(pos / zoom, p_mouse_pos, p_port_size, true); @@ -781,8 +782,9 @@ bool GraphEdit::is_in_input_hotzone(GraphNode *p_graph_node, int p_slot_index, c } bool GraphEdit::is_in_output_hotzone(GraphNode *p_graph_node, int p_slot_index, const Vector2 &p_mouse_pos, const Vector2i &p_port_size) { - if (get_script_instance() && get_script_instance()->has_method("_is_in_output_hotzone")) { - return get_script_instance()->call("_is_in_output_hotzone", p_graph_node, p_slot_index, p_mouse_pos); + bool success; + if (GDVIRTUAL_CALL(_is_in_output_hotzone, p_graph_node, p_slot_index, p_mouse_pos, success)) { + return success; } else { Vector2 pos = p_graph_node->get_connection_output_position(p_slot_index) + p_graph_node->get_position(); return is_in_port_hotzone(pos / zoom, p_mouse_pos, p_port_size, false); @@ -2216,8 +2218,8 @@ void GraphEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("is_right_disconnects_enabled"), &GraphEdit::is_right_disconnects_enabled); ClassDB::bind_method(D_METHOD("_update_scroll_offset"), &GraphEdit::_update_scroll_offset); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "_is_in_input_hotzone", PropertyInfo(Variant::OBJECT, "graph_node"), PropertyInfo(Variant::INT, "slot_index"), PropertyInfo(Variant::VECTOR2, "mouse_position"))); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "_is_in_output_hotzone", PropertyInfo(Variant::OBJECT, "graph_node"), PropertyInfo(Variant::INT, "slot_index"), PropertyInfo(Variant::VECTOR2, "mouse_position"))); + GDVIRTUAL_BIND(_is_in_input_hotzone, "graph_node", "slot_index", "mouse_position"); + GDVIRTUAL_BIND(_is_in_output_hotzone, "graph_node", "slot_index", "mouse_position"); ClassDB::bind_method(D_METHOD("get_zoom_hbox"), &GraphEdit::get_zoom_hbox); diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h index e064c237d0..1aa901f729 100644 --- a/scene/gui/graph_edit.h +++ b/scene/gui/graph_edit.h @@ -261,6 +261,8 @@ protected: void _notification(int p_what); GDVIRTUAL2RC(Vector<Vector2>, _get_connection_line, Vector2, Vector2) + GDVIRTUAL3R(bool, _is_in_input_hotzone, Object *, int, Vector2) + GDVIRTUAL3R(bool, _is_in_output_hotzone, Object *, int, Vector2) public: Error connect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port); |