summaryrefslogtreecommitdiff
path: root/scene/gui/control.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/control.cpp')
-rw-r--r--scene/gui/control.cpp54
1 files changed, 49 insertions, 5 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index bd6b8078ff..ec4886a6ac 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -580,8 +580,8 @@ void Control::_notification(int p_notification) {
} break;
case NOTIFICATION_DRAW: {
- Matrix32 xform;
- xform.set_origin(get_pos());
+ Matrix32 xform=Matrix32(data.rotation,get_pos());
+ xform.scale_basis(data.scale);
VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(),xform);
VisualServer::get_singleton()->canvas_item_set_custom_rect( get_canvas_item(),true, Rect2(Point2(),get_size()));
//emit_signal(SceneStringNames::get_singleton()->draw);
@@ -1927,6 +1927,7 @@ void Control::set_size(const Size2& p_size) {
data.margin[3] = _s2a( y+h, data.anchor[3], ph );
_size_changed();
+
}
@@ -2412,9 +2413,9 @@ Control::CursorShape Control::get_cursor_shape(const Point2& p_pos) const {
Matrix32 Control::get_transform() const {
- Matrix32 xf;
- xf.set_origin(get_pos());
- return xf;
+ Matrix32 xform=Matrix32(data.rotation,get_pos());
+ xform.scale_basis(data.scale);
+ return xform;
}
String Control::_get_tooltip() const {
@@ -2728,6 +2729,39 @@ bool Control::is_text_field() const {
return false;
}
+
+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_rotation) {
+
+ data.rotation=p_rotation;
+ update();
+ _notify_transform();
+}
+
+float Control::get_rotation() const{
+
+ return data.rotation;
+}
+
+void Control::set_scale(const Vector2& p_scale){
+
+ data.scale=p_scale;
+ update();
+ _notify_transform();
+}
+Vector2 Control::get_scale() const{
+
+ return data.scale;
+}
+
+
void Control::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_window_input_event"),&Control::_window_input_event);
@@ -2756,15 +2790,21 @@ 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_scale","scale"),&Control::set_scale);
ObjectTypeDB::bind_method(_MD("get_margin","margin"),&Control::get_margin);
ObjectTypeDB::bind_method(_MD("get_begin"),&Control::get_begin);
ObjectTypeDB::bind_method(_MD("get_end"),&Control::get_end);
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_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));
@@ -2846,6 +2886,8 @@ 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_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 );
ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/top" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_TOP );
@@ -2928,6 +2970,8 @@ Control::Control() {
data.v_size_flags=SIZE_FILL;
data.expand=1;
data.pending_min_size_update=false;
+ data.rotation=0;
+ data.scale=Vector2(1,1);
for (int i=0;i<4;i++) {