summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/physics_body_2d.cpp6
-rw-r--r--scene/3d/physics_body.cpp4
-rw-r--r--scene/gui/graph_edit.cpp16
-rw-r--r--scene/gui/line_edit.cpp11
-rw-r--r--scene/gui/scroll_container.cpp33
-rw-r--r--scene/gui/scroll_container.h1
6 files changed, 60 insertions, 11 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 90663bd675..d42bd6adaf 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -1234,7 +1234,7 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
on_ceiling = false;
on_wall = false;
colliders.clear();
- floor_normal = p_up_direction;
+ floor_normal = Vector2();
floor_velocity = Vector2();
while (p_max_slides) {
@@ -1473,8 +1473,8 @@ void KinematicBody2D::_notification(int p_what) {
void KinematicBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody2D::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false));
- ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "floor_normal", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
- ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "floor_normal", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide_with_snap, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody2D::move_and_slide_with_snap, DEFVAL(Vector2(0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec", "infinite_inertia"), &KinematicBody2D::test_move, DEFVAL(true));
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 999f39c841..caeae90238 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -1159,7 +1159,7 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
on_ceiling = false;
on_wall = false;
colliders.clear();
- floor_normal = p_up_direction;
+ floor_normal = Vector3();
floor_velocity = Vector3();
while (p_max_slides) {
@@ -1401,7 +1401,7 @@ void KinematicBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false));
ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody::move_and_slide, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
- ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "floor_normal", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody::move_and_slide_with_snap, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody::move_and_slide_with_snap, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec", "infinite_inertia"), &KinematicBody::test_move, DEFVAL(true));
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 399f998cb9..00ce57eb04 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -289,6 +289,20 @@ void GraphEdit::_notification(int p_what) {
zoom_plus->set_icon(get_icon("more"));
snap_button->set_icon(get_icon("snap"));
}
+ if (p_what == NOTIFICATION_READY) {
+ Size2 hmin = h_scroll->get_combined_minimum_size();
+ Size2 vmin = v_scroll->get_combined_minimum_size();
+
+ h_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 0);
+ h_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
+ h_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -hmin.height);
+ h_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
+
+ v_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -vmin.width);
+ v_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
+ v_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0);
+ v_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
+ }
if (p_what == NOTIFICATION_DRAW) {
draw_style_box(get_stylebox("bg"), Rect2(Point2(), get_size()));
@@ -1341,12 +1355,10 @@ GraphEdit::GraphEdit() {
h_scroll = memnew(HScrollBar);
h_scroll->set_name("_h_scroll");
top_layer->add_child(h_scroll);
- h_scroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
v_scroll = memnew(VScrollBar);
v_scroll->set_name("_v_scroll");
top_layer->add_child(v_scroll);
- v_scroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE);
updating = false;
connecting = false;
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index a6cd9a0665..0f3328dac5 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -1239,6 +1239,11 @@ void LineEdit::set_text(String p_text) {
clear_internal();
append_at_cursor(p_text);
+
+ if (expand_to_text_length) {
+ minimum_size_changed();
+ }
+
update();
cursor_pos = 0;
window_pos = 0;
@@ -1482,6 +1487,7 @@ void LineEdit::set_editable(bool p_editable) {
editable = p_editable;
_generate_context_menu();
+ minimum_size_changed();
update();
}
@@ -1617,7 +1623,11 @@ bool LineEdit::get_expand_to_text_length() const {
}
void LineEdit::set_clear_button_enabled(bool p_enabled) {
+ if (clear_button_enabled == p_enabled) {
+ return;
+ }
clear_button_enabled = p_enabled;
+ minimum_size_changed();
update();
}
@@ -1653,6 +1663,7 @@ void LineEdit::set_right_icon(const Ref<Texture> &p_icon) {
return;
}
right_icon = p_icon;
+ minimum_size_changed();
update();
}
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 05645d0263..509e6d19f6 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -214,6 +214,25 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
accept_event(); //accept event if scroll changed
}
+void ScrollContainer::_update_scrollbar_position() {
+
+ Size2 hmin = h_scroll->get_combined_minimum_size();
+ Size2 vmin = v_scroll->get_combined_minimum_size();
+
+ h_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 0);
+ h_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
+ h_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -hmin.height);
+ h_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
+
+ v_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -vmin.width);
+ v_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
+ v_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0);
+ v_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
+
+ h_scroll->raise();
+ v_scroll->raise();
+}
+
void ScrollContainer::_ensure_focused_visible(Control *p_control) {
if (!follow_focus) {
@@ -243,8 +262,7 @@ void ScrollContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
- h_scroll->call_deferred("raise");
- v_scroll->call_deferred("raise");
+ call_deferred("_update_scrollbar_position");
};
if (p_what == NOTIFICATION_READY) {
@@ -452,8 +470,12 @@ void ScrollContainer::_scroll_moved(float) {
};
void ScrollContainer::set_enable_h_scroll(bool p_enable) {
+ if (scroll_h == p_enable) {
+ return;
+ }
scroll_h = p_enable;
+ minimum_size_changed();
queue_sort();
}
@@ -463,8 +485,12 @@ bool ScrollContainer::is_h_scroll_enabled() const {
}
void ScrollContainer::set_enable_v_scroll(bool p_enable) {
+ if (scroll_v == p_enable) {
+ return;
+ }
scroll_v = p_enable;
+ minimum_size_changed();
queue_sort();
}
@@ -550,6 +576,7 @@ void ScrollContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_h_scroll_enabled"), &ScrollContainer::is_h_scroll_enabled);
ClassDB::bind_method(D_METHOD("set_enable_v_scroll", "enable"), &ScrollContainer::set_enable_v_scroll);
ClassDB::bind_method(D_METHOD("is_v_scroll_enabled"), &ScrollContainer::is_v_scroll_enabled);
+ ClassDB::bind_method(D_METHOD("_update_scrollbar_position"), &ScrollContainer::_update_scrollbar_position);
ClassDB::bind_method(D_METHOD("_ensure_focused_visible"), &ScrollContainer::_ensure_focused_visible);
ClassDB::bind_method(D_METHOD("set_h_scroll", "value"), &ScrollContainer::set_h_scroll);
ClassDB::bind_method(D_METHOD("get_h_scroll"), &ScrollContainer::get_h_scroll);
@@ -584,13 +611,11 @@ ScrollContainer::ScrollContainer() {
h_scroll->set_name("_h_scroll");
add_child(h_scroll);
h_scroll->connect("value_changed", this, "_scroll_moved");
- h_scroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
v_scroll = memnew(VScrollBar);
v_scroll->set_name("_v_scroll");
add_child(v_scroll);
v_scroll->connect("value_changed", this, "_scroll_moved");
- v_scroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE);
drag_speed = Vector2();
drag_touching = false;
diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h
index 608b29bd93..6423b36fcc 100644
--- a/scene/gui/scroll_container.h
+++ b/scene/gui/scroll_container.h
@@ -75,6 +75,7 @@ protected:
void _scroll_moved(float);
static void _bind_methods();
+ void _update_scrollbar_position();
void _ensure_focused_visible(Control *p_node);
public: