diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/animation/tween.cpp | 1 | ||||
-rw-r--r-- | scene/animation/tween.h | 8 | ||||
-rw-r--r-- | scene/gui/center_container.cpp | 32 | ||||
-rw-r--r-- | scene/gui/center_container.h | 5 | ||||
-rw-r--r-- | scene/gui/control.cpp | 6 | ||||
-rw-r--r-- | scene/gui/control.h | 2 |
6 files changed, 42 insertions, 12 deletions
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index f2df6d47c9..7e7d57c3c2 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "tween.h" +#include "method_bind_ext.inc" bool Tween::_set(const StringName& p_name, const Variant& p_value) { diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 51d5fc9132..c9d9863397 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -54,17 +54,15 @@ public: TRANS_CIRC, TRANS_BOUNCE, TRANS_BACK, - - TRANS_COUNT, + TRANS_COUNT, }; enum EaseType { EASE_IN, EASE_OUT, EASE_IN_OUT, - EASE_OUT_IN, - - EASE_COUNT, + EASE_OUT_IN, + EASE_COUNT, }; private: 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; } diff --git a/scene/gui/center_container.h b/scene/gui/center_container.h index 458e2e7251..9cd9173fab 100644 --- a/scene/gui/center_container.h +++ b/scene/gui/center_container.h @@ -36,11 +36,16 @@ class CenterContainer : public Container { OBJ_TYPE( CenterContainer, Container ); + bool use_top_left; protected: void _notification(int p_what); + static void _bind_methods(); public: + void set_use_top_left(bool p_enable); + bool is_using_top_left() const; + virtual Size2 get_minimum_size() const; CenterContainer(); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 6878793360..fc24294a70 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1738,9 +1738,9 @@ float Control::_a2s(float p_val, AnchorType p_anchor,float p_range) const { case ANCHOR_RATIO: { return Math::floor(p_range*p_val); } break; - case ANCHOR_CENTER: { - return Math::floor((p_range/2)-p_val); - } break; + case ANCHOR_CENTER: { + return Math::floor((p_range/2)-p_val); + } break; } return 0; } diff --git a/scene/gui/control.h b/scene/gui/control.h index f9225a1c2b..64b5a9b661 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -55,7 +55,7 @@ public: ANCHOR_BEGIN, ANCHOR_END, ANCHOR_RATIO, - ANCHOR_CENTER, + ANCHOR_CENTER, }; enum FocusMode { |