summaryrefslogtreecommitdiff
path: root/editor/quick_open.h
diff options
context:
space:
mode:
Diffstat (limited to 'editor/quick_open.h')
-rw-r--r--editor/quick_open.h38
1 files changed, 26 insertions, 12 deletions
diff --git a/editor/quick_open.h b/editor/quick_open.h
index e446ed6823..f1787d522b 100644
--- a/editor/quick_open.h
+++ b/editor/quick_open.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,28 +31,42 @@
#ifndef EDITOR_QUICK_OPEN_H
#define EDITOR_QUICK_OPEN_H
-#include "core/pair.h"
+#include "core/templates/oa_hash_map.h"
#include "editor_file_system.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/tree.h"
+
class EditorQuickOpen : public ConfirmationDialog {
GDCLASS(EditorQuickOpen, ConfirmationDialog);
LineEdit *search_box;
Tree *search_options;
StringName base_type;
- StringName ei;
- StringName ot;
- bool add_directories;
+ bool allow_multi_select;
- void _update_search();
+ Vector<String> files;
+ OAHashMap<String, Ref<Texture2D>> icons;
- void _sbox_input(const Ref<InputEvent> &p_ie);
- void _parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture2D>>> &list);
- Vector<Pair<String, Ref<Texture2D>>> _sort_fs(Vector<Pair<String, Ref<Texture2D>>> &list);
- float _path_cmp(String search, String path) const;
+ struct Entry {
+ String path;
+ float score = 0;
+ };
+
+ struct EntryComparator {
+ _FORCE_INLINE_ bool operator()(const Entry &A, const Entry &B) const {
+ return A.score > B.score;
+ }
+ };
+
+ void _update_search();
+ void _build_search_cache(EditorFileSystemDirectory *p_efsd);
+ float _score_path(const String &p_search, const String &p_path);
void _confirmed();
+ virtual void cancel_pressed() override;
+ void _cleanup();
+
+ void _sbox_input(const Ref<InputEvent> &p_ie);
void _text_changed(const String &p_newtext);
void _theme_changed();
@@ -67,7 +81,7 @@ public:
String get_selected() const;
Vector<String> get_selected_files() const;
- void popup_dialog(const StringName &p_base, bool p_enable_multi = false, bool p_add_dirs = false, bool p_dontclear = false);
+ void popup_dialog(const StringName &p_base, bool p_enable_multi = false, bool p_dontclear = false);
EditorQuickOpen();
};