From d92406751b0df6c76f8eb2f2c99398d63b2ce429 Mon Sep 17 00:00:00 2001 From: Markus Sauermann <6299227+Sauermann@users.noreply.github.com> Date: Fri, 11 Mar 2022 10:18:27 +0100 Subject: [PATCH] Use get_cursor_shape for identifying the cursor shape in AnimationTimelineEdit 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 4a8a6f892f6d4579c624faf2f35a6a9883e9cf44) --- editor/animation_track_editor.cpp | 16 +++++++++------- editor/animation_track_editor.h | 2 ++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index da0833a69db..f19f44b6aa8 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1724,13 +1724,6 @@ void AnimationTimelineEdit::_gui_input(const Ref &p_event) { Ref mm = p_event; if (mm.is_valid()) { - if (hsize_rect.has_point(mm->get_position())) { - // Change the cursor to indicate that the track name column's width can be adjusted - set_default_cursor_shape(Control::CURSOR_HSIZE); - } else { - set_default_cursor_shape(Control::CURSOR_ARROW); - } - if (dragging_hsize) { int ofs = mm->get_position().x - dragging_hsize_from; name_limit = dragging_hsize_at + ofs; @@ -1752,6 +1745,15 @@ void AnimationTimelineEdit::_gui_input(const Ref &p_event) { } } +Control::CursorShape AnimationTimelineEdit::get_cursor_shape(const Point2 &p_pos) const { + if (dragging_hsize || hsize_rect.has_point(p_pos)) { + // Indicate that the track name column's width can be adjusted + return Control::CURSOR_HSIZE; + } else { + return get_default_cursor_shape(); + } +} + void AnimationTimelineEdit::set_use_fps(bool p_use_fps) { use_fps = p_use_fps; update_values(); diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index ec02fbd3d0f..0229f59dacc 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -119,6 +119,8 @@ public: void set_hscroll(HScrollBar *p_hscroll); + virtual CursorShape get_cursor_shape(const Point2 &p_pos) const; + AnimationTimelineEdit(); };