@@ -1684,24 +1684,30 @@ void SceneTreeDialog::_show_all_nodes_changed(bool p_button_pressed) {
1684
1684
}
1685
1685
1686
1686
void SceneTreeDialog::set_valid_types (const Vector<StringName> &p_valid) {
1687
- if (p_valid.is_empty ()) {
1688
- return ;
1687
+ if (allowed_types_hbox) {
1688
+ allowed_types_hbox->queue_free ();
1689
+ allowed_types_hbox = nullptr ;
1690
+ valid_type_icons.clear ();
1689
1691
}
1690
1692
1691
1693
tree->set_valid_types (p_valid);
1692
1694
1693
- HBoxContainer *hbox = memnew (HBoxContainer);
1694
- content->add_child (hbox);
1695
- content->move_child (hbox, 0 );
1695
+ if (p_valid.is_empty ()) {
1696
+ return ;
1697
+ }
1698
+
1699
+ allowed_types_hbox = memnew (HBoxContainer);
1700
+ content->add_child (allowed_types_hbox);
1701
+ content->move_child (allowed_types_hbox, 0 );
1696
1702
1697
1703
{
1698
1704
Label *label = memnew (Label);
1699
- hbox ->add_child (label);
1705
+ allowed_types_hbox ->add_child (label);
1700
1706
label->set_text (TTR (" Allowed:" ));
1701
1707
}
1702
1708
1703
1709
HFlowContainer *hflow = memnew (HFlowContainer);
1704
- hbox ->add_child (hflow);
1710
+ allowed_types_hbox ->add_child (hflow);
1705
1711
hflow->set_h_size_flags (Control::SIZE_EXPAND_FILL);
1706
1712
1707
1713
for (const StringName &type : p_valid) {
@@ -1735,6 +1741,9 @@ void SceneTreeDialog::set_valid_types(const Vector<StringName> &p_valid) {
1735
1741
}
1736
1742
1737
1743
show_all_nodes->show ();
1744
+ if (is_inside_tree ()) {
1745
+ _update_valid_type_icons ();
1746
+ }
1738
1747
}
1739
1748
1740
1749
void SceneTreeDialog::_notification (int p_what) {
@@ -1753,11 +1762,7 @@ void SceneTreeDialog::_notification(int p_what) {
1753
1762
} break ;
1754
1763
1755
1764
case NOTIFICATION_THEME_CHANGED: {
1756
- filter->set_right_icon (get_editor_theme_icon (SNAME (" Search" )));
1757
- for (TextureRect *trect : valid_type_icons) {
1758
- trect->set_custom_minimum_size (Vector2 (get_theme_constant (SNAME (" class_icon_size" ), EditorStringName (Editor)), 0 ));
1759
- trect->set_texture (trect->get_meta (" icon" ));
1760
- }
1765
+ _update_valid_type_icons ();
1761
1766
} break ;
1762
1767
1763
1768
case NOTIFICATION_EXIT_TREE: {
@@ -1766,6 +1771,14 @@ void SceneTreeDialog::_notification(int p_what) {
1766
1771
}
1767
1772
}
1768
1773
1774
+ void SceneTreeDialog::_update_valid_type_icons () {
1775
+ filter->set_right_icon (get_editor_theme_icon (SNAME (" Search" )));
1776
+ for (TextureRect *trect : valid_type_icons) {
1777
+ trect->set_custom_minimum_size (Vector2 (get_theme_constant (SNAME (" class_icon_size" ), EditorStringName (Editor)), 0 ));
1778
+ trect->set_texture (trect->get_meta (" icon" ));
1779
+ }
1780
+ }
1781
+
1769
1782
void SceneTreeDialog::_cancel () {
1770
1783
hide ();
1771
1784
}
0 commit comments