Add grey display for deprecated enum options
This commit is contained in:
@@ -40,6 +40,11 @@ namespace FlaxEditor.GUI.ContextMenu
|
||||
/// </summary>
|
||||
public string ShortKeys;
|
||||
|
||||
/// <summary>
|
||||
/// The text color.
|
||||
/// </summary>
|
||||
public Color TextColor;
|
||||
|
||||
/// <summary>
|
||||
/// Item icon (best is 16x16).
|
||||
/// </summary>
|
||||
@@ -71,6 +76,7 @@ namespace FlaxEditor.GUI.ContextMenu
|
||||
{
|
||||
Text = text;
|
||||
ShortKeys = shortKeys;
|
||||
TextColor = Style.Current.Foreground;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -122,7 +128,7 @@ namespace FlaxEditor.GUI.ContextMenu
|
||||
var style = Style.Current;
|
||||
var backgroundRect = new Rectangle(-X + 3, 0, Parent.Width - 6, Height);
|
||||
var textRect = new Rectangle(0, 0, Width - 8, Height);
|
||||
var textColor = Enabled ? style.Foreground : style.ForegroundDisabled;
|
||||
var textColor = Enabled ? TextColor : style.ForegroundDisabled;
|
||||
|
||||
// Draw background
|
||||
if (IsMouseOver && Enabled)
|
||||
|
||||
@@ -10,6 +10,7 @@ using FlaxEditor.CustomEditors.Elements;
|
||||
using FlaxEditor.GUI.ContextMenu;
|
||||
using FlaxEditor.Scripting;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.GUI;
|
||||
|
||||
namespace FlaxEditor.GUI
|
||||
{
|
||||
@@ -59,17 +60,24 @@ namespace FlaxEditor.GUI
|
||||
/// </summary>
|
||||
public long Value;
|
||||
|
||||
/// <summary>
|
||||
/// Marks enum entry as deprecated and should not be used by users anymore (displayed in grey).
|
||||
/// </summary>
|
||||
public bool IsObsolete;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Entry"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="tooltip">The tooltip.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
public Entry(string name, long value, string tooltip = null)
|
||||
/// <param name="isObsolete">The deprecated entry flag.</param>
|
||||
public Entry(string name, long value, string tooltip = null, bool isObsolete = false)
|
||||
{
|
||||
Name = name;
|
||||
Tooltip = tooltip;
|
||||
Value = value;
|
||||
IsObsolete = isObsolete;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,10 +288,9 @@ namespace FlaxEditor.GUI
|
||||
default: throw new ArgumentOutOfRangeException(nameof(formatMode), formatMode, null);
|
||||
}
|
||||
}
|
||||
|
||||
string tooltip = Editor.Instance.CodeDocs.GetTooltip(new ScriptMemberInfo(field), attributes);
|
||||
|
||||
entries.Add(new Entry(name, Convert.ToInt64(field.GetRawConstantValue()), tooltip));
|
||||
bool isObsolete = attributes.Any(x => x is ObsoleteAttribute);
|
||||
entries.Add(new Entry(name, Convert.ToInt64(field.GetRawConstantValue()), tooltip, isObsolete));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,8 +298,11 @@ namespace FlaxEditor.GUI
|
||||
protected override void OnLayoutMenuButton(ContextMenuButton button, int index, bool construct = false)
|
||||
{
|
||||
base.OnLayoutMenuButton(button, index, construct);
|
||||
|
||||
if (IsFlags)
|
||||
button.CloseMenuOnClick = false;
|
||||
if (index < _entries.Count && _entries[index].IsObsolete)
|
||||
button.TextColor = Style.Current.ForegroundGrey;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in New Issue
Block a user