summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-11-20 09:12:14 +0100
committerGitHub <noreply@github.com>2017-11-20 09:12:14 +0100
commit3dad0ce8f4815165966751705a07fae6e6e2b796 (patch)
treedb67f749b569777544590d4b3e542a1110cac433 /editor
parent7b5c44730176a17f179a49dde4fbf119e4652221 (diff)
parent13b07fef8167459a6074759bc989c9380aa05eae (diff)
Merge pull request #12942 from sersoong/master-test
3.0 - add open feture to dependency_editor.cpp(View Owner..)
Diffstat (limited to 'editor')
-rw-r--r--editor/dependency_editor.cpp53
-rw-r--r--editor/dependency_editor.h16
-rw-r--r--editor/filesystem_dock.cpp2
3 files changed, 68 insertions, 3 deletions
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index 29e2423e9b..ec0ca3add5 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -281,6 +281,47 @@ DependencyEditor::DependencyEditor() {
}
/////////////////////////////////////
+void DependencyEditorOwners::_list_rmb_select(int p_item, const Vector2 &p_pos) {
+
+ file_options->clear();
+ file_options->set_size(Size2(1, 1));
+ if (p_item >= 0) {
+ file_options->add_item(TTR("Open"), FILE_OPEN);
+ }
+
+ file_options->set_position(owners->get_global_position() + p_pos);
+ file_options->popup();
+}
+
+void DependencyEditorOwners::_select_file(int p_idx) {
+
+ String fpath = owners->get_item_text(p_idx);
+
+ if (ResourceLoader::get_resource_type(fpath) == "PackedScene") {
+ editor->open_request(fpath);
+ hide();
+ emit_signal("confirmed");
+ }
+}
+
+void DependencyEditorOwners::_file_option(int p_option) {
+
+ switch (p_option) {
+ case FILE_OPEN: {
+ int idx = owners->get_current();
+ if (idx < 0 || idx >= owners->get_item_count())
+ break;
+ _select_file(idx);
+ } break;
+ }
+}
+
+void DependencyEditorOwners::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("_list_rmb_select"), &DependencyEditorOwners::_list_rmb_select);
+ ClassDB::bind_method(D_METHOD("_file_option"), &DependencyEditorOwners::_file_option);
+ ClassDB::bind_method(D_METHOD("_select_file"), &DependencyEditorOwners::_select_file);
+}
void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) {
@@ -329,9 +370,19 @@ void DependencyEditorOwners::show(const String &p_path) {
set_title(TTR("Owners Of:") + " " + p_path.get_file());
}
-DependencyEditorOwners::DependencyEditorOwners() {
+DependencyEditorOwners::DependencyEditorOwners(EditorNode *p_editor) {
+
+ editor = p_editor;
+
+ file_options = memnew(PopupMenu);
+ add_child(file_options);
+ file_options->connect("id_pressed", this, "_file_option");
owners = memnew(ItemList);
+ owners->set_select_mode(ItemList::SELECT_SINGLE);
+ owners->connect("item_rmb_selected", this, "_list_rmb_select");
+ owners->connect("item_activated", this, "_select_file");
+ owners->set_allow_rmb_select(true);
add_child(owners);
}
diff --git a/editor/dependency_editor.h b/editor/dependency_editor.h
index c7e9baa5c2..9b0aca67d5 100644
--- a/editor/dependency_editor.h
+++ b/editor/dependency_editor.h
@@ -36,6 +36,7 @@
#include "scene/gui/tree.h"
class EditorFileSystemDirectory;
+class EditorNode;
class DependencyEditor : public AcceptDialog {
GDCLASS(DependencyEditor, AcceptDialog);
@@ -71,12 +72,25 @@ class DependencyEditorOwners : public AcceptDialog {
GDCLASS(DependencyEditorOwners, AcceptDialog);
ItemList *owners;
+ PopupMenu *file_options;
+ EditorNode *editor;
String editing;
+
void _fill_owners(EditorFileSystemDirectory *efsd);
+ static void _bind_methods();
+ void _list_rmb_select(int p_item, const Vector2 &p_pos);
+ void _select_file(int p_idx);
+ void _file_option(int p_option);
+
+private:
+ enum FileMenu {
+ FILE_OPEN
+ };
+
public:
void show(const String &p_path);
- DependencyEditorOwners();
+ DependencyEditorOwners(EditorNode *p_editor);
};
class DependencyRemoveDialog : public ConfirmationDialog {
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 533401b317..eea8177687 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -1683,7 +1683,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
deps_editor = memnew(DependencyEditor);
add_child(deps_editor);
- owners_editor = memnew(DependencyEditorOwners);
+ owners_editor = memnew(DependencyEditorOwners(editor));
add_child(owners_editor);
remove_dialog = memnew(DependencyRemoveDialog);