summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2016-05-09 19:08:06 +0200
committerRémi Verschelde <remi@verschelde.fr>2016-05-09 19:08:06 +0200
commit0dfc4a2029e7a39ce521cc81da94fdaf73341ab2 (patch)
treecd4451d8797c2a408763b59b6f38e3579f651eb9 /scene/gui
parent7985bd8e15fc037b42e182972f40742d25d8b847 (diff)
parent4eab767a6fbc746f6a13e976b4e34d566e7cc4cd (diff)
Merge pull request #4571 from akien-mga/pr-rot-deg
Rotation APIs: Better exposure for degrees methods
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/control.cpp43
-rw-r--r--scene/gui/control.h7
2 files changed, 34 insertions, 16 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 86ec31a9c2..047b854862 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -2157,17 +2157,9 @@ bool Control::is_text_field() const {
}
-void Control::_set_rotation_deg(float p_rot) {
- set_rotation(Math::deg2rad(p_rot));
-}
-
-float Control::_get_rotation_deg() const {
- return Math::rad2deg(get_rotation());
-}
+void Control::set_rotation(float p_radians) {
-void Control::set_rotation(float p_rotation) {
-
- data.rotation=p_rotation;
+ data.rotation=p_radians;
update();
_notify_transform();
}
@@ -2177,6 +2169,25 @@ float Control::get_rotation() const{
return data.rotation;
}
+void Control::set_rotation_deg(float p_degrees) {
+ set_rotation(Math::deg2rad(p_degrees));
+}
+
+float Control::get_rotation_deg() const {
+ return Math::rad2deg(get_rotation());
+}
+
+// Kept for compatibility after rename to {s,g}et_rotation_deg.
+// Could be removed after a couple releases.
+void Control::_set_rotation_deg(float p_degrees) {
+ WARN_PRINT("Deprecated method Control._set_rotation_deg(): This method was renamed to set_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted.");
+ set_rotation_deg(p_degrees);
+}
+float Control::_get_rotation_deg() const {
+ WARN_PRINT("Deprecated method Control._get_rotation_deg(): This method was renamed to get_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted.");
+ return get_rotation_deg();
+}
+
void Control::set_scale(const Vector2& p_scale){
data.scale=p_scale;
@@ -2232,8 +2243,10 @@ void Control::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_size","size"),&Control::set_size);
ObjectTypeDB::bind_method(_MD("set_custom_minimum_size","size"),&Control::set_custom_minimum_size);
ObjectTypeDB::bind_method(_MD("set_global_pos","pos"),&Control::set_global_pos);
- ObjectTypeDB::bind_method(_MD("set_rotation","rotation"),&Control::set_rotation);
- ObjectTypeDB::bind_method(_MD("_set_rotation_deg","rotation"),&Control::_set_rotation_deg);
+ ObjectTypeDB::bind_method(_MD("set_rotation","radians"),&Control::set_rotation);
+ ObjectTypeDB::bind_method(_MD("set_rotation_deg","degrees"),&Control::set_rotation_deg);
+ // TODO: Obsolete this method (old name) properly (GH-4397)
+ ObjectTypeDB::bind_method(_MD("_set_rotation_deg","degrees"),&Control::_set_rotation_deg);
ObjectTypeDB::bind_method(_MD("set_scale","scale"),&Control::set_scale);
ObjectTypeDB::bind_method(_MD("get_margin","margin"),&Control::get_margin);
ObjectTypeDB::bind_method(_MD("get_begin"),&Control::get_begin);
@@ -2241,12 +2254,14 @@ void Control::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_pos"),&Control::get_pos);
ObjectTypeDB::bind_method(_MD("get_size"),&Control::get_size);
ObjectTypeDB::bind_method(_MD("get_rotation"),&Control::get_rotation);
+ ObjectTypeDB::bind_method(_MD("get_rotation_deg"),&Control::get_rotation_deg);
+ // TODO: Obsolete this method (old name) properly (GH-4397)
+ ObjectTypeDB::bind_method(_MD("_get_rotation_deg"),&Control::_get_rotation_deg);
ObjectTypeDB::bind_method(_MD("get_scale"),&Control::get_scale);
ObjectTypeDB::bind_method(_MD("get_custom_minimum_size"),&Control::get_custom_minimum_size);
ObjectTypeDB::bind_method(_MD("get_parent_area_size"),&Control::get_size);
ObjectTypeDB::bind_method(_MD("get_global_pos"),&Control::get_global_pos);
ObjectTypeDB::bind_method(_MD("get_rect"),&Control::get_rect);
- ObjectTypeDB::bind_method(_MD("_get_rotation_deg"),&Control::_get_rotation_deg);
ObjectTypeDB::bind_method(_MD("get_global_rect"),&Control::get_global_rect);
ObjectTypeDB::bind_method(_MD("set_area_as_parent_rect","margin"),&Control::set_area_as_parent_rect,DEFVAL(0));
ObjectTypeDB::bind_method(_MD("show_modal","exclusive"),&Control::show_modal,DEFVAL(false));
@@ -2325,7 +2340,7 @@ void Control::_bind_methods() {
ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/pos", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_pos"),_SCS("get_pos") );
ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/size", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_size"),_SCS("get_size") );
ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/min_size"), _SCS("set_custom_minimum_size"),_SCS("get_custom_minimum_size") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"rect/rotation",PROPERTY_HINT_RANGE,"-1080,1080,0.01"), _SCS("_set_rotation_deg"),_SCS("_get_rotation_deg") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"rect/rotation",PROPERTY_HINT_RANGE,"-1080,1080,0.01"), _SCS("set_rotation_deg"),_SCS("get_rotation_deg") );
ADD_PROPERTYNO( PropertyInfo(Variant::VECTOR2,"rect/scale"), _SCS("set_scale"),_SCS("get_scale") );
ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"hint/tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"),_SCS("_get_tooltip") );
ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/left" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_LEFT );
diff --git a/scene/gui/control.h b/scene/gui/control.h
index aa9a7612a5..f720185c9d 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -180,7 +180,8 @@ private:
void _size_changed();
String _get_tooltip() const;
- void _set_rotation_deg(float p_rot);
+ // Deprecated, should be removed in a future version.
+ void _set_rotation_deg(float p_degrees);
float _get_rotation_deg() const;
friend class Viewport;
@@ -275,8 +276,10 @@ public:
Rect2 get_global_rect() const;
Rect2 get_window_rect() const; ///< use with care, as it blocks waiting for the visual server
- void set_rotation(float p_rotation);
+ void set_rotation(float p_radians);
+ void set_rotation_deg(float p_degrees);
float get_rotation() const;
+ float get_rotation_deg() const;
void set_scale(const Vector2& p_scale);
Vector2 get_scale() const;