summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/dialogs.cpp2
-rw-r--r--scene/gui/gradient_edit.cpp5
-rw-r--r--scene/gui/graph_edit.cpp7
-rw-r--r--scene/gui/item_list.cpp6
-rw-r--r--scene/gui/range.cpp4
-rw-r--r--scene/gui/scroll_container.cpp2
-rw-r--r--scene/gui/text_edit.cpp3
-rw-r--r--scene/gui/tree.h2
8 files changed, 16 insertions, 15 deletions
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index a1b584bad6..b6e647d1af 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -161,7 +161,7 @@ void WindowDialog::_gui_input(const Ref<InputEvent> &p_event) {
global_pos.y = MAX(global_pos.y, 0); // Ensure title bar stays visible.
Rect2 rect = get_rect();
- Size2 min_size = get_minimum_size();
+ Size2 min_size = get_combined_minimum_size();
if (drag_type == DRAG_MOVE) {
rect.position = global_pos - drag_offset;
diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp
index 09ef6f26bf..5958106419 100644
--- a/scene/gui/gradient_edit.cpp
+++ b/scene/gui/gradient_edit.cpp
@@ -277,12 +277,13 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) {
if (points[i].offset == newofs && i != grabbed) {
valid = false;
+ break;
}
}
- if (!valid)
+ if (!valid || grabbed == -1) {
return;
-
+ }
points.write[grabbed].offset = newofs;
points.sort();
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 7827c66841..ed9fc0ce51 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -819,8 +819,11 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
if (gn && gn->is_selected()) {
Vector2 pos = (gn->get_drag_from() * zoom + drag_accum) / zoom;
- if (is_using_snap()) {
- int snap = get_snap();
+
+ // Snapping can be toggled temporarily by holding down Ctrl.
+ // This is done here as to not toggle the grid when holding down Ctrl.
+ if (is_using_snap() ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ const int snap = get_snap();
pos = pos.snapped(Vector2(snap, snap));
}
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 9c016b5a50..5682232bc4 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -100,7 +100,6 @@ void Range::set_value(double p_val) {
shared->emit_value_changed();
}
void Range::set_min(double p_min) {
-
shared->min = p_min;
set_value(shared->val);
@@ -109,7 +108,6 @@ void Range::set_min(double p_min) {
update_configuration_warning();
}
void Range::set_max(double p_max) {
-
shared->max = p_max;
set_value(shared->val);
@@ -173,6 +171,8 @@ void Range::set_as_ratio(double p_value) {
}
double Range::get_as_ratio() const {
+ ERR_FAIL_COND_V_MSG(Math::is_equal_approx(get_max(), get_min()), 0.0, "Cannot get ratio when minimum and maximum value are equal.");
+
if (shared->exp_ratio && get_min() >= 0) {
double exp_min = get_min() == 0 ? 0.0 : Math::log(get_min()) / Math::log((double)2);
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 8ddc31745e..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();
}
@@ -4593,6 +4591,7 @@ void TextEdit::_scroll_moved(double p_to_val) {
break;
}
}
+ n_line = MIN(n_line, text.size() - 1);
int line_wrap_amount = times_line_wraps(n_line);
int wi = line_wrap_amount - (sc - v_scroll_i - 1);
wi = CLAMP(wi, 0, line_wrap_amount);
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 361830173b..d5227f6e65 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -159,7 +159,7 @@ protected:
//bind helpers
Dictionary _get_range_config(int p_column) {
Dictionary d;
- double min, max, step;
+ double min = 0.0, max = 0.0, step = 0.0;
get_range_config(p_column, min, max, step);
d["min"] = min;
d["max"] = max;