summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/code_editor.cpp2
-rw-r--r--editor/doc/doc_data.cpp35
-rw-r--r--editor/doc/doc_data.h1
-rw-r--r--editor/editor_help.cpp66
-rw-r--r--editor/editor_properties.cpp51
-rw-r--r--editor/editor_properties.h15
-rw-r--r--editor/editor_settings.cpp13
-rw-r--r--editor/editor_spin_slider.h3
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp6
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp53
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h7
11 files changed, 225 insertions, 27 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 848921d870..ed50c7914e 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -166,6 +166,8 @@ bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col)
result_line = -1;
result_col = -1;
text_edit->set_search_text("");
+ text_edit->set_search_flags(p_flags);
+ text_edit->set_current_search_result(line, col);
set_error(text.empty() ? "" : TTR("No Matches"));
}
diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp
index 041f81d063..468819151f 100644
--- a/editor/doc/doc_data.cpp
+++ b/editor/doc/doc_data.cpp
@@ -248,6 +248,21 @@ void DocData::generate(bool p_basic_types) {
prop.setter = setter;
prop.getter = getter;
+ if (ClassDB::can_instance(name)) { // Cannot get default value of classes that can't be instanced
+ Variant default_value = ClassDB::class_get_default_property_value(name, E->get().name);
+ prop.default_value = default_value.get_construct_string();
+ } else {
+ List<StringName> inheriting_classes;
+ ClassDB::get_direct_inheriters_from_class(name, &inheriting_classes);
+ for (List<StringName>::Element *E2 = inheriting_classes.front(); E2; E2 = E2->next()) {
+ if (ClassDB::can_instance(E2->get())) {
+ Variant default_value = ClassDB::class_get_default_property_value(E2->get(), E->get().name);
+ prop.default_value = default_value.get_construct_string();
+ break;
+ }
+ }
+ }
+
bool found_type = false;
if (getter != StringName()) {
MethodBind *mb = ClassDB::get_method(name, getter);
@@ -412,6 +427,7 @@ void DocData::generate(bool p_basic_types) {
PropertyDoc pd;
pd.name = E->get();
pd.type = "int";
+ pd.default_value = itos(Theme::get_default()->get_constant(E->get(), cname));
c.theme_properties.push_back(pd);
}
@@ -422,6 +438,7 @@ void DocData::generate(bool p_basic_types) {
PropertyDoc pd;
pd.name = E->get();
pd.type = "Color";
+ pd.default_value = Variant(Theme::get_default()->get_color(E->get(), cname)).get_construct_string();
c.theme_properties.push_back(pd);
}
@@ -530,6 +547,7 @@ void DocData::generate(bool p_basic_types) {
PropertyDoc property;
property.name = pi.name;
property.type = Variant::get_type_name(pi.type);
+ property.default_value = v.get(pi.name).get_construct_string();
c.properties.push_back(property);
}
@@ -1063,12 +1081,15 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
for (int i = 0; i < c.properties.size(); i++) {
- String enum_text;
+ String additional_attributes;
if (c.properties[i].enumeration != String()) {
- enum_text = " enum=\"" + c.properties[i].enumeration + "\"";
+ additional_attributes += " enum=\"" + c.properties[i].enumeration + "\"";
+ }
+ if (c.properties[i].default_value != String()) {
+ additional_attributes += " default=\"" + c.properties[i].default_value.xml_escape(true) + "\"";
}
const PropertyDoc &p = c.properties[i];
- _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + enum_text + ">");
+ _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + additional_attributes + ">");
_write_string(f, 3, p.description.strip_edges().xml_escape());
_write_string(f, 2, "</member>");
}
@@ -1125,8 +1146,14 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
for (int i = 0; i < c.theme_properties.size(); i++) {
const PropertyDoc &p = c.theme_properties[i];
- _write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\">");
+
+ if (p.default_value != "")
+ _write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\" default=\"" + p.default_value.xml_escape(true) + "\">");
+ else
+ _write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\">");
+
_write_string(f, 3, p.description.strip_edges().xml_escape());
+
_write_string(f, 2, "</theme_item>");
}
_write_string(f, 1, "</theme_items>");
diff --git a/editor/doc/doc_data.h b/editor/doc/doc_data.h
index d3844adb7e..3d5867dcca 100644
--- a/editor/doc/doc_data.h
+++ b/editor/doc/doc_data.h
@@ -73,6 +73,7 @@ public:
String enumeration;
String description;
String setter, getter;
+ String default_value;
bool operator<(const PropertyDoc &p_prop) const {
return name < p_prop.name;
}
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 9918b655fb..ff50940842 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -48,9 +48,9 @@ void EditorHelp::_init_colors() {
text_color = get_color("default_color", "RichTextLabel");
headline_color = get_color("headline_color", "EditorHelp");
base_type_color = title_color.linear_interpolate(text_color, 0.5);
- comment_color = text_color * Color(1, 1, 1, 0.6);
+ comment_color = text_color * Color(1, 1, 1, 0.4);
symbol_color = comment_color;
- value_color = text_color * Color(1, 1, 1, 0.4);
+ value_color = text_color * Color(1, 1, 1, 0.6);
qualifier_color = text_color * Color(1, 1, 1, 0.8);
type_color = get_color("accent_color", "Editor").linear_interpolate(text_color, 0.5);
class_desc->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
@@ -258,9 +258,11 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
if (p_method.arguments[j].default_value != "") {
class_desc->push_color(symbol_color);
- class_desc->add_text("=");
+ class_desc->add_text(" = ");
class_desc->pop();
+ class_desc->push_color(value_color);
_add_text(_fix_constant(p_method.arguments[j].default_value));
+ class_desc->pop();
}
class_desc->pop();
@@ -471,23 +473,37 @@ void EditorHelp::_update_doc() {
if (cd.properties[i].description != "") {
describe = true;
}
+
class_desc->push_cell();
+ class_desc->push_font(doc_code_font);
+ class_desc->push_color(headline_color);
+
if (describe) {
class_desc->push_meta("@member " + cd.properties[i].name);
}
- class_desc->push_font(doc_code_font);
- class_desc->push_color(headline_color);
_add_text(cd.properties[i].name);
- class_desc->pop();
- class_desc->pop();
-
if (describe) {
class_desc->pop();
property_descr = true;
}
+ if (cd.properties[i].default_value != "") {
+ class_desc->push_color(symbol_color);
+ class_desc->add_text(" [default: ");
+ class_desc->pop();
+ class_desc->push_color(value_color);
+ _add_text(_fix_constant(cd.properties[i].default_value));
+ class_desc->pop();
+ class_desc->push_color(symbol_color);
+ class_desc->add_text("]");
+ class_desc->pop();
+ }
+
+ class_desc->pop();
+ class_desc->pop();
+
class_desc->pop();
}
@@ -613,6 +629,19 @@ void EditorHelp::_update_doc() {
class_desc->push_color(headline_color);
_add_text(cd.theme_properties[i].name);
class_desc->pop();
+
+ if (cd.theme_properties[i].default_value != "") {
+ class_desc->push_color(symbol_color);
+ class_desc->add_text(" [default: ");
+ class_desc->pop();
+ class_desc->push_color(value_color);
+ _add_text(_fix_constant(cd.theme_properties[i].default_value));
+ class_desc->pop();
+ class_desc->push_color(symbol_color);
+ class_desc->add_text("]");
+ class_desc->pop();
+ }
+
class_desc->pop();
if (cd.theme_properties[i].description != "") {
@@ -671,7 +700,7 @@ void EditorHelp::_update_doc() {
if (cd.signals[i].arguments[j].default_value != "") {
class_desc->push_color(symbol_color);
- class_desc->add_text("=");
+ class_desc->add_text(" = ");
class_desc->pop();
_add_text(cd.signals[i].arguments[j].default_value);
}
@@ -777,7 +806,7 @@ void EditorHelp::_update_doc() {
class_desc->add_text(" = ");
class_desc->pop();
class_desc->push_color(value_color);
- _add_text(enum_list[i].value);
+ _add_text(_fix_constant(enum_list[i].value));
class_desc->pop();
class_desc->pop();
if (enum_list[i].description != "") {
@@ -843,7 +872,7 @@ void EditorHelp::_update_doc() {
class_desc->add_text(" = ");
class_desc->pop();
class_desc->push_color(value_color);
- _add_text(constants[i].value);
+ _add_text(_fix_constant(constants[i].value));
class_desc->pop();
class_desc->pop();
@@ -963,6 +992,21 @@ void EditorHelp::_update_doc() {
class_desc->push_color(headline_color);
_add_text(cd.properties[i].name);
class_desc->pop(); // color
+
+ if (cd.properties[i].default_value != "") {
+ class_desc->push_color(symbol_color);
+ class_desc->add_text(" [default: ");
+ class_desc->pop(); // color
+
+ class_desc->push_color(value_color);
+ _add_text(_fix_constant(cd.properties[i].default_value));
+ class_desc->pop(); // color
+
+ class_desc->push_color(symbol_color);
+ class_desc->add_text("]");
+ class_desc->pop(); // color
+ }
+
class_desc->pop(); // font
class_desc->pop(); // cell
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 8e4ec47435..659893a1b6 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "editor_properties.h"
+
#include "editor/editor_resource_preview.h"
#include "editor_node.h"
#include "editor_properties_array_dict.h"
@@ -925,6 +926,9 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) {
preset->set_global_position(easing_draw->get_global_transform().xform(mb->get_position()));
preset->popup();
}
+ if (mb.is_valid() && mb->is_doubleclick() && mb->get_button_index() == BUTTON_LEFT) {
+ _setup_spin();
+ }
Ref<InputEventMouseMotion> mm = p_ev;
@@ -963,7 +967,6 @@ void EditorPropertyEasing::_draw_easing() {
Size2 s = easing_draw->get_size();
Rect2 r(Point2(), s);
r = r.grow(3);
- //get_stylebox("normal", "LineEdit")->draw(ci, r);
int points = 48;
@@ -1006,6 +1009,31 @@ void EditorPropertyEasing::_set_preset(int p_preset) {
easing_draw->update();
}
+void EditorPropertyEasing::_setup_spin() {
+ setting = true;
+ spin->setup_and_show();
+ spin->get_line_edit()->set_text(rtos(get_edited_object()->get(get_edited_property())));
+ setting = false;
+ spin->show();
+}
+
+void EditorPropertyEasing::_spin_value_changed(double p_value) {
+ if (setting)
+ return;
+
+ // 0 is a singularity, but both positive and negative values
+ // are otherwise allowed. Enforce 0+ as workaround.
+ if (Math::is_zero_approx(p_value)) {
+ p_value = 0.00001;
+ }
+ emit_changed(get_edited_property(), p_value);
+ _spin_focus_exited();
+}
+
+void EditorPropertyEasing::_spin_focus_exited() {
+ spin->hide();
+}
+
void EditorPropertyEasing::setup(bool p_full, bool p_flip) {
flip = p_flip;
@@ -1028,9 +1056,6 @@ void EditorPropertyEasing::_notification(int p_what) {
}
easing_draw->set_custom_minimum_size(Size2(0, get_font("font", "Label")->get_height() * 2));
} break;
- case NOTIFICATION_RESIZED: {
-
- } break;
}
}
@@ -1039,6 +1064,9 @@ void EditorPropertyEasing::_bind_methods() {
ClassDB::bind_method("_draw_easing", &EditorPropertyEasing::_draw_easing);
ClassDB::bind_method("_drag_easing", &EditorPropertyEasing::_drag_easing);
ClassDB::bind_method("_set_preset", &EditorPropertyEasing::_set_preset);
+
+ ClassDB::bind_method("_spin_value_changed", &EditorPropertyEasing::_spin_value_changed);
+ ClassDB::bind_method("_spin_focus_exited", &EditorPropertyEasing::_spin_focus_exited);
}
EditorPropertyEasing::EditorPropertyEasing() {
@@ -1053,6 +1081,19 @@ EditorPropertyEasing::EditorPropertyEasing() {
add_child(preset);
preset->connect("id_pressed", this, "_set_preset");
+ spin = memnew(EditorSpinSlider);
+ spin->set_flat(true);
+ spin->set_min(-100);
+ spin->set_max(100);
+ spin->set_step(0);
+ spin->set_hide_slider(true);
+ spin->set_allow_lesser(true);
+ spin->set_allow_greater(true);
+ spin->connect("value_changed", this, "_spin_value_changed");
+ spin->get_line_edit()->connect("focus_exited", this, "_spin_focus_exited");
+ spin->hide();
+ add_child(spin);
+
flip = false;
full = false;
}
@@ -2808,6 +2849,7 @@ EditorPropertyResource::EditorPropertyResource() {
assign->set_drag_forwarding(this);
assign->connect("draw", this, "_button_draw");
hbc->add_child(assign);
+ add_focusable(assign);
preview = memnew(TextureRect);
preview->set_expand(true);
@@ -2828,6 +2870,7 @@ EditorPropertyResource::EditorPropertyResource() {
edit->connect("pressed", this, "_update_menu");
hbc->add_child(edit);
edit->connect("gui_input", this, "_button_input");
+ add_focusable(edit);
file = NULL;
scene_tree = NULL;
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index 02d9349f2d..0a4a07cdc0 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -32,12 +32,12 @@
#define EDITOR_PROPERTIES_H
#include "editor/create_dialog.h"
-#include "editor/editor_file_system.h"
#include "editor/editor_inspector.h"
#include "editor/editor_spin_slider.h"
#include "editor/property_selector.h"
#include "editor/scene_tree_editor.h"
#include "scene/gui/color_picker.h"
+#include "scene/gui/line_edit.h"
class EditorPropertyNil : public EditorProperty {
GDCLASS(EditorPropertyNil, EditorProperty);
@@ -308,7 +308,11 @@ class EditorPropertyEasing : public EditorProperty {
GDCLASS(EditorPropertyEasing, EditorProperty);
Control *easing_draw;
PopupMenu *preset;
+ EditorSpinSlider *spin;
+ bool setting;
+
bool full;
+ bool flip;
enum {
EASING_ZERO,
@@ -321,13 +325,16 @@ class EditorPropertyEasing : public EditorProperty {
};
- bool flip;
-
void _drag_easing(const Ref<InputEvent> &p_ev);
void _draw_easing();
- void _notification(int p_what);
void _set_preset(int);
+ void _setup_spin();
+ void _spin_value_changed(double p_value);
+ void _spin_focus_exited();
+
+ void _notification(int p_what);
+
protected:
static void _bind_methods();
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 8521c0c723..a36163f661 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -1473,6 +1473,10 @@ void EditorSettings::get_shortcut_list(List<String> *r_shortcuts) {
Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) {
+ if (!EditorSettings::get_singleton()) {
+ return NULL;
+ }
+
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
if (!sc.is_valid()) {
ERR_EXPLAIN("Used ED_GET_SHORTCUT with invalid shortcut: " + p_path);
@@ -1508,6 +1512,15 @@ Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p
ie->set_metakey(bool(p_keycode & KEY_MASK_META));
}
+ if (!EditorSettings::get_singleton()) {
+ Ref<ShortCut> sc;
+ sc.instance();
+ sc->set_name(p_name);
+ sc->set_shortcut(ie);
+ sc->set_meta("original", ie);
+ return sc;
+ }
+
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
if (sc.is_valid()) {
diff --git a/editor/editor_spin_slider.h b/editor/editor_spin_slider.h
index 1523c20f48..d91380e175 100644
--- a/editor/editor_spin_slider.h
+++ b/editor/editor_spin_slider.h
@@ -102,6 +102,9 @@ public:
void set_custom_label_color(bool p_use_custom_label_color, Color p_custom_label_color);
+ void setup_and_show() { _focus_entered(); }
+ LineEdit *get_line_edit() { return value_input; }
+
virtual Size2 get_minimum_size() const;
EditorSpinSlider();
};
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 6ae3e2132a..e0e9d4af52 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -3611,7 +3611,8 @@ void CanvasItemEditor::_update_scrollbars() {
bool constrain_editor_view = bool(EditorSettings::get_singleton()->get("editors/2d/constrain_editor_view"));
if (canvas_item_rect.size.height <= (local_rect.size.y / zoom)) {
- if (constrain_editor_view && ABS(begin.y - previous_update_view_offset.y) < ABS(begin.y - view_offset.y)) {
+ float centered = -(size.y / 2) / zoom + screen_rect.y / 2;
+ if (constrain_editor_view && ABS(centered - previous_update_view_offset.y) < ABS(centered - view_offset.y)) {
view_offset.y = previous_update_view_offset.y;
}
@@ -3631,7 +3632,8 @@ void CanvasItemEditor::_update_scrollbars() {
}
if (canvas_item_rect.size.width <= (local_rect.size.x / zoom)) {
- if (constrain_editor_view && ABS(begin.x - previous_update_view_offset.x) < ABS(begin.x - view_offset.x)) {
+ float centered = -(size.x / 2) / zoom + screen_rect.x / 2;
+ if (constrain_editor_view && ABS(centered - previous_update_view_offset.x) < ABS(centered - view_offset.x)) {
view_offset.x = previous_update_view_offset.x;
}
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index ddf49aa9ea..b4200d5662 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -1238,6 +1238,30 @@ void VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
undo_redo->add_do_method(expr, "set_size", Size2(250 * EDSCALE, 150 * EDSCALE));
}
+ if (to_node != -1 && to_slot != -1) {
+ if (vsnode->get_output_port_count() > 0) {
+
+ int _from_node = id_to_use;
+ int _from_slot = 0;
+
+ if (visual_shader->is_port_types_compatible(vsnode->get_output_port_type(_from_slot), visual_shader->get_node(type, to_node)->get_input_port_type(to_slot))) {
+ undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, _from_node, _from_slot, to_node, to_slot);
+ undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, _from_node, _from_slot, to_node, to_slot);
+ }
+ }
+ } else if (from_node != -1 && from_slot != -1) {
+ if (vsnode->get_input_port_count() > 0) {
+
+ int _to_node = id_to_use;
+ int _to_slot = 0;
+
+ if (visual_shader->is_port_types_compatible(visual_shader->get_node(type, from_node)->get_output_port_type(from_slot), vsnode->get_input_port_type(_to_slot))) {
+ undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, from_node, from_slot, _to_node, _to_slot);
+ undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_slot, _to_node, _to_slot);
+ }
+ }
+ }
+
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
undo_redo->commit_action();
@@ -1307,6 +1331,15 @@ void VisualShaderEditor::_disconnection_request(const String &p_from, int p_from
}
void VisualShaderEditor::_connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position) {
+ from_node = p_from.to_int();
+ from_slot = p_from_slot;
+ _show_members_dialog(true);
+}
+
+void VisualShaderEditor::_connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position) {
+ to_node = p_to.to_int();
+ to_slot = p_to_slot;
+ _show_members_dialog(true);
}
void VisualShaderEditor::_delete_request(int which) {
@@ -1372,8 +1405,6 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> p_event) {
void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) {
- members_dialog->popup();
-
if (at_mouse_pos) {
saved_node_pos_dirty = true;
saved_node_pos = graph->get_local_mouse_position();
@@ -1382,6 +1413,7 @@ void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) {
members_dialog->popup();
members_dialog->set_position(gpos);
} else {
+ members_dialog->popup();
saved_node_pos_dirty = false;
members_dialog->set_position(graph->get_global_position() + Point2(5 * EDSCALE, 65 * EDSCALE));
}
@@ -1698,6 +1730,13 @@ void VisualShaderEditor::_member_create() {
}
}
+void VisualShaderEditor::_member_cancel() {
+ to_node = -1;
+ to_slot = -1;
+ from_node = -1;
+ from_slot = -1;
+}
+
void VisualShaderEditor::_tools_menu_option(int p_idx) {
TreeItem *category = members->get_root()->get_children();
@@ -1809,6 +1848,7 @@ void VisualShaderEditor::_bind_methods() {
ClassDB::bind_method("_edit_port_default_input", &VisualShaderEditor::_edit_port_default_input);
ClassDB::bind_method("_port_edited", &VisualShaderEditor::_port_edited);
ClassDB::bind_method("_connection_to_empty", &VisualShaderEditor::_connection_to_empty);
+ ClassDB::bind_method("_connection_from_empty", &VisualShaderEditor::_connection_from_empty);
ClassDB::bind_method("_line_edit_focus_out", &VisualShaderEditor::_line_edit_focus_out);
ClassDB::bind_method("_line_edit_changed", &VisualShaderEditor::_line_edit_changed);
ClassDB::bind_method("_port_name_focus_out", &VisualShaderEditor::_port_name_focus_out);
@@ -1840,6 +1880,7 @@ void VisualShaderEditor::_bind_methods() {
ClassDB::bind_method("_member_selected", &VisualShaderEditor::_member_selected);
ClassDB::bind_method("_member_unselected", &VisualShaderEditor::_member_unselected);
ClassDB::bind_method("_member_create", &VisualShaderEditor::_member_create);
+ ClassDB::bind_method("_member_cancel", &VisualShaderEditor::_member_cancel);
}
VisualShaderEditor *VisualShaderEditor::singleton = NULL;
@@ -1852,6 +1893,11 @@ VisualShaderEditor::VisualShaderEditor() {
saved_node_pos = Point2(0, 0);
ShaderLanguage::get_keyword_list(&keyword_list);
+ to_node = -1;
+ to_slot = -1;
+ from_node = -1;
+ from_slot = -1;
+
graph = memnew(GraphEdit);
add_child(graph);
graph->set_drag_forwarding(this);
@@ -1868,6 +1914,8 @@ VisualShaderEditor::VisualShaderEditor() {
graph->connect("duplicate_nodes_request", this, "_duplicate_nodes");
graph->connect("delete_nodes_request", this, "_on_nodes_delete");
graph->connect("gui_input", this, "_graph_gui_input");
+ graph->connect("connection_to_empty", this, "_connection_to_empty");
+ graph->connect("connection_from_empty", this, "_connection_from_empty");
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_VECTOR);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_BOOLEAN);
@@ -1953,6 +2001,7 @@ VisualShaderEditor::VisualShaderEditor() {
members_dialog->get_ok()->set_disabled(true);
members_dialog->set_resizable(true);
members_dialog->set_as_minsize();
+ members_dialog->connect("hide", this, "_member_cancel");
add_child(members_dialog);
alert = memnew(AcceptDialog);
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index e89814df3d..49a7a21ea7 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -160,7 +160,13 @@ class VisualShaderEditor : public VBoxContainer {
void _edit_port_default_input(Object *p_button, int p_node, int p_port);
void _port_edited();
+ int to_node;
+ int to_slot;
+ int from_node;
+ int from_slot;
+
void _connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position);
+ void _connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position);
void _line_edit_changed(const String &p_text, Object *line_edit, int p_node_id);
void _line_edit_focus_out(Object *line_edit, int p_node_id);
@@ -199,6 +205,7 @@ class VisualShaderEditor : public VBoxContainer {
void _member_selected();
void _member_unselected();
void _member_create();
+ void _member_cancel();
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;