Skip to content

Commit

Permalink
Merge pull request #59026 from Sauermann/fix-cursorshape-animationtra…
Browse files Browse the repository at this point in the history
…ckedittypeaudio
  • Loading branch information
akien-mga authored Mar 11, 2022
2 parents 015fdfc + 2494221 commit 6992c6e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
17 changes: 10 additions & 7 deletions editor/animation_track_editor_plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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;
Expand Down Expand Up @@ -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 ///

Expand Down
3 changes: 3 additions & 0 deletions editor/animation_track_editor_plugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -134,6 +135,8 @@ class AnimationTrackEditTypeAudio : public AnimationTrackEdit {
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();
};

Expand Down

0 comments on commit 6992c6e

Please sign in to comment.