summaryrefslogtreecommitdiff
path: root/editor/groups_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/groups_editor.cpp')
-rw-r--r--editor/groups_editor.cpp46
1 files changed, 30 insertions, 16 deletions
diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp
index c65d4e9e3b..1644bb9dbe 100644
--- a/editor/groups_editor.cpp
+++ b/editor/groups_editor.cpp
@@ -71,13 +71,13 @@ void GroupDialog::_load_nodes(Node *p_current) {
TreeItem *node = nullptr;
NodePath path = scene_tree->get_edited_scene_root()->get_path_to(p_current);
if (keep && p_current->is_in_group(selected_group)) {
- if (remove_filter->get_text().is_subsequence_ofi(String(p_current->get_name()))) {
+ if (remove_filter->get_text().is_subsequence_ofn(String(p_current->get_name()))) {
node = nodes_to_remove->create_item(remove_node_root);
keep = true;
} else {
keep = false;
}
- } else if (keep && add_filter->get_text().is_subsequence_ofi(String(p_current->get_name()))) {
+ } else if (keep && add_filter->get_text().is_subsequence_ofn(String(p_current->get_name()))) {
node = nodes_to_add->create_item(add_node_root);
keep = true;
} else {
@@ -144,8 +144,8 @@ void GroupDialog::_add_pressed() {
undo_redo->add_undo_method(this, "emit_signal", "group_edited");
// To force redraw of scene 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->add_do_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");
+ undo_redo->add_undo_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");
undo_redo->commit_action();
}
@@ -173,8 +173,8 @@ void GroupDialog::_removed_pressed() {
undo_redo->add_undo_method(this, "emit_signal", "group_edited");
// To force redraw of scene 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->add_do_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");
+ undo_redo->add_undo_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");
undo_redo->commit_action();
}
@@ -211,6 +211,10 @@ void GroupDialog::_add_group(String p_name) {
groups->ensure_cursor_is_visible();
}
+void GroupDialog::_add_group_text_changed(const String &p_new_text) {
+ add_group_button->set_disabled(p_new_text.strip_edges().is_empty());
+}
+
void GroupDialog::_group_renamed() {
TreeItem *renamed_group = groups->get_edited();
if (!renamed_group) {
@@ -333,8 +337,8 @@ void GroupDialog::_modify_group_pressed(Object *p_item, int p_column, int p_id)
undo_redo->add_undo_method(this, "emit_signal", "group_edited");
// To force redraw of scene 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->add_do_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");
+ undo_redo->add_undo_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");
undo_redo->commit_action();
} break;
@@ -370,7 +374,8 @@ void GroupDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_TRANSLATION_CHANGED:
case Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
- case NOTIFICATION_ENTER_TREE: {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
if (is_layout_rtl()) {
add_button->set_icon(groups->get_theme_icon(SNAME("Back"), SNAME("EditorIcons")));
remove_button->set_icon(groups->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")));
@@ -456,8 +461,9 @@ GroupDialog::GroupDialog() {
chbc->add_child(add_group_text);
add_group_text->set_h_size_flags(Control::SIZE_EXPAND_FILL);
add_group_text->connect("text_submitted", callable_mp(this, &GroupDialog::_add_group_pressed));
+ add_group_text->connect("text_changed", callable_mp(this, &GroupDialog::_add_group_text_changed));
- Button *add_group_button = memnew(Button);
+ add_group_button = memnew(Button);
add_group_button->set_text(TTR("Add"));
chbc->add_child(add_group_button);
add_group_button->connect("pressed", callable_mp(this, &GroupDialog::_add_group_pressed), varray(String()));
@@ -556,6 +562,8 @@ GroupDialog::GroupDialog() {
error = memnew(ConfirmationDialog);
add_child(error);
error->get_ok_button()->set_text(TTR("Close"));
+
+ _add_group_text_changed("");
}
////////////////////////////////////////////////////////////////////////////////
@@ -570,6 +578,7 @@ void GroupsEditor::_add_group(const String &p_group) {
return;
}
+ group_name->clear();
if (node->is_in_group(name)) {
return;
}
@@ -582,12 +591,10 @@ void GroupsEditor::_add_group(const String &p_group) {
undo_redo->add_undo_method(this, "update_tree");
// To force redraw of scene 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->add_do_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");
+ undo_redo->add_undo_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");
undo_redo->commit_action();
-
- group_name->clear();
}
void GroupsEditor::_modify_group(Object *p_item, int p_column, int p_id) {
@@ -610,8 +617,8 @@ void GroupsEditor::_modify_group(Object *p_item, int p_column, int p_id) {
undo_redo->add_undo_method(this, "update_tree");
// To force redraw of scene 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->add_do_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");
+ undo_redo->add_undo_method(SceneTreeDock::get_singleton()->get_tree_editor(), "update_tree");
undo_redo->commit_action();
} break;
@@ -621,6 +628,10 @@ void GroupsEditor::_modify_group(Object *p_item, int p_column, int p_id) {
}
}
+void GroupsEditor::_group_name_changed(const String &p_new_text) {
+ add->set_disabled(p_new_text.strip_edges().is_empty());
+}
+
struct _GroupInfoComparator {
bool operator()(const Node::GroupInfo &p_a, const Node::GroupInfo &p_b) const {
return p_a.name.operator String() < p_b.name.operator String();
@@ -710,6 +721,7 @@ GroupsEditor::GroupsEditor() {
group_name->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hbc->add_child(group_name);
group_name->connect("text_submitted", callable_mp(this, &GroupsEditor::_add_group));
+ group_name->connect("text_changed", callable_mp(this, &GroupsEditor::_group_name_changed));
add = memnew(Button);
add->set_text(TTR("Add"));
@@ -723,6 +735,8 @@ GroupsEditor::GroupsEditor() {
tree->connect("button_pressed", callable_mp(this, &GroupsEditor::_modify_group));
tree->add_theme_constant_override("draw_guides", 1);
add_theme_constant_override("separation", 3 * EDSCALE);
+
+ _group_name_changed("");
}
GroupsEditor::~GroupsEditor() {