@@ -591,14 +591,14 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
var group = layout.Group(title, editor);
|
||||
if ((Presenter.Features & FeatureFlags.CacheExpandedGroups) != 0)
|
||||
{
|
||||
if (Editor.Instance.ProjectCache.IsCollapsedGroup(title))
|
||||
group.Panel.Close(false);
|
||||
if (Editor.Instance.ProjectCache.IsGroupToggled(title))
|
||||
group.Panel.Close();
|
||||
else
|
||||
group.Panel.Open(false);
|
||||
group.Panel.IsClosedChanged += panel => Editor.Instance.ProjectCache.SetCollapsedGroup(panel.HeaderText, panel.IsClosed);
|
||||
group.Panel.Open();
|
||||
group.Panel.IsClosedChanged += panel => Editor.Instance.ProjectCache.SetGroupToggle(panel.HeaderText, panel.IsClosed);
|
||||
}
|
||||
else
|
||||
group.Panel.Open(false);
|
||||
group.Panel.Open();
|
||||
|
||||
// Customize
|
||||
group.Panel.TooltipText = Editor.Instance.CodeDocs.GetTooltip(scriptType);
|
||||
|
||||
@@ -25,6 +25,11 @@ namespace FlaxEditor.CustomEditors
|
||||
/// </summary>
|
||||
internal bool isRootGroup = true;
|
||||
|
||||
/// <summary>
|
||||
/// Parent container who created this one.
|
||||
/// </summary>
|
||||
internal LayoutElementsContainer _parent;
|
||||
|
||||
/// <summary>
|
||||
/// The children.
|
||||
/// </summary>
|
||||
@@ -40,6 +45,24 @@ namespace FlaxEditor.CustomEditors
|
||||
/// </summary>
|
||||
public abstract ContainerControl ContainerControl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Custom Editors layout presenter.
|
||||
/// </summary>
|
||||
internal CustomEditorPresenter Presenter
|
||||
{
|
||||
get
|
||||
{
|
||||
CustomEditorPresenter result;
|
||||
var container = this;
|
||||
do
|
||||
{
|
||||
result = container as CustomEditorPresenter;
|
||||
container = container._parent;
|
||||
} while (container != null);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds new group element.
|
||||
/// </summary>
|
||||
@@ -81,17 +104,31 @@ namespace FlaxEditor.CustomEditors
|
||||
public GroupElement Group(string title, bool useTransparentHeader = false)
|
||||
{
|
||||
var element = new GroupElement();
|
||||
if (!isRootGroup)
|
||||
var presenter = Presenter;
|
||||
var isSubGroup = !isRootGroup;
|
||||
if (isSubGroup)
|
||||
element.Panel.Close();
|
||||
if (presenter != null && (presenter.Features & FeatureFlags.CacheExpandedGroups) != 0)
|
||||
{
|
||||
element.Panel.Close(false);
|
||||
}
|
||||
else if (this is CustomEditorPresenter presenter && (presenter.Features & FeatureFlags.CacheExpandedGroups) != 0)
|
||||
{
|
||||
if (Editor.Instance.ProjectCache.IsCollapsedGroup(title))
|
||||
element.Panel.Close(false);
|
||||
element.Panel.IsClosedChanged += OnPanelIsClosedChanged;
|
||||
// Build group identifier (made of path from group titles)
|
||||
var expandPath = title;
|
||||
var container = this;
|
||||
while (container != null && !(container is CustomEditorPresenter))
|
||||
{
|
||||
if (container.ContainerControl is DropPanel dropPanel)
|
||||
expandPath = dropPanel.HeaderText + "/" + expandPath;
|
||||
container = container._parent;
|
||||
}
|
||||
|
||||
// Caching/restoring expanded groups (non-root groups cache expanded state so invert boolean expression)
|
||||
if (Editor.Instance.ProjectCache.IsGroupToggled(expandPath) ^ isSubGroup)
|
||||
element.Panel.Close();
|
||||
else
|
||||
element.Panel.Open();
|
||||
element.Panel.IsClosedChanged += panel => Editor.Instance.ProjectCache.SetGroupToggle(expandPath, panel.IsClosed ^ isSubGroup);
|
||||
}
|
||||
element.isRootGroup = false;
|
||||
element._parent = this;
|
||||
element.Panel.HeaderText = title;
|
||||
if (useTransparentHeader)
|
||||
{
|
||||
@@ -103,11 +140,6 @@ namespace FlaxEditor.CustomEditors
|
||||
return element;
|
||||
}
|
||||
|
||||
private void OnPanelIsClosedChanged(DropPanel panel)
|
||||
{
|
||||
Editor.Instance.ProjectCache.SetCollapsedGroup(panel.HeaderText, panel.IsClosed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds new horizontal panel element.
|
||||
/// </summary>
|
||||
@@ -627,7 +659,6 @@ namespace FlaxEditor.CustomEditors
|
||||
if (style == DisplayStyle.Group)
|
||||
{
|
||||
var group = Group(name, editor, true);
|
||||
group.Panel.Close(false);
|
||||
group.Panel.TooltipText = tooltip;
|
||||
return group.Object(values, editor);
|
||||
}
|
||||
@@ -657,7 +688,6 @@ namespace FlaxEditor.CustomEditors
|
||||
if (style == DisplayStyle.Group)
|
||||
{
|
||||
var group = Group(label.Text, editor, true);
|
||||
group.Panel.Close(false);
|
||||
group.Panel.TooltipText = tooltip;
|
||||
return group.Object(values, editor);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user