Compare commits

..

2 Commits

Author SHA1 Message Date
monxa 72b588af8f
Merge 5ebb36077a into 760af804c0 2024-10-04 14:56:06 +00:00
Alexander Montag 5ebb36077a
Implement Tree Search Functionality with Highlighting and Filtering
This commit introduces a comprehensive Tree Search feature, including:
- Tree highlighting: Highlights items that match the search query.
- Counting descendants: Shows the number of matching items within collapsed branches.
- Jump to next match: on enter.
- (Limbo-)Shortcut: Default CTRL-F.
- Menu entry: Misc->Search Tree.
- Remember separate SearchInfo for each tab.

Key implementation details:
- Optimized performance for large trees
- Implemented recursive filtering for efficiency
- Added UI elements including next/previous match buttons

Development History:
- Initial implementation of highlighting and filtering
- Multiple rounds of performance optimization
- Bug fixes and refactoring for correctness
- UI enhancements and polish
- Code cleanup and style improvements
2024-10-04 16:55:53 +02:00
1 changed files with 4 additions and 7 deletions

View File

@ -238,18 +238,14 @@ void TreeSearch::_update_ordered_tree_items(TreeItem *p_tree_item) {
void TreeSearch::_update_number_matches() {
ERR_FAIL_COND(!tree_reference);
number_matches.clear();
number_matches.reserve(ordered_tree_items.size());
TreeItem * tree_root = tree_reference->get_root();
if (!tree_root){
return;
}
_update_number_matches(tree_reference->get_root());
}
void TreeSearch::_update_number_matches(TreeItem *item) {
ERR_FAIL_COND(!item);
for (int i = 0; i < item->get_child_count(); i++) {
TreeItem *child = item->get_child(i);
_update_number_matches(child);
@ -268,7 +264,7 @@ void TreeSearch::_update_number_matches(TreeItem *item) {
}
String TreeSearch::_get_search_mask() const {
ERR_FAIL_COND(!search_panel);
ERR_FAIL_COND_V(!search_panel, "");
return search_panel->get_text();
}
@ -528,6 +524,7 @@ void TreeSearchPanel::_initialize_controls() {
find_next_button->set_theme_type_variation(LW_NAME(FlatButton));
find_prev_button->set_theme_type_variation(LW_NAME(FlatButton));
close_button->set_tooltip_text("Hide");
find_next_button->set_tooltip_text("Next Match");
find_prev_button->set_tooltip_text("Previous Match");
@ -562,7 +559,7 @@ void TreeSearchPanel::_notification(int p_what) {
// Close callbacks
close_button->connect(LW_NAME(pressed), Callable(this, LW_NAME(set_visible)).bind(false));
close_button->connect(LW_NAME(pressed), Callable(this, LW_NAME(emit_signal)).bind(LW_NAME(Close)));
close_button->set_shortcut(LW_GET_SHORTCUT("limbo_ai/hide_tree_search")); // TODO: use internal shortcut. also sets tooltip...
close_button->set_shortcut(LW_GET_SHORTCUT("limbo_ai/hide_tree_search")); // TODO: use internal shortcut.
// Search callbacks
Callable c_update_requested = Callable(this, LW_NAME(emit_signal)).bind("update_requested");
Callable c_text_submitted = Callable(this, LW_NAME(emit_signal)).bind(LW_NAME(text_submitted));