From 329e90dfc66e12a0323418cf9ea4d7471eabcc44 Mon Sep 17 00:00:00 2001 From: Alexander Montag Date: Sat, 28 Sep 2024 15:45:52 +0000 Subject: [PATCH] Rename TreeSearch::notify_item_edited Also: Run clang-format. Remove comment. --- editor/task_tree.cpp | 4 +--- editor/tree_search.cpp | 7 +++---- editor/tree_search.h | 11 ++++++----- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/editor/task_tree.cpp b/editor/task_tree.cpp index 31f0fe8..7a4c5bc 100644 --- a/editor/task_tree.cpp +++ b/editor/task_tree.cpp @@ -112,7 +112,7 @@ void TaskTree::_update_item(TreeItem *p_item) { if (!warning_text.is_empty()) { p_item->add_button(0, theme_cache.task_warning_icon, 0, false, warning_text); } - tree_search->on_item_edited(p_item); // this is necessary to preserve custom drawing from tree search. + tree_search->notify_item_edited(p_item); // this is necessary to preserve custom drawing from tree search. } void TaskTree::_update_tree() { @@ -582,8 +582,6 @@ TaskTree::TaskTree() { editable = true; updating_tree = false; - // for Tree + TreeSearch, we want a VBoxContainer. For now, rather than changing this classes type, let's do nesting: - // TaskTree -> VBoxContainer -> [Tree, TreeSearchPanel] VBoxContainer *vbox_container = memnew(VBoxContainer); add_child(vbox_container); vbox_container->set_anchors_preset(PRESET_FULL_RECT); diff --git a/editor/tree_search.cpp b/editor/tree_search.cpp index ec19741..0711272 100644 --- a/editor/tree_search.cpp +++ b/editor/tree_search.cpp @@ -200,7 +200,7 @@ void TreeSearch::_highlight_tree(const String &p_search_mask) { // custom draw callback for highlighting (bind the parent_drw_method to this) void TreeSearch::_draw_highlight_item(TreeItem *p_tree_item, Rect2 p_rect, Callable p_parent_draw_method) { - if (!p_tree_item){ + if (!p_tree_item) { return; } // call any parent draw methods such as for probability FIRST. @@ -326,7 +326,7 @@ Vector TreeSearch::_find_matching_entries(TreeItem *p_tree_item, con TreeItem *child = p_tree_item->get_child(i); _find_matching_entries(child, p_search_mask, p_accum); } - + // sort the result if we are at the root if (p_tree_item == p_tree_item->get_tree()->get_root()) { p_accum.sort(); @@ -448,7 +448,7 @@ inline bool TreeSearch::_vector_has_bsearch(Vector p_vec, T *element) { return in_array && p_vec[idx] == element; } -void TreeSearch::on_item_edited(TreeItem *item) { +void TreeSearch::notify_item_edited(TreeItem *item) { if (item->get_cell_mode(0) != TreeItem::CELL_MODE_CUSTOM) { return; } @@ -486,7 +486,6 @@ void TreeSearch::update_search(Tree *p_tree) { if (search_mode == TreeSearchMode::FILTER) { _filter_tree(search_mask); } - } TreeSearch::TreeSearch(TreeSearchPanel *p_search_panel) { diff --git a/editor/tree_search.h b/editor/tree_search.h index 830c36c..a1c8259 100644 --- a/editor/tree_search.h +++ b/editor/tree_search.h @@ -24,12 +24,12 @@ #endif // LIMBOAI_GDEXTENSION #ifdef LIMBOAI_MODULE +#include "core/templates/hash_map.h" #include "scene/gui/check_box.h" #include "scene/gui/flow_container.h" #include "scene/gui/label.h" #include "scene/gui/line_edit.h" #include "scene/gui/tree.h" -#include "core/templates/hash_map.h" #endif // LIMBOAI_MODULE using namespace godot; @@ -41,6 +41,7 @@ enum TreeSearchMode { class TreeSearchPanel : public HFlowContainer { GDCLASS(TreeSearchPanel, HFlowContainer) + private: Button *toggle_button_filter_highlight; Button *close_button; @@ -95,7 +96,7 @@ private: // Custom draw-Callback (bind inherited Callable). void _draw_highlight_item(TreeItem *p_tree_item, Rect2 p_rect, Callable p_parent_draw_method); - + void _update_matching_entries(const String &p_search_mask); void _update_ordered_tree_items(TreeItem *p_tree_item); void _update_number_matches(); @@ -116,10 +117,10 @@ protected: public: void update_search(Tree *p_tree); - void on_item_edited(TreeItem *p_item); + void notify_item_edited(TreeItem *p_item); - TreeSearch(){ERR_FAIL_MSG("TreeSearch needs a TreeSearchPanel to work properly");} - TreeSearch(TreeSearchPanel * p_search_panel); + TreeSearch() { ERR_FAIL_MSG("TreeSearch needs a TreeSearchPanel to work properly"); } + TreeSearch(TreeSearchPanel *p_search_panel); }; #endif // TREE_SEARCH_H