summaryrefslogtreecommitdiff
path: root/scene/gui/container.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/container.cpp')
-rw-r--r--scene/gui/container.cpp65
1 files changed, 30 insertions, 35 deletions
diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp
index 655c6e1bbf..811b41863c 100644
--- a/scene/gui/container.cpp
+++ b/scene/gui/container.cpp
@@ -27,9 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "container.h"
-#include "scene/scene_string_names.h"
#include "message_queue.h"
-
+#include "scene/scene_string_names.h"
void Container::_child_minsize_changed() {
@@ -47,12 +46,10 @@ void Container::add_child_notify(Node *p_child) {
if (!control)
return;
- control->connect("size_flags_changed",this,"queue_sort");
- control->connect("minimum_size_changed",this,"_child_minsize_changed");
- control->connect("visibility_changed",this,"_child_minsize_changed");
+ control->connect("size_flags_changed", this, "queue_sort");
+ control->connect("minimum_size_changed", this, "_child_minsize_changed");
+ control->connect("visibility_changed", this, "_child_minsize_changed");
queue_sort();
-
-
}
void Container::move_child_notify(Node *p_child) {
@@ -63,8 +60,6 @@ void Container::move_child_notify(Node *p_child) {
return;
queue_sort();
-
-
}
void Container::remove_child_notify(Node *p_child) {
@@ -75,9 +70,9 @@ void Container::remove_child_notify(Node *p_child) {
if (!control)
return;
- control->disconnect("size_flags_changed",this,"queue_sort");
- control->disconnect("minimum_size_changed",this,"_child_minsize_changed");
- control->disconnect("visibility_changed",this,"_child_minsize_changed");
+ control->disconnect("size_flags_changed", this, "queue_sort");
+ control->disconnect("minimum_size_changed", this, "_child_minsize_changed");
+ control->disconnect("visibility_changed", this, "_child_minsize_changed");
queue_sort();
}
@@ -88,33 +83,33 @@ void Container::_sort_children() {
notification(NOTIFICATION_SORT_CHILDREN);
emit_signal(SceneStringNames::get_singleton()->sort_children);
- pending_sort=false;
+ pending_sort = false;
}
-void Container::fit_child_in_rect(Control *p_child,const Rect2& p_rect) {
+void Container::fit_child_in_rect(Control *p_child, const Rect2 &p_rect) {
- ERR_FAIL_COND(p_child->get_parent()!=this);
+ ERR_FAIL_COND(p_child->get_parent() != this);
Size2 minsize = p_child->get_combined_minimum_size();
- Rect2 r=p_rect;
+ Rect2 r = p_rect;
- if (!(p_child->get_h_size_flags()&SIZE_FILL)) {
- r.size.x=minsize.x;
- r.pos.x += Math::floor((p_rect.size.x - minsize.x)/2);
+ if (!(p_child->get_h_size_flags() & SIZE_FILL)) {
+ r.size.x = minsize.x;
+ r.pos.x += Math::floor((p_rect.size.x - minsize.x) / 2);
}
- if (!(p_child->get_v_size_flags()&SIZE_FILL)) {
- r.size.y=minsize.y;
- r.pos.y += Math::floor((p_rect.size.y - minsize.y)/2);
+ if (!(p_child->get_v_size_flags() & SIZE_FILL)) {
+ r.size.y = minsize.y;
+ r.pos.y += Math::floor((p_rect.size.y - minsize.y) / 2);
}
- for(int i=0;i<4;i++)
- p_child->set_anchor(Margin(i),ANCHOR_BEGIN);
+ for (int i = 0; i < 4; i++)
+ p_child->set_anchor(Margin(i), ANCHOR_BEGIN);
p_child->set_pos(r.pos);
p_child->set_size(r.size);
p_child->set_rotation(0);
- p_child->set_scale(Vector2(1,1));
+ p_child->set_scale(Vector2(1, 1));
}
void Container::queue_sort() {
@@ -125,16 +120,16 @@ void Container::queue_sort() {
if (pending_sort)
return;
- MessageQueue::get_singleton()->push_call(this,"_sort_children");
- pending_sort=true;
+ MessageQueue::get_singleton()->push_call(this, "_sort_children");
+ pending_sort = true;
}
void Container::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- pending_sort=false;
+ pending_sort = false;
queue_sort();
} break;
case NOTIFICATION_RESIZED: {
@@ -156,17 +151,17 @@ void Container::_notification(int p_what) {
void Container::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_sort_children"),&Container::_sort_children);
- ClassDB::bind_method(D_METHOD("_child_minsize_changed"),&Container::_child_minsize_changed);
+ ClassDB::bind_method(D_METHOD("_sort_children"), &Container::_sort_children);
+ ClassDB::bind_method(D_METHOD("_child_minsize_changed"), &Container::_child_minsize_changed);
- ClassDB::bind_method(D_METHOD("queue_sort"),&Container::queue_sort);
- ClassDB::bind_method(D_METHOD("fit_child_in_rect","child:Control","rect"),&Container::fit_child_in_rect);
+ ClassDB::bind_method(D_METHOD("queue_sort"), &Container::queue_sort);
+ ClassDB::bind_method(D_METHOD("fit_child_in_rect", "child:Control", "rect"), &Container::fit_child_in_rect);
- BIND_CONSTANT( NOTIFICATION_SORT_CHILDREN );
+ BIND_CONSTANT(NOTIFICATION_SORT_CHILDREN);
ADD_SIGNAL(MethodInfo("sort_children"));
}
Container::Container() {
- pending_sort=false;
+ pending_sort = false;
}