diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-09-06 19:55:22 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-09-06 19:55:22 -0300 |
commit | 181fdce1e9c0b31f3a4ff14e25b2e0fec7108da0 (patch) | |
tree | 51c1503ce8b0b1f3021852fd2963d9c00f88c48b | |
parent | 0094c30938c870cdc0dd546be792c7f1951b5e08 (diff) |
Better snapping for graph ports, closes #6394
-rw-r--r-- | scene/gui/graph_edit.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 8b03dbbc2d..0de6add8cb 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -360,7 +360,8 @@ bool GraphEdit::_filter_input(const Point2& p_point) { Ref<Texture> port =get_icon("port","GraphNode"); - float grab_r=port->get_width()*0.5; + float grab_r_extend = 2.0; + float grab_r=port->get_width()*0.5*grab_r_extend; for(int i=get_child_count()-1;i>=0;i--) { GraphNode *gn=get_child(i)->cast_to<GraphNode>(); @@ -379,8 +380,9 @@ bool GraphEdit::_filter_input(const Point2& p_point) { for(int j=0;j<gn->get_connection_input_count();j++) { Vector2 pos = gn->get_connection_input_pos(j)+gn->get_pos(); - if (pos.distance_to(p_point)<grab_r) + if (pos.distance_to(p_point)<grab_r) { return true; + } } @@ -392,11 +394,13 @@ bool GraphEdit::_filter_input(const Point2& p_point) { void GraphEdit::_top_layer_input(const InputEvent& p_ev) { + + float grab_r_extend = 2.0; if (p_ev.type==InputEvent::MOUSE_BUTTON && p_ev.mouse_button.button_index==BUTTON_LEFT && p_ev.mouse_button.pressed) { Ref<Texture> port =get_icon("port","GraphNode"); Vector2 mpos(p_ev.mouse_button.x,p_ev.mouse_button.y); - float grab_r=port->get_width()*0.5; + float grab_r=port->get_width()*0.5*grab_r_extend; for(int i=get_child_count()-1;i>=0;i--) { GraphNode *gn=get_child(i)->cast_to<GraphNode>(); @@ -517,7 +521,7 @@ void GraphEdit::_top_layer_input(const InputEvent& p_ev) { Ref<Texture> port =get_icon("port","GraphNode"); Vector2 mpos(p_ev.mouse_button.x,p_ev.mouse_button.y); - float grab_r=port->get_width()*0.5; + float grab_r=port->get_width()*0.5*grab_r_extend; for(int i=get_child_count()-1;i>=0;i--) { GraphNode *gn=get_child(i)->cast_to<GraphNode>(); |