Fix state machine box selection

This commit is contained in:
Guilherme Felipe de C. G. da Silva 2022-05-03 12:42:51 -03:00
parent 8aa791d166
commit e72b86b499

View File

@ -370,6 +370,36 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
state_machine_draw->update();
}
// Move mouse while moving box select
if (mm.is_valid() && box_selecting) {
box_selecting_to = state_machine_draw->get_local_mouse_position();
box_selecting_rect = Rect2(MIN(box_selecting_from.x, box_selecting_to.x),
MIN(box_selecting_from.y, box_selecting_to.y),
ABS(box_selecting_from.x - box_selecting_to.x),
ABS(box_selecting_from.y - box_selecting_to.y));
for (int i = 0; i < node_rects.size(); i++) {
bool in_box = node_rects[i].node.intersects(box_selecting_rect);
if (in_box) {
if (previous_selected.has(node_rects[i].node_name)) {
selected_nodes.erase(node_rects[i].node_name);
} else {
selected_nodes.insert(node_rects[i].node_name);
}
} else {
if (previous_selected.has(node_rects[i].node_name)) {
selected_nodes.insert(node_rects[i].node_name);
} else {
selected_nodes.erase(node_rects[i].node_name);
}
}
}
state_machine_draw->update();
}
if (mm.is_valid()) {
state_machine_draw->grab_focus();