summaryrefslogtreecommitdiff
path: root/tools/editor/quick_open.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor/quick_open.cpp')
-rw-r--r--tools/editor/quick_open.cpp76
1 files changed, 62 insertions, 14 deletions
diff --git a/tools/editor/quick_open.cpp b/tools/editor/quick_open.cpp
index 6135a4ab64..828275340b 100644
--- a/tools/editor/quick_open.cpp
+++ b/tools/editor/quick_open.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,7 +30,7 @@
#include "os/keyboard.h"
-void EditorQuickOpen::popup(const StringName &p_base, bool p_dontclear, bool p_add_dirs) {
+void EditorQuickOpen::popup(const StringName &p_base, bool p_enable_multi, bool p_add_dirs, bool p_dontclear) {
add_directories=p_add_dirs;
popup_centered_ratio(0.6);
@@ -38,13 +38,38 @@ void EditorQuickOpen::popup(const StringName &p_base, bool p_dontclear, bool p_a
search_box->select_all();
else
search_box->clear();
+ if (p_enable_multi)
+ search_options->set_select_mode(Tree::SELECT_MULTI);
+ else
+ search_options->set_select_mode(Tree::SELECT_SINGLE);
search_box->grab_focus();
base_type=p_base;
_update_search();
+}
+
+String EditorQuickOpen::get_selected() const {
+ TreeItem *ti = search_options->get_selected();
+ if (!ti)
+ return String();
+ return "res://" + ti->get_text(0);
}
+Vector<String> EditorQuickOpen::get_selected_files() const {
+
+ Vector<String> files;
+
+ TreeItem* item = search_options->get_next_selected(search_options->get_root());
+ while (item) {
+
+ files.push_back("res://"+item->get_text(0));
+
+ item = search_options->get_next_selected(item);
+ }
+
+ return files;
+}
void EditorQuickOpen::_text_changed(const String& p_newtext) {
@@ -53,14 +78,33 @@ void EditorQuickOpen::_text_changed(const String& p_newtext) {
void EditorQuickOpen::_sbox_input(const InputEvent& p_ie) {
- if (p_ie.type==InputEvent::KEY && (
- p_ie.key.scancode == KEY_UP ||
- p_ie.key.scancode == KEY_DOWN ||
- p_ie.key.scancode == KEY_PAGEUP ||
- p_ie.key.scancode == KEY_PAGEDOWN ) ) {
+ if (p_ie.type==InputEvent::KEY) {
- search_options->call("_input_event",p_ie);
- search_box->accept_event();
+ switch(p_ie.key.scancode) {
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_PAGEUP:
+ case KEY_PAGEDOWN: {
+
+ search_options->call("_input_event", p_ie);
+ search_box->accept_event();
+
+ TreeItem *root = search_options->get_root();
+ if (!root->get_children())
+ break;
+
+ TreeItem *current = search_options->get_selected();
+
+ TreeItem *item = search_options->get_next_selected(root);
+ while (item) {
+ item->deselect(0);
+ item = search_options->get_next_selected(item);
+ }
+
+ current->select(0);
+
+ } break;
+ }
}
}
@@ -100,9 +144,6 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) {
ti->set_text(0,file);
Ref<Texture> icon = get_icon( (has_icon(efsd->get_file_type(i),ei)?efsd->get_file_type(i):ot),ei);
ti->set_icon(0,icon);
- if (root->get_children()==ti)
- ti->select(0);
-
}
}
@@ -123,6 +164,13 @@ void EditorQuickOpen::_update_search() {
TreeItem *root = search_options->create_item();
_parse_fs(EditorFileSystem::get_singleton()->get_filesystem());
+ if (root->get_children()) {
+ TreeItem *ti = root->get_children();
+
+ ti->select(0);
+ ti->set_as_cursor(0);
+ }
+
get_ok()->set_disabled(root->get_children()==NULL);
}
@@ -132,7 +180,7 @@ void EditorQuickOpen::_confirmed() {
TreeItem *ti = search_options->get_selected();
if (!ti)
return;
- emit_signal("quick_open","res://"+ti->get_text(0));
+ emit_signal("quick_open");
hide();
}
@@ -156,7 +204,7 @@ void EditorQuickOpen::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_confirmed"),&EditorQuickOpen::_confirmed);
ObjectTypeDB::bind_method(_MD("_sbox_input"),&EditorQuickOpen::_sbox_input);
- ADD_SIGNAL(MethodInfo("quick_open",PropertyInfo(Variant::STRING,"respath")));
+ ADD_SIGNAL(MethodInfo("quick_open"));
}