summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2016-07-26 23:19:41 +0200
committerRémi Verschelde <rverschelde@gmail.com>2016-07-26 23:19:41 +0200
commit60e19f77519caee64842319443cd19e20c699d81 (patch)
tree646c1a33239aaee784d469d8c4efe6b7a64b3fb8
parentccf6b3151d1445f3e1bc351056a64b8f0094bc63 (diff)
Fix GraphEdit dragging issues at scales != 1
Works around the issue originally described in #5907 (that was then hijacked to describe the broader issue it exposes).
-rw-r--r--scene/gui/graph_edit.cpp5
-rw-r--r--scene/gui/graph_edit.h1
2 files changed, 5 insertions, 1 deletions
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 06b1c42690..9ad621b7aa 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -548,7 +548,9 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
if (p_ev.type==InputEvent::MOUSE_MOTION && dragging) {
just_selected=true;
- drag_accum+=Vector2(p_ev.mouse_motion.relative_x,p_ev.mouse_motion.relative_y);
+ // TODO: Remove local mouse pos hack if/when InputEventMouseMotion is fixed to support floats
+ //drag_accum+=Vector2(p_ev.mouse_motion.relative_x,p_ev.mouse_motion.relative_y);
+ drag_accum = get_local_mouse_pos() - drag_origin;
for(int i=get_child_count()-1;i>=0;i--) {
GraphNode *gn=get_child(i)->cast_to<GraphNode>();
if (gn && gn->is_selected())
@@ -665,6 +667,7 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
dragging = true;
drag_accum = Vector2();
+ drag_origin = get_local_mouse_pos();
just_selected = !gn->is_selected();
if(!gn->is_selected() && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
for (int i = 0; i < get_child_count(); i++) {
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index ac4e71ba49..ed6838ac1d 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -92,6 +92,7 @@ private:
bool dragging;
bool just_selected;
Vector2 drag_accum;
+ Point2 drag_origin; // Workaround for GH-5907
float zoom;