summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/code_editor.cpp4
-rw-r--r--editor/connections_dialog.cpp676
-rw-r--r--editor/connections_dialog.h85
-rw-r--r--editor/create_dialog.cpp9
-rw-r--r--editor/editor_data.cpp8
-rw-r--r--editor/editor_data.h1
-rw-r--r--editor/editor_node.cpp1
-rw-r--r--editor/editor_plugin.cpp5
-rw-r--r--editor/editor_plugin.h1
-rw-r--r--editor/editor_settings.cpp13
-rw-r--r--editor/editor_themes.cpp4
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp106
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h2
-rw-r--r--editor/plugins/script_text_editor.cpp6
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp19
-rw-r--r--editor/project_export.cpp9
-rw-r--r--editor/project_settings_editor.cpp9
-rw-r--r--editor/scene_tree_dock.cpp7
-rw-r--r--editor/settings_config_dialog.cpp9
19 files changed, 633 insertions, 341 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 19bcb28fa5..24e86770bf 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -650,12 +650,12 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
}
void CodeTextEditor::_zoom_in() {
- font_resize_val += EDSCALE;
+ font_resize_val += MAX(EDSCALE, 1.0f);
_zoom_changed();
}
void CodeTextEditor::_zoom_out() {
- font_resize_val -= EDSCALE;
+ font_resize_val -= MAX(EDSCALE, 1.0f);
_zoom_changed();
}
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index ef133e2589..7f93917744 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -35,6 +35,7 @@
#include "plugins/script_editor_plugin.h"
#include "print_string.h"
#include "scene/gui/label.h"
+#include "scene/gui/popup_menu.h"
class ConnectDialogBinds : public Object {
@@ -87,51 +88,12 @@ public:
}
};
-void ConnectDialog::_notification(int p_what) {
-
- if (p_what == NOTIFICATION_ENTER_TREE) {
- bind_editor->edit(cdbinds);
- }
-}
-
-void ConnectDialog::_tree_node_selected() {
-
- //dst_method_list->get_popup()->clear();
- Node *current = tree->get_selected();
-
- if (!current) {
- make_callback->hide();
- return;
- }
-
- if (current->get_script().is_null())
- make_callback->hide();
- else
- make_callback->show();
-
- dst_path->set_text(node->get_path_to(current));
-}
-
-void ConnectDialog::edit(Node *p_node) {
-
- node = p_node;
-
- //dst_method_list->get_popup()->clear();
-
- tree->set_selected(NULL);
- tree->set_marked(node, true);
- dst_path->set_text("");
- dst_method->set_text("");
- deferred->set_pressed(false);
- oneshot->set_pressed(false);
- cdbinds->params.clear();
- cdbinds->notify_changed();
-}
-
+/*
+Signal automatically called by parent dialog.
+*/
void ConnectDialog::ok_pressed() {
if (dst_method->get_text() == "") {
-
error->set_text(TTR("Method in target Node must be specified!"));
error->popup_centered_minsize();
return;
@@ -147,39 +109,35 @@ void ConnectDialog::ok_pressed() {
emit_signal("connected");
hide();
}
+
void ConnectDialog::_cancel_pressed() {
hide();
}
-NodePath ConnectDialog::get_dst_path() const {
-
- return dst_path->get_text();
-}
-
-bool ConnectDialog::get_deferred() const {
-
- return deferred->is_pressed();
-}
-
-bool ConnectDialog::get_oneshot() const {
-
- return oneshot->is_pressed();
-}
+/*
+Called each time a target node is selected within the target node tree.
+*/
+void ConnectDialog::_tree_node_selected() {
-StringName ConnectDialog::get_dst_method() const {
+ Node *current = tree->get_selected();
- String txt = dst_method->get_text();
- if (txt.find("(") != -1)
- txt = txt.left(txt.find("(")).strip_edges();
- return txt;
-}
+ if (!current) {
+ make_callback->hide();
+ return;
+ }
-Vector<Variant> ConnectDialog::get_binds() const {
+ if (current->get_script().is_null())
+ make_callback->hide();
+ else
+ make_callback->show();
- return cdbinds->params;
+ dst_path->set_text(source->get_path_to(current));
}
+/*
+Adds a new parameter bind to connection.
+*/
void ConnectDialog::_add_bind() {
if (cdbinds->params.size() >= VARIANT_ARG_MAX)
@@ -189,7 +147,6 @@ void ConnectDialog::_add_bind() {
Variant value;
switch (vt) {
-
case Variant::BOOL: value = false; break;
case Variant::INT: value = 0; break;
case Variant::REAL: value = 0.0; break;
@@ -203,7 +160,6 @@ void ConnectDialog::_add_bind() {
case Variant::BASIS: value = Basis(); break;
case Variant::TRANSFORM: value = Transform(); break;
case Variant::COLOR: value = Color(); break;
-
default: { ERR_FAIL(); } break;
}
@@ -213,6 +169,9 @@ void ConnectDialog::_add_bind() {
cdbinds->notify_changed();
}
+/*
+Remove parameter bind from connection.
+*/
void ConnectDialog::_remove_bind() {
String st = bind_editor->get_selected_path();
@@ -225,25 +184,106 @@ void ConnectDialog::_remove_bind() {
cdbinds->notify_changed();
}
+void ConnectDialog::_notification(int p_what) {
+
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ bind_editor->edit(cdbinds);
+ }
+}
+
+void ConnectDialog::_bind_methods() {
+
+ ClassDB::bind_method("_cancel", &ConnectDialog::_cancel_pressed);
+ ClassDB::bind_method("_tree_node_selected", &ConnectDialog::_tree_node_selected);
+ ClassDB::bind_method("_add_bind", &ConnectDialog::_add_bind);
+ ClassDB::bind_method("_remove_bind", &ConnectDialog::_remove_bind);
+
+ ADD_SIGNAL(MethodInfo("connected"));
+}
+
+Node *ConnectDialog::get_source() const {
+
+ return source;
+}
+
+StringName ConnectDialog::get_signal_name() const {
+
+ return signal;
+}
+
+NodePath ConnectDialog::get_dst_path() const {
+
+ return dst_path->get_text();
+}
+
void ConnectDialog::set_dst_node(Node *p_node) {
tree->set_selected(p_node);
}
+StringName ConnectDialog::get_dst_method_name() const {
+
+ String txt = dst_method->get_text();
+ if (txt.find("(") != -1)
+ txt = txt.left(txt.find("(")).strip_edges();
+ return txt;
+}
+
void ConnectDialog::set_dst_method(const StringName &p_method) {
dst_method->set_text(p_method);
}
-void ConnectDialog::_bind_methods() {
+Vector<Variant> ConnectDialog::get_binds() const {
- ClassDB::bind_method("_cancel", &ConnectDialog::_cancel_pressed);
- ClassDB::bind_method("_tree_node_selected", &ConnectDialog::_tree_node_selected);
+ return cdbinds->params;
+}
- ClassDB::bind_method("_add_bind", &ConnectDialog::_add_bind);
- ClassDB::bind_method("_remove_bind", &ConnectDialog::_remove_bind);
+bool ConnectDialog::get_deferred() const {
- ADD_SIGNAL(MethodInfo("connected"));
+ return deferred->is_pressed();
+}
+
+bool ConnectDialog::get_oneshot() const {
+
+ return oneshot->is_pressed();
+}
+
+/*
+Returns true if ConnectDialog is being used to edit an existing connection.
+*/
+bool ConnectDialog::is_editing() const {
+
+ return bEditMode;
+}
+
+/*
+Initialize ConnectDialog and populate fields with expected data.
+If creating a connection from scratch, sensible defaults are used.
+If editing an existing connection, previous data is retained.
+*/
+void ConnectDialog::init(Connection c, bool bEdit) {
+
+ source = static_cast<Node *>(c.source);
+ signal = c.signal;
+
+ tree->set_selected(NULL);
+ tree->set_marked(source, true);
+
+ set_dst_node(static_cast<Node *>(c.target));
+ set_dst_method(c.method);
+
+ bool bDeferred = (c.flags & CONNECT_DEFERRED) == CONNECT_DEFERRED;
+ bool bOneshot = (c.flags & CONNECT_ONESHOT) == CONNECT_ONESHOT;
+
+ deferred->set_pressed(bDeferred);
+ oneshot->set_pressed(bOneshot);
+
+ cdbinds->params.clear();
+ cdbinds->params = c.binds;
+ cdbinds->notify_changed();
+
+ bEditMode = bEdit;
}
ConnectDialog::ConnectDialog() {
@@ -261,6 +301,8 @@ ConnectDialog::ConnectDialog() {
tree = memnew(SceneTreeEditor(false));
tree->get_scene_tree()->connect("item_activated", this, "_ok");
+ tree->connect("node_selected", this, "_tree_node_selected");
+
vbc_left->add_margin_child(TTR("Connect To Node:"), tree, true);
VBoxContainer *vbc_right = memnew(VBoxContainer);
@@ -272,12 +314,10 @@ ConnectDialog::ConnectDialog() {
type_list = memnew(OptionButton);
type_list->set_h_size_flags(SIZE_EXPAND_FILL);
add_bind_hb->add_child(type_list);
-
type_list->add_item("bool", Variant::BOOL);
type_list->add_item("int", Variant::INT);
type_list->add_item("real", Variant::REAL);
type_list->add_item("string", Variant::STRING);
- //type_list->add_separator();
type_list->add_item("Vector2", Variant::VECTOR2);
type_list->add_item("Rect2", Variant::RECT2);
type_list->add_item("Vector3", Variant::VECTOR3);
@@ -286,12 +326,10 @@ ConnectDialog::ConnectDialog() {
type_list->add_item("AABB", Variant::AABB);
type_list->add_item("Basis", Variant::BASIS);
type_list->add_item("Transform", Variant::TRANSFORM);
- //type_list->add_separator();
type_list->add_item("Color", Variant::COLOR);
type_list->select(0);
Button *add_bind = memnew(Button);
-
add_bind->set_text(TTR("Add"));
add_bind_hb->add_child(add_bind);
add_bind->connect("pressed", this, "_add_bind");
@@ -318,7 +356,8 @@ ConnectDialog::ConnectDialog() {
dst_method->set_h_size_flags(SIZE_EXPAND_FILL);
dstm_hb->add_child(dst_method);
- /*dst_method_list = memnew( MenuButton );
+ /*
+ dst_method_list = memnew( MenuButton );
dst_method_list->set_text("List...");
dst_method_list->set_anchor( MARGIN_RIGHT, ANCHOR_END );
dst_method_list->set_anchor( MARGIN_LEFT, ANCHOR_END );
@@ -327,7 +366,6 @@ ConnectDialog::ConnectDialog() {
dst_method_list->set_begin( Point2( 70,59) );
dst_method_list->set_end( Point2( 15,39 ) );
*/
- //add_child(dst_method_list);
make_callback = memnew(CheckButton);
make_callback->set_toggle_mode(true);
@@ -343,8 +381,6 @@ ConnectDialog::ConnectDialog() {
oneshot->set_text(TTR("Oneshot"));
dstm_hb->add_child(oneshot);
- tree->connect("node_selected", this, "_tree_node_selected");
-
set_as_toplevel(true);
cdbinds = memnew(ConnectDialogBinds);
@@ -356,134 +392,365 @@ ConnectDialog::ConnectDialog() {
}
ConnectDialog::~ConnectDialog() {
+
memdelete(cdbinds);
}
-void ConnectionsDock::_notification(int p_what) {
-
- if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- update_tree();
- }
-}
+//ConnectionsDock ==========================
-void ConnectionsDock::_close() {
+struct _ConnectionsDockMethodInfoSort {
- hide();
-}
+ _FORCE_INLINE_ bool operator()(const MethodInfo &a, const MethodInfo &b) const {
+ return a.name < b.name;
+ }
+};
-void ConnectionsDock::_connect() {
+/*
+Post-ConnectDialog callback for creating/editing connections.
+Creates or edits connections based on state of the ConnectDialog when "Connect" is pressed.
+*/
+void ConnectionsDock::_make_or_edit_connection() {
TreeItem *it = tree->get_selected();
ERR_FAIL_COND(!it);
- String signal = it->get_metadata(0).operator Dictionary()["name"];
NodePath dst_path = connect_dialog->get_dst_path();
- Node *target = node->get_node(dst_path);
+ Node *target = selectedNode->get_node(dst_path);
ERR_FAIL_COND(!target);
- StringName dst_method = connect_dialog->get_dst_method();
+ Connection cToMake;
+ cToMake.source = connect_dialog->get_source();
+ cToMake.target = target;
+ cToMake.signal = connect_dialog->get_signal_name();
+ cToMake.method = connect_dialog->get_dst_method_name();
+ cToMake.binds = connect_dialog->get_binds();
bool defer = connect_dialog->get_deferred();
bool oshot = connect_dialog->get_oneshot();
- Vector<Variant> binds = connect_dialog->get_binds();
- PoolStringArray args = it->get_metadata(0).operator Dictionary()["args"];
- int flags = CONNECT_PERSIST | (defer ? CONNECT_DEFERRED : 0) | (oshot ? CONNECT_ONESHOT : 0);
+ cToMake.flags = CONNECT_PERSIST | (defer ? CONNECT_DEFERRED : 0) | (oshot ? CONNECT_ONESHOT : 0);
- undo_redo->create_action(vformat(TTR("Connect '%s' to '%s'"), signal, String(dst_method)));
- undo_redo->add_do_method(node, "connect", signal, target, dst_method, binds, flags);
- undo_redo->add_undo_method(node, "disconnect", signal, target, dst_method);
+ if (connect_dialog->is_editing()) {
+ _disconnect(*it);
+ _connect(cToMake);
+ } else {
+ _connect(cToMake);
+ }
+
+ if (connect_dialog->get_make_callback()) {
+ PoolStringArray args = it->get_metadata(0).operator Dictionary()["args"];
+ editor->emit_signal("script_add_function_request", target, cToMake.method, args);
+ hide();
+ }
+
+ update_tree();
+}
+
+/*
+Creates single connection w/ undo-redo functionality.
+*/
+void ConnectionsDock::_connect(Connection cToMake) {
+
+ Node *source = static_cast<Node *>(cToMake.source);
+ Node *target = static_cast<Node *>(cToMake.target);
+
+ if (!source || !target)
+ return;
+
+ undo_redo->create_action(vformat(TTR("Connect '%s' to '%s'"), String(cToMake.signal), String(cToMake.method)));
+
+ undo_redo->add_do_method(source, "connect", cToMake.signal, target, cToMake.method, cToMake.binds, cToMake.flags);
+ undo_redo->add_undo_method(source, "disconnect", cToMake.signal, target, cToMake.method);
undo_redo->add_do_method(this, "update_tree");
undo_redo->add_undo_method(this, "update_tree");
undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree
- undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree
+ undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree");
undo_redo->commit_action();
+}
- if (connect_dialog->get_make_callback()) {
+/*
+Break single connection w/ undo-redo functionality.
+*/
+void ConnectionsDock::_disconnect(TreeItem &item) {
- print_line("request connect");
- editor->emit_signal("script_add_function_request", target, dst_method, args);
- hide();
+ Connection c = item.get_metadata(0);
+ ERR_FAIL_COND(c.source != selectedNode); //shouldn't happen but...bugcheck
+
+ undo_redo->create_action(vformat(TTR("Disconnect '%s' from '%s'"), c.signal, c.method));
+
+ undo_redo->add_do_method(selectedNode, "disconnect", c.signal, c.target, c.method);
+ undo_redo->add_undo_method(selectedNode, "connect", c.signal, c.target, c.method, c.binds, c.flags);
+ undo_redo->add_do_method(this, "update_tree");
+ undo_redo->add_undo_method(this, "update_tree");
+ undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree
+ undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree");
+
+ undo_redo->commit_action();
+}
+
+/*
+Break all conections of currently selected signal.
+Can undo-redo as a single action.
+*/
+void ConnectionsDock::_disconnect_all() {
+
+ TreeItem *item = tree->get_selected();
+
+ if (!_is_item_signal(*item))
+ return;
+
+ TreeItem *child = item->get_children();
+ String signalName = item->get_metadata(0).operator Dictionary()["name"];
+ undo_redo->create_action(vformat(TTR("Disconnect all from signal: '%s'"), signalName));
+
+ while (child) {
+ Connection c = child->get_metadata(0);
+ undo_redo->add_do_method(selectedNode, "disconnect", c.signal, c.target, c.method);
+ undo_redo->add_undo_method(selectedNode, "connect", c.signal, c.target, c.method, c.binds, c.flags);
+ child = child->get_next();
}
- update_tree();
+ undo_redo->add_do_method(this, "update_tree");
+ undo_redo->add_undo_method(this, "update_tree");
+ undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree");
+ undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree");
+
+ undo_redo->commit_action();
}
-void ConnectionsDock::_connect_pressed() {
+void ConnectionsDock::_tree_item_selected() {
TreeItem *item = tree->get_selected();
- if (!item) {
- //no idea how this happened, but disable
+ if (!item) { //Unlikely. Disable button just in case.
+ connect_button->set_text(TTR("Connect..."));
connect_button->set_disabled(true);
+ } else if (_is_item_signal(*item)) {
+ connect_button->set_text(TTR("Connect..."));
+ connect_button->set_disabled(false);
+ } else {
+ connect_button->set_text(TTR("Disconnect"));
+ connect_button->set_disabled(false);
+ }
+}
+
+void ConnectionsDock::_tree_item_activated() { //"Activation" on double-click.
+
+ TreeItem *item = tree->get_selected();
+
+ if (!item)
return;
+
+ if (_is_item_signal(*item)) {
+ _open_connection_dialog(*item);
+ } else {
+ _go_to_script(*item);
}
- if (item->get_parent() == tree->get_root() || item->get_parent()->get_parent() == tree->get_root()) {
- //a signal - connect
- String signal = item->get_metadata(0).operator Dictionary()["name"];
- String signalname = signal;
- String midname = node->get_name();
- for (int i = 0; i < midname.length(); i++) {
- CharType c = midname[i];
- if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_') {
- //all good
- } else if (c == ' ') {
+}
+
+bool ConnectionsDock::_is_item_signal(TreeItem &item) {
+
+ return (item.get_parent() == tree->get_root() || item.get_parent()->get_parent() == tree->get_root());
+}
+
+/*
+Open connection dialog with TreeItem data to CREATE a brand-new connection.
+*/
+void ConnectionsDock::_open_connection_dialog(TreeItem &item) {
+
+ String signal = item.get_metadata(0).operator Dictionary()["name"];
+ String signalname = signal;
+ String midname = selectedNode->get_name();
+ for (int i = 0; i < midname.length(); i++) { //TODO: Regex filter may be cleaner.
+ CharType c = midname[i];
+ if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_')) {
+ if (c == ' ') {
+ //Replace spaces with underlines.
c = '_';
} else {
+ //Remove any other characters.
midname.remove(i);
i--;
continue;
}
-
- midname[i] = c;
}
+ midname[i] = c;
+ }
+
+ Node *dst_node = selectedNode->get_owner() ? selectedNode->get_owner() : selectedNode;
+ StringName dst_method = "_on_" + midname + "_" + signal;
+
+ Connection c;
+ c.source = selectedNode;
+ c.signal = StringName(signalname);
+ c.target = dst_node;
+ c.method = dst_method;
+
+ connect_dialog->init(c);
+ connect_dialog->set_title(TTR("Connect Signal: ") + signalname);
+ connect_dialog->popup_centered_ratio();
+}
+
+/*
+Open connection dialog with Connection data to EDIT an existing connection.
+*/
+void ConnectionsDock::_open_connection_dialog(Connection cToEdit) {
+
+ Node *src = static_cast<Node *>(cToEdit.source);
+ Node *dst = static_cast<Node *>(cToEdit.target);
- connect_dialog->edit(node);
+ if (src && dst) {
+ connect_dialog->init(cToEdit, true);
+ connect_dialog->set_title(TTR("Edit Connection: ") + cToEdit.signal);
connect_dialog->popup_centered_ratio();
- connect_dialog->set_title(TTR("Connecting Signal:") + " " + signalname);
- connect_dialog->set_dst_method("_on_" + midname + "_" + signal);
- connect_dialog->set_dst_node(node->get_owner() ? node->get_owner() : node);
+ }
+}
+
+/*
+Open slot method location in script editor.
+*/
+void ConnectionsDock::_go_to_script(TreeItem &item) {
+
+ if (_is_item_signal(item))
+ return;
+
+ Connection c = item.get_metadata(0);
+ ERR_FAIL_COND(c.source != selectedNode); //shouldn't happen but...bugcheck
+
+ if (!c.target)
+ return;
+
+ Ref<Script> script = c.target->get_script();
+
+ if (script.is_null())
+ return;
+
+ if (script.is_valid() && ScriptEditor::get_singleton()->script_goto_method(script, c.method)) {
+ editor->call("_editor_select", EditorNode::EDITOR_SCRIPT);
+ }
+}
+
+void ConnectionsDock::_handle_signal_menu_option(int option) {
+
+ TreeItem *item = tree->get_selected();
+
+ if (!item)
+ return;
+
+ switch (option) {
+ case CONNECT: {
+ _open_connection_dialog(*item);
+ } break;
+ case DISCONNECT_ALL: {
+ StringName signalName = item->get_metadata(0).operator Dictionary()["name"];
+ disconnect_all_dialog->set_text(TTR("Are you sure you want to remove all connections from the \"") + signalName + "\" signal?");
+ disconnect_all_dialog->popup_centered();
+ } break;
+ }
+}
+
+void ConnectionsDock::_handle_slot_menu_option(int option) {
+
+ TreeItem *item = tree->get_selected();
+
+ if (!item)
+ return;
+
+ switch (option) {
+ case EDIT: {
+ Connection c = item->get_metadata(0);
+ _open_connection_dialog(c);
+ } break;
+ case GO_TO_SCRIPT: {
+ _go_to_script(*item);
+ } break;
+ case DISCONNECT: {
+ _disconnect(*item);
+ update_tree();
+ } break;
+ }
+}
+
+void ConnectionsDock::_rmb_pressed(Vector2 position) {
+ TreeItem *item = tree->get_selected();
+
+ if (!item)
+ return;
+
+ Vector2 global_position = tree->get_global_position() + position;
+
+ if (_is_item_signal(*item)) {
+ signal_menu->set_position(global_position);
+ signal_menu->popup();
} else {
- //a slot- disconnect
- Connection c = item->get_metadata(0);
- ERR_FAIL_COND(c.source != node); //shouldn't happen but...bugcheck
-
- undo_redo->create_action(vformat(TTR("Disconnect '%s' from '%s'"), c.signal, c.method));
- undo_redo->add_do_method(node, "disconnect", c.signal, c.target, c.method);
- undo_redo->add_undo_method(node, "connect", c.signal, c.target, c.method, Vector<Variant>(), c.flags);
- undo_redo->add_do_method(this, "update_tree");
- undo_redo->add_undo_method(this, "update_tree");
- undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree
- undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree
- undo_redo->commit_action();
-
- c.source->disconnect(c.signal, c.target, c.method);
+ slot_menu->set_position(global_position);
+ slot_menu->popup();
+ }
+}
+
+void ConnectionsDock::_close() {
+
+ hide();
+}
+
+void ConnectionsDock::_connect_pressed() {
+
+ TreeItem *item = tree->get_selected();
+ if (!item) {
+ connect_button->set_disabled(true);
+ return;
+ }
+
+ if (_is_item_signal(*item)) {
+ _open_connection_dialog(*item);
+ } else {
+ _disconnect(*item);
update_tree();
}
}
-struct _ConnectionsDockMethodInfoSort {
+void ConnectionsDock::_notification(int p_what) {
- _FORCE_INLINE_ bool operator()(const MethodInfo &a, const MethodInfo &b) const {
- return a.name < b.name;
+ if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
+ update_tree();
}
-};
+}
+
+void ConnectionsDock::_bind_methods() {
+
+ ClassDB::bind_method("_make_or_edit_connection", &ConnectionsDock::_make_or_edit_connection);
+ ClassDB::bind_method("_disconnect_all", &ConnectionsDock::_disconnect_all);
+ ClassDB::bind_method("_tree_item_selected", &ConnectionsDock::_tree_item_selected);
+ ClassDB::bind_method("_tree_item_activated", &ConnectionsDock::_tree_item_activated);
+ ClassDB::bind_method("_handle_signal_menu_option", &ConnectionsDock::_handle_signal_menu_option);
+ ClassDB::bind_method("_handle_slot_menu_option", &ConnectionsDock::_handle_slot_menu_option);
+ ClassDB::bind_method("_rmb_pressed", &ConnectionsDock::_rmb_pressed);
+ ClassDB::bind_method("_close", &ConnectionsDock::_close);
+ ClassDB::bind_method("_connect_pressed", &ConnectionsDock::_connect_pressed);
+ ClassDB::bind_method("update_tree", &ConnectionsDock::update_tree);
+}
+
+void ConnectionsDock::set_node(Node *p_node) {
+
+ selectedNode = p_node;
+ update_tree();
+}
void ConnectionsDock::update_tree() {
tree->clear();
- if (!node)
+ if (!selectedNode)
return;
TreeItem *root = tree->create_item();
List<MethodInfo> node_signals;
- node->get_signal_list(&node_signals);
+ selectedNode->get_signal_list(&node_signals);
//node_signals.sort_custom<_ConnectionsDockMethodInfoSort>();
bool did_script = false;
- StringName base = node->get_class();
+ StringName base = selectedNode->get_class();
while (base) {
@@ -493,7 +760,7 @@ void ConnectionsDock::update_tree() {
if (!did_script) {
- Ref<Script> scr = node->get_script();
+ Ref<Script> scr = selectedNode->get_script();
if (scr.is_valid()) {
scr->get_script_signal_list(&node_signals);
if (scr->get_path().is_resource_file())
@@ -563,7 +830,7 @@ void ConnectionsDock::update_tree() {
item->set_icon(0, get_icon("Signal", "EditorIcons"));
List<Object::Connection> connections;
- node->get_signal_connection_list(mi.name, &connections);
+ selectedNode->get_signal_connection_list(mi.name, &connections);
for (List<Object::Connection>::Element *F = connections.front(); F; F = F->next()) {
@@ -575,7 +842,7 @@ void ConnectionsDock::update_tree() {
if (!target)
continue;
- String path = String(node->get_path_to(target)) + " :: " + c.method + "()";
+ String path = String(selectedNode->get_path_to(target)) + " :: " + c.method + "()";
if (c.flags & CONNECT_DEFERRED)
path += " (deferred)";
if (c.flags & CONNECT_ONESHOT)
@@ -610,88 +877,6 @@ void ConnectionsDock::update_tree() {
connect_button->set_disabled(true);
}
-void ConnectionsDock::set_node(Node *p_node) {
-
- node = p_node;
- update_tree();
-}
-
-void ConnectionsDock::_something_selected() {
-
- TreeItem *item = tree->get_selected();
- if (!item) {
- //no idea how this happened, but disable
- connect_button->set_text(TTR("Connect..."));
- connect_button->set_disabled(true);
-
- } else if (item->get_parent() == tree->get_root() || item->get_parent()->get_parent() == tree->get_root()) {
- //a signal - connect
- connect_button->set_text(TTR("Connect..."));
- connect_button->set_disabled(false);
-
- } else {
- //a slot- disconnect
- connect_button->set_text(TTR("Disconnect"));
- connect_button->set_disabled(false);
- }
-}
-
-void ConnectionsDock::_something_activated() {
-
- TreeItem *item = tree->get_selected();
-
- if (!item)
- return;
-
- if (item->get_parent() == tree->get_root() || item->get_parent()->get_parent() == tree->get_root()) {
- // a signal - connect
- String signal = item->get_metadata(0).operator Dictionary()["name"];
- String midname = node->get_name();
- for (int i = 0; i < midname.length(); i++) {
- CharType c = midname[i];
- if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_') {
- //all good
- } else if (c == ' ') {
- c = '_';
- } else {
- midname.remove(i);
- i--;
- continue;
- }
-
- midname[i] = c;
- }
-
- connect_dialog->edit(node);
- connect_dialog->popup_centered_ratio();
- connect_dialog->set_dst_method("_on_" + midname + "_" + signal);
- connect_dialog->set_dst_node(node->get_owner() ? node->get_owner() : node);
- } else {
- // a slot - go to target method
- Connection c = item->get_metadata(0);
- ERR_FAIL_COND(c.source != node); //shouldn't happen but...bugcheck
-
- if (!c.target)
- return;
-
- Ref<Script> script = c.target->get_script();
-
- if (script.is_valid() && ScriptEditor::get_singleton()->script_goto_method(script, c.method)) {
- editor->call("_editor_select", EditorNode::EDITOR_SCRIPT);
- }
- }
-}
-
-void ConnectionsDock::_bind_methods() {
-
- ClassDB::bind_method("_connect", &ConnectionsDock::_connect);
- ClassDB::bind_method("_something_selected", &ConnectionsDock::_something_selected);
- ClassDB::bind_method("_something_activated", &ConnectionsDock::_something_activated);
- ClassDB::bind_method("_close", &ConnectionsDock::_close);
- ClassDB::bind_method("_connect_pressed", &ConnectionsDock::_connect_pressed);
- ClassDB::bind_method("update_tree", &ConnectionsDock::update_tree);
-}
-
ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
editor = p_editor;
@@ -705,6 +890,7 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
tree->set_hide_root(true);
vbc->add_child(tree);
tree->set_v_size_flags(SIZE_EXPAND_FILL);
+ tree->set_allow_rmb_select(true);
connect_button = memnew(Button);
connect_button->set_text(TTR("Connect"));
@@ -713,15 +899,29 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
hb->add_spacer();
hb->add_child(connect_button);
connect_button->connect("pressed", this, "_connect_pressed");
- //add_child(tree);
connect_dialog = memnew(ConnectDialog);
connect_dialog->set_as_toplevel(true);
add_child(connect_dialog);
- remove_confirm = memnew(ConfirmationDialog);
- remove_confirm->set_as_toplevel(true);
- add_child(remove_confirm);
+ disconnect_all_dialog = memnew(ConfirmationDialog);
+ disconnect_all_dialog->set_as_toplevel(true);
+ add_child(disconnect_all_dialog);
+ disconnect_all_dialog->connect("confirmed", this, "_disconnect_all");
+ disconnect_all_dialog->set_text(TTR("Are you sure you want to remove all connections from this signal?"));
+
+ signal_menu = memnew(PopupMenu);
+ add_child(signal_menu);
+ signal_menu->connect("id_pressed", this, "_handle_signal_menu_option");
+ signal_menu->add_item(TTR("Connect..."), CONNECT);
+ signal_menu->add_item(TTR("Disconnect All"), DISCONNECT_ALL);
+
+ slot_menu = memnew(PopupMenu);
+ add_child(slot_menu);
+ slot_menu->connect("id_pressed", this, "_handle_slot_menu_option");
+ slot_menu->add_item(TTR("Edit..."), EDIT);
+ slot_menu->add_item(TTR("Go To Method"), GO_TO_SCRIPT);
+ slot_menu->add_item(TTR("Disconnect"), DISCONNECT);
/*
node_only->set_anchor( MARGIN_TOP, ANCHOR_END );
@@ -732,10 +932,10 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
node_only->set_end( Point2( 10,44) );
*/
- remove_confirm->connect("confirmed", this, "_remove_confirm");
- connect_dialog->connect("connected", this, "_connect");
- tree->connect("item_selected", this, "_something_selected");
- tree->connect("item_activated", this, "_something_activated");
+ connect_dialog->connect("connected", this, "_make_or_edit_connection");
+ tree->connect("item_selected", this, "_tree_item_selected");
+ tree->connect("item_activated", this, "_tree_item_activated");
+ tree->connect("item_rmb_selected", this, "_rmb_pressed");
add_constant_override("separation", 3 * EDSCALE);
}
diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h
index 5e26e00f67..932ff693e4 100644
--- a/editor/connections_dialog.h
+++ b/editor/connections_dialog.h
@@ -28,6 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+/**
+@author Juan Linietsky <reduzio@gmail.com>
+*/
+
#ifndef CONNECTIONS_DIALOG_H
#define CONNECTIONS_DIALOG_H
@@ -42,27 +46,28 @@
#include "scene/gui/tree.h"
#include "undo_redo.h"
-/**
-@author Juan Linietsky <reduzio@gmail.com>
-*/
-
+class PopupMenu;
class ConnectDialogBinds;
class ConnectDialog : public ConfirmationDialog {
GDCLASS(ConnectDialog, ConfirmationDialog);
- ConfirmationDialog *error;
+ Node *source;
+ StringName signal;
LineEdit *dst_path;
LineEdit *dst_method;
+ ConnectDialogBinds *cdbinds;
+ bool bEditMode;
+
SceneTreeEditor *tree;
+ ConfirmationDialog *error;
+ PropertyEditor *bind_editor;
OptionButton *type_list;
CheckButton *deferred;
CheckButton *oneshot;
CheckButton *make_callback;
- PropertyEditor *bind_editor;
- Node *node;
- ConnectDialogBinds *cdbinds;
+
void ok_pressed();
void _cancel_pressed();
void _tree_node_selected();
@@ -74,37 +79,71 @@ protected:
static void _bind_methods();
public:
- bool get_make_callback() { return make_callback->is_visible() && make_callback->is_pressed(); }
+ Node *get_source() const;
+ StringName get_signal_name() const;
NodePath get_dst_path() const;
- StringName get_dst_method() const;
+ void set_dst_node(Node *p_node);
+ StringName get_dst_method_name() const;
+ void set_dst_method(const StringName &p_method);
+ Vector<Variant> get_binds() const;
+
+ bool get_make_callback() { return make_callback->is_visible() && make_callback->is_pressed(); }
bool get_deferred() const;
bool get_oneshot() const;
- Vector<Variant> get_binds() const;
- void set_dst_method(const StringName &p_method);
- void set_dst_node(Node *p_node);
+ bool is_editing() const;
- void edit(Node *p_node);
+ void init(Connection c, bool bEdit = false);
ConnectDialog();
~ConnectDialog();
};
+//========================================
+
class ConnectionsDock : public VBoxContainer {
GDCLASS(ConnectionsDock, VBoxContainer);
- Button *connect_button;
- EditorNode *editor;
- Node *node;
+ //Right-click Pop-up Menu Options.
+ enum SignalMenuOption {
+ CONNECT,
+ DISCONNECT_ALL
+ };
+
+ enum SlotMenuOption {
+ EDIT,
+ GO_TO_SCRIPT,
+ DISCONNECT
+ };
+
+ Node *selectedNode;
Tree *tree;
- ConfirmationDialog *remove_confirm;
+ EditorNode *editor;
+
+ ConfirmationDialog *disconnect_all_dialog;
ConnectDialog *connect_dialog;
+ Button *connect_button;
+ PopupMenu *signal_menu;
+ PopupMenu *slot_menu;
+ UndoRedo *undo_redo;
+
+ void _make_or_edit_connection();
+ void _connect(Connection cToMake);
+ void _disconnect(TreeItem &item);
+ void _disconnect_all();
+ void _tree_item_selected();
+ void _tree_item_activated();
+ bool _is_item_signal(TreeItem &item);
+
+ void _open_connection_dialog(TreeItem &item);
+ void _open_connection_dialog(Connection cToEdit);
+ void _go_to_script(TreeItem &item);
+
+ void _handle_signal_menu_option(int option);
+ void _handle_slot_menu_option(int option);
+ void _rmb_pressed(Vector2 position);
void _close();
- void _connect();
- void _something_selected();
- void _something_activated();
- UndoRedo *undo_redo;
protected:
void _connect_pressed();
@@ -113,9 +152,7 @@ protected:
public:
void set_undoredo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
-
void set_node(Node *p_node);
- String get_selected_type();
void update_tree();
ConnectionsDock(EditorNode *p_editor = NULL);
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index 78fb35e354..36978e37a5 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -87,7 +87,14 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode) {
if (EditorSettings::get_singleton()->has_setting("interface/dialogs/create_new_node_bounds")) {
popup(EditorSettings::get_singleton()->get("interface/dialogs/create_new_node_bounds"));
} else {
- popup_centered_ratio();
+
+ Size2 popup_size = Size2(900, 700) * editor_get_scale();
+ Size2 window_size = get_viewport_rect().size;
+
+ popup_size.x = MIN(window_size.x * 0.8, popup_size.x);
+ popup_size.y = MIN(window_size.y * 0.8, popup_size.y);
+
+ popup_centered(popup_size);
}
if (p_dont_clear) {
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index 37a35b6ebf..b584107bcb 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -364,6 +364,14 @@ void EditorData::notify_edited_scene_changed() {
}
}
+void EditorData::notify_resource_saved(const Ref<Resource> &p_resource) {
+
+ for (int i = 0; i < editor_plugins.size(); i++) {
+
+ editor_plugins[i]->notify_resource_saved(p_resource);
+ }
+}
+
void EditorData::clear_editor_states() {
for (int i = 0; i < editor_plugins.size(); i++) {
diff --git a/editor/editor_data.h b/editor/editor_data.h
index 1a498a6150..5a0b58464a 100644
--- a/editor/editor_data.h
+++ b/editor/editor_data.h
@@ -204,6 +204,7 @@ public:
void save_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history, const Dictionary &p_custom);
Dictionary restore_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history);
void notify_edited_scene_changed();
+ void notify_resource_saved(const Ref<Resource> &p_resource);
EditorData();
};
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index d8c85df83d..23c6ee4c3e 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -631,6 +631,7 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St
((Resource *)p_resource.ptr())->set_path(path);
emit_signal("resource_saved", p_resource);
+ editor_data.notify_resource_saved(p_resource);
}
void EditorNode::save_resource(const Ref<Resource> &p_resource) {
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index 336eaf719c..2e4e887165 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -473,6 +473,10 @@ void EditorPlugin::notify_scene_closed(const String &scene_filepath) {
emit_signal("scene_closed", scene_filepath);
}
+void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) {
+ emit_signal("resource_saved", p_resource);
+}
+
Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial *p_spatial) {
//??
if (get_script_instance() && get_script_instance()->has_method("create_spatial_gizmo")) {
@@ -757,6 +761,7 @@ void EditorPlugin::_bind_methods() {
ADD_SIGNAL(MethodInfo("scene_changed", PropertyInfo(Variant::OBJECT, "scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "filepath")));
ADD_SIGNAL(MethodInfo("main_screen_changed", PropertyInfo(Variant::STRING, "screen_name")));
+ ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource")));
BIND_ENUM_CONSTANT(CONTAINER_TOOLBAR);
BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_MENU);
diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h
index 05cc6e07e3..ebc4afdfeb 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -167,6 +167,7 @@ public:
void notify_main_screen_changed(const String &screen_name);
void notify_scene_changed(const Node *scn_root);
void notify_scene_closed(const String &scene_filepath);
+ void notify_resource_saved(const Ref<Resource> &p_resource);
virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial *p_spatial);
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 9f55ae32b0..4a9432780c 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -400,8 +400,17 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("editors/grid_map/pick_distance", 5000.0);
- _initial_set("editors/3d/grid_color", Color::html("808080"));
- hints["editors/3d/grid_color"] = PropertyInfo(Variant::COLOR, "editors/3d/grid_color", PROPERTY_HINT_COLOR_NO_ALPHA, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ _initial_set("editors/3d/primary_grid_color", Color::html("909090"));
+ hints["editors/3d/primary_grid_color"] = PropertyInfo(Variant::COLOR, "editors/3d/primary_grid_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+
+ _initial_set("editors/3d/secondary_grid_color", Color::html("606060"));
+ hints["editors/3d/secondary_grid_color"] = PropertyInfo(Variant::COLOR, "editors/3d/secondary_grid_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+
+ _initial_set("editors/3d/grid_size", 50);
+ hints["editors/3d/grid_size"] = PropertyInfo(Variant::INT, "editors/3d/grid_size", PROPERTY_HINT_RANGE, "1,500,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+
+ _initial_set("editors/3d/primary_grid_steps", 10);
+ hints["editors/3d/primary_grid_steps"] = PropertyInfo(Variant::INT, "editors/3d/primary_grid_steps", PROPERTY_HINT_RANGE, "1,100,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("editors/3d/default_fov", 70.0);
_initial_set("editors/3d/default_z_near", 0.05);
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index e93df835e4..bf7236cc2b 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -912,6 +912,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_constant("shadow_as_outline", "Label", 0 * EDSCALE);
theme->set_constant("line_spacing", "Label", 3 * EDSCALE);
+ // LinkButton
+ theme->set_stylebox("focus", "LinkButton", style_empty);
+ theme->set_color("font_color", "LinkButton", font_color);
+
// TooltipPanel
Ref<StyleBoxFlat> style_tooltip = style_popup->duplicate();
style_tooltip->set_bg_color(Color(mono_color.r, mono_color.g, mono_color.b, 0.9));
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 8cad40c9ce..93aeca6632 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -467,32 +467,28 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no
const real_t grab_distance = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
- bool locked = p_node->has_meta("_edit_lock_") && p_node->get_meta("_edit_lock_");
-
- if (!locked) {
- for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
- if (canvas_item && !canvas_item->is_set_as_toplevel()) {
- _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_limit, p_parent_xform * canvas_item->get_transform(), p_canvas_xform);
- } else {
- CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node);
- _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_limit, Transform2D(), cl ? cl->get_transform() : p_canvas_xform);
- }
- if (p_limit != 0 && r_items.size() >= p_limit)
- return;
+ for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
+ if (canvas_item && !canvas_item->is_set_as_toplevel()) {
+ _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_limit, p_parent_xform * canvas_item->get_transform(), p_canvas_xform);
+ } else {
+ CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node);
+ _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_limit, Transform2D(), cl ? cl->get_transform() : p_canvas_xform);
}
+ if (p_limit != 0 && r_items.size() >= p_limit)
+ return;
+ }
- if (canvas_item && canvas_item->is_visible_in_tree()) {
- Transform2D xform = (p_parent_xform * p_canvas_xform * canvas_item->get_transform()).affine_inverse();
- const real_t local_grab_distance = xform.basis_xform(Vector2(grab_distance, 0)).length();
- if (canvas_item->_edit_is_selected_on_click(xform.xform(p_pos), local_grab_distance)) {
- Node2D *node = Object::cast_to<Node2D>(canvas_item);
+ if (canvas_item && canvas_item->is_visible_in_tree()) {
+ Transform2D xform = (p_parent_xform * p_canvas_xform * canvas_item->get_transform()).affine_inverse();
+ const real_t local_grab_distance = xform.basis_xform(Vector2(grab_distance, 0)).length();
+ if (canvas_item->_edit_is_selected_on_click(xform.xform(p_pos), local_grab_distance)) {
+ Node2D *node = Object::cast_to<Node2D>(canvas_item);
- _SelectResult res;
- res.item = canvas_item;
- res.z_index = node ? node->get_z_index() : 0;
- res.has_z = node;
- r_items.push_back(res);
- }
+ _SelectResult res;
+ res.item = canvas_item;
+ res.z_index = node ? node->get_z_index() : 0;
+ res.has_z = node;
+ r_items.push_back(res);
}
}
@@ -509,14 +505,14 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel
for (int i = 0; i < r_items.size(); i++) {
Node *node = r_items[i].item;
- // Make sure the selected node is in the current scene
- while (node && node != scene && node->get_owner() != scene) {
+ // Make sure the selected node is in the current scene, or editable
+ while (node && node != get_tree()->get_edited_scene_root() && node->get_owner() != scene && !scene->is_editable_instance(node->get_owner())) {
node = node->get_parent();
};
// Replace the node by the group if grouped
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(node);
- while (node && node != scene) {
+ while (node && node != scene->get_parent()) {
CanvasItem *canvas_item_tmp = Object::cast_to<CanvasItem>(node);
if (canvas_item_tmp && node->has_meta("_edit_group_")) {
canvas_item = canvas_item_tmp;
@@ -525,7 +521,7 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel
}
//Remove the item if invalid
- if (!canvas_item || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner()))) {
+ if (!canvas_item || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner())) || (canvas_item->has_meta("_edit_lock_") && canvas_item->get_meta("_edit_lock_"))) {
r_items.remove(i);
i--;
} else {
@@ -541,13 +537,13 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n
return;
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
+ Node *scene = editor->get_edited_scene();
- bool inherited = p_node != get_tree()->get_edited_scene_root() && p_node->get_filename() != "";
- bool editable = !inherited || EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(p_node);
+ bool editable = p_node == scene || p_node->get_owner() == scene || scene->is_editable_instance(p_node->get_owner());
bool lock_children = p_node->has_meta("_edit_group_") && p_node->get_meta("_edit_group_");
bool locked = p_node->has_meta("_edit_lock_") && p_node->get_meta("_edit_lock_");
- if (!lock_children && !locked && editable) {
+ if (!lock_children || !editable) {
for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
if (canvas_item && !canvas_item->is_set_as_toplevel()) {
_find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, p_parent_xform * canvas_item->get_transform(), p_canvas_xform);
@@ -558,7 +554,7 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n
}
}
- if (canvas_item && canvas_item->is_visible_in_tree() && !canvas_item->has_meta("_edit_lock_")) {
+ if (canvas_item && canvas_item->is_visible_in_tree() && !locked && editable) {
Transform2D xform = p_parent_xform * p_canvas_xform * canvas_item->get_transform();
if (canvas_item->_edit_use_rect()) {
@@ -2593,9 +2589,6 @@ void CanvasItemEditor::_draw_bones() {
for (Map<BoneKey, BoneList>::Element *E = bone_list.front(); E; E = E->next()) {
- E->get().from = Vector2();
- E->get().to = Vector2();
-
Node2D *from_node = Object::cast_to<Node2D>(ObjectDB::get_instance(E->key().from));
Node2D *to_node = Object::cast_to<Node2D>(ObjectDB::get_instance(E->key().to));
@@ -2615,9 +2608,6 @@ void CanvasItemEditor::_draw_bones() {
else
to = transform.xform(from_node->get_global_transform().xform(Vector2(E->get().length, 0)));
- E->get().from = from;
- E->get().to = to;
-
Vector2 rel = to - from;
Vector2 relt = rel.tangent().normalized() * bone_width;
Vector2 reln = rel.normalized();
@@ -2679,7 +2669,7 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans
ERR_FAIL_COND(!p_node);
Node *scene = editor->get_edited_scene();
- if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node))
+ if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node->get_owner()))
return;
CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
if (canvas_item && !canvas_item->is_visible())
@@ -2805,27 +2795,20 @@ bool CanvasItemEditor::_build_bones_list(Node *p_node) {
}
}
- CanvasItem *c = Object::cast_to<CanvasItem>(p_node);
- if (!c) {
- return false;
- }
-
- Node *p = c->get_parent();
- if (!p) {
- return false;
- }
-
- if (!c->is_visible()) {
+ CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node);
+ Node *scene = editor->get_edited_scene();
+ if (!canvas_item || !canvas_item->is_visible() || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner()))) {
return false;
}
- if (Object::cast_to<Bone2D>(c)) {
+ Node *parent = canvas_item->get_parent();
- if (Object::cast_to<Bone2D>(p)) {
- //add as bone->parent relationship
+ if (Object::cast_to<Bone2D>(canvas_item)) {
+ if (Object::cast_to<Bone2D>(parent)) {
+ // Add as bone->parent relationship
BoneKey bk;
- bk.from = p->get_instance_id();
- bk.to = c->get_instance_id();
+ bk.from = parent->get_instance_id();
+ bk.to = canvas_item->get_instance_id();
if (!bone_list.has(bk)) {
BoneList b;
b.length = 0;
@@ -2836,8 +2819,9 @@ bool CanvasItemEditor::_build_bones_list(Node *p_node) {
}
if (!has_child_bones) {
+ // Add a last bone if the Bone2D has no Bone2D child
BoneKey bk;
- bk.from = c->get_instance_id();
+ bk.from = canvas_item->get_instance_id();
bk.to = 0;
if (!bone_list.has(bk)) {
BoneList b;
@@ -2849,11 +2833,12 @@ bool CanvasItemEditor::_build_bones_list(Node *p_node) {
return true;
}
- if (c->has_meta("_edit_bone_")) {
+ if (canvas_item->has_meta("_edit_bone_")) {
+ // Add a "custom bone"
BoneKey bk;
- bk.from = c->get_parent()->get_instance_id();
- bk.to = c->get_instance_id();
+ bk.from = parent->get_instance_id();
+ bk.to = canvas_item->get_instance_id();
if (!bone_list.has(bk)) {
BoneList b;
b.length = 0;
@@ -2938,6 +2923,7 @@ void CanvasItemEditor::_notification(int p_what) {
int nb_control = 0;
int nb_having_pivot = 0;
+ // Update the viewport if the canvas_item changes
List<CanvasItem *> selection = _get_edited_canvas_items();
for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get();
@@ -2983,12 +2969,14 @@ void CanvasItemEditor::_notification(int p_what) {
nb_having_pivot++;
}
}
+
// Activate / Deactivate the pivot tool
pivot_button->set_disabled(nb_having_pivot == 0);
// Show / Hide the layout button
presets_menu->set_visible(nb_control > 0 && nb_control == selection.size());
+ // Update the viewport if bones changes
for (Map<BoneKey, BoneList>::Element *E = bone_list.front(); E; E = E->next()) {
Object *b = ObjectDB::get_instance(E->key().from);
@@ -2999,7 +2987,7 @@ void CanvasItemEditor::_notification(int p_what) {
}
Node2D *b2 = Object::cast_to<Node2D>(b);
- if (!b2) {
+ if (!b2 || !b2->is_inside_tree()) {
continue;
}
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index eb3595cae6..a1957b892e 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -266,8 +266,6 @@ class CanvasItemEditor : public VBoxContainer {
Transform2D xform;
float length;
uint64_t last_pass;
- Vector2 from;
- Vector2 to;
};
uint64_t bone_last_frame;
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index c872a6f28b..45f5e667fa 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -746,6 +746,8 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
_goto_line(p_row);
+ result.class_name = result.class_name.trim_prefix("_");
+
switch (result.type) {
case ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION: {
@@ -1007,6 +1009,10 @@ void ScriptTextEditor::_edit_option(int p_op) {
}
int next_line = to_line + 1;
+ if (to_line >= tx->get_line_count() - 1) {
+ tx->set_line(to_line, tx->get_line(to_line) + "\n");
+ }
+
tx->begin_complex_operation();
for (int i = from_line; i <= to_line; i++) {
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index f341b970e2..1e6c736381 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -4598,7 +4598,10 @@ void SpatialEditor::_init_grid() {
PoolVector<Color> grid_colors[3];
PoolVector<Vector3> grid_points[3];
- Color grid_color = EditorSettings::get_singleton()->get("editors/3d/grid_color");
+ Color primary_grid_color = EditorSettings::get_singleton()->get("editors/3d/primary_grid_color");
+ Color secondary_grid_color = EditorSettings::get_singleton()->get("editors/3d/secondary_grid_color");
+ int grid_size = EditorSettings::get_singleton()->get("editors/3d/grid_size");
+ int primary_grid_steps = EditorSettings::get_singleton()->get("editors/3d/primary_grid_steps");
for (int i = 0; i < 3; i++) {
Vector3 axis;
@@ -4608,19 +4611,17 @@ void SpatialEditor::_init_grid() {
Vector3 axis_n2;
axis_n2[(i + 2) % 3] = 1;
-#define ORIGIN_GRID_SIZE 50
-
- for (int j = -ORIGIN_GRID_SIZE; j <= ORIGIN_GRID_SIZE; j++) {
- Vector3 p1 = axis_n1 * j + axis_n2 * -ORIGIN_GRID_SIZE;
+ for (int j = -grid_size; j <= grid_size; j++) {
+ Vector3 p1 = axis_n1 * j + axis_n2 * -grid_size;
Vector3 p1_dest = p1 * (-axis_n2 + axis_n1);
- Vector3 p2 = axis_n2 * j + axis_n1 * -ORIGIN_GRID_SIZE;
+ Vector3 p2 = axis_n2 * j + axis_n1 * -grid_size;
Vector3 p2_dest = p2 * (-axis_n1 + axis_n2);
- Color line_color = grid_color;
+ Color line_color = secondary_grid_color;
if (j == 0) {
continue;
- } else if (j % 10 == 0) {
- line_color *= 1.5;
+ } else if (j % primary_grid_steps == 0) {
+ line_color = primary_grid_color;
}
grid_points[i].push_back(p1);
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index 8b8c756219..9f87fc82b5 100644
--- a/editor/project_export.cpp
+++ b/editor/project_export.cpp
@@ -81,7 +81,14 @@ void ProjectExportDialog::popup_export() {
if (EditorSettings::get_singleton()->has_setting("interface/dialogs/export_bounds")) {
popup(EditorSettings::get_singleton()->get("interface/dialogs/export_bounds"));
} else {
- popup_centered_ratio();
+
+ Size2 popup_size = Size2(900, 700) * editor_get_scale();
+ Size2 window_size = get_viewport_rect().size;
+
+ popup_size.x = MIN(window_size.x * 0.8, popup_size.x);
+ popup_size.y = MIN(window_size.y * 0.8, popup_size.y);
+
+ popup_centered(popup_size);
}
}
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 21f5e596be..a4265b4e32 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -768,7 +768,14 @@ void ProjectSettingsEditor::popup_project_settings() {
if (EditorSettings::get_singleton()->has_setting("interface/dialogs/project_settings_bounds")) {
popup(EditorSettings::get_singleton()->get("interface/dialogs/project_settings_bounds"));
} else {
- popup_centered_ratio();
+
+ Size2 popup_size = Size2(900, 700) * editor_get_scale();
+ Size2 window_size = get_viewport_rect().size;
+
+ popup_size.x = MIN(window_size.x * 0.8, popup_size.x);
+ popup_size.y = MIN(window_size.y * 0.8, popup_size.y);
+
+ popup_centered(popup_size);
}
globals_editor->update_category_list();
_update_translations();
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 38027a34a7..ba661813d6 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -107,7 +107,12 @@ void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) {
void SceneTreeDock::instance(const String &p_file) {
Node *parent = scene_tree->get_selected();
- if (!parent || !edited_scene) {
+
+ if (!parent) {
+ Node *parent = edited_scene;
+ };
+
+ if (!edited_scene) {
current_option = -1;
accept->get_ok()->set_text(TTR("OK :("));
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp
index f50f9f6f5f..c3e9e4ab62 100644
--- a/editor/settings_config_dialog.cpp
+++ b/editor/settings_config_dialog.cpp
@@ -101,7 +101,14 @@ void EditorSettingsDialog::popup_edit_settings() {
if (EditorSettings::get_singleton()->has_setting("interface/dialogs/editor_settings_bounds")) {
popup(EditorSettings::get_singleton()->get("interface/dialogs/editor_settings_bounds"));
} else {
- popup_centered_ratio(0.7);
+
+ Size2 popup_size = Size2(900, 700) * editor_get_scale();
+ Size2 window_size = get_viewport_rect().size;
+
+ popup_size.x = MIN(window_size.x * 0.8, popup_size.x);
+ popup_size.y = MIN(window_size.y * 0.8, popup_size.y);
+
+ popup_centered(popup_size);
}
_focus_current_search_box();