diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-09-02 22:12:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-02 22:12:04 +0200 |
commit | 413db5d8ff3272b6e994f8323971876dac0f71e4 (patch) | |
tree | e636fb6bfde1d460fea4f8f3ddf47cd7ce3930ca /scene/gui | |
parent | 169c1dc9ef85d4d0e4aafe7dfaa7654329b36dda (diff) | |
parent | 98a0c2b20fe12deb61ca7eb805951b8b42b3b275 (diff) |
Merge pull request #31889 from Calinou/gradient-editor-add-snapping
Implement snapping in the Gradient editor
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/gradient_edit.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp index 75f5f79873..09ef6f26bf 100644 --- a/scene/gui/gradient_edit.cpp +++ b/scene/gui/gradient_edit.cpp @@ -241,9 +241,13 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) { float newofs = CLAMP(x / float(total_w), 0, 1); - //Snap to nearest point if holding shift - if (mm->get_shift()) { - float snap_threshold = 0.03; + // Snap to "round" coordinates if holding Ctrl. + // Be more precise if holding Shift as well + if (mm->get_control()) { + newofs = Math::stepify(newofs, mm->get_shift() ? 0.025 : 0.1); + } else if (mm->get_shift()) { + // Snap to nearest point if holding just Shift + const float snap_threshold = 0.03; float smallest_ofs = snap_threshold; bool found = false; int nearest_point = 0; |