Merge pull request #29897 from Chaosus/fix_animation_track_selection

Fix animation keys selection with SHIFT/CTRL
This commit is contained in:
Rémi Verschelde 2019-06-19 16:45:42 +02:00 committed by GitHub
commit 4476ea81aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -2083,8 +2083,6 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
moving_selection_from_ofs = (mb->get_position().x - timeline->get_name_limit()) / timeline->get_zoom_scale(); moving_selection_from_ofs = (mb->get_position().x - timeline->get_name_limit()) / timeline->get_zoom_scale();
} }
accept_event(); accept_event();
} else {
emit_signal("clear_selection");
} }
} }
@ -2326,7 +2324,7 @@ void AnimationTrackEdit::set_in_group(bool p_enable) {
update(); update();
} }
void AnimationTrackEdit::append_to_selection(const Rect2 &p_box) { void AnimationTrackEdit::append_to_selection(const Rect2 &p_box, bool p_deselection) {
Rect2 select_rect(timeline->get_name_limit(), 0, get_size().width - timeline->get_name_limit() - timeline->get_buttons_width(), get_size().height); Rect2 select_rect(timeline->get_name_limit(), 0, get_size().width - timeline->get_name_limit() - timeline->get_buttons_width(), get_size().height);
select_rect = select_rect.clip(p_box); select_rect = select_rect.clip(p_box);
@ -2339,7 +2337,10 @@ void AnimationTrackEdit::append_to_selection(const Rect2 &p_box) {
rect.position.x += offset; rect.position.x += offset;
if (select_rect.intersects(rect)) { if (select_rect.intersects(rect)) {
emit_signal("select_key", i, false); if (p_deselection)
emit_signal("deselect_key", i);
else
emit_signal("select_key", i, false);
} }
} }
} }
@ -4342,7 +4343,7 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) {
Rect2 local_rect = box_select_rect; Rect2 local_rect = box_select_rect;
local_rect.position -= track_edits[i]->get_global_position(); local_rect.position -= track_edits[i]->get_global_position();
track_edits[i]->append_to_selection(local_rect); track_edits[i]->append_to_selection(local_rect, mb->get_command());
} }
if (_get_track_selected() == -1 && track_edits.size() > 0) { //minimal hack to make shortcuts work if (_get_track_selected() == -1 && track_edits.size() > 0) { //minimal hack to make shortcuts work
@ -4374,8 +4375,8 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) {
} }
if (!box_selection->is_visible_in_tree()) { if (!box_selection->is_visible_in_tree()) {
if (!mm->get_shift()) { if (!mm->get_command() && !mm->get_shift()) {
_clear_selection(); //only append if shift is pressed _clear_selection();
} }
box_selection->show(); box_selection->show();
} }

View File

@ -231,7 +231,7 @@ public:
void cancel_drop(); void cancel_drop();
void set_in_group(bool p_enable); void set_in_group(bool p_enable);
void append_to_selection(const Rect2 &p_box); void append_to_selection(const Rect2 &p_box, bool p_deselection);
AnimationTrackEdit(); AnimationTrackEdit();
}; };