summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/gradient_edit.cpp5
-rw-r--r--scene/gui/graph_edit.cpp7
-rw-r--r--scene/gui/range.cpp2
-rw-r--r--scene/gui/tree.h2
4 files changed, 11 insertions, 5 deletions
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/range.cpp b/scene/gui/range.cpp
index 9c016b5a50..362697b4ad 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -173,6 +173,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/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;