diff --git a/Source/Editor/GUI/CurveEditor.cs b/Source/Editor/GUI/CurveEditor.cs index 1ad94a9d8..abf68d39e 100644 --- a/Source/Editor/GUI/CurveEditor.cs +++ b/Source/Editor/GUI/CurveEditor.cs @@ -671,8 +671,20 @@ namespace FlaxEditor.GUI /// public override void ShowWholeCurve() { - ViewScale = ApplyUseModeMask(EnableZoom, _mainPanel.Size / _contents.Size, ViewScale); - ViewOffset = ApplyUseModeMask(EnablePanning, -_mainPanel.ControlsBounds.Location, ViewOffset); + _mainPanel.GetDesireClientArea(out var mainPanelArea); + ViewScale = ApplyUseModeMask(EnableZoom, mainPanelArea.Size / _contents.Size, ViewScale); + Float2 minPos = Float2.Maximum; + foreach (var point in _points) + { + var pos = point.PointToParent(point.Location); + Float2.Min(ref minPos, ref pos, out minPos); + } + var minPosPoint = _contents.PointToParent(ref minPos); + var scroll = new Float2(_mainPanel.HScrollBar.TargetValue, _mainPanel.VScrollBar.TargetValue); + scroll = ApplyUseModeMask(EnablePanning, minPosPoint, scroll); + _mainPanel.HScrollBar.TargetValue = scroll.X; + _mainPanel.VScrollBar.TargetValue = scroll.Y; + UpdateKeyframes(); } diff --git a/Source/Engine/UI/GUI/Panels/Panel.cs b/Source/Engine/UI/GUI/Panels/Panel.cs index 3923e7108..0f802bd45 100644 --- a/Source/Engine/UI/GUI/Panels/Panel.cs +++ b/Source/Engine/UI/GUI/Panels/Panel.cs @@ -265,13 +265,12 @@ namespace FlaxEngine.GUI { bool wasLocked = _isLayoutLocked; _isLayoutLocked = true; - if (HScrollBar != null) HScrollBar.Value = -value.X; if (VScrollBar != null) VScrollBar.Value = -value.Y; - _isLayoutLocked = wasLocked; + base.SetViewOffset(ref value); } diff --git a/Source/Engine/UI/GUI/Panels/ScrollBar.cs b/Source/Engine/UI/GUI/Panels/ScrollBar.cs index 712c3e606..8f3ad5f38 100644 --- a/Source/Engine/UI/GUI/Panels/ScrollBar.cs +++ b/Source/Engine/UI/GUI/Panels/ScrollBar.cs @@ -330,7 +330,7 @@ namespace FlaxEngine.GUI bool needUpdate = Mathf.Abs(_thumbOpacity - targetOpacity) > 0.001f; // Ensure scroll bar is visible and smoothing is required - if (Visible && Mathf.Abs(_targetValue - _value) > 0.01f) + if (Visible && (Mathf.Abs(_targetValue - _value) > 0.0001f || _scrollAnimationProgress < 1.0f)) { // Interpolate or not if running slow float value; @@ -348,6 +348,8 @@ namespace FlaxEngine.GUI // https://easings.net/#easeOutSine var easedProgress = Mathf.Sin((progress * Mathf.Pi) / 2); + if (progress >= 1.0f) + easedProgress = 1.0f; value = Mathf.Lerp(_startValue, _targetValue, easedProgress); _scrollAnimationProgress = progress; @@ -356,7 +358,7 @@ namespace FlaxEngine.GUI { value = _targetValue; _startValue = _targetValue; - _scrollAnimationProgress = 0f; + _scrollAnimationProgress = 1f; } _value = value;