Merge pull request #40033 from hinlopen/create-dialog-search

Improve Create Dialog search ranking and rewrite calculation
This commit is contained in:
Rémi Verschelde 2020-07-04 15:52:20 +02:00 committed by GitHub
commit 597b268150
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 433 additions and 533 deletions

File diff suppressed because it is too large Load Diff

View File

@ -35,60 +35,65 @@
#include "scene/gui/button.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/item_list.h"
#include "scene/gui/label.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/tree.h"
class CreateDialog : public ConfirmationDialog {
GDCLASS(CreateDialog, ConfirmationDialog);
Vector<String> favorite_list;
Tree *favorites;
Tree *recent;
Button *favorite;
LineEdit *search_box;
Tree *search_options;
HashMap<String, TreeItem *> search_options_types;
HashMap<String, RES> search_loaded_scripts;
bool is_replace_mode;
String base_type;
String icon_fallback;
String preferred_search_result_type;
Button *favorite;
Vector<String> favorite_list;
Tree *favorites;
ItemList *recent;
EditorHelpBit *help_bit;
HashMap<String, TreeItem *> search_options_types;
HashMap<String, String> custom_type_parents;
HashMap<String, int> custom_type_indices;
List<StringName> type_list;
Set<StringName> type_blacklist;
void _update_search();
bool _should_hide_type(const String &p_type) const;
void _add_type(const String &p_current, bool p_cpp_type);
void _configure_search_option_item(TreeItem *r_item, const String &p_type, const bool p_cpp_type);
String _top_result(const Vector<String> p_candidates, const String &p_search_text) const;
float _score_type(const String &p_type, const String &p_search) const;
bool _is_type_preferred(const String &p_type) const;
void _fill_type_list();
void _cleanup();
void _sbox_input(const Ref<InputEvent> &p_ie);
void _text_changed(const String &p_newtext);
void select_type(const String &p_type);
void _item_selected();
void _hide_requested();
void _update_search();
void _update_favorite_list();
void _save_favorite_list();
void _confirmed();
virtual void cancel_pressed();
void _favorite_toggled();
void _history_selected();
void _history_selected(int p_idx);
void _favorite_selected();
void _history_activated();
void _history_activated(int p_idx);
void _favorite_activated();
void _sbox_input(const Ref<InputEvent> &p_ie);
void _confirmed();
void _text_changed(const String &p_newtext);
Ref<Texture2D> _get_editor_icon(const String &p_type) const;
void add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root, TreeItem **to_select);
void select_type(const String &p_type);
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
bool _is_class_disabled_by_feature_profile(const StringName &p_class);
bool _is_type_prefered(const String &type);
bool _is_class_disabled_by_feature_profile(const StringName &p_class) const;
void _load_favorites_and_history();
protected:
void _notification(int p_what);
@ -100,11 +105,11 @@ public:
Object *instance_selected();
String get_selected_type();
void set_base_type(const String &p_base);
String get_base_type() const;
void set_base_type(const String &p_base) { base_type = p_base; }
String get_base_type() const { return base_type; }
void set_preferred_search_result_type(const String &p_preferred_type);
String get_preferred_search_result_type();
void set_preferred_search_result_type(const String &p_preferred_type) { preferred_search_result_type = p_preferred_type; }
String get_preferred_search_result_type() { return preferred_search_result_type; }
void popup_create(bool p_dont_clear, bool p_replace_mode = false, const String &p_select_type = "Node");