summaryrefslogtreecommitdiffstats
path: root/scene/main
diff options
context:
space:
mode:
authorMichael Alexsander <michaelalexsander@protonmail.com>2024-11-01 18:40:25 -0300
committerMichael Alexsander <michaelalexsander@protonmail.com>2024-11-02 15:43:18 -0300
commit58e79bfa9a0b0dc6edb04fdf1676ea8027a9f27d (patch)
treedc0acadc6f6e4e0ac6195b0d3b3e149ea33258fb /scene/main
parentc6c464cf9ae56e8b68620af65125dd980d0e8122 (diff)
downloadredot-engine-58e79bfa9a0b0dc6edb04fdf1676ea8027a9f27d.tar.gz
Compile certain `CanvasItem._edit_*()` functions with `DEBUG_ENABLED`
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/canvas_item.cpp8
-rw-r--r--scene/main/canvas_item.h23
2 files changed, 20 insertions, 11 deletions
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp
index 7c8bf9c809..f87dad1889 100644
--- a/scene/main/canvas_item.cpp
+++ b/scene/main/canvas_item.cpp
@@ -44,7 +44,7 @@
#define ERR_DRAW_GUARD \
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside this node's `_draw()`, functions connected to its `draw` signal, or when it receives NOTIFICATION_DRAW.")
-#ifdef TOOLS_ENABLED
+#ifdef DEBUG_ENABLED
bool CanvasItem::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
if (_edit_use_rect()) {
return _edit_get_rect().has_point(p_point);
@@ -52,11 +52,13 @@ bool CanvasItem::_edit_is_selected_on_click(const Point2 &p_point, double p_tole
return p_point.length() < p_tolerance;
}
}
+#endif // DEBUG_ENABLED
+#ifdef TOOLS_ENABLED
Transform2D CanvasItem::_edit_get_transform() const {
return Transform2D(_edit_get_rotation(), _edit_get_position() + _edit_get_pivot());
}
-#endif
+#endif //TOOLS_ENABLED
bool CanvasItem::is_visible_in_tree() const {
ERR_READ_THREAD_GUARD_V(false);
@@ -1158,7 +1160,7 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("_edit_get_pivot"), &CanvasItem::_edit_get_pivot);
ClassDB::bind_method(D_METHOD("_edit_use_pivot"), &CanvasItem::_edit_use_pivot);
ClassDB::bind_method(D_METHOD("_edit_get_transform"), &CanvasItem::_edit_get_transform);
-#endif
+#endif //TOOLS_ENABLED
ClassDB::bind_method(D_METHOD("get_canvas_item"), &CanvasItem::get_canvas_item);
diff --git a/scene/main/canvas_item.h b/scene/main/canvas_item.h
index 5c4477234b..c74f8238e3 100644
--- a/scene/main/canvas_item.h
+++ b/scene/main/canvas_item.h
@@ -174,7 +174,7 @@ protected:
void _draw_multiline_bind_compat_84523(const Vector<Point2> &p_points, const Color &p_color, real_t p_width);
void _draw_multiline_colors_bind_compat_84523(const Vector<Point2> &p_points, const Vector<Color> &p_colors, real_t p_width);
static void _bind_compatibility_methods();
-#endif
+#endif // DISABLE_DEPRECATED
void _validate_property(PropertyInfo &p_property) const;
@@ -193,11 +193,9 @@ public:
NOTIFICATION_WORLD_2D_CHANGED = 36,
};
- /* EDITOR */
-#ifdef TOOLS_ENABLED
- // Select the node
- virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
+ /* EDITOR AND DEBUGGING */
+#ifdef TOOLS_ENABLED
// Save and restore a CanvasItem state
virtual void _edit_set_state(const Dictionary &p_state) {}
virtual Dictionary _edit_get_state() const { return Dictionary(); }
@@ -216,9 +214,7 @@ public:
virtual real_t _edit_get_rotation() const { return 0.0; }
// Used to resize/move the node
- virtual bool _edit_use_rect() const { return false; } // MAYBE REPLACE BY A _edit_get_editmode()
virtual void _edit_set_rect(const Rect2 &p_rect) {}
- virtual Rect2 _edit_get_rect() const { return Rect2(0, 0, 0, 0); }
virtual Size2 _edit_get_minimum_size() const { return Size2(-1, -1); } // LOOKS WEIRD
// Used to set a pivot
@@ -227,7 +223,18 @@ public:
virtual Point2 _edit_get_pivot() const { return Point2(); }
virtual Transform2D _edit_get_transform() const;
-#endif
+#endif // TOOLS_ENABLED
+
+#ifdef DEBUG_ENABLED
+ // Those need to be available in debug runtime, to allow for node selection.
+
+ // Select the node.
+ virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
+
+ // Used to resize/move the node.
+ virtual bool _edit_use_rect() const { return false; } // Maybe replace with _edit_get_editmode().
+ virtual Rect2 _edit_get_rect() const { return Rect2(0, 0, 0, 0); }
+#endif // DEBUG_ENABLED
void update_draw_order();