Remove get_local_mouse_position() hack in GraphEdit

(cherry picked from commit 00457c68bc)
This commit is contained in:
smartin015 2020-05-04 20:36:52 +02:00 committed by Rémi Verschelde
parent 05cd3ff8ba
commit 8cab02ec06
2 changed files with 6 additions and 9 deletions

View File

@ -812,9 +812,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
if (mm.is_valid() && dragging) { if (mm.is_valid() && dragging) {
just_selected = true; just_selected = true;
// TODO: Remove local mouse pos hack if/when InputEventMouseMotion is fixed to support floats drag_accum += mm->get_relative();
//drag_accum+=Vector2(mm->get_relative().x,mm->get_relative().y);
drag_accum = get_local_mouse_position() - drag_origin;
for (int i = get_child_count() - 1; i >= 0; i--) { for (int i = get_child_count() - 1; i >= 0; i--) {
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (gn && gn->is_selected()) { if (gn && gn->is_selected()) {
@ -834,7 +832,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
} }
if (mm.is_valid() && box_selecting) { if (mm.is_valid() && box_selecting) {
box_selecting_to = get_local_mouse_position(); box_selecting_to = mm->get_position();
box_selecting_rect = Rect2(MIN(box_selecting_from.x, box_selecting_to.x), box_selecting_rect = Rect2(MIN(box_selecting_from.x, box_selecting_to.x),
MIN(box_selecting_from.y, box_selecting_to.y), MIN(box_selecting_from.y, box_selecting_to.y),
@ -894,8 +892,9 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
if (gn) { if (gn) {
Rect2 r = gn->get_rect(); Rect2 r = gn->get_rect();
r.size *= zoom; r.size *= zoom;
if (r.has_point(get_local_mouse_position())) if (r.has_point(b->get_position())) {
gn->set_selected(false); gn->set_selected(false);
}
} }
} }
} }
@ -932,7 +931,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
if (gn_selected->is_resizing()) if (gn_selected->is_resizing())
continue; continue;
if (gn_selected->has_point(gn_selected->get_local_mouse_position())) { if (gn_selected->has_point(b->get_position() - gn_selected->get_position())) {
gn = gn_selected; gn = gn_selected;
break; break;
} }
@ -946,7 +945,6 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
dragging = true; dragging = true;
drag_accum = Vector2(); drag_accum = Vector2();
drag_origin = get_local_mouse_position();
just_selected = !gn->is_selected(); just_selected = !gn->is_selected();
if (!gn->is_selected() && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) { if (!gn->is_selected() && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
for (int i = 0; i < get_child_count(); i++) { for (int i = 0; i < get_child_count(); i++) {
@ -980,7 +978,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
return; return;
box_selecting = true; box_selecting = true;
box_selecting_from = get_local_mouse_position(); box_selecting_from = b->get_position();
if (b->get_control()) { if (b->get_control()) {
box_selection_mode_additive = true; box_selection_mode_additive = true;
previus_selected.clear(); previus_selected.clear();

View File

@ -99,7 +99,6 @@ private:
bool dragging; bool dragging;
bool just_selected; bool just_selected;
Vector2 drag_accum; Vector2 drag_accum;
Point2 drag_origin; // Workaround for GH-5907
float zoom; float zoom;