@@ -153,6 +153,21 @@ namespace FlaxEditor.GUI
|
||||
/// </summary>
|
||||
public abstract void UpdateTangents();
|
||||
|
||||
/// <summary>
|
||||
/// Shows the whole curve.
|
||||
/// </summary>
|
||||
public abstract void ShowWholeCurve();
|
||||
|
||||
/// <summary>
|
||||
/// Resets the view.
|
||||
/// </summary>
|
||||
public void ResetView()
|
||||
{
|
||||
ViewScale = ApplyUseModeMask(EnableZoom, Vector2.One, ViewScale);
|
||||
ViewOffset = ApplyUseModeMask(EnablePanning, Vector2.Zero, ViewOffset);
|
||||
UpdateKeyframes();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the animation curve value at the specified time.
|
||||
/// </summary>
|
||||
@@ -204,6 +219,14 @@ namespace FlaxEditor.GUI
|
||||
/// <param name="value">The keyframe value.</param>
|
||||
public abstract void SetKeyframeValue(int index, object value);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the keyframe point (in keyframes space).
|
||||
/// </summary>
|
||||
/// <param name="index">The keyframe index.</param>
|
||||
/// <param name="component">The keyframe value component index.</param>
|
||||
/// <returns>The point in time/value space.</returns>
|
||||
public abstract Vector2 GetKeyframePoint(int index, int component);
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="UseMode"/> into the <see cref="Vector2"/> mask.
|
||||
/// </summary>
|
||||
|
||||
@@ -77,13 +77,11 @@ namespace FlaxEditor.GUI
|
||||
// Moving view
|
||||
if (_rightMouseDown)
|
||||
{
|
||||
// Calculate delta
|
||||
Vector2 delta = location - _movingViewLastPos;
|
||||
delta *= GetUseModeMask(_editor.EnablePanning);
|
||||
delta *= GetUseModeMask(_editor.EnablePanning) * _editor.ViewScale;
|
||||
if (delta.LengthSquared > 0.01f)
|
||||
{
|
||||
// Move view
|
||||
_editor.ViewOffset += delta * _editor.ViewScale;
|
||||
_editor._mainPanel.ViewOffset += delta;
|
||||
_movingViewLastPos = location;
|
||||
Cursor = CursorType.SizeAll;
|
||||
}
|
||||
@@ -239,7 +237,7 @@ namespace FlaxEditor.GUI
|
||||
if (Root.GetKey(KeyboardKeys.Control))
|
||||
{
|
||||
// Add to selection
|
||||
keyframe.Select();
|
||||
keyframe.IsSelected = true;
|
||||
_editor.UpdateTangents();
|
||||
}
|
||||
// Check if node isn't selected
|
||||
@@ -247,7 +245,7 @@ namespace FlaxEditor.GUI
|
||||
{
|
||||
// Select node
|
||||
_editor.ClearSelection();
|
||||
keyframe.Select();
|
||||
keyframe.IsSelected = true;
|
||||
_editor.UpdateTangents();
|
||||
}
|
||||
|
||||
@@ -260,7 +258,7 @@ namespace FlaxEditor.GUI
|
||||
if (_movingSelectionOffsets == null || _movingSelectionOffsets.Length != _editor._points.Count)
|
||||
_movingSelectionOffsets = new Vector2[_editor._points.Count];
|
||||
for (int i = 0; i < _movingSelectionOffsets.Length; i++)
|
||||
_movingSelectionOffsets[i] = _editor._points[i].TimeValue - _movingSelectionStart;
|
||||
_movingSelectionOffsets[i] = _editor._points[i].Point - _movingSelectionStart;
|
||||
_editor.OnEditingStart();
|
||||
Focus();
|
||||
Tooltip?.Hide();
|
||||
@@ -361,7 +359,7 @@ namespace FlaxEditor.GUI
|
||||
{
|
||||
// Select node
|
||||
selectionCount = 1;
|
||||
point.Select();
|
||||
point.IsSelected = true;
|
||||
_editor.UpdateTangents();
|
||||
}
|
||||
|
||||
|
||||
@@ -152,16 +152,7 @@ namespace FlaxEditor.GUI
|
||||
/// <summary>
|
||||
/// Gets the point time and value on a curve.
|
||||
/// </summary>
|
||||
public Vector2 TimeValue
|
||||
{
|
||||
get
|
||||
{
|
||||
var k = Editor.GetKeyframe(Index);
|
||||
var time = Editor.GetKeyframeTime(k);
|
||||
var value = Editor.GetKeyframeValue(k);
|
||||
return new Vector2(time, Editor.Accessor.GetCurveValue(ref value, Component));
|
||||
}
|
||||
}
|
||||
public Vector2 Point => Editor.GetKeyframePoint(Index, Component);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Draw()
|
||||
@@ -190,21 +181,8 @@ namespace FlaxEditor.GUI
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds this keyframe to the selection.
|
||||
/// </summary>
|
||||
public void Select()
|
||||
{
|
||||
IsSelected = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes this keyframe from the selection.
|
||||
/// </summary>
|
||||
public void Deselect()
|
||||
{
|
||||
IsSelected = false;
|
||||
}
|
||||
/// <inheritdoc />
|
||||
protected override bool ShowTooltip => base.ShowTooltip && !Editor._contents._isMovingSelection;
|
||||
|
||||
/// <summary>
|
||||
/// Updates the tooltip.
|
||||
@@ -350,7 +328,11 @@ namespace FlaxEditor.GUI
|
||||
public override Vector2 ViewOffset
|
||||
{
|
||||
get => _mainPanel.ViewOffset;
|
||||
set => _mainPanel.ViewOffset = value;
|
||||
set
|
||||
{
|
||||
_mainPanel.ViewOffset = value;
|
||||
_mainPanel.FastScroll();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -614,7 +596,7 @@ namespace FlaxEditor.GUI
|
||||
var p = _points[i];
|
||||
if (p.IsSelected)
|
||||
{
|
||||
p.Deselect();
|
||||
p.IsSelected = false;
|
||||
indicesToRemove.Add(p.Index);
|
||||
}
|
||||
}
|
||||
@@ -628,26 +610,14 @@ namespace FlaxEditor.GUI
|
||||
OnEditingEnd();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the whole curve.
|
||||
/// </summary>
|
||||
public void ShowWholeCurve()
|
||||
/// <inheritdoc />
|
||||
public override void ShowWholeCurve()
|
||||
{
|
||||
ViewScale = ApplyUseModeMask(EnableZoom, _mainPanel.Size / _contents.Size, ViewScale);
|
||||
ViewOffset = ApplyUseModeMask(EnablePanning, -_mainPanel.ControlsBounds.Location, ViewOffset);
|
||||
UpdateKeyframes();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the view.
|
||||
/// </summary>
|
||||
public void ResetView()
|
||||
{
|
||||
ViewScale = ApplyUseModeMask(EnableZoom, Vector2.One, ViewScale);
|
||||
ViewOffset = ApplyUseModeMask(EnablePanning, Vector2.Zero, ViewOffset);
|
||||
UpdateKeyframes();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Evaluate(out object result, float time, bool loop = false)
|
||||
{
|
||||
@@ -671,7 +641,7 @@ namespace FlaxEditor.GUI
|
||||
{
|
||||
for (int i = 0; i < _points.Count; i++)
|
||||
{
|
||||
_points[i].Deselect();
|
||||
_points[i].IsSelected = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -679,7 +649,7 @@ namespace FlaxEditor.GUI
|
||||
{
|
||||
for (int i = 0; i < _points.Count; i++)
|
||||
{
|
||||
_points[i].Select();
|
||||
_points[i].IsSelected = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1244,6 +1214,13 @@ namespace FlaxEditor.GUI
|
||||
OnEdited();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Vector2 GetKeyframePoint(int index, int component)
|
||||
{
|
||||
var k = _keyframes[index];
|
||||
return new Vector2(k.Time, Accessor.GetCurveValue(ref k.Value, component));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int KeyframesCount => _keyframes.Count;
|
||||
|
||||
@@ -1910,6 +1887,13 @@ namespace FlaxEditor.GUI
|
||||
OnEdited();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Vector2 GetKeyframePoint(int index, int component)
|
||||
{
|
||||
var k = _keyframes[index];
|
||||
return new Vector2(k.Time, Accessor.GetCurveValue(ref k.Value, component));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int KeyframesCount => _keyframes.Count;
|
||||
|
||||
@@ -1928,35 +1912,32 @@ namespace FlaxEditor.GUI
|
||||
// Place keyframes
|
||||
Rectangle curveContentAreaBounds = _mainPanel.GetClientArea();
|
||||
var viewScale = ViewScale;
|
||||
var pointsSize = _showCollapsed ? new Vector2(4.0f / viewScale.X, Height - 2.0f) : KeyframesSize / viewScale;
|
||||
for (int i = 0; i < _points.Count; i++)
|
||||
{
|
||||
var p = _points[i];
|
||||
var k = _keyframes[p.Index];
|
||||
|
||||
var location = GetKeyframePoint(ref k, p.Component);
|
||||
var point = new Vector2
|
||||
var point = GetKeyframePoint(ref k, p.Component);
|
||||
var location = new Vector2
|
||||
(
|
||||
location.X * UnitsPerSecond - p.Width * 0.5f,
|
||||
location.Y * -UnitsPerSecond - p.Height * 0.5f + curveContentAreaBounds.Height
|
||||
point.X * UnitsPerSecond - pointsSize.X * 0.5f,
|
||||
point.Y * -UnitsPerSecond - pointsSize.Y * 0.5f + curveContentAreaBounds.Height
|
||||
);
|
||||
|
||||
if (_showCollapsed)
|
||||
{
|
||||
point.Y = 1.0f;
|
||||
p.Size = new Vector2(4.0f / viewScale.X, Height - 2.0f);
|
||||
location.Y = 1.0f;
|
||||
p.Visible = p.Component == 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
p.Size = KeyframesSize / viewScale;
|
||||
p.Visible = true;
|
||||
}
|
||||
p.Location = point;
|
||||
p.Bounds = new Rectangle(location, pointsSize);
|
||||
}
|
||||
|
||||
// Calculate bounds
|
||||
var bounds = _points[0].Bounds;
|
||||
for (var i = 1; i < _points.Count; i++)
|
||||
for (int i = 1; i < _points.Count; i++)
|
||||
{
|
||||
bounds = Rectangle.Union(bounds, _points[i].Bounds);
|
||||
}
|
||||
|
||||
@@ -1276,24 +1276,24 @@ namespace FlaxEditor.GUI.Timeline
|
||||
case KeyboardKeys.ArrowUp:
|
||||
{
|
||||
int index = IndexInParent;
|
||||
if (index > 0)
|
||||
while (index != 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
toSelect = Parent.GetChild(--index) as Track;
|
||||
} while (index != -1 && toSelect != null && !toSelect.HasParentsExpanded);
|
||||
toSelect = Parent.GetChild(--index) as Track;
|
||||
if (toSelect != null && toSelect.HasParentsExpanded)
|
||||
break;
|
||||
toSelect = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KeyboardKeys.ArrowDown:
|
||||
{
|
||||
int index = IndexInParent;
|
||||
if (index < Parent.ChildrenCount - 1)
|
||||
while (index < Parent.ChildrenCount - 1)
|
||||
{
|
||||
do
|
||||
{
|
||||
toSelect = Parent.GetChild(++index) as Track;
|
||||
} while (index != Parent.ChildrenCount && toSelect != null && !toSelect.HasParentsExpanded);
|
||||
toSelect = Parent.GetChild(++index) as Track;
|
||||
if (toSelect != null && toSelect.HasParentsExpanded)
|
||||
break;
|
||||
toSelect = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -259,6 +259,8 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
{
|
||||
Height = IsExpanded ? ExpandedHeight : CollapsedHeight;
|
||||
UpdateCurve();
|
||||
if (IsExpanded)
|
||||
Curve.ShowWholeCurve();
|
||||
|
||||
base.OnExpandedChanged();
|
||||
}
|
||||
|
||||
@@ -172,6 +172,15 @@ namespace FlaxEngine.GUI
|
||||
base.SetViewOffset(ref value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cuts the scroll bars value smoothing and imminently goes to the target scroll value.
|
||||
/// </summary>
|
||||
public void FastScroll()
|
||||
{
|
||||
HScrollBar?.FastScroll();
|
||||
VScrollBar?.FastScroll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scrolls the view to the given control area.
|
||||
/// </summary>
|
||||
|
||||
@@ -182,6 +182,19 @@ namespace FlaxEngine.GUI
|
||||
_orientation = orientation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cuts the scroll bar value smoothing and imminently goes to the target scroll value.
|
||||
/// </summary>
|
||||
public void FastScroll()
|
||||
{
|
||||
if (!Mathf.NearEqual(_value, _targetValue))
|
||||
{
|
||||
_value = _targetValue;
|
||||
SetUpdate(ref _update, null);
|
||||
OnValueChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scrolls the view to the desire range (favors minimum value if cannot cover whole range in a bounds).
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user