From 67b6604a6735dd46969b1add39ee626d48815de4 Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Thu, 24 Mar 2022 11:33:09 +0100 Subject: [PATCH] Add automatic group panels hiding if all properties are hidden by `VisibleIf` rule --- .../CustomEditors/Editors/GenericEditor.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Source/Editor/CustomEditors/Editors/GenericEditor.cs b/Source/Editor/CustomEditors/Editors/GenericEditor.cs index 4ca761634..fb1ead44a 100644 --- a/Source/Editor/CustomEditors/Editors/GenericEditor.cs +++ b/Source/Editor/CustomEditors/Editors/GenericEditor.cs @@ -229,6 +229,7 @@ namespace FlaxEditor.CustomEditors.Editors } } + private static HashSet _visibleIfPropertiesListsCache; private VisibleIfCache[] _visibleIfCaches; private bool _isNull; @@ -761,8 +762,13 @@ namespace FlaxEditor.CustomEditors.Editors if (_visibleIfCaches != null) { + if (_visibleIfPropertiesListsCache == null) + _visibleIfPropertiesListsCache = new HashSet(); + else + _visibleIfPropertiesListsCache.Clear(); try { + // Update VisibleIf rules for (int i = 0; i < _visibleIfCaches.Length; i++) { ref var c = ref _visibleIfCaches[i]; @@ -798,6 +804,21 @@ namespace FlaxEditor.CustomEditors.Editors { c.Group.Panel.Visible = visible; } + if (c.PropertiesList != null) + _visibleIfPropertiesListsCache.Add(c.PropertiesList.Properties); + } + + // Hide properties lists with all labels being hidden + foreach (var propertiesList in _visibleIfPropertiesListsCache) + { + propertiesList.Visible = propertiesList.Children.Any(c => c.Visible); + } + + // Hide group panels with all properties lists hidden + foreach (var propertiesList in _visibleIfPropertiesListsCache) + { + if (propertiesList.Parent is DropPanel dropPanel) + dropPanel.Visible = propertiesList.Visible || !dropPanel.Children.All(c => c is PropertiesList && !c.Visible); } } catch (Exception ex)