From 9174ac7386454d943747d85bafdac573618ace30 Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Mon, 31 Mar 2014 19:02:21 +0800 Subject: Add anchor options "Center" --- scene/gui/control.cpp | 19 +++++++++++++++---- scene/gui/control.h | 3 ++- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'scene/gui') diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 1bb34c1a67..53d36e64ea 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1660,6 +1660,10 @@ void Control::_size_changed() { margin_pos[i]=area*data.margin[i]; } break; + case ANCHOR_CENTER: { + + margin_pos[i]=(area/2)-data.margin[i]; + } break; } } @@ -1724,6 +1728,9 @@ float Control::_s2a(float p_val, AnchorType p_anchor,float p_range) const { case ANCHOR_RATIO: { return p_val/p_range; } break; + case ANCHOR_CENTER: { + return (p_range/2)-p_val; + } break; } return 0; @@ -1743,6 +1750,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; } return 0; } @@ -2772,10 +2782,10 @@ void Control::_bind_methods() { BIND_VMETHOD(MethodInfo(Variant::BOOL,"can_drop_data",PropertyInfo(Variant::VECTOR2,"pos"),PropertyInfo(Variant::NIL,"data"))); BIND_VMETHOD(MethodInfo("drop_data",PropertyInfo(Variant::VECTOR2,"pos"),PropertyInfo(Variant::NIL,"data"))); - ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/left", PROPERTY_HINT_ENUM, "Begin,End,Ratio"), _SCS("set_anchor"),_SCS("get_anchor"), MARGIN_LEFT ); - ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/top", PROPERTY_HINT_ENUM, "Begin,End,Ratio"), _SCS("set_anchor"),_SCS("get_anchor"), MARGIN_TOP ); - ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/right", PROPERTY_HINT_ENUM, "Begin,End,Ratio"), _SCS("set_anchor"),_SCS("get_anchor"), MARGIN_RIGHT ); - ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/bottom", PROPERTY_HINT_ENUM, "Begin,End,Ratio"), _SCS("set_anchor"),_SCS("get_anchor"), MARGIN_BOTTOM ); + ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/left", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("set_anchor"),_SCS("get_anchor"), MARGIN_LEFT ); + ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/top", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("set_anchor"),_SCS("get_anchor"), MARGIN_TOP ); + ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/right", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("set_anchor"),_SCS("get_anchor"), MARGIN_RIGHT ); + ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/bottom", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("set_anchor"),_SCS("get_anchor"), MARGIN_BOTTOM ); ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin/left", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"), MARGIN_LEFT ); ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin/top", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"), MARGIN_TOP ); @@ -2801,6 +2811,7 @@ void Control::_bind_methods() { BIND_CONSTANT( ANCHOR_BEGIN ); BIND_CONSTANT( ANCHOR_END ); BIND_CONSTANT( ANCHOR_RATIO ); + BIND_CONSTANT( ANCHOR_CENTER ); BIND_CONSTANT( FOCUS_NONE ); BIND_CONSTANT( FOCUS_CLICK ); BIND_CONSTANT( FOCUS_ALL ); diff --git a/scene/gui/control.h b/scene/gui/control.h index a5d302105f..dd8854f80e 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -54,7 +54,8 @@ public: enum AnchorType { ANCHOR_BEGIN, ANCHOR_END, - ANCHOR_RATIO + ANCHOR_RATIO, + ANCHOR_CENTER, }; enum FocusMode { -- cgit v1.2.3 From 9f33134c93ecbadda70e8eefc50563e29b2eb7f2 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 5 Apr 2014 12:39:30 -0300 Subject: =?UTF-8?q?-Support=20for=20changing=20fonts=20-Detect=20when=20fr?= =?UTF-8?q?ee()=20might=20crash=20the=20project=20and=20throw=20error=20-f?= =?UTF-8?q?ixed=202D=20Bounce=20in=20physics=20(3d=20still=20broken)=20-re?= =?UTF-8?q?named=20=E2=80=9Con=5Ftop=E2=80=9D=20property=20to=20=E2=80=9Cb?= =?UTF-8?q?ehind=5Fparent=E2=80=9D,=20which=20makes=20more=20sense,=20old?= =?UTF-8?q?=20on=5Ftop=20remains=20there=20for=20compatibility=20but=20is?= =?UTF-8?q?=20invisible.=20-large=20amount=20of=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scene/gui/control.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scene/gui') diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 53d36e64ea..83c0397554 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -351,11 +351,13 @@ void Control::_notification(int p_notification) { window->tooltip_timer = memnew( Timer ); add_child(window->tooltip_timer); + window->tooltip_timer->force_parent_owned(); window->tooltip_timer->set_wait_time( GLOBAL_DEF("display/tooltip_delay",0.7)); window->tooltip_timer->connect("timeout",this,"_window_show_tooltip"); window->tooltip=NULL; window->tooltip_popup = memnew( TooltipPanel ); add_child(window->tooltip_popup); + window->tooltip_popup->force_parent_owned(); window->tooltip_label = memnew( TooltipLabel ); window->tooltip_popup->add_child(window->tooltip_label); window->tooltip_popup->set_as_toplevel(true); -- cgit v1.2.3