@@ -591,14 +591,14 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
var group = layout.Group(title, editor);
|
var group = layout.Group(title, editor);
|
||||||
if ((Presenter.Features & FeatureFlags.CacheExpandedGroups) != 0)
|
if ((Presenter.Features & FeatureFlags.CacheExpandedGroups) != 0)
|
||||||
{
|
{
|
||||||
if (Editor.Instance.ProjectCache.IsCollapsedGroup(title))
|
if (Editor.Instance.ProjectCache.IsGroupToggled(title))
|
||||||
group.Panel.Close(false);
|
group.Panel.Close();
|
||||||
else
|
else
|
||||||
group.Panel.Open(false);
|
group.Panel.Open();
|
||||||
group.Panel.IsClosedChanged += panel => Editor.Instance.ProjectCache.SetCollapsedGroup(panel.HeaderText, panel.IsClosed);
|
group.Panel.IsClosedChanged += panel => Editor.Instance.ProjectCache.SetGroupToggle(panel.HeaderText, panel.IsClosed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
group.Panel.Open(false);
|
group.Panel.Open();
|
||||||
|
|
||||||
// Customize
|
// Customize
|
||||||
group.Panel.TooltipText = Editor.Instance.CodeDocs.GetTooltip(scriptType);
|
group.Panel.TooltipText = Editor.Instance.CodeDocs.GetTooltip(scriptType);
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ namespace FlaxEditor.CustomEditors
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal bool isRootGroup = true;
|
internal bool isRootGroup = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parent container who created this one.
|
||||||
|
/// </summary>
|
||||||
|
internal LayoutElementsContainer _parent;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The children.
|
/// The children.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -40,6 +45,24 @@ namespace FlaxEditor.CustomEditors
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract ContainerControl ContainerControl { get; }
|
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>
|
/// <summary>
|
||||||
/// Adds new group element.
|
/// Adds new group element.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -81,17 +104,31 @@ namespace FlaxEditor.CustomEditors
|
|||||||
public GroupElement Group(string title, bool useTransparentHeader = false)
|
public GroupElement Group(string title, bool useTransparentHeader = false)
|
||||||
{
|
{
|
||||||
var element = new GroupElement();
|
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);
|
// Build group identifier (made of path from group titles)
|
||||||
}
|
var expandPath = title;
|
||||||
else if (this is CustomEditorPresenter presenter && (presenter.Features & FeatureFlags.CacheExpandedGroups) != 0)
|
var container = this;
|
||||||
{
|
while (container != null && !(container is CustomEditorPresenter))
|
||||||
if (Editor.Instance.ProjectCache.IsCollapsedGroup(title))
|
{
|
||||||
element.Panel.Close(false);
|
if (container.ContainerControl is DropPanel dropPanel)
|
||||||
element.Panel.IsClosedChanged += OnPanelIsClosedChanged;
|
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.isRootGroup = false;
|
||||||
|
element._parent = this;
|
||||||
element.Panel.HeaderText = title;
|
element.Panel.HeaderText = title;
|
||||||
if (useTransparentHeader)
|
if (useTransparentHeader)
|
||||||
{
|
{
|
||||||
@@ -103,11 +140,6 @@ namespace FlaxEditor.CustomEditors
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPanelIsClosedChanged(DropPanel panel)
|
|
||||||
{
|
|
||||||
Editor.Instance.ProjectCache.SetCollapsedGroup(panel.HeaderText, panel.IsClosed);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds new horizontal panel element.
|
/// Adds new horizontal panel element.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -627,7 +659,6 @@ namespace FlaxEditor.CustomEditors
|
|||||||
if (style == DisplayStyle.Group)
|
if (style == DisplayStyle.Group)
|
||||||
{
|
{
|
||||||
var group = Group(name, editor, true);
|
var group = Group(name, editor, true);
|
||||||
group.Panel.Close(false);
|
|
||||||
group.Panel.TooltipText = tooltip;
|
group.Panel.TooltipText = tooltip;
|
||||||
return group.Object(values, editor);
|
return group.Object(values, editor);
|
||||||
}
|
}
|
||||||
@@ -657,7 +688,6 @@ namespace FlaxEditor.CustomEditors
|
|||||||
if (style == DisplayStyle.Group)
|
if (style == DisplayStyle.Group)
|
||||||
{
|
{
|
||||||
var group = Group(label.Text, editor, true);
|
var group = Group(label.Text, editor, true);
|
||||||
group.Panel.Close(false);
|
|
||||||
group.Panel.TooltipText = tooltip;
|
group.Panel.TooltipText = tooltip;
|
||||||
return group.Object(values, editor);
|
return group.Object(values, editor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace FlaxEditor.Modules
|
|||||||
private DateTime _lastSaveTime;
|
private DateTime _lastSaveTime;
|
||||||
|
|
||||||
private readonly HashSet<Guid> _expandedActors = new HashSet<Guid>();
|
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>();
|
private readonly Dictionary<string, string> _customData = new Dictionary<string, string>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -62,26 +62,26 @@ namespace FlaxEditor.Modules
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
/// <param name="title">The group title.</param>
|
/// <param name="title">The group title.</param>
|
||||||
/// <returns><c>true</c> if group is collapsed; otherwise, <c>false</c>.</returns>
|
/// <returns><c>true</c> if group is toggled; otherwise, <c>false</c>.</returns>
|
||||||
public bool IsCollapsedGroup(string title)
|
public bool IsGroupToggled(string title)
|
||||||
{
|
{
|
||||||
return _collapsedGroups.Contains(title);
|
return _toggledGroups.Contains(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the group collapsed cached value.
|
/// Sets the group collapsed/opened cached value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="title">The group title.</param>
|
/// <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>
|
/// <param name="isToggled">If set to <c>true</c> group will be cached as a toggled, otherwise false.</param>
|
||||||
public void SetCollapsedGroup(string title, bool isCollapsed)
|
public void SetGroupToggle(string title, bool isToggled)
|
||||||
{
|
{
|
||||||
if (isCollapsed)
|
if (isToggled)
|
||||||
_collapsedGroups.Add(title);
|
_toggledGroups.Add(title);
|
||||||
else
|
else
|
||||||
_collapsedGroups.Remove(title);
|
_toggledGroups.Remove(title);
|
||||||
_isDirty = true;
|
_isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ namespace FlaxEditor.Modules
|
|||||||
_expandedActors.Add(new Guid(bytes16));
|
_expandedActors.Add(new Guid(bytes16));
|
||||||
}
|
}
|
||||||
|
|
||||||
_collapsedGroups.Clear();
|
_toggledGroups.Clear();
|
||||||
_customData.Clear();
|
_customData.Clear();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -176,7 +176,7 @@ namespace FlaxEditor.Modules
|
|||||||
_expandedActors.Add(new Guid(bytes16));
|
_expandedActors.Add(new Guid(bytes16));
|
||||||
}
|
}
|
||||||
|
|
||||||
_collapsedGroups.Clear();
|
_toggledGroups.Clear();
|
||||||
|
|
||||||
_customData.Clear();
|
_customData.Clear();
|
||||||
int customDataCount = reader.ReadInt32();
|
int customDataCount = reader.ReadInt32();
|
||||||
@@ -201,11 +201,9 @@ namespace FlaxEditor.Modules
|
|||||||
}
|
}
|
||||||
|
|
||||||
int collapsedGroupsCount = reader.ReadInt32();
|
int collapsedGroupsCount = reader.ReadInt32();
|
||||||
_collapsedGroups.Clear();
|
_toggledGroups.Clear();
|
||||||
for (int i = 0; i < collapsedGroupsCount; i++)
|
for (int i = 0; i < collapsedGroupsCount; i++)
|
||||||
{
|
_toggledGroups.Add(reader.ReadString());
|
||||||
_collapsedGroups.Add(reader.ReadString());
|
|
||||||
}
|
|
||||||
|
|
||||||
_customData.Clear();
|
_customData.Clear();
|
||||||
int customDataCount = reader.ReadInt32();
|
int customDataCount = reader.ReadInt32();
|
||||||
@@ -259,11 +257,9 @@ namespace FlaxEditor.Modules
|
|||||||
writer.Write(e.ToByteArray());
|
writer.Write(e.ToByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.Write(_collapsedGroups.Count);
|
writer.Write(_toggledGroups.Count);
|
||||||
foreach (var e in _collapsedGroups)
|
foreach (var e in _toggledGroups)
|
||||||
{
|
|
||||||
writer.Write(e);
|
writer.Write(e);
|
||||||
}
|
|
||||||
|
|
||||||
writer.Write(_customData.Count);
|
writer.Write(_customData.Count);
|
||||||
foreach (var e in _customData)
|
foreach (var e in _customData)
|
||||||
@@ -284,7 +280,6 @@ namespace FlaxEditor.Modules
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
SaveGuarded();
|
SaveGuarded();
|
||||||
|
|
||||||
_isDirty = false;
|
_isDirty = false;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
Reference in New Issue
Block a user