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.cpp46
1 files changed, 42 insertions, 4 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 2e28baa137..c08e10b9ff 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -49,14 +49,22 @@
Variant Control::edit_get_state() const {
- return get_rect();
+ Dictionary s;
+ s["rect"]=get_rect();
+ s["rot"]=get_rotation();
+ s["scale"]=get_scale();
+ return s;
}
void Control::edit_set_state(const Variant& p_state) {
- Rect2 state=p_state;
+ Dictionary s=p_state;
+
+ Rect2 state=s["rect"];
set_pos(state.pos);
set_size(state.size);
+ set_rotation(s["rot"]);
+ set_scale(s["scale"]);
}
void Control::set_custom_minimum_size(const Size2& p_custom) {
@@ -754,6 +762,11 @@ bool Control::is_window_modal_on_top() const {
return get_viewport()->_gui_is_modal_on_top(this);
}
+uint64_t Control::get_modal_frame() const {
+
+ return data.modal_frame;
+}
+
Size2 Control::get_minimum_size() const {
@@ -1829,6 +1842,7 @@ void Control::show_modal(bool p_exclusive) {
raise();
data.modal_exclusive=p_exclusive;
data.MI=get_viewport()->_gui_show_modal(this);
+ data.modal_frame=OS::get_singleton()->get_frames_drawn();
}
@@ -1851,7 +1865,7 @@ void Control::_modal_stack_remove() {
}
-void Control::_propagate_theme_changed(CanvasItem *p_at,Control *p_owner) {
+void Control::_propagate_theme_changed(CanvasItem *p_at,Control *p_owner,bool p_assign) {
Control *c = p_at->cast_to<Control>();
@@ -1870,15 +1884,30 @@ void Control::_propagate_theme_changed(CanvasItem *p_at,Control *p_owner) {
if (c) {
- c->data.theme_owner=p_owner;
+ if (p_assign) {
+ c->data.theme_owner=p_owner;
+ }
c->_notification(NOTIFICATION_THEME_CHANGED);
c->update();
}
}
+
+void Control::_theme_changed() {
+
+ _propagate_theme_changed(this,this,false);
+}
+
void Control::set_theme(const Ref<Theme>& p_theme) {
+ if (data.theme==p_theme)
+ return;
+
+ if (data.theme.is_valid()) {
+ data.theme->disconnect("changed",this,"_theme_changed");
+ }
+
data.theme=p_theme;
if (!p_theme.is_null()) {
@@ -1895,6 +1924,9 @@ void Control::set_theme(const Ref<Theme>& p_theme) {
}
+ if (data.theme.is_valid()) {
+ data.theme->connect("changed",this,"_theme_changed");
+ }
}
@@ -2230,6 +2262,7 @@ void Control::set_rotation(float p_radians) {
data.rotation=p_radians;
update();
_notify_transform();
+ _change_notify("rect/rotation");
}
float Control::get_rotation() const{
@@ -2434,6 +2467,10 @@ void Control::_bind_methods() {
ObjectTypeDB::bind_method(_MD("minimum_size_changed"), &Control::minimum_size_changed);
+ ObjectTypeDB::bind_method(_MD("_theme_changed"), &Control::_theme_changed);
+
+
+
ObjectTypeDB::bind_method(_MD("_font_changed"), &Control::_font_changed);
BIND_VMETHOD(MethodInfo("_input_event",PropertyInfo(Variant::INPUT_EVENT,"event")));
@@ -2539,6 +2576,7 @@ Control::Control() {
data.parent_canvas_item=NULL;
data.scale=Vector2(1,1);
data.drag_owner=0;
+ data.modal_frame=0;
for (int i=0;i<4;i++) {