diff --git a/Source/Editor/GUI/CurveEditor.Base.cs b/Source/Editor/GUI/CurveEditor.Base.cs
index 2dfc7a889..8621d443b 100644
--- a/Source/Editor/GUI/CurveEditor.Base.cs
+++ b/Source/Editor/GUI/CurveEditor.Base.cs
@@ -153,6 +153,21 @@ namespace FlaxEditor.GUI
///
public abstract void UpdateTangents();
+ ///
+ /// Shows the whole curve.
+ ///
+ public abstract void ShowWholeCurve();
+
+ ///
+ /// Resets the view.
+ ///
+ public void ResetView()
+ {
+ ViewScale = ApplyUseModeMask(EnableZoom, Vector2.One, ViewScale);
+ ViewOffset = ApplyUseModeMask(EnablePanning, Vector2.Zero, ViewOffset);
+ UpdateKeyframes();
+ }
+
///
/// Evaluates the animation curve value at the specified time.
///
@@ -204,6 +219,14 @@ namespace FlaxEditor.GUI
/// The keyframe value.
public abstract void SetKeyframeValue(int index, object value);
+ ///
+ /// Gets the keyframe point (in keyframes space).
+ ///
+ /// The keyframe index.
+ /// The keyframe value component index.
+ /// The point in time/value space.
+ public abstract Vector2 GetKeyframePoint(int index, int component);
+
///
/// Converts the into the mask.
///
diff --git a/Source/Editor/GUI/CurveEditor.Contents.cs b/Source/Editor/GUI/CurveEditor.Contents.cs
index 9bbfe89d2..2058a0aa7 100644
--- a/Source/Editor/GUI/CurveEditor.Contents.cs
+++ b/Source/Editor/GUI/CurveEditor.Contents.cs
@@ -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();
}
diff --git a/Source/Editor/GUI/CurveEditor.cs b/Source/Editor/GUI/CurveEditor.cs
index c44aa232c..d22721592 100644
--- a/Source/Editor/GUI/CurveEditor.cs
+++ b/Source/Editor/GUI/CurveEditor.cs
@@ -152,16 +152,7 @@ namespace FlaxEditor.GUI
///
/// Gets the point time and value on a curve.
///
- 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);
///
public override void Draw()
@@ -190,21 +181,8 @@ namespace FlaxEditor.GUI
return false;
}
- ///
- /// Adds this keyframe to the selection.
- ///
- public void Select()
- {
- IsSelected = true;
- }
-
- ///
- /// Removes this keyframe from the selection.
- ///
- public void Deselect()
- {
- IsSelected = false;
- }
+ ///
+ protected override bool ShowTooltip => base.ShowTooltip && !Editor._contents._isMovingSelection;
///
/// 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();
+ }
}
///
@@ -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();
}
- ///
- /// Shows the whole curve.
- ///
- public void ShowWholeCurve()
+ ///
+ public override void ShowWholeCurve()
{
ViewScale = ApplyUseModeMask(EnableZoom, _mainPanel.Size / _contents.Size, ViewScale);
ViewOffset = ApplyUseModeMask(EnablePanning, -_mainPanel.ControlsBounds.Location, ViewOffset);
UpdateKeyframes();
}
- ///
- /// Resets the view.
- ///
- public void ResetView()
- {
- ViewScale = ApplyUseModeMask(EnableZoom, Vector2.One, ViewScale);
- ViewOffset = ApplyUseModeMask(EnablePanning, Vector2.Zero, ViewOffset);
- UpdateKeyframes();
- }
-
///
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();
}
+ ///
+ public override Vector2 GetKeyframePoint(int index, int component)
+ {
+ var k = _keyframes[index];
+ return new Vector2(k.Time, Accessor.GetCurveValue(ref k.Value, component));
+ }
+
///
public override int KeyframesCount => _keyframes.Count;
@@ -1910,6 +1887,13 @@ namespace FlaxEditor.GUI
OnEdited();
}
+ ///
+ public override Vector2 GetKeyframePoint(int index, int component)
+ {
+ var k = _keyframes[index];
+ return new Vector2(k.Time, Accessor.GetCurveValue(ref k.Value, component));
+ }
+
///
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);
}
diff --git a/Source/Editor/GUI/Timeline/Track.cs b/Source/Editor/GUI/Timeline/Track.cs
index 297371159..66528efab 100644
--- a/Source/Editor/GUI/Timeline/Track.cs
+++ b/Source/Editor/GUI/Timeline/Track.cs
@@ -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;
}
diff --git a/Source/Editor/GUI/Timeline/Tracks/CurvePropertyTrack.cs b/Source/Editor/GUI/Timeline/Tracks/CurvePropertyTrack.cs
index 8e01d2706..080cdca67 100644
--- a/Source/Editor/GUI/Timeline/Tracks/CurvePropertyTrack.cs
+++ b/Source/Editor/GUI/Timeline/Tracks/CurvePropertyTrack.cs
@@ -259,6 +259,8 @@ namespace FlaxEditor.GUI.Timeline.Tracks
{
Height = IsExpanded ? ExpandedHeight : CollapsedHeight;
UpdateCurve();
+ if (IsExpanded)
+ Curve.ShowWholeCurve();
base.OnExpandedChanged();
}
diff --git a/Source/Engine/UI/GUI/Panels/Panel.cs b/Source/Engine/UI/GUI/Panels/Panel.cs
index b2a011040..fb503affa 100644
--- a/Source/Engine/UI/GUI/Panels/Panel.cs
+++ b/Source/Engine/UI/GUI/Panels/Panel.cs
@@ -172,6 +172,15 @@ namespace FlaxEngine.GUI
base.SetViewOffset(ref value);
}
+ ///
+ /// Cuts the scroll bars value smoothing and imminently goes to the target scroll value.
+ ///
+ public void FastScroll()
+ {
+ HScrollBar?.FastScroll();
+ VScrollBar?.FastScroll();
+ }
+
///
/// Scrolls the view to the given control area.
///
diff --git a/Source/Engine/UI/GUI/Panels/ScrollBar.cs b/Source/Engine/UI/GUI/Panels/ScrollBar.cs
index 0175de5a5..bea692e19 100644
--- a/Source/Engine/UI/GUI/Panels/ScrollBar.cs
+++ b/Source/Engine/UI/GUI/Panels/ScrollBar.cs
@@ -182,6 +182,19 @@ namespace FlaxEngine.GUI
_orientation = orientation;
}
+ ///
+ /// Cuts the scroll bar value smoothing and imminently goes to the target scroll value.
+ ///
+ public void FastScroll()
+ {
+ if (!Mathf.NearEqual(_value, _targetValue))
+ {
+ _value = _targetValue;
+ SetUpdate(ref _update, null);
+ OnValueChanged();
+ }
+ }
+
///
/// Scrolls the view to the desire range (favors minimum value if cannot cover whole range in a bounds).
///