summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-11-26 10:51:20 +0100
committerGitHub <noreply@github.com>2019-11-26 10:51:20 +0100
commita698fd1b46c748efcc116af3d48d0f5980822c66 (patch)
treea0477e9629974b108f3a663f00e526c81ad6e4a7
parent55f86e9b7b25e44e5fe7acd9e55d1e26c5a67e95 (diff)
parentbfd5e098794ecb1f563b53e29f6981fda86381e9 (diff)
Merge pull request #33908 from akien-mga/range-fix-max-errors
Range: Fix cases where max was set to or below min value
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.cpp4
-rw-r--r--scene/gui/item_list.cpp6
-rw-r--r--scene/gui/range.cpp2
-rw-r--r--scene/gui/scroll_container.cpp2
-rw-r--r--scene/gui/text_edit.cpp2
5 files changed, 7 insertions, 9 deletions
diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp
index e07f041eb1..475e4c8d67 100644
--- a/editor/plugins/animation_blend_space_1d_editor.cpp
+++ b/editor/plugins/animation_blend_space_1d_editor.cpp
@@ -702,13 +702,13 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
bottom_hb->set_h_size_flags(SIZE_EXPAND_FILL);
min_value = memnew(SpinBox);
- min_value->set_max(0);
min_value->set_min(-10000);
+ min_value->set_max(0);
min_value->set_step(0.01);
max_value = memnew(SpinBox);
- max_value->set_max(10000);
max_value->set_min(0.01);
+ max_value->set_max(10000);
max_value->set_step(0.01);
label_value = memnew(LineEdit);
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 1406586361..3884622942 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -969,16 +969,16 @@ void ItemList::_notification(int p_what) {
}
if (all_fit) {
- float page = size.height - bg->get_minimum_size().height;
+ float page = MAX(0, size.height - bg->get_minimum_size().height);
float max = MAX(page, ofs.y + max_h);
if (auto_height)
auto_height_value = ofs.y + max_h + bg->get_minimum_size().height;
- scroll_bar->set_max(max);
- scroll_bar->set_page(page);
if (max <= page) {
scroll_bar->set_value(0);
scroll_bar->hide();
} else {
+ scroll_bar->set_max(max);
+ scroll_bar->set_page(page);
scroll_bar->show();
if (do_autoscroll_to_bottom)
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index 362697b4ad..97775f2946 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -100,6 +100,7 @@ void Range::set_value(double p_val) {
shared->emit_value_changed();
}
void Range::set_min(double p_min) {
+ ERR_FAIL_COND_MSG(p_min >= shared->max, "Range cannot have min value higher or equal to its max value.");
shared->min = p_min;
set_value(shared->val);
@@ -109,6 +110,7 @@ void Range::set_min(double p_min) {
update_configuration_warning();
}
void Range::set_max(double p_max) {
+ ERR_FAIL_COND_MSG(p_max <= shared->min, "Range cannot have max value lower or equal to its min value.");
shared->max = p_max;
set_value(shared->val);
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index a840e3fec1..fa23bf91dd 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -388,7 +388,6 @@ void ScrollContainer::update_scrollbars() {
if (hide_scroll_v) {
v_scroll->hide();
- v_scroll->set_max(0);
scroll.y = 0;
} else {
@@ -406,7 +405,6 @@ void ScrollContainer::update_scrollbars() {
if (hide_scroll_h) {
h_scroll->hide();
- h_scroll->set_max(0);
scroll.x = 0;
} else {
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index b997d7a064..2558a930b6 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -417,7 +417,6 @@ void TextEdit::_update_scrollbars() {
cursor.line_ofs = 0;
cursor.wrap_ofs = 0;
v_scroll->set_value(0);
- v_scroll->set_max(0);
v_scroll->hide();
}
@@ -436,7 +435,6 @@ void TextEdit::_update_scrollbars() {
cursor.x_ofs = 0;
h_scroll->set_value(0);
- h_scroll->set_max(0);
h_scroll->hide();
}