Merge pull request #98736 from YeldhamDev/i_love_introducing_regressions
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
🔗 GHA / 🪲 Godot CPP (push) Has been cancelled

Compile certain `CanvasItem._edit_*()` functions with `DEBUG_ENABLED`
This commit is contained in:
Clay John 2024-11-02 13:59:31 -07:00 committed by GitHub
commit 1bffd6c73b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
41 changed files with 155 additions and 121 deletions

View File

@ -56,7 +56,9 @@ Point2 AnimatedSprite2D::_edit_get_pivot() const {
bool AnimatedSprite2D::_edit_use_pivot() const {
return true;
}
#endif // TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 AnimatedSprite2D::_edit_get_rect() const {
return _get_rect();
}
@ -75,7 +77,7 @@ bool AnimatedSprite2D::_edit_use_rect() const {
}
return t.is_valid();
}
#endif
#endif // DEBUG_ENABLED
Rect2 AnimatedSprite2D::get_anchorable_rect() const {
return _get_rect();
@ -593,7 +595,7 @@ void AnimatedSprite2D::get_argument_options(const StringName &p_function, int p_
}
Node2D::get_argument_options(p_function, p_idx, r_options);
}
#endif
#endif // TOOLS_ENABLED
#ifndef DISABLE_DEPRECATED
bool AnimatedSprite2D::_set(const StringName &p_name, const Variant &p_value) {

View File

@ -66,7 +66,7 @@ class AnimatedSprite2D : public Node2D {
protected:
#ifndef DISABLE_DEPRECATED
bool _set(const StringName &p_name, const Variant &p_value);
#endif
#endif // DISABLE_DEPRECATED
static void _bind_methods();
void _notification(int p_what);
void _validate_property(PropertyInfo &p_property) const;
@ -79,9 +79,12 @@ public:
virtual void _edit_set_pivot(const Point2 &p_pivot) override;
virtual Point2 _edit_get_pivot() const override;
virtual bool _edit_use_pivot() const override;
#endif // TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
#endif
#endif // DEBUG_ENABLED
virtual Rect2 get_anchorable_rect() const override;
@ -129,7 +132,7 @@ public:
#ifdef TOOLS_ENABLED
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
#endif
#endif // TOOLS_ENABLED
AnimatedSprite2D();
};

View File

@ -45,7 +45,7 @@ void BackBufferCopy::_update_copy_mode() {
}
}
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 BackBufferCopy::_edit_get_rect() const {
return rect;
}
@ -53,7 +53,7 @@ Rect2 BackBufferCopy::_edit_get_rect() const {
bool BackBufferCopy::_edit_use_rect() const {
return true;
}
#endif
#endif // DEBUG_ENABLED
Rect2 BackBufferCopy::get_anchorable_rect() const {
return rect;

View File

@ -54,10 +54,10 @@ protected:
void _validate_property(PropertyInfo &p_property) const;
public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
#endif
#endif // DEBUG_ENABLED
void set_rect(const Rect2 &p_rect);
Rect2 get_rect() const;

View File

@ -54,7 +54,7 @@ void Light2D::_update_light_visibility() {
if (editor_only) {
editor_ok = false;
}
#endif
#endif // TOOLS_ENABLED
RS::get_singleton()->canvas_light_set_enabled(canvas_light, enabled && is_visible_in_tree() && editor_ok);
}
@ -343,7 +343,6 @@ Light2D::~Light2D() {
//////////////////////////////
#ifdef TOOLS_ENABLED
Dictionary PointLight2D::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state();
state["offset"] = get_texture_offset();
@ -367,7 +366,9 @@ Point2 PointLight2D::_edit_get_pivot() const {
bool PointLight2D::_edit_use_pivot() const {
return true;
}
#endif // TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 PointLight2D::_edit_get_rect() const {
if (texture.is_null()) {
return Rect2();
@ -380,7 +381,7 @@ Rect2 PointLight2D::_edit_get_rect() const {
bool PointLight2D::_edit_use_rect() const {
return !texture.is_null();
}
#endif
#endif // DEBUG_ENABLED
Rect2 PointLight2D::get_anchorable_rect() const {
if (texture.is_null()) {

View File

@ -160,9 +160,12 @@ public:
virtual void _edit_set_pivot(const Point2 &p_pivot) override;
virtual Point2 _edit_get_pivot() const override;
virtual bool _edit_use_pivot() const override;
#endif // TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
#endif
#endif // DEBUG_ENABLED
virtual Rect2 get_anchorable_rect() const override;

View File

@ -35,7 +35,7 @@
#define LINE_GRAB_WIDTH 8
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 OccluderPolygon2D::_edit_get_rect() const {
if (rect_cache_dirty) {
if (closed) {
@ -83,7 +83,7 @@ bool OccluderPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, double
return false;
}
}
#endif
#endif // DEBUG_ENABLED
void OccluderPolygon2D::set_polygon(const Vector<Vector2> &p_polygon) {
polygon = p_polygon;
@ -156,7 +156,7 @@ OccluderPolygon2D::~OccluderPolygon2D() {
void LightOccluder2D::_poly_changed() {
#ifdef DEBUG_ENABLED
queue_redraw();
#endif
#endif // DEBUG_ENABLED
}
void LightOccluder2D::_physics_interpolated_changed() {
@ -218,7 +218,7 @@ void LightOccluder2D::_notification(int p_what) {
}
}
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 LightOccluder2D::_edit_get_rect() const {
return occluder_polygon.is_valid() ? occluder_polygon->_edit_get_rect() : Rect2();
}
@ -226,14 +226,14 @@ Rect2 LightOccluder2D::_edit_get_rect() const {
bool LightOccluder2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
return occluder_polygon.is_valid() ? occluder_polygon->_edit_is_selected_on_click(p_point, p_tolerance) : false;
}
#endif
#endif // DEBUG_ENABLED
void LightOccluder2D::set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polygon) {
#ifdef DEBUG_ENABLED
if (occluder_polygon.is_valid()) {
occluder_polygon->disconnect_changed(callable_mp(this, &LightOccluder2D::_poly_changed));
}
#endif
#endif // DEBUG_ENABLED
occluder_polygon = p_polygon;
if (occluder_polygon.is_valid()) {
@ -247,7 +247,7 @@ void LightOccluder2D::set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polyg
occluder_polygon->connect_changed(callable_mp(this, &LightOccluder2D::_poly_changed));
}
queue_redraw();
#endif
#endif // DEBUG_ENABLED
}
Ref<OccluderPolygon2D> LightOccluder2D::get_occluder_polygon() const {

View File

@ -56,11 +56,10 @@ protected:
static void _bind_methods();
public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
#endif
#endif // DEBUG_ENABLED
void set_polygon(const Vector<Vector2> &p_polygon);
Vector<Vector2> get_polygon() const;
@ -93,10 +92,10 @@ protected:
static void _bind_methods();
public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;
#endif
#endif // DEBUG_ENABLED
void set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polygon);
Ref<OccluderPolygon2D> get_occluder_polygon() const;

View File

@ -36,7 +36,7 @@
Line2D::Line2D() {
}
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 Line2D::_edit_get_rect() const {
if (_points.size() == 0) {
return Rect2(0, 0, 0, 0);

View File

@ -55,7 +55,7 @@ public:
LINE_TEXTURE_STRETCH
};
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;

View File

@ -61,7 +61,7 @@ void Marker2D::_draw_cross() {
draw_multiline_colors(points, colors);
}
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 Marker2D::_edit_get_rect() const {
real_t extents = get_gizmo_extents();
return Rect2(Point2(-extents, -extents), Size2(extents * 2, extents * 2));
@ -70,7 +70,7 @@ Rect2 Marker2D::_edit_get_rect() const {
bool Marker2D::_edit_use_rect() const {
return false;
}
#endif
#endif // DEBUG_ENABLED
void Marker2D::_notification(int p_what) {
switch (p_what) {

View File

@ -45,10 +45,10 @@ protected:
static void _bind_methods();
public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
#endif
#endif // DEBUG_ENABLED
void set_gizmo_extents(real_t p_extents);
real_t get_gizmo_extents() const;

View File

@ -88,7 +88,7 @@ Ref<Texture2D> MeshInstance2D::get_texture() const {
return texture;
}
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 MeshInstance2D::_edit_get_rect() const {
if (mesh.is_valid()) {
AABB aabb = mesh->get_aabb();
@ -101,7 +101,7 @@ Rect2 MeshInstance2D::_edit_get_rect() const {
bool MeshInstance2D::_edit_use_rect() const {
return mesh.is_valid();
}
#endif
#endif // DEBUG_ENABLED
MeshInstance2D::MeshInstance2D() {
}

View File

@ -45,10 +45,10 @@ protected:
static void _bind_methods();
public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
#endif
#endif // DEBUG_ENABLED
void set_mesh(const Ref<Mesh> &p_mesh);
Ref<Mesh> get_mesh() const;

View File

@ -84,7 +84,7 @@ Ref<Texture2D> MultiMeshInstance2D::get_texture() const {
return texture;
}
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 MultiMeshInstance2D::_edit_get_rect() const {
if (multimesh.is_valid()) {
AABB aabb = multimesh->get_aabb();
@ -93,7 +93,7 @@ Rect2 MultiMeshInstance2D::_edit_get_rect() const {
return Node2D::_edit_get_rect();
}
#endif
#endif // DEBUG_ENABLED
MultiMeshInstance2D::MultiMeshInstance2D() {
}

View File

@ -46,9 +46,9 @@ protected:
static void _bind_methods();
public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
#endif
#endif // DEBUG_ENABLED
void set_multimesh(const Ref<MultiMesh> &p_multimesh);
Ref<MultiMesh> get_multimesh() const;

View File

@ -132,7 +132,7 @@ void NavigationLink2D::_notification(int p_what) {
}
}
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 NavigationLink2D::_edit_get_rect() const {
if (!is_inside_tree()) {
return Rect2();
@ -152,7 +152,7 @@ bool NavigationLink2D::_edit_is_selected_on_click(const Point2 &p_point, double
Vector2 closest_point = Geometry2D::get_closest_point_to_segment(p_point, segment);
return p_point.distance_to(closest_point) < p_tolerance;
}
#endif // TOOLS_ENABLED
#endif // DEBUG_ENABLED
RID NavigationLink2D::get_rid() const {
return link;

View File

@ -62,10 +62,10 @@ protected:
#endif // DISABLE_DEPRECATED
public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;
#endif
#endif // DEBUG_ENABLED
RID get_rid() const;
void set_enabled(bool p_enabled);

View File

@ -142,7 +142,7 @@ RID NavigationRegion2D::get_region_rid() const {
return get_rid();
}
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 NavigationRegion2D::_edit_get_rect() const {
return navigation_polygon.is_valid() ? navigation_polygon->_edit_get_rect() : Rect2();
}
@ -150,7 +150,7 @@ Rect2 NavigationRegion2D::_edit_get_rect() const {
bool NavigationRegion2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
return navigation_polygon.is_valid() ? navigation_polygon->_edit_is_selected_on_click(p_point, p_tolerance) : false;
}
#endif
#endif // DEBUG_ENABLED
void NavigationRegion2D::_notification(int p_what) {
switch (p_what) {

View File

@ -75,10 +75,10 @@ protected:
#endif // DISABLE_DEPRECATED
public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;
#endif
#endif // DEBUG_ENABLED
RID get_rid() const;
void set_enabled(bool p_enabled);

View File

@ -37,7 +37,7 @@
#include "editor/themes/editor_scale.h"
#endif
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 Path2D::_edit_get_rect() const {
if (!curve.is_valid() || curve->get_point_count() == 0) {
return Rect2(0, 0, 0, 0);

View File

@ -48,7 +48,7 @@ protected:
static void _bind_methods();
public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;

View File

@ -217,7 +217,7 @@ CollisionPolygon2D::BuildMode CollisionPolygon2D::get_build_mode() const {
return build_mode;
}
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 CollisionPolygon2D::_edit_get_rect() const {
return aabb;
}

View File

@ -65,7 +65,7 @@ protected:
static void _bind_methods();
public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;

View File

@ -59,11 +59,11 @@ protected:
static void _bind_methods();
public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;
#else
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
#endif // TOOLS_ENABLED
#endif // DEBUG_ENABLED
void set_shape(const Ref<Shape2D> &p_shape);
Ref<Shape2D> get_shape() const;

View File

@ -57,7 +57,9 @@ Point2 Polygon2D::_edit_get_pivot() const {
bool Polygon2D::_edit_use_pivot() const {
return true;
}
#endif // TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 Polygon2D::_edit_get_rect() const {
if (rect_cache_dirty) {
int l = polygon.size();
@ -88,7 +90,7 @@ bool Polygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toler
}
return Geometry2D::is_point_in_polygon(p_point - get_offset(), polygon2d);
}
#endif
#endif // DEBUG_ENABLED
void Polygon2D::_validate_property(PropertyInfo &p_property) const {
if (!invert && p_property.name == "invert_border") {

View File

@ -87,11 +87,14 @@ public:
virtual void _edit_set_pivot(const Point2 &p_pivot) override;
virtual Point2 _edit_get_pivot() const override;
virtual bool _edit_use_pivot() const override;
#endif // TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;
#endif
#endif // DEBUG_ENABLED
void set_polygon(const Vector<Vector2> &p_polygon);
Vector<Vector2> get_polygon() const;

View File

@ -56,7 +56,9 @@ Point2 Sprite2D::_edit_get_pivot() const {
bool Sprite2D::_edit_use_pivot() const {
return true;
}
#endif // TOOLS_ENABLED
#ifdef DEBUG_ENABLED
bool Sprite2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
return is_pixel_opaque(p_point);
}
@ -68,7 +70,7 @@ Rect2 Sprite2D::_edit_get_rect() const {
bool Sprite2D::_edit_use_rect() const {
return texture.is_valid();
}
#endif
#endif // DEBUG_ENABLED
Rect2 Sprite2D::get_anchorable_rect() const {
return get_rect();

View File

@ -74,11 +74,14 @@ public:
virtual void _edit_set_pivot(const Point2 &p_pivot) override;
virtual Point2 _edit_get_pivot() const override;
virtual bool _edit_use_pivot() const override;
#endif // TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
#endif
#endif // DEBUG_ENABLED
bool is_pixel_opaque(const Point2 &p_point) const;

View File

@ -89,7 +89,7 @@ void TileMap::_set_tile_map_data_using_compatibility_format(int p_layer, TileMap
SWAP(local[8], local[11]);
SWAP(local[9], local[10]);
}
#endif
#endif // BIG_ENDIAN_ENABLED
// Extracts position in TileMap.
int16_t x = decode_uint16(&local[0]);
int16_t y = decode_uint16(&local[2]);
@ -172,7 +172,7 @@ void TileMap::_notification(int p_what) {
bool in_editor = false;
#ifdef TOOLS_ENABLED
in_editor = Engine::get_singleton()->is_editor_hint();
#endif
#endif // TOOLS_ENABLED
if (is_inside_tree() && collision_animatable && !in_editor) {
// Update transform on the physics tick when in animatable mode.
last_valid_transform = new_transform;
@ -188,7 +188,7 @@ void TileMap::_notification(int p_what) {
bool in_editor = false;
#ifdef TOOLS_ENABLED
in_editor = Engine::get_singleton()->is_editor_hint();
#endif
#endif // TOOLS_ENABLED
if (is_inside_tree() && collision_animatable && !in_editor) {
// Store last valid transform.
@ -209,7 +209,7 @@ void TileMap::force_update(int p_layer) {
notify_runtime_tile_data_update(p_layer);
update_internals();
}
#endif
#endif // DISABLE_DEPRECATED
void TileMap::set_rendering_quadrant_size(int p_size) {
ERR_FAIL_COND_MSG(p_size < 1, "TileMapQuadrant size cannot be smaller than 1.");
@ -649,7 +649,7 @@ void TileMap::notify_runtime_tile_data_update(int p_layer) {
}
}
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 TileMap::_edit_get_rect() const {
// Return the visible rect of the tilemap.
if (layers.is_empty()) {
@ -667,7 +667,7 @@ Rect2 TileMap::_edit_get_rect() const {
const_cast<TileMap *>(this)->item_rect_changed(any_changed);
return rect;
}
#endif
#endif // DEBUG_ENABLED
bool TileMap::_set(const StringName &p_name, const Variant &p_value) {
int index;
@ -726,7 +726,7 @@ bool TileMap::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = get_rendering_quadrant_size();
return true;
}
#endif
#endif // DISABLE_DEPRECATED
else {
return property_helper.property_get_value(sname, r_ret);
}

View File

@ -107,16 +107,16 @@ protected:
VisibilityMode _get_navigation_visibility_mode_bind_compat_87115();
static void _bind_compatibility_methods();
#endif
#endif // DISABLE_DEPRECATED
public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
#endif
#endif // DEBUG_ENABLED
#ifndef DISABLE_DEPRECATED
void force_update(int p_layer);
#endif
#endif // DISABLE_DEPRECATED
void set_rendering_quadrant_size(int p_size);
int get_rendering_quadrant_size() const;

View File

@ -330,7 +330,7 @@ void TouchScreenButton::_release(bool p_exiting_tree) {
}
}
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 TouchScreenButton::_edit_get_rect() const {
if (texture_normal.is_null()) {
return CanvasItem::_edit_get_rect();
@ -342,7 +342,7 @@ Rect2 TouchScreenButton::_edit_get_rect() const {
bool TouchScreenButton::_edit_use_rect() const {
return !texture_normal.is_null();
}
#endif
#endif // DEBUG_ENABLED
Rect2 TouchScreenButton::get_anchorable_rect() const {
if (texture_normal.is_null()) {

View File

@ -76,10 +76,10 @@ protected:
#endif // DISABLE_DEPRECATED
public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
#endif
#endif // DEBUG_ENABLED
void set_texture_normal(const Ref<Texture2D> &p_texture);
Ref<Texture2D> get_texture_normal() const;

View File

@ -30,7 +30,7 @@
#include "visible_on_screen_notifier_2d.h"
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 VisibleOnScreenNotifier2D::_edit_get_rect() const {
return rect;
}
@ -38,7 +38,7 @@ Rect2 VisibleOnScreenNotifier2D::_edit_get_rect() const {
bool VisibleOnScreenNotifier2D::_edit_use_rect() const {
return true;
}
#endif
#endif // DEBUG_ENABLED
void VisibleOnScreenNotifier2D::_visibility_enter() {
if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) {

View File

@ -54,10 +54,10 @@ protected:
static void _bind_methods();
public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
#endif
#endif // DEBUG_ENABLED
void set_rect(const Rect2 &p_rect);
Rect2 get_rect() const;

View File

@ -44,7 +44,7 @@
#ifdef TOOLS_ENABLED
#include "editor/plugins/control_editor_plugin.h"
#endif
#endif // TOOLS_ENABLED
// Editor plugin interoperability.
@ -140,14 +140,6 @@ void Control::_edit_set_rect(const Rect2 &p_edit_rect) {
set_size(p_edit_rect.size.snappedf(1), ControlEditorToolbar::get_singleton()->is_anchors_mode_enabled());
}
Rect2 Control::_edit_get_rect() const {
return Rect2(Point2(), get_size());
}
bool Control::_edit_use_rect() const {
return true;
}
void Control::_edit_set_rotation(real_t p_rotation) {
set_rotation(p_rotation);
}
@ -178,7 +170,17 @@ bool Control::_edit_use_pivot() const {
Size2 Control::_edit_get_minimum_size() const {
return get_combined_minimum_size();
}
#endif
#endif // TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 Control::_edit_get_rect() const {
return Rect2(Point2(), get_size());
}
bool Control::_edit_use_rect() const {
return true;
}
#endif // DEBUG_ENABLED
void Control::reparent(Node *p_parent, bool p_keep_global_transform) {
ERR_MAIN_THREAD_GUARD;
@ -239,7 +241,7 @@ void Control::get_argument_options(const StringName &p_function, int p_idx, List
}
CanvasItem::get_argument_options(p_function, p_idx, r_options);
}
#endif
#endif // TOOLS_ENABLED
PackedStringArray Control::get_configuration_warnings() const {
ERR_READ_THREAD_GUARD_V(PackedStringArray());
@ -663,7 +665,7 @@ Rect2 Control::get_parent_anchorable_rect() const {
#else
parent_rect = get_viewport()->get_visible_rect();
#endif
#endif // TOOLS_ENABLED
}
return parent_rect;
@ -1396,7 +1398,7 @@ void Control::set_position(const Point2 &p_point, bool p_keep_offsets) {
data.pos_cache = p_point;
return;
}
#endif
#endif // TOOLS_ENABLED
if (p_keep_offsets) {
_compute_anchors(Rect2(p_point, data.size_cache), data.offset, data.anchor);
@ -1440,7 +1442,7 @@ void Control::_set_size(const Size2 &p_size) {
if (data.size_warning && (data.anchor[SIDE_LEFT] != data.anchor[SIDE_RIGHT] || data.anchor[SIDE_TOP] != data.anchor[SIDE_BOTTOM])) {
WARN_PRINT("Nodes with non-equal opposite anchors will have their size overridden after _ready(). \nIf you want to set size, change the anchors or consider using set_deferred().");
}
#endif
#endif // DEBUG_ENABLED
set_size(p_size);
}
@ -1462,7 +1464,7 @@ void Control::set_size(const Size2 &p_size, bool p_keep_offsets) {
data.size_cache = new_size;
return;
}
#endif
#endif // TOOLS_ENABLED
if (p_keep_offsets) {
_compute_anchors(Rect2(data.pos_cache, new_size), data.offset, data.anchor);
@ -2745,7 +2747,7 @@ Variant Control::get_theme_item(Theme::DataType p_data_type, const StringName &p
Ref<Texture2D> Control::get_editor_theme_icon(const StringName &p_name) const {
return get_theme_icon(p_name, SNAME("EditorIcons"));
}
#endif
#endif // TOOLS_ENABLED
bool Control::has_theme_icon(const StringName &p_name, const StringName &p_theme_type) const {
ERR_READ_THREAD_GUARD_V(false);
@ -3087,7 +3089,7 @@ bool Control::is_layout_rtl() const {
const_cast<Control *>(this)->data.is_rtl = true;
return data.is_rtl;
}
#endif
#endif // TOOLS_ENABLED
Node *parent_node = get_parent();
while (parent_node) {
Control *parent_control = Object::cast_to<Control>(parent_node);
@ -3162,7 +3164,7 @@ bool Control::is_auto_translating() const {
ERR_READ_THREAD_GUARD_V(false);
return can_auto_translate();
}
#endif
#endif // DISABLE_DEPRECATED
void Control::set_tooltip_auto_translate_mode(AutoTranslateMode p_mode) {
ERR_MAIN_THREAD_GUARD;
@ -3215,7 +3217,7 @@ void Control::_notification(int p_notification) {
case NOTIFICATION_EDITOR_POST_SAVE: {
saving = false;
} break;
#endif
#endif // TOOLS_ENABLED
case NOTIFICATION_POSTINITIALIZE: {
data.initialized = true;
@ -3261,7 +3263,7 @@ void Control::_notification(int p_notification) {
case NOTIFICATION_READY: {
#ifdef DEBUG_ENABLED
connect(SceneStringName(ready), callable_mp(this, &Control::_clear_size_warning), CONNECT_DEFERRED | CONNECT_ONE_SHOT);
#endif
#endif // DEBUG_ENABLED
} break;
case NOTIFICATION_ENTER_CANVAS: {
@ -3573,7 +3575,7 @@ void Control::_bind_methods() {
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_auto_translate", "enable"), &Control::set_auto_translate);
ClassDB::bind_method(D_METHOD("is_auto_translating"), &Control::is_auto_translating);
#endif
#endif // DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_localize_numeral_system", "enable"), &Control::set_localize_numeral_system);
ClassDB::bind_method(D_METHOD("is_localizing_numeral_system"), &Control::is_localizing_numeral_system);
@ -3628,7 +3630,7 @@ void Control::_bind_methods() {
#ifndef DISABLE_DEPRECATED
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_translate", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_auto_translate", "is_auto_translating");
#endif
#endif // DISABLE_DEPRECATED
ADD_GROUP("Tooltip", "tooltip_");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "tooltip_text", PROPERTY_HINT_MULTILINE_TEXT), "set_tooltip_text", "get_tooltip_text");

View File

@ -48,7 +48,7 @@ class Control : public CanvasItem {
#ifdef TOOLS_ENABLED
bool saving = false;
#endif
#endif //TOOLS_ENABLED
public:
enum Anchor {
@ -396,8 +396,6 @@ public:
virtual Size2 _edit_get_scale() const override;
virtual void _edit_set_rect(const Rect2 &p_edit_rect) override;
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
virtual void _edit_set_rotation(real_t p_rotation) override;
virtual real_t _edit_get_rotation() const override;
@ -408,7 +406,13 @@ public:
virtual bool _edit_use_pivot() const override;
virtual Size2 _edit_get_minimum_size() const override;
#endif
#endif //TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
#endif // DEBUG_ENABLED
virtual void reparent(Node *p_parent, bool p_keep_global_transform = true) override;
// Editor integration.
@ -418,7 +422,7 @@ public:
PackedStringArray get_configuration_warnings() const override;
#ifdef TOOLS_ENABLED
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
#endif
#endif //TOOLS_ENABLED
virtual bool is_text_field() const;
@ -605,7 +609,7 @@ public:
Variant get_theme_item(Theme::DataType p_data_type, const StringName &p_name, const StringName &p_theme_type = StringName()) const;
#ifdef TOOLS_ENABLED
Ref<Texture2D> get_editor_theme_icon(const StringName &p_name) const;
#endif
#endif //TOOLS_ENABLED
bool has_theme_icon_override(const StringName &p_name) const;
bool has_theme_stylebox_override(const StringName &p_name) const;
@ -637,7 +641,7 @@ public:
#ifndef DISABLE_DEPRECATED
void set_auto_translate(bool p_enable);
bool is_auto_translating() const;
#endif
#endif //DISABLE_DEPRECATED
void set_tooltip_auto_translate_mode(AutoTranslateMode p_mode);
AutoTranslateMode get_tooltip_auto_translate_mode() const;

View File

@ -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);

View File

@ -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();

View File

@ -36,7 +36,7 @@
#include "thirdparty/misc/polypartition.h"
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 NavigationPolygon::_edit_get_rect() const {
RWLockRead read_lock(rwlock);
if (rect_cache_dirty) {
@ -79,7 +79,7 @@ bool NavigationPolygon::_edit_is_selected_on_click(const Point2 &p_point, double
}
return false;
}
#endif
#endif // DEBUG_ENABLED
void NavigationPolygon::set_vertices(const Vector<Vector2> &p_vertices) {
RWLockWrite write_lock(rwlock);

View File

@ -68,10 +68,11 @@ protected:
TypedArray<Vector<Vector2>> _get_outlines() const;
public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 _edit_get_rect() const;
bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
#endif
#endif // DEBUG_ENABLED
enum SamplePartitionType {
SAMPLE_PARTITION_CONVEX_PARTITION = 0,
SAMPLE_PARTITION_TRIANGULATE,