diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-01-07 01:45:46 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-01-07 01:45:46 -0300 |
commit | 7a0e4c822caa0d91506f693cb0cea2188927939f (patch) | |
tree | 5bf2c9762277d82938d942435771c3be4b67c03e /scene/gui | |
parent | bd0356207631602f35e2111bc73bca2bd53e91a1 (diff) |
-Visual Shader Editing Finished, PLEASE TEST!
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/graph_edit.cpp | 50 | ||||
-rw-r--r-- | scene/gui/graph_edit.h | 4 |
2 files changed, 54 insertions, 0 deletions
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 957e63e3ce..5f38d541b7 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -265,6 +265,37 @@ void GraphEdit::_top_layer_input(const InputEvent& p_ev) { Vector2 pos = gn->get_connection_input_pos(j)+gn->get_pos(); if (pos.distance_to(mpos)<grab_r) { + + if (right_disconnects) { + //check disconnect + for (List<Connection>::Element*E=connections.front();E;E=E->next()) { + + if (E->get().to==gn->get_name() && E->get().to_port==j) { + + Node*fr = get_node(String(E->get().from)); + if (fr && fr->cast_to<GraphNode>()) { + + connecting_from=E->get().from; + connecting_index=E->get().from_port; + connecting_out=true; + connecting_type=fr->cast_to<GraphNode>()->get_connection_output_type(E->get().from_port); + connecting_color=fr->cast_to<GraphNode>()->get_connection_output_color(E->get().from_port); + connecting_target=false; + connecting_to=pos; + + emit_signal("disconnection_request",E->get().from,E->get().from_port,E->get().to,E->get().to_port); + fr = get_node(String(connecting_from)); //maybe it was erased + if (fr && fr->cast_to<GraphNode>()) { + connecting=true; + } + return; + } + + } + } + } + + connecting=true; connecting_from=gn->get_name(); connecting_index=j; @@ -474,11 +505,26 @@ void GraphEdit::clear_connections() { } +void GraphEdit::set_right_disconnects(bool p_enable) { + + right_disconnects=p_enable; +} + +bool GraphEdit::is_right_disconnects_enabled() const{ + + return right_disconnects; +} + + void GraphEdit::_bind_methods() { ObjectTypeDB::bind_method(_MD("connect_node:Error","from","from_port","to","to_port"),&GraphEdit::connect_node); ObjectTypeDB::bind_method(_MD("is_node_connected","from","from_port","to","to_port"),&GraphEdit::is_node_connected); ObjectTypeDB::bind_method(_MD("disconnect_node","from","from_port","to","to_port"),&GraphEdit::disconnect_node); + + ObjectTypeDB::bind_method(_MD("set_right_disconnects","enable"),&GraphEdit::set_right_disconnects); + ObjectTypeDB::bind_method(_MD("is_right_disconnects_enabled"),&GraphEdit::is_right_disconnects_enabled); + ObjectTypeDB::bind_method(_MD("_graph_node_moved"),&GraphEdit::_graph_node_moved); ObjectTypeDB::bind_method(_MD("_graph_node_raised"),&GraphEdit::_graph_node_raised); @@ -489,9 +535,12 @@ void GraphEdit::_bind_methods() { ObjectTypeDB::bind_method(_MD("_input_event"),&GraphEdit::_input_event); ADD_SIGNAL(MethodInfo("connection_request",PropertyInfo(Variant::STRING,"from"),PropertyInfo(Variant::INT,"from_slot"),PropertyInfo(Variant::STRING,"to"),PropertyInfo(Variant::INT,"to_slot"))); + ADD_SIGNAL(MethodInfo("disconnection_request",PropertyInfo(Variant::STRING,"from"),PropertyInfo(Variant::INT,"from_slot"),PropertyInfo(Variant::STRING,"to"),PropertyInfo(Variant::INT,"to_slot"))); } + + GraphEdit::GraphEdit() { top_layer=NULL; top_layer=memnew(GraphEditFilter(this)); @@ -511,6 +560,7 @@ GraphEdit::GraphEdit() { top_layer->add_child(v_scroll); updating=false; connecting=false; + right_disconnects=false; h_scroll->connect("value_changed", this,"_scroll_moved"); v_scroll->connect("value_changed", this,"_scroll_moved"); diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h index f8a2f3fee7..1df2776cef 100644 --- a/scene/gui/graph_edit.h +++ b/scene/gui/graph_edit.h @@ -51,6 +51,7 @@ private: + bool right_disconnects; bool updating; List<Connection> connections; @@ -86,6 +87,9 @@ public: void get_connection_list(List<Connection> *r_connections); + void set_right_disconnects(bool p_enable); + bool is_right_disconnects_enabled() const; + GraphEdit(); }; |