summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scene/gui/graph_node.cpp24
-rw-r--r--scene/gui/graph_node.h5
2 files changed, 29 insertions, 0 deletions
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index 08c8c60d7a..a20a11b79c 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -31,6 +31,9 @@
#include "graph_node.h"
#include "core/string/translation.h"
+#ifdef TOOLS_ENABLED
+#include "graph_edit.h"
+#endif
struct _MinSizeCache {
int min_size;
@@ -458,6 +461,27 @@ void GraphNode::_shape() {
title_buf->add_string(title, font, font_size, opentype_features, (language != "") ? language : TranslationServer::get_singleton()->get_tool_locale());
}
+#ifdef TOOLS_ENABLED
+void GraphNode::_edit_set_position(const Point2 &p_position) {
+ GraphEdit *graph = Object::cast_to<GraphEdit>(get_parent());
+ if (graph) {
+ Point2 offset = (p_position + graph->get_scroll_ofs()) * graph->get_zoom();
+ set_position_offset(offset);
+ }
+ set_position(p_position);
+}
+
+void GraphNode::_validate_property(PropertyInfo &property) const {
+ Control::_validate_property(property);
+ GraphEdit *graph = Object::cast_to<GraphEdit>(get_parent());
+ if (graph) {
+ if (property.name == "rect_position") {
+ property.usage |= PROPERTY_USAGE_READ_ONLY;
+ }
+ }
+}
+#endif
+
void GraphNode::set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right, const Ref<Texture2D> &p_custom_left, const Ref<Texture2D> &p_custom_right) {
ERR_FAIL_COND_MSG(p_idx < 0, vformat("Cannot set slot with p_idx (%d) lesser than zero.", p_idx));
diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h
index c7c7006bfc..2238cfdb56 100644
--- a/scene/gui/graph_node.h
+++ b/scene/gui/graph_node.h
@@ -98,6 +98,11 @@ private:
Overlay overlay = OVERLAY_DISABLED;
+#ifdef TOOLS_ENABLED
+ void _edit_set_position(const Point2 &p_position) override;
+ void _validate_property(PropertyInfo &property) const override;
+#endif
+
protected:
virtual void gui_input(const Ref<InputEvent> &p_ev) override;
void _notification(int p_what);