summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2022-03-11 14:23:39 +0100
committerGitHub <noreply@github.com>2022-03-11 14:23:39 +0100
commit6992c6e2fcfad9b966ad3c0dbf5bc99da73b6a8a (patch)
tree547c7eb8a0278bf240c2bf02902df9e86524ea1c
parent015fdfc28d3709387383b365a91c78dc0fe7aa35 (diff)
parent24942214d90ccaaad7a8eac77ccf2ec6d79b2446 (diff)
Merge pull request #59026 from Sauermann/fix-cursorshape-animationtrackedittypeaudio
-rw-r--r--editor/animation_track_editor_plugins.cpp17
-rw-r--r--editor/animation_track_editor_plugins.h3
2 files changed, 13 insertions, 7 deletions
diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp
index e87678a51b..9fd42a8ab8 100644
--- a/editor/animation_track_editor_plugins.cpp
+++ b/editor/animation_track_editor_plugins.cpp
@@ -1080,12 +1080,7 @@ void AnimationTrackEditTypeAudio::gui_input(const Ref<InputEvent> &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()) {
@@ -1097,7 +1092,7 @@ void AnimationTrackEditTypeAudio::gui_input(const Ref<InputEvent> &p_event) {
}
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT && get_default_cursor_shape() == CURSOR_HSIZE) {
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT && over_drag_position) {
len_resizing = true;
len_resizing_start = mb->is_shift_pressed();
len_resizing_from_px = mb->get_position().x;
@@ -1134,6 +1129,14 @@ void AnimationTrackEditTypeAudio::gui_input(const Ref<InputEvent> &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 271c1a000b..7022f524c5 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 override;
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) override;
+ virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override;
+
AnimationTrackEditTypeAudio();
};