Fix curve editor showing whole curve in a view
This commit is contained in:
@@ -671,8 +671,20 @@ namespace FlaxEditor.GUI
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ShowWholeCurve()
|
public override void ShowWholeCurve()
|
||||||
{
|
{
|
||||||
ViewScale = ApplyUseModeMask(EnableZoom, _mainPanel.Size / _contents.Size, ViewScale);
|
_mainPanel.GetDesireClientArea(out var mainPanelArea);
|
||||||
ViewOffset = ApplyUseModeMask(EnablePanning, -_mainPanel.ControlsBounds.Location, ViewOffset);
|
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();
|
UpdateKeyframes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -265,13 +265,12 @@ namespace FlaxEngine.GUI
|
|||||||
{
|
{
|
||||||
bool wasLocked = _isLayoutLocked;
|
bool wasLocked = _isLayoutLocked;
|
||||||
_isLayoutLocked = true;
|
_isLayoutLocked = true;
|
||||||
|
|
||||||
if (HScrollBar != null)
|
if (HScrollBar != null)
|
||||||
HScrollBar.Value = -value.X;
|
HScrollBar.Value = -value.X;
|
||||||
if (VScrollBar != null)
|
if (VScrollBar != null)
|
||||||
VScrollBar.Value = -value.Y;
|
VScrollBar.Value = -value.Y;
|
||||||
|
|
||||||
_isLayoutLocked = wasLocked;
|
_isLayoutLocked = wasLocked;
|
||||||
|
|
||||||
base.SetViewOffset(ref value);
|
base.SetViewOffset(ref value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ namespace FlaxEngine.GUI
|
|||||||
bool needUpdate = Mathf.Abs(_thumbOpacity - targetOpacity) > 0.001f;
|
bool needUpdate = Mathf.Abs(_thumbOpacity - targetOpacity) > 0.001f;
|
||||||
|
|
||||||
// Ensure scroll bar is visible and smoothing is required
|
// 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
|
// Interpolate or not if running slow
|
||||||
float value;
|
float value;
|
||||||
@@ -348,6 +348,8 @@ namespace FlaxEngine.GUI
|
|||||||
|
|
||||||
// https://easings.net/#easeOutSine
|
// https://easings.net/#easeOutSine
|
||||||
var easedProgress = Mathf.Sin((progress * Mathf.Pi) / 2);
|
var easedProgress = Mathf.Sin((progress * Mathf.Pi) / 2);
|
||||||
|
if (progress >= 1.0f)
|
||||||
|
easedProgress = 1.0f;
|
||||||
value = Mathf.Lerp(_startValue, _targetValue, easedProgress);
|
value = Mathf.Lerp(_startValue, _targetValue, easedProgress);
|
||||||
|
|
||||||
_scrollAnimationProgress = progress;
|
_scrollAnimationProgress = progress;
|
||||||
@@ -356,7 +358,7 @@ namespace FlaxEngine.GUI
|
|||||||
{
|
{
|
||||||
value = _targetValue;
|
value = _targetValue;
|
||||||
_startValue = _targetValue;
|
_startValue = _targetValue;
|
||||||
_scrollAnimationProgress = 0f;
|
_scrollAnimationProgress = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
_value = value;
|
_value = value;
|
||||||
|
|||||||
Reference in New Issue
Block a user