Skip to content

Commit

Permalink
Compile CanvasItem._edit_*() functions with DEBUG_ENABLED
Browse files Browse the repository at this point in the history
  • Loading branch information
YeldhamDev committed Nov 1, 2024
1 parent c6c464c commit a401812
Show file tree
Hide file tree
Showing 42 changed files with 51 additions and 48 deletions.
2 changes: 1 addition & 1 deletion scene/2d/animated_sprite_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#include "scene/main/viewport.h"

#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Dictionary AnimatedSprite2D::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state();
state["offset"] = offset;
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/animated_sprite_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class AnimatedSprite2D : public Node2D {
void _validate_property(PropertyInfo &p_property) const;

public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Dictionary _edit_get_state() const override;
virtual void _edit_set_state(const Dictionary &p_state) override;

Expand Down
2 changes: 1 addition & 1 deletion scene/2d/back_buffer_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void BackBufferCopy::_update_copy_mode() {
}
}

#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Rect2 BackBufferCopy::_edit_get_rect() const {
return rect;
}
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/back_buffer_copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class BackBufferCopy : public Node2D {
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
Expand Down
3 changes: 1 addition & 2 deletions scene/2d/light_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,7 @@ Light2D::~Light2D() {

//////////////////////////////

#ifdef TOOLS_ENABLED

#ifdef DEBUG_ENABLED
Dictionary PointLight2D::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state();
state["offset"] = get_texture_offset();
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/light_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class PointLight2D : public Light2D {
static void _bind_methods();

public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Dictionary _edit_get_state() const override;
virtual void _edit_set_state(const Dictionary &p_state) override;

Expand Down
4 changes: 2 additions & 2 deletions scene/2d/light_occluder_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions scene/2d/light_occluder_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class OccluderPolygon2D : public Resource {
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
Expand Down Expand Up @@ -93,7 +93,7 @@ class LightOccluder2D : public Node2D {
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
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/line_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/line_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Line2D : public Node2D {
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;
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/marker_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/marker_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Marker2D : public Node2D {
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
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/mesh_instance_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/mesh_instance_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MeshInstance2D : public Node2D {
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
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/multimesh_instance_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/multimesh_instance_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MultiMeshInstance2D : public Node2D {
static void _bind_methods();

public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
#endif

Expand Down
4 changes: 2 additions & 2 deletions scene/2d/navigation_link_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/navigation_link_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class NavigationLink2D : public Node2D {
#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
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/navigation_region_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/navigation_region_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class NavigationRegion2D : public Node2D {
#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
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/node_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#include "scene/main/viewport.h"

#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Dictionary Node2D::_edit_get_state() const {
Dictionary state;
state["position"] = get_position();
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/node_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Node2D : public CanvasItem {
static void _bind_methods();

public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Dictionary _edit_get_state() const override;
virtual void _edit_set_state(const Dictionary &p_state) override;

Expand Down
2 changes: 1 addition & 1 deletion scene/2d/path_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/path_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Path2D : public Node2D {
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;
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/physics/collision_polygon_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/physics/collision_polygon_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class CollisionPolygon2D : public Node2D {
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;
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/polygon_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "core/math/geometry_2d.h"
#include "skeleton_2d.h"

#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Dictionary Polygon2D::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state();
state["offset"] = offset;
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/polygon_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Polygon2D : public Node2D {
void _validate_property(PropertyInfo &p_property) const;

public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Dictionary _edit_get_state() const override;
virtual void _edit_set_state(const Dictionary &p_state) override;

Expand Down
2 changes: 1 addition & 1 deletion scene/2d/sprite_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#include "scene/main/window.h"

#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Dictionary Sprite2D::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state();
state["offset"] = offset;
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/sprite_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Sprite2D : public Node2D {
void _validate_property(PropertyInfo &p_property) const;

public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Dictionary _edit_get_state() const override;
virtual void _edit_set_state(const Dictionary &p_state) override;

Expand Down
2 changes: 1 addition & 1 deletion scene/2d/tile_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/tile_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class TileMap : public Node2D {
#endif

public:
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Rect2 _edit_get_rect() const override;
#endif

Expand Down
2 changes: 1 addition & 1 deletion scene/2d/touch_screen_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/touch_screen_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class TouchScreenButton : public Node2D {
#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
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/visible_on_screen_notifier_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion scene/2d/visible_on_screen_notifier_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class VisibleOnScreenNotifier2D : public Node2D {
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
Expand Down
6 changes: 5 additions & 1 deletion scene/gui/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
// Editor plugin interoperability.

// TODO: Decouple controls from their editor plugin and get rid of this.
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
Dictionary Control::_edit_get_state() const {
Dictionary s;
s["rotation"] = get_rotation();
Expand Down Expand Up @@ -119,7 +119,9 @@ void Control::_edit_set_state(const Dictionary &p_state) {

void Control::_edit_set_position(const Point2 &p_position) {
ERR_FAIL_COND_MSG(!Engine::get_singleton()->is_editor_hint(), "This function can only be used from editor plugins.");
#ifdef TOOLS_ENABLED
set_position(p_position, ControlEditorToolbar::get_singleton()->is_anchors_mode_enabled() && get_parent_control());
#endif
}

Point2 Control::_edit_get_position() const {
Expand All @@ -136,8 +138,10 @@ Size2 Control::_edit_get_scale() const {

void Control::_edit_set_rect(const Rect2 &p_edit_rect) {
ERR_FAIL_COND_MSG(!Engine::get_singleton()->is_editor_hint(), "This function can only be used from editor plugins.");
#ifdef TOOLS_ENABLED
set_position((get_position() + get_transform().basis_xform(p_edit_rect.position)).snappedf(1), ControlEditorToolbar::get_singleton()->is_anchors_mode_enabled());
set_size(p_edit_rect.size.snappedf(1), ControlEditorToolbar::get_singleton()->is_anchors_mode_enabled());
#endif
}

Rect2 Control::_edit_get_rect() const {
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ class Control : public CanvasItem {
// Editor plugin interoperability.

// TODO: Decouple controls from their editor plugin and get rid of this.
#ifdef TOOLS_ENABLED
#ifdef DEBUG_ENABLED
virtual Dictionary _edit_get_state() const override;
virtual void _edit_set_state(const Dictionary &p_state) override;

Expand Down
Loading

0 comments on commit a401812

Please sign in to comment.