Don't compile editor-only function when tools=no

This commit is contained in:
Gilles Roudière 2019-10-21 23:37:07 +02:00
parent 76678b2609
commit b5251eb00f
38 changed files with 126 additions and 42 deletions

View file

@ -35,6 +35,7 @@
#define NORMAL_SUFFIX "_normal" #define NORMAL_SUFFIX "_normal"
#ifdef TOOLS_ENABLED
Dictionary AnimatedSprite::_edit_get_state() const { Dictionary AnimatedSprite::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state(); Dictionary state = Node2D::_edit_get_state();
state["offset"] = offset; state["offset"] = offset;
@ -72,6 +73,7 @@ bool AnimatedSprite::_edit_use_rect() const {
t = frames->get_frame(animation, frame); t = frames->get_frame(animation, frame);
return t.is_valid(); return t.is_valid();
} }
#endif
Rect2 AnimatedSprite::get_anchorable_rect() const { Rect2 AnimatedSprite::get_anchorable_rect() const {
return _get_rect(); return _get_rect();

View file

@ -156,6 +156,7 @@ protected:
virtual void _validate_property(PropertyInfo &property) const; virtual void _validate_property(PropertyInfo &property) const;
public: public:
#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const; virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state); virtual void _edit_set_state(const Dictionary &p_state);
@ -164,6 +165,7 @@ public:
virtual bool _edit_use_pivot() const; virtual bool _edit_use_pivot() const;
virtual Rect2 _edit_get_rect() const; virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const; virtual bool _edit_use_rect() const;
#endif
virtual Rect2 get_anchorable_rect() const; virtual Rect2 get_anchorable_rect() const;

View file

@ -50,6 +50,7 @@ void BackBufferCopy::_update_copy_mode() {
} }
} }
#ifdef TOOLS_ENABLED
Rect2 BackBufferCopy::_edit_get_rect() const { Rect2 BackBufferCopy::_edit_get_rect() const {
return rect; return rect;
@ -58,6 +59,7 @@ Rect2 BackBufferCopy::_edit_get_rect() const {
bool BackBufferCopy::_edit_use_rect() const { bool BackBufferCopy::_edit_use_rect() const {
return true; return true;
} }
#endif
Rect2 BackBufferCopy::get_anchorable_rect() const { Rect2 BackBufferCopy::get_anchorable_rect() const {

View file

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

View file

@ -351,7 +351,7 @@ CanvasItemMaterial::~CanvasItemMaterial() {
} }
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
#ifdef TOOLS_ENABLED
bool CanvasItem::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { bool CanvasItem::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
if (_edit_use_rect()) { if (_edit_use_rect()) {
return _edit_get_rect().has_point(p_point); return _edit_get_rect().has_point(p_point);
@ -363,6 +363,7 @@ bool CanvasItem::_edit_is_selected_on_click(const Point2 &p_point, double p_tole
Transform2D CanvasItem::_edit_get_transform() const { Transform2D CanvasItem::_edit_get_transform() const {
return Transform2D(_edit_get_rotation(), _edit_get_position() + _edit_get_pivot()); return Transform2D(_edit_get_rotation(), _edit_get_position() + _edit_get_pivot());
} }
#endif
bool CanvasItem::is_visible_in_tree() const { bool CanvasItem::is_visible_in_tree() const {
@ -1121,9 +1122,10 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("_toplevel_raise_self"), &CanvasItem::_toplevel_raise_self); ClassDB::bind_method(D_METHOD("_toplevel_raise_self"), &CanvasItem::_toplevel_raise_self);
ClassDB::bind_method(D_METHOD("_update_callback"), &CanvasItem::_update_callback); ClassDB::bind_method(D_METHOD("_update_callback"), &CanvasItem::_update_callback);
#ifdef TOOLS_ENABLED
ClassDB::bind_method(D_METHOD("_edit_set_state", "state"), &CanvasItem::_edit_set_state); ClassDB::bind_method(D_METHOD("_edit_set_state", "state"), &CanvasItem::_edit_set_state);
ClassDB::bind_method(D_METHOD("_edit_get_state"), &CanvasItem::_edit_get_state); ClassDB::bind_method(D_METHOD("_edit_get_state"), &CanvasItem::_edit_get_state);
ClassDB::bind_method(D_METHOD("_edit_set_position", "position"), &CanvasItem::_edit_set_position); ClassDB::bind_method(D_METHOD("_edit_set_position", "position"), &CanvasItem::_edit_set_position);
ClassDB::bind_method(D_METHOD("_edit_get_position"), &CanvasItem::_edit_get_position); ClassDB::bind_method(D_METHOD("_edit_get_position"), &CanvasItem::_edit_get_position);
ClassDB::bind_method(D_METHOD("_edit_set_scale", "scale"), &CanvasItem::_edit_set_scale); ClassDB::bind_method(D_METHOD("_edit_set_scale", "scale"), &CanvasItem::_edit_set_scale);
@ -1138,6 +1140,7 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("_edit_get_pivot"), &CanvasItem::_edit_get_pivot); 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_use_pivot"), &CanvasItem::_edit_use_pivot);
ClassDB::bind_method(D_METHOD("_edit_get_transform"), &CanvasItem::_edit_get_transform); ClassDB::bind_method(D_METHOD("_edit_get_transform"), &CanvasItem::_edit_get_transform);
#endif
ClassDB::bind_method(D_METHOD("get_canvas_item"), &CanvasItem::get_canvas_item); ClassDB::bind_method(D_METHOD("get_canvas_item"), &CanvasItem::get_canvas_item);

View file

@ -249,7 +249,7 @@ public:
}; };
/* EDITOR */ /* EDITOR */
#ifdef TOOLS_ENABLED
// Select the node // Select the node
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const; virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
@ -282,6 +282,7 @@ public:
virtual Point2 _edit_get_pivot() const { return Point2(); }; virtual Point2 _edit_get_pivot() const { return Point2(); };
virtual Transform2D _edit_get_transform() const; virtual Transform2D _edit_get_transform() const;
#endif
/* VISIBILITY */ /* VISIBILITY */

View file

@ -227,6 +227,7 @@ CollisionPolygon2D::BuildMode CollisionPolygon2D::get_build_mode() const {
return build_mode; return build_mode;
} }
#ifdef TOOLS_ENABLED
Rect2 CollisionPolygon2D::_edit_get_rect() const { Rect2 CollisionPolygon2D::_edit_get_rect() const {
return aabb; return aabb;
@ -240,6 +241,7 @@ bool CollisionPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, doubl
return Geometry::is_point_in_polygon(p_point, Variant(polygon)); return Geometry::is_point_in_polygon(p_point, Variant(polygon));
} }
#endif
String CollisionPolygon2D::get_configuration_warning() const { String CollisionPolygon2D::get_configuration_warning() const {

View file

@ -67,16 +67,18 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
#endif
void set_build_mode(BuildMode p_mode); void set_build_mode(BuildMode p_mode);
BuildMode get_build_mode() const; BuildMode get_build_mode() const;
void set_polygon(const Vector<Point2> &p_polygon); void set_polygon(const Vector<Point2> &p_polygon);
Vector<Point2> get_polygon() const; Vector<Point2> get_polygon() const;
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
virtual String get_configuration_warning() const; virtual String get_configuration_warning() const;
void set_disabled(bool p_disabled); void set_disabled(bool p_disabled);

View file

@ -33,6 +33,7 @@
#include "core/engine.h" #include "core/engine.h"
#include "servers/visual_server.h" #include "servers/visual_server.h"
#ifdef TOOLS_ENABLED
Dictionary Light2D::_edit_get_state() const { Dictionary Light2D::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state(); Dictionary state = Node2D::_edit_get_state();
state["offset"] = get_texture_offset(); state["offset"] = get_texture_offset();
@ -68,6 +69,7 @@ Rect2 Light2D::_edit_get_rect() const {
bool Light2D::_edit_use_rect() const { bool Light2D::_edit_use_rect() const {
return !texture.is_null(); return !texture.is_null();
} }
#endif
Rect2 Light2D::get_anchorable_rect() const { Rect2 Light2D::get_anchorable_rect() const {
if (texture.is_null()) if (texture.is_null())

View file

@ -85,6 +85,7 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const; virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state); virtual void _edit_set_state(const Dictionary &p_state);
@ -93,6 +94,7 @@ public:
virtual bool _edit_use_pivot() const; virtual bool _edit_use_pivot() const;
virtual Rect2 _edit_get_rect() const; virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const; virtual bool _edit_use_rect() const;
#endif
virtual Rect2 get_anchorable_rect() const; virtual Rect2 get_anchorable_rect() const;

View file

@ -33,6 +33,8 @@
#include "core/engine.h" #include "core/engine.h"
#define LINE_GRAB_WIDTH 8 #define LINE_GRAB_WIDTH 8
#ifdef TOOLS_ENABLED
Rect2 OccluderPolygon2D::_edit_get_rect() const { Rect2 OccluderPolygon2D::_edit_get_rect() const {
if (rect_cache_dirty) { if (rect_cache_dirty) {
@ -80,6 +82,7 @@ bool OccluderPolygon2D::_edit_is_selected_on_click(const Point2 &p_point, double
return false; return false;
} }
} }
#endif
void OccluderPolygon2D::set_polygon(const PoolVector<Vector2> &p_polygon) { void OccluderPolygon2D::set_polygon(const PoolVector<Vector2> &p_polygon) {
@ -215,6 +218,7 @@ void LightOccluder2D::_notification(int p_what) {
} }
} }
#ifdef TOOLS_ENABLED
Rect2 LightOccluder2D::_edit_get_rect() const { Rect2 LightOccluder2D::_edit_get_rect() const {
return occluder_polygon.is_valid() ? occluder_polygon->_edit_get_rect() : Rect2(); return occluder_polygon.is_valid() ? occluder_polygon->_edit_get_rect() : Rect2();
@ -224,6 +228,7 @@ bool LightOccluder2D::_edit_is_selected_on_click(const Point2 &p_point, double p
return occluder_polygon.is_valid() ? occluder_polygon->_edit_is_selected_on_click(p_point, p_tolerance) : false; return occluder_polygon.is_valid() ? occluder_polygon->_edit_is_selected_on_click(p_point, p_tolerance) : false;
} }
#endif
void LightOccluder2D::set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polygon) { void LightOccluder2D::set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polygon) {

View file

@ -57,8 +57,10 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const; virtual Rect2 _edit_get_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const; virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
#endif
void set_polygon(const PoolVector<Vector2> &p_polygon); void set_polygon(const PoolVector<Vector2> &p_polygon);
PoolVector<Vector2> get_polygon() const; PoolVector<Vector2> get_polygon() const;
@ -91,8 +93,10 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const; virtual Rect2 _edit_get_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const; virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
#endif
void set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polygon); void set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polygon);
Ref<OccluderPolygon2D> get_occluder_polygon() const; Ref<OccluderPolygon2D> get_occluder_polygon() const;

View file

@ -50,6 +50,7 @@ Line2D::Line2D() {
_antialiased = false; _antialiased = false;
} }
#ifdef TOOLS_ENABLED
Rect2 Line2D::_edit_get_rect() const { Rect2 Line2D::_edit_get_rect() const {
if (_points.size() == 0) if (_points.size() == 0)
@ -79,6 +80,7 @@ bool Line2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toleranc
return false; return false;
} }
#endif
void Line2D::set_points(const PoolVector<Vector2> &p_points) { void Line2D::set_points(const PoolVector<Vector2> &p_points) {
_points = p_points; _points = p_points;

View file

@ -56,11 +56,13 @@ public:
LINE_TEXTURE_STRETCH LINE_TEXTURE_STRETCH
}; };
Line2D(); #ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const; virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const; virtual bool _edit_use_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const; virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
#endif
Line2D();
void set_points(const PoolVector<Vector2> &p_points); void set_points(const PoolVector<Vector2> &p_points);
PoolVector<Vector2> get_points() const; PoolVector<Vector2> get_points() const;

View file

@ -94,6 +94,7 @@ Ref<Texture> MeshInstance2D::get_texture() const {
return texture; return texture;
} }
#ifdef TOOLS_ENABLED
Rect2 MeshInstance2D::_edit_get_rect() const { Rect2 MeshInstance2D::_edit_get_rect() const {
if (mesh.is_valid()) { if (mesh.is_valid()) {
@ -103,6 +104,7 @@ Rect2 MeshInstance2D::_edit_get_rect() const {
return Node2D::_edit_get_rect(); return Node2D::_edit_get_rect();
} }
#endif
MeshInstance2D::MeshInstance2D() { MeshInstance2D::MeshInstance2D() {
} }

View file

@ -46,6 +46,10 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
#endif
void set_mesh(const Ref<Mesh> &p_mesh); void set_mesh(const Ref<Mesh> &p_mesh);
Ref<Mesh> get_mesh() const; Ref<Mesh> get_mesh() const;
@ -55,8 +59,6 @@ public:
void set_normal_map(const Ref<Texture> &p_texture); void set_normal_map(const Ref<Texture> &p_texture);
Ref<Texture> get_normal_map() const; Ref<Texture> get_normal_map() const;
virtual Rect2 _edit_get_rect() const;
MeshInstance2D(); MeshInstance2D();
}; };

View file

@ -94,6 +94,7 @@ Ref<Texture> MultiMeshInstance2D::get_normal_map() const {
return normal_map; return normal_map;
} }
#ifdef TOOLS_ENABLED
Rect2 MultiMeshInstance2D::_edit_get_rect() const { Rect2 MultiMeshInstance2D::_edit_get_rect() const {
if (multimesh.is_valid()) { if (multimesh.is_valid()) {
@ -103,6 +104,7 @@ Rect2 MultiMeshInstance2D::_edit_get_rect() const {
return Node2D::_edit_get_rect(); return Node2D::_edit_get_rect();
} }
#endif
MultiMeshInstance2D::MultiMeshInstance2D() { MultiMeshInstance2D::MultiMeshInstance2D() {
} }

View file

@ -47,6 +47,10 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
#endif
void set_multimesh(const Ref<MultiMesh> &p_multimesh); void set_multimesh(const Ref<MultiMesh> &p_multimesh);
Ref<MultiMesh> get_multimesh() const; Ref<MultiMesh> get_multimesh() const;
@ -56,8 +60,6 @@ public:
void set_normal_map(const Ref<Texture> &p_texture); void set_normal_map(const Ref<Texture> &p_texture);
Ref<Texture> get_normal_map() const; Ref<Texture> get_normal_map() const;
virtual Rect2 _edit_get_rect() const;
MultiMeshInstance2D(); MultiMeshInstance2D();
~MultiMeshInstance2D(); ~MultiMeshInstance2D();
}; };

View file

@ -36,6 +36,7 @@
#include "thirdparty/misc/triangulator.h" #include "thirdparty/misc/triangulator.h"
#ifdef TOOLS_ENABLED
Rect2 NavigationPolygon::_edit_get_rect() const { Rect2 NavigationPolygon::_edit_get_rect() const {
if (rect_cache_dirty) { if (rect_cache_dirty) {
@ -75,6 +76,7 @@ bool NavigationPolygon::_edit_is_selected_on_click(const Point2 &p_point, double
} }
return false; return false;
} }
#endif
void NavigationPolygon::set_vertices(const PoolVector<Vector2> &p_vertices) { void NavigationPolygon::set_vertices(const PoolVector<Vector2> &p_vertices) {
@ -357,7 +359,7 @@ bool NavigationPolygonInstance::is_enabled() const {
} }
///////////////////////////// /////////////////////////////
#ifdef TOOLS_ENABLED
Rect2 NavigationPolygonInstance::_edit_get_rect() const { Rect2 NavigationPolygonInstance::_edit_get_rect() const {
return navpoly.is_valid() ? navpoly->_edit_get_rect() : Rect2(); return navpoly.is_valid() ? navpoly->_edit_get_rect() : Rect2();
@ -367,6 +369,7 @@ bool NavigationPolygonInstance::_edit_is_selected_on_click(const Point2 &p_point
return navpoly.is_valid() ? navpoly->_edit_is_selected_on_click(p_point, p_tolerance) : false; return navpoly.is_valid() ? navpoly->_edit_is_selected_on_click(p_point, p_tolerance) : false;
} }
#endif
void NavigationPolygonInstance::_notification(int p_what) { void NavigationPolygonInstance::_notification(int p_what) {

View file

@ -57,8 +57,10 @@ protected:
Array _get_outlines() const; Array _get_outlines() const;
public: public:
#ifdef TOOLS_ENABLED
Rect2 _edit_get_rect() const; Rect2 _edit_get_rect() const;
bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const; bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
#endif
void set_vertices(const PoolVector<Vector2> &p_vertices); void set_vertices(const PoolVector<Vector2> &p_vertices);
PoolVector<Vector2> get_vertices() const; PoolVector<Vector2> get_vertices() const;
@ -100,8 +102,10 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const; virtual Rect2 _edit_get_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const; virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
#endif
void set_enabled(bool p_enabled); void set_enabled(bool p_enabled);
bool is_enabled() const; bool is_enabled() const;

View file

@ -35,6 +35,7 @@
#include "scene/main/viewport.h" #include "scene/main/viewport.h"
#include "servers/visual_server.h" #include "servers/visual_server.h"
#ifdef TOOLS_ENABLED
Dictionary Node2D::_edit_get_state() const { Dictionary Node2D::_edit_get_state() const {
Dictionary state; Dictionary state;
@ -44,6 +45,7 @@ Dictionary Node2D::_edit_get_state() const {
return state; return state;
} }
void Node2D::_edit_set_state(const Dictionary &p_state) { void Node2D::_edit_set_state(const Dictionary &p_state) {
pos = p_state["position"]; pos = p_state["position"];
@ -119,6 +121,7 @@ void Node2D::_edit_set_rect(const Rect2 &p_edit_rect) {
_change_notify("scale"); _change_notify("scale");
_change_notify("position"); _change_notify("position");
} }
#endif
void Node2D::_update_xform_values() { void Node2D::_update_xform_values() {

View file

@ -55,6 +55,7 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const; virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state); virtual void _edit_set_state(const Dictionary &p_state);
@ -69,6 +70,7 @@ public:
virtual bool _edit_use_rotation() const; virtual bool _edit_use_rotation() const;
virtual void _edit_set_rect(const Rect2 &p_edit_rect); virtual void _edit_set_rect(const Rect2 &p_edit_rect);
#endif
void set_position(const Point2 &p_pos); void set_position(const Point2 &p_pos);
void set_rotation(float p_radians); void set_rotation(float p_radians);

View file

@ -37,6 +37,7 @@
#include "editor/editor_scale.h" #include "editor/editor_scale.h"
#endif #endif
#ifdef TOOLS_ENABLED
Rect2 Path2D::_edit_get_rect() const { Rect2 Path2D::_edit_get_rect() const {
if (!curve.is_valid() || curve->get_point_count() == 0) if (!curve.is_valid() || curve->get_point_count() == 0)
@ -85,6 +86,7 @@ bool Path2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toleranc
return false; return false;
} }
#endif
void Path2D::_notification(int p_what) { void Path2D::_notification(int p_what) {

View file

@ -47,9 +47,11 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const; virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const; virtual bool _edit_use_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const; virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
#endif
void set_curve(const Ref<Curve2D> &p_curve); void set_curve(const Ref<Curve2D> &p_curve);
Ref<Curve2D> get_curve() const; Ref<Curve2D> get_curve() const;

View file

@ -33,6 +33,7 @@
#include "core/math/geometry.h" #include "core/math/geometry.h"
#include "skeleton_2d.h" #include "skeleton_2d.h"
#ifdef TOOLS_ENABLED
Dictionary Polygon2D::_edit_get_state() const { Dictionary Polygon2D::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state(); Dictionary state = Node2D::_edit_get_state();
state["offset"] = offset; state["offset"] = offset;
@ -87,6 +88,7 @@ bool Polygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toler
} }
return Geometry::is_point_in_polygon(p_point - get_offset(), polygon2d); return Geometry::is_point_in_polygon(p_point - get_offset(), polygon2d);
} }
#endif
void Polygon2D::_skeleton_bone_setup_changed() { void Polygon2D::_skeleton_bone_setup_changed() {
update(); update();

View file

@ -77,6 +77,7 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const; virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state); virtual void _edit_set_state(const Dictionary &p_state);
@ -87,6 +88,7 @@ public:
virtual bool _edit_use_rect() const; virtual bool _edit_use_rect() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const; virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
#endif
void set_polygon(const PoolVector<Vector2> &p_polygon); void set_polygon(const PoolVector<Vector2> &p_polygon);
PoolVector<Vector2> get_polygon() const; PoolVector<Vector2> get_polygon() const;

View file

@ -43,6 +43,7 @@ void Position2D::_draw_cross() {
draw_line(Point2(0, -extents), Point2(0, +extents), Color(0.53, 0.84, 0.01)); draw_line(Point2(0, -extents), Point2(0, +extents), Color(0.53, 0.84, 0.01));
} }
#ifdef TOOLS_ENABLED
Rect2 Position2D::_edit_get_rect() const { Rect2 Position2D::_edit_get_rect() const {
float extents = get_gizmo_extents(); float extents = get_gizmo_extents();
@ -52,6 +53,7 @@ Rect2 Position2D::_edit_get_rect() const {
bool Position2D::_edit_use_rect() const { bool Position2D::_edit_use_rect() const {
return false; return false;
} }
#endif
void Position2D::_notification(int p_what) { void Position2D::_notification(int p_what) {

View file

@ -44,8 +44,10 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const; virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const; virtual bool _edit_use_rect() const;
#endif
void set_gizmo_extents(float p_extents); void set_gizmo_extents(float p_extents);
float get_gizmo_extents() const; float get_gizmo_extents() const;

View file

@ -34,6 +34,7 @@
#include "scene/main/viewport.h" #include "scene/main/viewport.h"
#include "scene/scene_string_names.h" #include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
Dictionary Sprite::_edit_get_state() const { Dictionary Sprite::_edit_get_state() const {
Dictionary state = Node2D::_edit_get_state(); Dictionary state = Node2D::_edit_get_state();
state["offset"] = offset; state["offset"] = offset;
@ -58,6 +59,11 @@ bool Sprite::_edit_use_pivot() const {
return true; return true;
} }
bool Sprite::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
return is_pixel_opaque(p_point);
}
Rect2 Sprite::_edit_get_rect() const { Rect2 Sprite::_edit_get_rect() const {
return get_rect(); return get_rect();
} }
@ -65,6 +71,7 @@ Rect2 Sprite::_edit_get_rect() const {
bool Sprite::_edit_use_rect() const { bool Sprite::_edit_use_rect() const {
return texture.is_valid(); return texture.is_valid();
} }
#endif
Rect2 Sprite::get_anchorable_rect() const { Rect2 Sprite::get_anchorable_rect() const {
return get_rect(); return get_rect();
@ -305,11 +312,6 @@ int Sprite::get_hframes() const {
return hframes; return hframes;
} }
bool Sprite::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
return is_pixel_opaque(p_point);
}
bool Sprite::is_pixel_opaque(const Point2 &p_point) const { bool Sprite::is_pixel_opaque(const Point2 &p_point) const {
if (texture.is_null()) if (texture.is_null())

View file

@ -67,6 +67,7 @@ protected:
virtual void _validate_property(PropertyInfo &property) const; virtual void _validate_property(PropertyInfo &property) const;
public: public:
#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const; virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state); virtual void _edit_set_state(const Dictionary &p_state);
@ -75,10 +76,11 @@ public:
virtual bool _edit_use_pivot() const; virtual bool _edit_use_pivot() const;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const; virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;
bool is_pixel_opaque(const Point2 &p_point) const;
virtual Rect2 _edit_get_rect() const; virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const; virtual bool _edit_use_rect() const;
#endif
bool is_pixel_opaque(const Point2 &p_point) const;
void set_texture(const Ref<Texture> &p_texture); void set_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_texture() const; Ref<Texture> get_texture() const;

View file

@ -1282,6 +1282,7 @@ PoolVector<int> TileMap::_get_tile_data() const {
return data; return data;
} }
#ifdef TOOLS_ENABLED
Rect2 TileMap::_edit_get_rect() const { Rect2 TileMap::_edit_get_rect() const {
if (pending_update) { if (pending_update) {
const_cast<TileMap *>(this)->update_dirty_quadrants(); const_cast<TileMap *>(this)->update_dirty_quadrants();
@ -1290,6 +1291,7 @@ Rect2 TileMap::_edit_get_rect() const {
} }
return rect_cache; return rect_cache;
} }
#endif
void TileMap::set_collision_layer(uint32_t p_layer) { void TileMap::set_collision_layer(uint32_t p_layer) {

View file

@ -244,7 +244,9 @@ public:
INVALID_CELL = -1 INVALID_CELL = -1
}; };
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const; virtual Rect2 _edit_get_rect() const;
#endif
void set_tileset(const Ref<TileSet> &p_tileset); void set_tileset(const Ref<TileSet> &p_tileset);
Ref<TileSet> get_tileset() const; Ref<TileSet> get_tileset() const;

View file

@ -135,7 +135,9 @@ void TouchScreenButton::_notification(int p_what) {
return; return;
if (shape.is_valid()) { if (shape.is_valid()) {
Color draw_col = get_tree()->get_debug_collisions_color(); Color draw_col = get_tree()->get_debug_collisions_color();
Vector2 pos = shape_centered ? _edit_get_rect().size * 0.5f : Vector2();
Vector2 size = texture.is_null() ? shape->get_rect().size : texture->get_size();
Vector2 pos = shape_centered ? size * 0.5f : Vector2();
draw_set_transform_matrix(get_canvas_transform().translated(pos)); draw_set_transform_matrix(get_canvas_transform().translated(pos));
shape->draw(get_canvas_item(), draw_col); shape->draw(get_canvas_item(), draw_col);
} }
@ -251,9 +253,7 @@ void TouchScreenButton::_input(const Ref<InputEvent> &p_event) {
} }
bool TouchScreenButton::_is_point_inside(const Point2 &p_point) { bool TouchScreenButton::_is_point_inside(const Point2 &p_point) {
Point2 coord = (get_global_transform_with_canvas()).affine_inverse().xform(p_point); Point2 coord = (get_global_transform_with_canvas()).affine_inverse().xform(p_point);
Rect2 item_rect = _edit_get_rect();
bool touched = false; bool touched = false;
bool check_rect = true; bool check_rect = true;
@ -261,7 +261,7 @@ bool TouchScreenButton::_is_point_inside(const Point2 &p_point) {
if (shape.is_valid()) { if (shape.is_valid()) {
check_rect = false; check_rect = false;
Transform2D xform = shape_centered ? Transform2D().translated(item_rect.size * 0.5f) : Transform2D(); Transform2D xform = shape_centered ? Transform2D().translated(shape->get_rect().size * 0.5f) : Transform2D();
touched = shape->collide(xform, unit_rect, Transform2D(0, coord + Vector2(0.5, 0.5))); touched = shape->collide(xform, unit_rect, Transform2D(0, coord + Vector2(0.5, 0.5)));
} }
@ -277,7 +277,7 @@ bool TouchScreenButton::_is_point_inside(const Point2 &p_point) {
if (!touched && check_rect) { if (!touched && check_rect) {
if (texture.is_valid()) if (texture.is_valid())
touched = item_rect.has_point(coord); touched = Rect2(Size2(), texture->get_size()).has_point(coord);
} }
return touched; return touched;
@ -324,6 +324,7 @@ void TouchScreenButton::_release(bool p_exiting_tree) {
} }
} }
#ifdef TOOLS_ENABLED
Rect2 TouchScreenButton::_edit_get_rect() const { Rect2 TouchScreenButton::_edit_get_rect() const {
if (texture.is_null()) if (texture.is_null())
return CanvasItem::_edit_get_rect(); return CanvasItem::_edit_get_rect();
@ -334,6 +335,7 @@ Rect2 TouchScreenButton::_edit_get_rect() const {
bool TouchScreenButton::_edit_use_rect() const { bool TouchScreenButton::_edit_use_rect() const {
return !texture.is_null(); return !texture.is_null();
} }
#endif
Rect2 TouchScreenButton::get_anchorable_rect() const { Rect2 TouchScreenButton::get_anchorable_rect() const {
if (texture.is_null()) if (texture.is_null())

View file

@ -74,6 +74,11 @@ protected:
static void _bind_methods(); static void _bind_methods();
public: public:
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
#endif
void set_texture(const Ref<Texture> &p_texture); void set_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_texture() const; Ref<Texture> get_texture() const;
@ -103,8 +108,6 @@ public:
bool is_pressed() const; bool is_pressed() const;
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
virtual Rect2 get_anchorable_rect() const; virtual Rect2 get_anchorable_rect() const;
TouchScreenButton(); TouchScreenButton();

View file

@ -38,6 +38,16 @@
#include "scene/main/viewport.h" #include "scene/main/viewport.h"
#include "scene/scene_string_names.h" #include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
Rect2 VisibilityNotifier2D::_edit_get_rect() const {
return rect;
}
bool VisibilityNotifier2D::_edit_use_rect() const {
return true;
}
#endif
void VisibilityNotifier2D::_enter_viewport(Viewport *p_viewport) { void VisibilityNotifier2D::_enter_viewport(Viewport *p_viewport) {
ERR_FAIL_COND(viewports.has(p_viewport)); ERR_FAIL_COND(viewports.has(p_viewport));
@ -84,15 +94,6 @@ void VisibilityNotifier2D::set_rect(const Rect2 &p_rect) {
_change_notify("rect"); _change_notify("rect");
} }
Rect2 VisibilityNotifier2D::_edit_get_rect() const {
return rect;
}
bool VisibilityNotifier2D::_edit_use_rect() const {
return true;
}
Rect2 VisibilityNotifier2D::get_rect() const { Rect2 VisibilityNotifier2D::get_rect() const {
return rect; return rect;

View file

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

View file

@ -47,6 +47,7 @@
#include "editor/plugins/canvas_item_editor_plugin.h" #include "editor/plugins/canvas_item_editor_plugin.h"
#endif #endif
#ifdef TOOLS_ENABLED
Dictionary Control::_edit_get_state() const { Dictionary Control::_edit_get_state() const {
Dictionary s; Dictionary s;
@ -155,6 +156,11 @@ bool Control::_edit_use_pivot() const {
return true; return true;
} }
Size2 Control::_edit_get_minimum_size() const {
return get_combined_minimum_size();
}
#endif
void Control::set_custom_minimum_size(const Size2 &p_custom) { void Control::set_custom_minimum_size(const Size2 &p_custom) {
if (p_custom == data.custom_minimum_size) if (p_custom == data.custom_minimum_size)
@ -193,11 +199,6 @@ Size2 Control::get_combined_minimum_size() const {
return data.minimum_size_cache; return data.minimum_size_cache;
} }
Size2 Control::_edit_get_minimum_size() const {
return get_combined_minimum_size();
}
Transform2D Control::_get_internal_transform() const { Transform2D Control::_get_internal_transform() const {
Transform2D rot_scale; Transform2D rot_scale;

View file

@ -279,6 +279,7 @@ public:
}; };
/* EDITOR */ /* EDITOR */
#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const; virtual Dictionary _edit_get_state() const;
virtual void _edit_set_state(const Dictionary &p_state); virtual void _edit_set_state(const Dictionary &p_state);
@ -301,6 +302,7 @@ public:
virtual bool _edit_use_pivot() const; virtual bool _edit_use_pivot() const;
virtual Size2 _edit_get_minimum_size() const; virtual Size2 _edit_get_minimum_size() const;
#endif
void accept_event(); void accept_event();