Add sub-groups expanded state restoring in Properties window

#1049
This commit is contained in:
Wojtek Figat
2024-02-17 23:42:57 +01:00
parent 37dfdad7e2
commit c305bed829
3 changed files with 67 additions and 42 deletions

View File

@@ -18,7 +18,7 @@ namespace FlaxEditor.Modules
private DateTime _lastSaveTime;
private readonly HashSet<Guid> _expandedActors = new HashSet<Guid>();
private readonly HashSet<string> _collapsedGroups = new HashSet<string>();
private readonly HashSet<string> _toggledGroups = new HashSet<string>();
private readonly Dictionary<string, string> _customData = new Dictionary<string, string>();
/// <summary>
@@ -62,26 +62,26 @@ namespace FlaxEditor.Modules
}
/// <summary>
/// Determines whether group identified by the given title is collapsed in the UI.
/// Determines whether group identified by the given title is collapsed/opened in the UI.
/// </summary>
/// <param name="title">The group title.</param>
/// <returns><c>true</c> if group is collapsed; otherwise, <c>false</c>.</returns>
public bool IsCollapsedGroup(string title)
/// <returns><c>true</c> if group is toggled; otherwise, <c>false</c>.</returns>
public bool IsGroupToggled(string title)
{
return _collapsedGroups.Contains(title);
return _toggledGroups.Contains(title);
}
/// <summary>
/// Sets the group collapsed cached value.
/// Sets the group collapsed/opened cached value.
/// </summary>
/// <param name="title">The group title.</param>
/// <param name="isCollapsed">If set to <c>true</c> group will be cached as an collapsed, otherwise false.</param>
public void SetCollapsedGroup(string title, bool isCollapsed)
/// <param name="isToggled">If set to <c>true</c> group will be cached as a toggled, otherwise false.</param>
public void SetGroupToggle(string title, bool isToggled)
{
if (isCollapsed)
_collapsedGroups.Add(title);
if (isToggled)
_toggledGroups.Add(title);
else
_collapsedGroups.Remove(title);
_toggledGroups.Remove(title);
_isDirty = true;
}
@@ -160,7 +160,7 @@ namespace FlaxEditor.Modules
_expandedActors.Add(new Guid(bytes16));
}
_collapsedGroups.Clear();
_toggledGroups.Clear();
_customData.Clear();
break;
@@ -176,7 +176,7 @@ namespace FlaxEditor.Modules
_expandedActors.Add(new Guid(bytes16));
}
_collapsedGroups.Clear();
_toggledGroups.Clear();
_customData.Clear();
int customDataCount = reader.ReadInt32();
@@ -201,11 +201,9 @@ namespace FlaxEditor.Modules
}
int collapsedGroupsCount = reader.ReadInt32();
_collapsedGroups.Clear();
_toggledGroups.Clear();
for (int i = 0; i < collapsedGroupsCount; i++)
{
_collapsedGroups.Add(reader.ReadString());
}
_toggledGroups.Add(reader.ReadString());
_customData.Clear();
int customDataCount = reader.ReadInt32();
@@ -259,11 +257,9 @@ namespace FlaxEditor.Modules
writer.Write(e.ToByteArray());
}
writer.Write(_collapsedGroups.Count);
foreach (var e in _collapsedGroups)
{
writer.Write(_toggledGroups.Count);
foreach (var e in _toggledGroups)
writer.Write(e);
}
writer.Write(_customData.Count);
foreach (var e in _customData)
@@ -284,7 +280,6 @@ namespace FlaxEditor.Modules
try
{
SaveGuarded();
_isDirty = false;
}
catch (Exception ex)