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.cpp98
1 files changed, 79 insertions, 19 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index c08e10b9ff..bf35fd25bd 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -422,7 +422,40 @@ void Control::_resize(const Size2& p_size) {
_size_changed();
}
+//moved theme configuration here, so controls can set up even if still not inside active scene
+void Control::add_child_notify(Node *p_child) {
+
+ Control *child_c=p_child->cast_to<Control>();
+ if (!child_c)
+ return;
+
+ if (child_c->data.theme.is_null() && data.theme_owner) {
+ child_c->data.theme_owner=data.theme_owner;
+ child_c->notification(NOTIFICATION_THEME_CHANGED);
+ }
+}
+
+void Control::remove_child_notify(Node *p_child) {
+
+ Control *child_c=p_child->cast_to<Control>();
+ if (!child_c)
+ return;
+
+ if (child_c->data.theme_owner && child_c->data.theme.is_null()) {
+ child_c->data.theme_owner=NULL;
+ //notification(NOTIFICATION_THEME_CHANGED);
+ }
+
+}
+
+void Control::_update_canvas_item_transform() {
+
+ Matrix32 xform=Matrix32(data.rotation,get_pos());
+ xform.scale_basis(data.scale);
+ VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(),xform);
+
+}
void Control::_notification(int p_notification) {
@@ -512,10 +545,10 @@ void Control::_notification(int p_notification) {
}
- if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
- data.theme_owner=data.parent->data.theme_owner;
- notification(NOTIFICATION_THEME_CHANGED);
- }
+ //if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
+ // data.theme_owner=data.parent->data.theme_owner;
+ // notification(NOTIFICATION_THEME_CHANGED);
+ //}
} break;
case NOTIFICATION_EXIT_CANVAS: {
@@ -547,10 +580,10 @@ void Control::_notification(int p_notification) {
data.parent=NULL;
data.parent_canvas_item=NULL;
- if (data.theme_owner && data.theme.is_null()) {
- data.theme_owner=NULL;
+ //if (data.theme_owner && data.theme.is_null()) {
+ // data.theme_owner=NULL;
//notification(NOTIFICATION_THEME_CHANGED);
- }
+ //}
} break;
case NOTIFICATION_MOVED_IN_PARENT: {
@@ -574,10 +607,9 @@ void Control::_notification(int p_notification) {
} break;
case NOTIFICATION_DRAW: {
- 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()));
+ _update_canvas_item_transform();
+ VisualServer::get_singleton()->canvas_item_set_custom_rect( get_canvas_item(),!data.disable_visibility_clip, Rect2(Point2(),get_size()));
+
//emit_signal(SceneStringNames::get_singleton()->draw);
} break;
@@ -1246,17 +1278,24 @@ void Control::_size_changed() {
new_size_cache.x = MAX( minimum_size.x, new_size_cache.x );
new_size_cache.y = MAX( minimum_size.y, new_size_cache.y );
-
- if (new_pos_cache == data.pos_cache && new_size_cache == data.size_cache)
- return; // did not change, don't emit signal
+ bool pos_changed = new_pos_cache != data.pos_cache;
+ bool size_changed = new_size_cache != data.size_cache;
data.pos_cache=new_pos_cache;
data.size_cache=new_size_cache;
- notification(NOTIFICATION_RESIZED);
- item_rect_changed();
- _change_notify_margins();
- _notify_transform();
+ if (size_changed) {
+ notification(NOTIFICATION_RESIZED);
+ }
+ if (pos_changed || size_changed) {
+ item_rect_changed(size_changed);
+ _change_notify_margins();
+ _notify_transform();
+ }
+
+ if (pos_changed && !size_changed) {
+ _update_canvas_item_transform(); //move because it won't be updated
+ }
}
float Control::_get_parent_range(int p_idx) const {
@@ -2188,7 +2227,7 @@ void Control::grab_click_focus() {
void Control::minimum_size_changed() {
- if (!is_inside_tree())
+ if (!is_inside_tree() || data.block_minimum_size_adjust)
return;
if (data.pending_min_size_update)
@@ -2348,7 +2387,26 @@ Control *Control::get_root_parent_control() const {
return const_cast<Control*>(root);
}
+void Control::set_block_minimum_size_adjust(bool p_block) {
+ data.block_minimum_size_adjust=p_block;
+}
+
+bool Control::is_minimum_size_adjust_blocked() const {
+ return data.block_minimum_size_adjust;
+}
+
+
+void Control::set_disable_visibility_clip(bool p_ignore) {
+
+ data.disable_visibility_clip=p_ignore;
+ update();
+}
+
+bool Control::is_visibility_clip_disabled() const {
+
+ return data.disable_visibility_clip;
+}
void Control::_bind_methods() {
@@ -2577,6 +2635,8 @@ Control::Control() {
data.scale=Vector2(1,1);
data.drag_owner=0;
data.modal_frame=0;
+ data.block_minimum_size_adjust=false;
+ data.disable_visibility_clip=false;
for (int i=0;i<4;i++) {