summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorsanikoyes <sanikoyes@163.com>2014-04-06 21:52:47 +0800
committersanikoyes <sanikoyes@163.com>2014-04-06 21:52:47 +0800
commit77a840e350668a9c80b1e63b9b73aac44221c53b (patch)
tree40d2115e639bdc72a61811ac4f2fb0f04ec8eb7f /scene/gui
parent14bbdcb139b35e6d206df1ab3176d34245b72329 (diff)
parentded365031ede27b7a6efef59bc886343f58d310b (diff)
Merge branch 'master' into hotfix-android-unicode-ime-input
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/control.cpp21
-rw-r--r--scene/gui/control.h3
2 files changed, 19 insertions, 5 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 1bb34c1a67..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);
@@ -1660,6 +1662,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 +1730,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 +1752,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 +2784,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 +2813,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 {