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.cpp61
1 files changed, 55 insertions, 6 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index bd6b8078ff..23a7ae00da 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -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);
@@ -916,6 +916,7 @@ void Control::_window_show_tooltip() {
void Control::_window_call_input(Control *p_control,const InputEvent& p_input) {
+ _block();
while(p_control) {
@@ -932,6 +933,9 @@ void Control::_window_call_input(Control *p_control,const InputEvent& p_input) {
break;
p_control=p_control->data.parent;
}
+
+ _unblock();
+
}
void Control::_window_input_event(InputEvent p_event) {
@@ -1067,6 +1071,7 @@ void Control::_window_input_event(InputEvent p_event) {
Size2 pos = mpos;
pos = window->focus_inv_xform.xform(pos);
+
window->mouse_over->drop_data(pos,window->drag_data);
window->drag_data=Variant();
//change mouse accordingly
@@ -1927,6 +1932,7 @@ void Control::set_size(const Size2& p_size) {
data.margin[3] = _s2a( y+h, data.anchor[3], ph );
_size_changed();
+
}
@@ -2412,9 +2418,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 +2734,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 +2795,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 +2891,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 +2975,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++) {