Fix curve tangent handles to maintain size relative to the current view scale
Fix curve tangent colors to match editor style Fix curve tangents editing to have stable movement no matter the view scale #2455
This commit is contained in:
@@ -234,7 +234,7 @@ namespace FlaxEditor.GUI
|
|||||||
var k = _editor.GetKeyframe(_movingTangent.Index);
|
var k = _editor.GetKeyframe(_movingTangent.Index);
|
||||||
var kv = _editor.GetKeyframeValue(k);
|
var kv = _editor.GetKeyframeValue(k);
|
||||||
var value = _editor.Accessor.GetCurveValue(ref kv, _movingTangent.Component);
|
var value = _editor.Accessor.GetCurveValue(ref kv, _movingTangent.Component);
|
||||||
_movingTangent.TangentValue = PointToKeyframes(location, ref viewRect).Y - value;
|
_movingTangent.TangentValue = (PointToKeyframes(location, ref viewRect).Y - value) * _editor.ViewScale.X;
|
||||||
_editor.UpdateTangents();
|
_editor.UpdateTangents();
|
||||||
Cursor = CursorType.SizeNS;
|
Cursor = CursorType.SizeNS;
|
||||||
_movedKeyframes = true;
|
_movedKeyframes = true;
|
||||||
|
|||||||
@@ -163,10 +163,11 @@ namespace FlaxEditor.GUI
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
|
var style = Style.Current;
|
||||||
var rect = new Rectangle(Float2.Zero, Size);
|
var rect = new Rectangle(Float2.Zero, Size);
|
||||||
var color = Editor.ShowCollapsed ? Color.Gray : Editor.Colors[Component];
|
var color = Editor.ShowCollapsed ? style.ForegroundDisabled : Editor.Colors[Component];
|
||||||
if (IsSelected)
|
if (IsSelected)
|
||||||
color = Editor.ContainsFocus ? Color.YellowGreen : Color.Lerp(Color.Gray, Color.YellowGreen, 0.4f);
|
color = Editor.ContainsFocus ? style.SelectionBorder : Color.Lerp(style.ForegroundDisabled, style.SelectionBorder, 0.4f);
|
||||||
if (IsMouseOver)
|
if (IsMouseOver)
|
||||||
color *= 1.1f;
|
color *= 1.1f;
|
||||||
Render2D.FillRectangle(rect, color);
|
Render2D.FillRectangle(rect, color);
|
||||||
@@ -244,14 +245,19 @@ namespace FlaxEditor.GUI
|
|||||||
set => Editor.SetKeyframeTangentInternal(Index, IsIn, Component, value);
|
set => Editor.SetKeyframeTangentInternal(Index, IsIn, Component, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal float TangentOffset => 50.0f / Editor.ViewScale.X;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
|
var style = Style.Current;
|
||||||
|
var thickness = 6.0f / Mathf.Max(Editor.ViewScale.X, 1.0f);
|
||||||
|
var size = Size;
|
||||||
var pointPos = PointFromParent(Point.Center);
|
var pointPos = PointFromParent(Point.Center);
|
||||||
Render2D.DrawLine(Size * 0.5f, pointPos, Color.Gray);
|
Render2D.DrawLine(size * 0.5f, pointPos, style.ForegroundDisabled, thickness);
|
||||||
|
|
||||||
var rect = new Rectangle(Float2.Zero, Size);
|
var rect = new Rectangle(Float2.Zero, size);
|
||||||
var color = Color.MediumVioletRed;
|
var color = style.BorderSelected;
|
||||||
if (IsMouseOver)
|
if (IsMouseOver)
|
||||||
color *= 1.1f;
|
color *= 1.1f;
|
||||||
Render2D.FillRectangle(rect, color);
|
Render2D.FillRectangle(rect, color);
|
||||||
@@ -2202,7 +2208,7 @@ namespace FlaxEditor.GUI
|
|||||||
|
|
||||||
var tangent = t.TangentValue;
|
var tangent = t.TangentValue;
|
||||||
var direction = t.IsIn ? -1.0f : 1.0f;
|
var direction = t.IsIn ? -1.0f : 1.0f;
|
||||||
var offset = 30.0f;
|
var offset = t.TangentOffset;
|
||||||
var location = GetKeyframePoint(ref k, selectedComponent);
|
var location = GetKeyframePoint(ref k, selectedComponent);
|
||||||
t.Size = KeyframesSize / ViewScale;
|
t.Size = KeyframesSize / ViewScale;
|
||||||
t.Location = new Float2
|
t.Location = new Float2
|
||||||
@@ -2229,6 +2235,18 @@ namespace FlaxEditor.GUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void SetScaleInternal(ref Float2 scale)
|
||||||
|
{
|
||||||
|
base.SetScaleInternal(ref scale);
|
||||||
|
|
||||||
|
if (!_showCollapsed)
|
||||||
|
{
|
||||||
|
// Refresh keyframes when zooming (their size depends on the scale)
|
||||||
|
UpdateKeyframes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void OnShowContextMenu(ContextMenu.ContextMenu cm, int selectionCount)
|
protected override void OnShowContextMenu(ContextMenu.ContextMenu cm, int selectionCount)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user