Rename TreeSearch::notify_item_edited

Also: Run clang-format. Remove comment.
This commit is contained in:
Alexander Montag 2024-09-28 15:45:52 +00:00
parent 84b2a60521
commit 329e90dfc6
3 changed files with 10 additions and 12 deletions

View File

@ -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);

View File

@ -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<TreeItem *> 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<T *> 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) {

View File

@ -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