Improve component labels for colors #4153

This commit is contained in:
2026-09-20 22:50:34 +02:00
parent 223d16b684
commit 7d1d222d63
3 changed files with 24 additions and 26 deletions
+22
View File
@@ -179,6 +179,28 @@ namespace FlaxEditor.GUI
UpdateKeyframes();
}
internal static string GetComponentLabel(int component, Type valueType)
{
if (valueType == typeof(Color) || valueType == typeof(Color32))
{
switch (component)
{
case 0: return "r";
case 1: return "g";
case 2: return "b";
case 3: return "a";
}
}
switch (component)
{
case 0: return "x";
case 1: return "y";
case 2: return "z";
case 3: return "w";
default: return (component + 1).ToString();
}
}
/// <summary>
/// Evaluates the animation curve value at the specified time.
/// </summary>
+1 -13
View File
@@ -91,18 +91,6 @@ namespace FlaxEditor.GUI
return firstHit;
}
private static string GetComponentName(int component)
{
switch (component)
{
case 0: return "X";
case 1: return "Y";
case 2: return "Z";
case 3: return "W";
default: return (component + 1).ToString();
}
}
private void SelectKeyframePoint(KeyframePoint keyframe, bool addToSelection)
{
if (!addToSelection)
@@ -646,7 +634,7 @@ namespace FlaxEditor.GUI
for (int i = 0; i < components; i++)
{
var component = i;
componentMenu.ContextMenu.AddButton(GetComponentName(component), () => SelectKeyframeComponent(point.Index, component));
componentMenu.ContextMenu.AddButton(GetComponentLabel(component, typeof(T)), () => SelectKeyframeComponent(point.Index, component));
}
}
var totalSelectionCount = _editor.KeyframesEditorContext?.OnKeyframesSelectionCount() ?? selectionCount;
+1 -13
View File
@@ -1279,24 +1279,12 @@ namespace FlaxEditor.GUI
continue;
var center = GetControlCenterInEditor(point);
var label = GetComponentLabel(point.Component);
var label = GetComponentLabel(point.Component, ValueType);
var labelRect = new Rectangle(center.X + 12.0f, center.Y - 22.0f, 34.0f, 28.0f);
Render2D.DrawText(style.FontMedium, label, labelRect, Colors[point.Component], TextAlignment.Near, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, 1.25f);
}
}
private static string GetComponentLabel(int component)
{
switch (component)
{
case 0: return "x";
case 1: return "y";
case 2: return "z";
case 3: return "w";
default: return (component + 1).ToString();
}
}
/// <inheritdoc />
public override void Draw()
{