Make TreeSearchMode member of TreeSearch

This commit is contained in:
Alexander Montag 2024-09-28 17:58:42 +02:00
parent 329e90dfc6
commit 3b73f24f33
2 changed files with 38 additions and 36 deletions

View File

@ -118,11 +118,11 @@ bool TreeSearchPanel::has_focus() {
return false;
}
TreeSearchMode TreeSearchPanel::get_search_mode() {
TreeSearch::TreeSearchMode TreeSearchPanel::get_search_mode() {
if (!check_button_filter_highlight || !check_button_filter_highlight->is_pressed()) {
return TreeSearchMode::HIGHLIGHT;
return TreeSearch::TreeSearchMode::HIGHLIGHT;
}
return TreeSearchMode::FILTER;
return TreeSearch::TreeSearchMode::FILTER;
}
String TreeSearchPanel::get_text() {

View File

@ -34,39 +34,7 @@
using namespace godot;
enum TreeSearchMode {
HIGHLIGHT = 0,
FILTER = 1
};
class TreeSearchPanel : public HFlowContainer {
GDCLASS(TreeSearchPanel, HFlowContainer)
private:
Button *toggle_button_filter_highlight;
Button *close_button;
Label *label_filter;
LineEdit *line_edit_search;
CheckBox *check_button_filter_highlight;
void _initialize_controls();
void _initialize_close_callbacks();
void _add_spacer(float width_multiplier = 1.f);
void _on_draw_highlight(TreeItem *p_item, Rect2 p_rect);
void _emit_text_submitted(const String &p_text);
void _emit_update_requested();
void _notification(int p_what);
protected:
static void _bind_methods();
public:
TreeSearchMode get_search_mode();
String get_text();
void show_and_focus();
TreeSearchPanel();
bool has_focus();
};
class TreeSearchPanel;
class TreeSearch : public RefCounted {
GDCLASS(TreeSearch, RefCounted)
@ -116,6 +84,11 @@ protected:
static void _bind_methods() {}
public:
enum TreeSearchMode {
HIGHLIGHT = 0,
FILTER = 1
};
void update_search(Tree *p_tree);
void notify_item_edited(TreeItem *p_item);
@ -123,5 +96,34 @@ public:
TreeSearch(TreeSearchPanel *p_search_panel);
};
class TreeSearchPanel : public HFlowContainer {
GDCLASS(TreeSearchPanel, HFlowContainer)
private:
Button *toggle_button_filter_highlight;
Button *close_button;
Label *label_filter;
LineEdit *line_edit_search;
CheckBox *check_button_filter_highlight;
void _initialize_controls();
void _initialize_close_callbacks();
void _add_spacer(float width_multiplier = 1.f);
void _on_draw_highlight(TreeItem *p_item, Rect2 p_rect);
void _emit_text_submitted(const String &p_text);
void _emit_update_requested();
void _notification(int p_what);
protected:
static void _bind_methods();
public:
TreeSearch::TreeSearchMode get_search_mode();
String get_text();
void show_and_focus();
TreeSearchPanel();
bool has_focus();
};
#endif // TREE_SEARCH_H
#endif // ! TOOLS_ENABLED