Fix curve editor showing whole curve in a view

This commit is contained in:
Wojtek Figat
2024-11-28 18:27:09 +01:00
parent e2ed618056
commit 6f0a2c0288
3 changed files with 19 additions and 6 deletions

View File

@@ -671,8 +671,20 @@ namespace FlaxEditor.GUI
/// <inheritdoc />
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();
}

View File

@@ -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);
}

View File

@@ -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;