Clean up TreeSearch: Consistent p_params, -Destructor

This commit is contained in:
Alexander Montag 2024-09-26 05:28:59 +00:00
parent 8d29f16963
commit 1145ce0252
2 changed files with 26 additions and 26 deletions

View File

@ -173,7 +173,6 @@ void TreeSearch::_highlight_tree(const String &p_search_mask) {
int num_m = number_matches.has(entry) ? number_matches.get(entry) : 0; int num_m = number_matches.has(entry) ? number_matches.get(entry) : 0;
if (num_m == 0) { if (num_m == 0) {
continue; continue;
;
} }
// make sure to also call any draw method already defined. // make sure to also call any draw method already defined.
@ -217,7 +216,7 @@ void TreeSearch::_draw_highlight_item(TreeItem *p_tree_item, Rect2 p_rect, Strin
font = p_tree_item->get_tree()->get_theme_font(LW_NAME(font)); font = p_tree_item->get_tree()->get_theme_font(LW_NAME(font));
} }
ERR_FAIL_NULL(font); ERR_FAIL_NULL(font);
double font_size = p_tree_item->get_custom_font_size(0); float font_size = p_tree_item->get_custom_font_size(0);
if (font_size == -1) { if (font_size == -1) {
font_size = p_tree_item->get_tree()->get_theme_font_size(LW_NAME(font)); font_size = p_tree_item->get_tree()->get_theme_font_size(LW_NAME(font));
} }
@ -273,9 +272,9 @@ void TreeSearch::_draw_highlight_item(TreeItem *p_tree_item, Rect2 p_rect, Strin
} }
} }
void TreeSearch::_update_matching_entries(const String &search_mask) { void TreeSearch::_update_matching_entries(const String &p_search_mask) {
Vector<TreeItem *> accum; Vector<TreeItem *> accum;
matching_entries = _find_matching_entries(tree_reference->get_root(), search_mask, accum); matching_entries = _find_matching_entries(tree_reference->get_root(), p_search_mask, accum);
} }
/* this linearizes the tree into [ordered_tree_items] like so: /* this linearizes the tree into [ordered_tree_items] like so:
@ -367,16 +366,21 @@ TreeSearch::StringSearchIndices TreeSearch::_substring_bounds(const String &p_se
return result; return result;
} }
void TreeSearch::_select_item(TreeItem *item) { void TreeSearch::_select_item(TreeItem *p_item) {
if (!item) if (!p_item)
return; return;
tree_reference->set_selected(item, 0); tree_reference->set_selected(p_item, 0);
tree_reference->scroll_to_item(item);
item = item->get_parent(); // first unfold ancestors
while (item) { TreeItem * ancestor = p_item->get_parent();
item->set_collapsed(false); ancestor = ancestor->get_parent();
item = item->get_parent(); while (ancestor) {
ancestor->set_collapsed(false);
ancestor = ancestor->get_parent();
} }
// then scroll to [item]
tree_reference->scroll_to_item(p_item);
} }
void TreeSearch::_select_first_match() { void TreeSearch::_select_first_match() {
@ -477,9 +481,6 @@ TreeSearch::TreeSearch() {
search_panel = memnew(TreeSearchPanel); search_panel = memnew(TreeSearchPanel);
} }
TreeSearch::~TreeSearch() {
}
/* !TreeSearch */ /* !TreeSearch */
#endif // TOOLS_ENABLED #endif // TOOLS_ENABLED

View File

@ -52,8 +52,8 @@ private:
void _initialize_close_callbacks(); void _initialize_close_callbacks();
void _add_spacer(float width_multiplier = 1.f); void _add_spacer(float width_multiplier = 1.f);
void _on_draw_highlight(TreeItem *item, Rect2 rect); void _on_draw_highlight(TreeItem *p_item, Rect2 p_rect);
void _emit_text_changed(const String &text); void _emit_text_changed(const String &p_text);
void _emit_text_submitted(const String &p_text); void _emit_text_submitted(const String &p_text);
void _emit_filter_toggled(); void _emit_filter_toggled();
void _notification(int p_what); void _notification(int p_what);
@ -91,16 +91,16 @@ private:
void _filter_tree(const String &p_search_mask); void _filter_tree(const String &p_search_mask);
void _highlight_tree(const String &p_search_mask); void _highlight_tree(const String &p_search_mask);
void _draw_highlight_item(TreeItem *tree_item, Rect2 rect, String search_mask, Callable parent_draw_method); void _draw_highlight_item(TreeItem *p_tree_item, Rect2 p_rect, String p_search_mask, Callable p_parent_draw_method);
void _update_matching_entries(const String &search_mask); void _update_matching_entries(const String &p_search_mask);
void _update_ordered_tree_items(TreeItem *tree_item); void _update_ordered_tree_items(TreeItem *p_tree_item);
void _update_number_matches(); void _update_number_matches();
Vector<TreeItem *> _find_matching_entries(TreeItem *tree_item, const String &search_mask, Vector<TreeItem *> &buffer); Vector<TreeItem *> _find_matching_entries(TreeItem *p_tree_item, const String &p_search_mask, Vector<TreeItem *> &p_buffer);
StringSearchIndices _substring_bounds(const String &searchable, const String &search_mask) const; StringSearchIndices _substring_bounds(const String &p_searchable, const String &p_search_mask) const;
void _select_item(TreeItem *item); void _select_item(TreeItem *p_item);
void _select_first_match(); void _select_first_match();
void _select_next_match(); void _select_next_match();
@ -111,12 +111,11 @@ protected:
public: public:
// we will add everything from TaskTree.h // we will add everything from TaskTree.h
void update_search(Tree *tree); void update_search(Tree *p_tree);
void on_item_edited(TreeItem *item); void on_item_edited(TreeItem *p_item);
TreeSearchPanel *search_panel; TreeSearchPanel *search_panel;
TreeSearch(); TreeSearch();
~TreeSearch();
}; };
#endif // TREE_SEARCH_H #endif // TREE_SEARCH_H