Unify highlight and filter, simplify ui

This commit is contained in:
Alexander Montag 2024-09-25 17:03:46 +00:00
parent 18a6bbeae6
commit 8c323956e3
2 changed files with 12 additions and 17 deletions

View File

@ -43,14 +43,12 @@
void TreeSearchPanel::_initialize_controls() { void TreeSearchPanel::_initialize_controls() {
line_edit_search = memnew(LineEdit); line_edit_search = memnew(LineEdit);
check_button_filter_highlight = memnew(CheckButton); check_button_filter_highlight = memnew(CheckBox);
close_button = memnew(Button); close_button = memnew(Button);
label_highlight = memnew(Label);
label_filter = memnew(Label); label_filter = memnew(Label);
line_edit_search->set_placeholder(TTR("Search tree")); line_edit_search->set_placeholder(TTR("Search tree"));
label_highlight->set_text(TTR("Highlight"));
label_filter->set_text(TTR("Filter")); label_filter->set_text(TTR("Filter"));
BUTTON_SET_ICON(close_button, get_theme_icon(LW_NAME(Close), LW_NAME(EditorIcons))); BUTTON_SET_ICON(close_button, get_theme_icon(LW_NAME(Close), LW_NAME(EditorIcons)));
@ -65,10 +63,9 @@ void TreeSearchPanel::_initialize_controls() {
_add_spacer(0.25); // otherwise the lineedits expand margin touches the left border. _add_spacer(0.25); // otherwise the lineedits expand margin touches the left border.
add_child(line_edit_search); add_child(line_edit_search);
_add_spacer();
add_child(label_highlight);
add_child(check_button_filter_highlight); add_child(check_button_filter_highlight);
add_child(label_filter); add_child(label_filter);
_add_spacer();
add_child(close_button); add_child(close_button);
_add_spacer(0.25); _add_spacer(0.25);
} }
@ -467,12 +464,11 @@ void TreeSearch::update_search(Tree *p_tree) {
_update_matching_entries(search_mask); _update_matching_entries(search_mask);
_update_number_matches(); _update_number_matches();
if (search_mode == TreeSearchMode::HIGHLIGHT) {
_highlight_tree(search_mask); _highlight_tree(search_mask);
if (!search_panel->is_connected("text_submitted", callable_mp(this, &TreeSearch::_select_next_match))) { if (!search_panel->is_connected("text_submitted", callable_mp(this, &TreeSearch::_select_next_match))) {
search_panel->connect("text_submitted", callable_mp(this, &TreeSearch::_select_next_match)); search_panel->connect("text_submitted", callable_mp(this, &TreeSearch::_select_next_match));
} }
}
if (search_mode == TreeSearchMode::FILTER) { if (search_mode == TreeSearchMode::FILTER) {
_filter_tree(search_mask); _filter_tree(search_mask);
} }

View File

@ -17,7 +17,7 @@
#include "../bt/tasks/bt_task.h" // for tree item parsing #include "../bt/tasks/bt_task.h" // for tree item parsing
#ifdef LIMBOAI_GDEXTENSION #ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/check_button.hpp> #include <godot_cpp/classes/check_box.hpp>
#include <godot_cpp/classes/h_flow_container.hpp> #include <godot_cpp/classes/h_flow_container.hpp>
#include <godot_cpp/classes/label.hpp> #include <godot_cpp/classes/label.hpp>
#include <godot_cpp/classes/line_edit.hpp> #include <godot_cpp/classes/line_edit.hpp>
@ -26,7 +26,7 @@
#endif // LIMBOAI_GDEXTENSION #endif // LIMBOAI_GDEXTENSION
#ifdef LIMBOAI_MODULE #ifdef LIMBOAI_MODULE
#include "scene/gui/check_button.h" #include "scene/gui/check_box.h"
#include "scene/gui/flow_container.h" #include "scene/gui/flow_container.h"
#include "scene/gui/label.h" #include "scene/gui/label.h"
#include "scene/gui/line_edit.h" #include "scene/gui/line_edit.h"
@ -45,10 +45,9 @@ class TreeSearchPanel : public HFlowContainer {
private: private:
Button *toggle_button_filter_highlight; Button *toggle_button_filter_highlight;
Button *close_button; Button *close_button;
Label *label_highlight;
Label *label_filter; Label *label_filter;
LineEdit *line_edit_search; LineEdit *line_edit_search;
CheckButton *check_button_filter_highlight; CheckBox *check_button_filter_highlight;
void _initialize_controls(); void _initialize_controls();
void _initialize_close_callbacks(); void _initialize_close_callbacks();
void _add_spacer(float width_multiplier = 1.f); void _add_spacer(float width_multiplier = 1.f);