TaskPalette filter: Add background for category list

This commit is contained in:
Serhii Snitsaruk 2023-08-26 16:57:18 +02:00
parent 62f964474c
commit a601d44517
2 changed files with 10 additions and 0 deletions

View File

@ -305,6 +305,10 @@ void TaskPalette::_filter_data_changed() {
call_deferred(SNAME("refresh"));
}
void TaskPalette::_draw_category_choice_background() {
category_choice_background->draw(category_choice->get_canvas_item(), Rect2(Point2(), category_choice->get_size()));
}
void TaskPalette::refresh() {
filter_edit->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
@ -420,6 +424,9 @@ void TaskPalette::_notification(int p_what) {
select_all->set_icon(get_theme_icon(SNAME("LimboSelectAll"), SNAME("EditorIcons")));
deselect_all->set_icon(get_theme_icon(SNAME("LimboDeselectAll"), SNAME("EditorIcons")));
category_choice_background = get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"));
category_choice->queue_redraw();
if (is_visible_in_tree()) {
refresh();
}
@ -564,6 +571,7 @@ TaskPalette::TaskPalette() {
category_filter->add_child(category_exclude);
category_choice = memnew(VBoxContainer);
category_choice->connect("draw", callable_mp(this, &TaskPalette::_draw_category_choice_background));
vbox->add_child(category_choice);
HBoxContainer *selection_controls = memnew(HBoxContainer);

View File

@ -101,6 +101,7 @@ private:
Button *deselect_all;
ScrollContainer *category_scroll;
VBoxContainer *category_list;
Ref<StyleBox> category_choice_background;
String context_task;
@ -115,6 +116,7 @@ private:
void _set_all_filter_categories(bool p_selected);
void _category_item_toggled(bool p_pressed, const String &p_category);
void _filter_data_changed();
void _draw_category_choice_background();
_FORCE_INLINE_ void _set_category_excluded(const String &p_category, bool p_excluded) {
if (p_excluded) {