@@ -15,13 +15,23 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
private int _firstTimeShow;
|
private int _firstTimeShow;
|
||||||
private BezierCurveEditor<T> _curve;
|
private BezierCurveEditor<T> _curve;
|
||||||
private Splitter _splitter;
|
private Splitter _splitter;
|
||||||
|
private string _heightCachedPath;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Initialize(LayoutElementsContainer layout)
|
public override void Initialize(LayoutElementsContainer layout)
|
||||||
{
|
{
|
||||||
var item = layout.CustomContainer<BezierCurveEditor<T>>();
|
var item = layout.CustomContainer<BezierCurveEditor<T>>();
|
||||||
_curve = item.CustomControl;
|
_curve = item.CustomControl;
|
||||||
_curve.Height = 120.0f;
|
var height = 120.0f;
|
||||||
|
var presenter = Presenter;
|
||||||
|
if (presenter != null && (presenter.Features & FeatureFlags.CacheExpandedGroups) != 0)
|
||||||
|
{
|
||||||
|
// Try to restore curve height
|
||||||
|
_heightCachedPath = layout.GetLayoutCachePath("Height");
|
||||||
|
if (Editor.Instance.ProjectCache.TryGetCustomData(_heightCachedPath, out float cachedHeight) && cachedHeight > 10.0f)
|
||||||
|
height = cachedHeight;
|
||||||
|
}
|
||||||
|
_curve.Height = height;
|
||||||
_curve.Edited += OnCurveEdited;
|
_curve.Edited += OnCurveEdited;
|
||||||
_firstTimeShow = 4; // For some weird reason it needs several frames of warmup (probably due to sliders smoothing)
|
_firstTimeShow = 4; // For some weird reason it needs several frames of warmup (probably due to sliders smoothing)
|
||||||
_splitter = new Splitter
|
_splitter = new Splitter
|
||||||
@@ -45,7 +55,11 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
|
|
||||||
private void OnSplitterMoved(Float2 location)
|
private void OnSplitterMoved(Float2 location)
|
||||||
{
|
{
|
||||||
_curve.Height = Mathf.Clamp(_splitter.PointToParent(location).Y, 50.0f, 1000.0f);
|
_curve.Height = Mathf.Clamp(_splitter.PointToParent(location).Y, 50.0f, 1000.0f);
|
||||||
|
|
||||||
|
// Cache curve height
|
||||||
|
if (_heightCachedPath != null)
|
||||||
|
Editor.Instance.ProjectCache.SetCustomData(_heightCachedPath, _curve.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -133,13 +147,23 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
private int _firstTimeShow;
|
private int _firstTimeShow;
|
||||||
private LinearCurveEditor<T> _curve;
|
private LinearCurveEditor<T> _curve;
|
||||||
private Splitter _splitter;
|
private Splitter _splitter;
|
||||||
|
private string _heightCachedPath;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Initialize(LayoutElementsContainer layout)
|
public override void Initialize(LayoutElementsContainer layout)
|
||||||
{
|
{
|
||||||
var item = layout.CustomContainer<LinearCurveEditor<T>>();
|
var item = layout.CustomContainer<LinearCurveEditor<T>>();
|
||||||
_curve = item.CustomControl;
|
_curve = item.CustomControl;
|
||||||
_curve.Height = 120.0f;
|
var height = 120.0f;
|
||||||
|
var presenter = Presenter;
|
||||||
|
if (presenter != null && (presenter.Features & FeatureFlags.CacheExpandedGroups) != 0)
|
||||||
|
{
|
||||||
|
// Try to restore curve height
|
||||||
|
_heightCachedPath = layout.GetLayoutCachePath("Height");
|
||||||
|
if (Editor.Instance.ProjectCache.TryGetCustomData(_heightCachedPath, out float cachedHeight) && cachedHeight > 10.0f)
|
||||||
|
height = cachedHeight;
|
||||||
|
}
|
||||||
|
_curve.Height = height;
|
||||||
_curve.Edited += OnCurveEdited;
|
_curve.Edited += OnCurveEdited;
|
||||||
_firstTimeShow = 4; // For some weird reason it needs several frames of warmup (probably due to sliders smoothing)
|
_firstTimeShow = 4; // For some weird reason it needs several frames of warmup (probably due to sliders smoothing)
|
||||||
_splitter = new Splitter
|
_splitter = new Splitter
|
||||||
@@ -164,6 +188,10 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
private void OnSplitterMoved(Float2 location)
|
private void OnSplitterMoved(Float2 location)
|
||||||
{
|
{
|
||||||
_curve.Height = Mathf.Clamp(_splitter.PointToParent(location).Y, 50.0f, 1000.0f);
|
_curve.Height = Mathf.Clamp(_splitter.PointToParent(location).Y, 50.0f, 1000.0f);
|
||||||
|
|
||||||
|
// Cache curve height
|
||||||
|
if (_heightCachedPath != null)
|
||||||
|
Editor.Instance.ProjectCache.SetCustomData(_heightCachedPath, _curve.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -96,6 +96,20 @@ namespace FlaxEditor.CustomEditors
|
|||||||
menu.Show(groupPanel, location);
|
menu.Show(groupPanel, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal string GetLayoutCachePath(string name)
|
||||||
|
{
|
||||||
|
// Build group identifier (made of path from group titles)
|
||||||
|
var expandPath = name;
|
||||||
|
var container = this;
|
||||||
|
while (container != null && !(container is CustomEditorPresenter))
|
||||||
|
{
|
||||||
|
if (container.ContainerControl is DropPanel dropPanel)
|
||||||
|
expandPath = dropPanel.HeaderText + "/" + expandPath;
|
||||||
|
container = container._parent;
|
||||||
|
}
|
||||||
|
return expandPath;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds new group element.
|
/// Adds new group element.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -112,14 +126,7 @@ namespace FlaxEditor.CustomEditors
|
|||||||
if (presenter != null && (presenter.Features & FeatureFlags.CacheExpandedGroups) != 0)
|
if (presenter != null && (presenter.Features & FeatureFlags.CacheExpandedGroups) != 0)
|
||||||
{
|
{
|
||||||
// Build group identifier (made of path from group titles)
|
// Build group identifier (made of path from group titles)
|
||||||
var expandPath = title;
|
var expandPath = GetLayoutCachePath(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)
|
// Caching/restoring expanded groups (non-root groups cache expanded state so invert boolean expression)
|
||||||
if (Editor.Instance.ProjectCache.IsGroupToggled(expandPath) ^ isSubGroup)
|
if (Editor.Instance.ProjectCache.IsGroupToggled(expandPath) ^ isSubGroup)
|
||||||
|
|||||||
Reference in New Issue
Block a user