Merge pull request #5926 from akien-mga/pr-graphedit-drag

Fix GraphEdit dragging issues at scales != 1
This commit is contained in:
Juan Linietsky 2016-07-26 18:49:51 -03:00 committed by GitHub
commit 542bd81e76
2 changed files with 5 additions and 1 deletions

View File

@ -548,7 +548,9 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
if (p_ev.type==InputEvent::MOUSE_MOTION && dragging) { if (p_ev.type==InputEvent::MOUSE_MOTION && dragging) {
just_selected=true; 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--) { for(int i=get_child_count()-1;i>=0;i--) {
GraphNode *gn=get_child(i)->cast_to<GraphNode>(); GraphNode *gn=get_child(i)->cast_to<GraphNode>();
if (gn && gn->is_selected()) if (gn && gn->is_selected())
@ -665,6 +667,7 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
dragging = true; dragging = true;
drag_accum = Vector2(); drag_accum = Vector2();
drag_origin = get_local_mouse_pos();
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++) {

View File

@ -92,6 +92,7 @@ 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;