diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2016-05-06 23:38:08 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2016-05-06 23:38:08 +0200 |
commit | 4eab767a6fbc746f6a13e976b4e34d566e7cc4cd (patch) | |
tree | fb577113bcc70a23d88cfd74141030eb842edb4f /scene/main | |
parent | e7f78cddc91696bd47b5e5400f0b4b4fd654fd6b (diff) |
Rotation APIs: Better exposure for degrees methods
Made public the various set/getters for rotations in degrees.
For consistency, renamed the exposed method names to remove the leading
underscore, and kept the old names with a deprecation warning.
Fixes #4511.
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/canvas_layer.cpp | 48 | ||||
-rw-r--r-- | scene/main/canvas_layer.h | 7 |
2 files changed, 37 insertions, 18 deletions
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index bc37cde4a2..c31a57f819 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -94,13 +94,13 @@ Vector2 CanvasLayer::get_offset() const { } -void CanvasLayer::set_rotation(real_t p_rotation) { +void CanvasLayer::set_rotation(real_t p_radians) { if (locrotscale_dirty) _update_locrotscale(); - rot=p_rotation; + rot=p_radians; _update_xform(); } @@ -113,6 +113,29 @@ real_t CanvasLayer::get_rotation() const { return rot; } +void CanvasLayer::set_rotationd(real_t p_degrees) { + + set_rotation(Math::deg2rad(p_degrees)); +} + +real_t CanvasLayer::get_rotationd() const { + + return Math::rad2deg(get_rotation()); +} + +// Kept for compatibility after rename to {s,g}et_rotationd. +// Could be removed after a couple releases. +void CanvasLayer::_set_rotationd(real_t p_degrees) { + + WARN_PRINT("Deprecated method CanvasLayer._set_rotationd(): This method was renamed to set_rotationd. Please adapt your code accordingly, as the old method will be obsoleted."); + set_rotationd(p_degrees); +} + +real_t CanvasLayer::_get_rotationd() const { + + WARN_PRINT("Deprecated method CanvasLayer._get_rotationd(): This method was renamed to get_rotationd. Please adapt your code accordingly, as the old method will be obsoleted."); + return get_rotationd(); +} void CanvasLayer::set_scale(const Vector2& p_scale) { @@ -122,7 +145,6 @@ void CanvasLayer::set_scale(const Vector2& p_scale) { scale=p_scale; _update_xform(); - } Vector2 CanvasLayer::get_scale() const { @@ -193,16 +215,6 @@ RID CanvasLayer::get_viewport() const { return viewport; } -void CanvasLayer::_set_rotationd(real_t p_rotation) { - - set_rotation(Math::deg2rad(p_rotation)); -} - -real_t CanvasLayer::_get_rotationd() const { - - return Math::rad2deg(get_rotation()); -} - void CanvasLayer::_bind_methods() { @@ -216,10 +228,14 @@ void CanvasLayer::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_offset","offset"),&CanvasLayer::set_offset); ObjectTypeDB::bind_method(_MD("get_offset"),&CanvasLayer::get_offset); - ObjectTypeDB::bind_method(_MD("set_rotation","rotation"),&CanvasLayer::set_rotation); + ObjectTypeDB::bind_method(_MD("set_rotation","radians"),&CanvasLayer::set_rotation); ObjectTypeDB::bind_method(_MD("get_rotation"),&CanvasLayer::get_rotation); - ObjectTypeDB::bind_method(_MD("_set_rotationd","rotationd"),&CanvasLayer::_set_rotationd); + ObjectTypeDB::bind_method(_MD("set_rotationd","degrees"),&CanvasLayer::set_rotationd); + ObjectTypeDB::bind_method(_MD("get_rotationd"),&CanvasLayer::get_rotationd); + + // TODO: Obsolete those two methods (old name) properly (GH-4397) + ObjectTypeDB::bind_method(_MD("_set_rotationd","degrees"),&CanvasLayer::_set_rotationd); ObjectTypeDB::bind_method(_MD("_get_rotationd"),&CanvasLayer::_get_rotationd); ObjectTypeDB::bind_method(_MD("set_scale","scale"),&CanvasLayer::set_scale); @@ -231,7 +247,7 @@ void CanvasLayer::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::INT,"layer",PROPERTY_HINT_RANGE,"-128,128,1"),_SCS("set_layer"),_SCS("get_layer") ); //ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"transform",PROPERTY_HINT_RANGE),_SCS("set_transform"),_SCS("get_transform") ); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset") ); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"rotation"),_SCS("_set_rotationd"),_SCS("_get_rotationd") ); + ADD_PROPERTY( PropertyInfo(Variant::REAL,"rotation"),_SCS("set_rotationd"),_SCS("get_rotationd") ); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scale"),_SCS("set_scale"),_SCS("get_scale") ); } diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h index 809b3fae7f..a3e8211a43 100644 --- a/scene/main/canvas_layer.h +++ b/scene/main/canvas_layer.h @@ -48,7 +48,7 @@ class CanvasLayer : public Node { RID viewport; Viewport *vp; - + // Deprecated, should be removed in a future version. void _set_rotationd(real_t p_rotation); real_t _get_rotationd() const; @@ -70,9 +70,12 @@ public: void set_offset(const Vector2& p_offset); Vector2 get_offset() const; - void set_rotation(real_t p_rotation); + void set_rotation(real_t p_radians); real_t get_rotation() const; + void set_rotationd(real_t p_degrees); + real_t get_rotationd() const; + void set_scale(const Vector2& p_scale); Vector2 get_scale() const; |