From e2bd1ad6da66fd720aaba3449ffe619f19544da9 Mon Sep 17 00:00:00 2001 From: Markus Sauermann <6299227+Sauermann@users.noreply.github.com> Date: Fri, 11 Mar 2022 13:14:19 +0100 Subject: [PATCH] Use get_cursor_shape for identifying the cursor shape in AnimationTrackEditTypeAudio get_cursor_shape() is used in cases where a Control displays different cursors in different areas. There is no need to set the default cursor shape on every mouse move event. (cherry picked from commit 24942214d90ccaaad7a8eac77ccf2ec6d79b2446) --- editor/animation_track_editor_plugins.cpp | 17 ++++++++++------- editor/animation_track_editor_plugins.h | 3 +++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index da82101bffa..6ed239c5678 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -1051,12 +1051,7 @@ void AnimationTrackEditTypeAudio::_gui_input(const Ref &p_event) { len_resizing_index = i; } } - - if (use_hsize_cursor) { - set_default_cursor_shape(CURSOR_HSIZE); - } else { - set_default_cursor_shape(CURSOR_ARROW); - } + over_drag_position = use_hsize_cursor; } if (len_resizing && mm.is_valid()) { @@ -1068,7 +1063,7 @@ void AnimationTrackEditTypeAudio::_gui_input(const Ref &p_event) { } Ref mb = p_event; - if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && get_default_cursor_shape() == CURSOR_HSIZE) { + if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && over_drag_position) { len_resizing = true; len_resizing_start = mb->get_shift(); len_resizing_from_px = mb->get_position().x; @@ -1105,6 +1100,14 @@ void AnimationTrackEditTypeAudio::_gui_input(const Ref &p_event) { AnimationTrackEdit::_gui_input(p_event); } +Control::CursorShape AnimationTrackEditTypeAudio::get_cursor_shape(const Point2 &p_pos) const { + if (over_drag_position || len_resizing) { + return Control::CURSOR_HSIZE; + } else { + return get_default_cursor_shape(); + } +} + //////////////////// /// SUB ANIMATION /// diff --git a/editor/animation_track_editor_plugins.h b/editor/animation_track_editor_plugins.h index 86e9227a09e..fa6bd26182c 100644 --- a/editor/animation_track_editor_plugins.h +++ b/editor/animation_track_editor_plugins.h @@ -119,6 +119,7 @@ class AnimationTrackEditTypeAudio : public AnimationTrackEdit { int len_resizing_index; float len_resizing_from_px; float len_resizing_rel; + bool over_drag_position = false; protected: static void _bind_methods(); @@ -134,6 +135,8 @@ public: virtual bool is_key_selectable_by_distance() const; virtual void draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right); + virtual CursorShape get_cursor_shape(const Point2 &p_pos) const; + AnimationTrackEditTypeAudio(); };