// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
using FlaxEditor.CustomEditors.Elements;
using FlaxEditor.GUI;
using FlaxEngine;
using FlaxEngine.GUI;
namespace FlaxEditor.CustomEditors.Editors
{
///
/// Default implementation of the inspector used to edit styles.
///
[CustomEditor(typeof(Style)), DefaultEditor]
public class StyleEditor : CustomEditor
{
private CustomElement _element;
///
public override DisplayStyle Style => DisplayStyle.Inline;
///
/// Initializes this editor.
///
/// The layout builder.
public override void Initialize(LayoutElementsContainer layout)
{
var style = (Style)Values[0];
_element = layout.Custom();
_element.CustomControl.Value = style;
_element.CustomControl.ValueChanged += OnValueChanged;
}
private void OnValueChanged()
{
SetValue(_element.CustomControl.Value);
}
///
public override void Refresh()
{
base.Refresh();
if (HasDifferentValues)
{
}
else
{
_element.CustomControl.Value = (Style)Values[0];
}
}
}
}