summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/animation/animation_tree_player.cpp9
-rw-r--r--scene/gui/control.cpp35
-rw-r--r--scene/gui/control.h4
3 files changed, 34 insertions, 14 deletions
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index cc9e6c71e3..9dcad8a533 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -637,10 +637,15 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
} break;
case NODE_TIMESCALE: {
TimeScaleNode *tsn = static_cast<TimeScaleNode*>(nb);
+ float rem;
if (p_seek)
- return _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time,switched,true,p_filter,p_reverse_weight);
+ rem = _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time,switched,true,p_filter,p_reverse_weight);
+ else
+ rem = _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time*tsn->scale,switched,false,p_filter,p_reverse_weight);
+ if (tsn->scale == 0)
+ return INFINITY;
else
- return _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time*tsn->scale,switched,false,p_filter,p_reverse_weight);
+ return rem / tsn->scale;
} break;
case NODE_TIMESEEK: {
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 295ec03702..0364f73275 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -39,6 +39,9 @@
#include "scene/scene_string_names.h"
#include "scene/gui/panel.h"
#include "scene/gui/label.h"
+#ifdef TOOLS_ENABLED
+#include "tools/editor/editor_settings.h"
+#endif
#include <stdio.h>
@@ -1153,20 +1156,31 @@ float Control::_a2s(float p_val, AnchorType p_anchor,float p_range) const {
}
-void Control::set_anchor(Margin p_margin,AnchorType p_anchor) {
+void Control::set_anchor(Margin p_margin,AnchorType p_anchor, bool p_keep_margin) {
if (!is_inside_tree()) {
- data.anchor[p_margin]=p_anchor;
- } else {
+ data.anchor[p_margin] = p_anchor;
+ } else if(!p_keep_margin) {
float pr = _get_parent_range(p_margin);
float s = _a2s( data.margin[p_margin], data.anchor[p_margin], pr );
- data.anchor[p_margin]=p_anchor;
+ data.anchor[p_margin] = p_anchor;
data.margin[p_margin] = _s2a( s, p_anchor, pr );
+ } else {
+ data.anchor[p_margin] = p_anchor;
+ _size_changed();
}
_change_notify();
}
+void Control::_set_anchor(Margin p_margin,AnchorType p_anchor) {
+ #ifdef TOOLS_ENABLED
+ set_anchor(p_margin, p_anchor, EDITOR_DEF("2d_editor/keep_margins_when_changing_anchors", false));
+ #else
+ set_anchor(p_margin, p_anchor);
+ #endif
+}
+
void Control::set_anchor_and_margin(Margin p_margin,AnchorType p_anchor, float p_pos) {
set_anchor(p_margin,p_anchor);
@@ -2090,7 +2104,8 @@ void Control::_bind_methods() {
ObjectTypeDB::bind_method(_MD("accept_event"),&Control::accept_event);
ObjectTypeDB::bind_method(_MD("get_minimum_size"),&Control::get_minimum_size);
ObjectTypeDB::bind_method(_MD("get_combined_minimum_size"),&Control::get_combined_minimum_size);
- ObjectTypeDB::bind_method(_MD("set_anchor","margin","anchor_mode"),&Control::set_anchor);
+ ObjectTypeDB::bind_method(_MD("set_anchor","margin","anchor_mode","keep_margin"),&Control::set_anchor,DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("_set_anchor","margin","anchor_mode"),&Control::_set_anchor);
ObjectTypeDB::bind_method(_MD("get_anchor","margin"),&Control::get_anchor);
ObjectTypeDB::bind_method(_MD("set_margin","margin","offset"),&Control::set_margin);
ObjectTypeDB::bind_method(_MD("set_anchor_and_margin","margin","anchor_mode","offset"),&Control::set_anchor_and_margin);
@@ -2184,10 +2199,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,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,"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 );
@@ -2304,5 +2319,3 @@ Control::Control() {
Control::~Control()
{
}
-
-
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 851d8316fb..1e2db7a575 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -162,6 +162,8 @@ private:
Control *_get_focus_neighbour(Margin p_margin,int p_count=0);
+ void _set_anchor(Margin p_margin,AnchorType p_anchor);
+
float _get_parent_range(int p_idx) const;
float _get_range(int p_idx) const;
float _s2a(float p_val, AnchorType p_anchor,float p_range) const;
@@ -244,7 +246,7 @@ public:
/* POSITIONING */
- void set_anchor(Margin p_margin,AnchorType p_anchor);
+ void set_anchor(Margin p_margin,AnchorType p_anchor, bool p_keep_margin=false);
void set_anchor_and_margin(Margin p_margin,AnchorType p_anchor, float p_pos);
AnchorType get_anchor(Margin p_margin) const;