diff options
author | Eric M <itsjusteza@gmail.com> | 2020-05-06 10:38:15 +1000 |
---|---|---|
committer | Eric M <itsjusteza@gmail.com> | 2020-05-06 17:43:31 +1000 |
commit | 915ab50673e9ee2304716b2094edf17f1a8adfef (patch) | |
tree | 1af334c63748d51d88bfe7f1317bfd0f17be2008 /editor/editor_spin_slider.cpp | |
parent | 2435d4bdb93c65465cfddd027bfaa02b9ca60c8d (diff) |
Updated editor spin slider to have better behaviour and adjusted control's size_flags_stretch_ratio value range
Diffstat (limited to 'editor/editor_spin_slider.cpp')
-rw-r--r-- | editor/editor_spin_slider.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 1506c574dd..2c70e16610 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -36,6 +36,9 @@ #include "editor_scale.h" String EditorSpinSlider::get_tooltip(const Point2 &p_pos) const { + if (grabber->is_visible()) { + return rtos(get_value()) + "\n\n" + TTR("Hold Ctrl to round to integers. Hold Shift for more precise changes."); + } return rtos(get_value()); } @@ -111,7 +114,21 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { } if (grabbing_spinner) { + // Don't make the user scroll all the way back to 'in range' if they went off the end. + if (pre_grab_value < get_min() && !is_lesser_allowed()) { + pre_grab_value = get_min(); + } + if (pre_grab_value > get_max() && !is_greater_allowed()) { + pre_grab_value = get_max(); + } + if (mm->get_control()) { + // If control was just pressed, don't make the value do a huge jump in magnitude. + if (grabbing_spinner_dist_cache != 0) { + pre_grab_value += grabbing_spinner_dist_cache * get_step(); + grabbing_spinner_dist_cache = 0; + } + set_value(Math::round(pre_grab_value + get_step() * grabbing_spinner_dist_cache * 10)); } else { set_value(pre_grab_value + get_step() * grabbing_spinner_dist_cache); |