summaryrefslogtreecommitdiffstats
path: root/scene/gui/center_container.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-09-17 11:53:29 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-09-17 11:53:29 -0300
commitfa004d5c0fb79e59f81d53ab8f53906a930a8453 (patch)
treed36a10e4758c5ef93daab7f69a9647d44998d355 /scene/gui/center_container.cpp
parent64b01d6ce04350ad9d0cf36bf489426ff7ccd40c (diff)
downloadredot-engine-fa004d5c0fb79e59f81d53ab8f53906a930a8453.tar.gz
Small Fixes
----------- -Added Ability for centering on top left for centercontainer -Added ability to bind more than 5 parameters (must include an extra file)
Diffstat (limited to 'scene/gui/center_container.cpp')
-rw-r--r--scene/gui/center_container.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/scene/gui/center_container.cpp b/scene/gui/center_container.cpp
index 9cedf02371..4f8f50781c 100644
--- a/scene/gui/center_container.cpp
+++ b/scene/gui/center_container.cpp
@@ -32,6 +32,8 @@
Size2 CenterContainer::get_minimum_size() const {
+ if (use_top_left)
+ return Size2();
Size2 ms;
for(int i=0;i<get_child_count();i++) {
@@ -53,6 +55,20 @@ Size2 CenterContainer::get_minimum_size() const {
}
+
+void CenterContainer::set_use_top_left(bool p_enable) {
+
+ use_top_left=p_enable;
+ queue_sort();
+
+}
+
+bool CenterContainer::is_using_top_left() const {
+
+ return use_top_left;
+}
+
+
void CenterContainer::_notification(int p_what) {
if (p_what==NOTIFICATION_SORT_CHILDREN) {
@@ -65,14 +81,24 @@ void CenterContainer::_notification(int p_what) {
continue;
if (c->is_set_as_toplevel())
continue;
+
Size2 minsize = c->get_combined_minimum_size();
- Point2 ofs = ((size - minsize)/2.0).floor();
+ Point2 ofs = use_top_left ? (-minsize*0.5).floor() : ((size - minsize)/2.0).floor();
fit_child_in_rect(c,Rect2(ofs,minsize));
}
}
}
-CenterContainer::CenterContainer()
-{
+void CenterContainer::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("set_use_top_left","enable"),&CenterContainer::set_use_top_left);
+ ObjectTypeDB::bind_method(_MD("is_using_top_left"),&CenterContainer::is_using_top_left);
+
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"use_top_left"),_SCS("set_use_top_left"),_SCS("is_using_top_left"));
+}
+
+CenterContainer::CenterContainer() {
+
+ use_top_left=false;
}