Add better timeline UI positioning for improved viewport navigation

This commit is contained in:
Wojtek Figat
2021-08-10 13:29:42 +02:00
parent 94b4c20b35
commit c1b2fc19c1
4 changed files with 14 additions and 11 deletions

View File

@@ -27,7 +27,8 @@ namespace FlaxEditor.GUI.Timeline.GUI
{ {
var style = Style.Current; var style = Style.Current;
var icon = Editor.Instance.Icons.VisjectArrowClosed32; var icon = Editor.Instance.Icons.VisjectArrowClosed32;
var timeAxisHeaderOffset = -_timeline.MediaBackground.ViewOffset.Y; var timeAxisOverlap = Timeline.HeaderTopAreaHeight * 0.5f;
var timeAxisHeaderOffset = -_timeline.MediaBackground.ViewOffset.Y - timeAxisOverlap;
Matrix3x3.RotationZ(Mathf.PiOverTwo, out var m1); Matrix3x3.RotationZ(Mathf.PiOverTwo, out var m1);
var m2 = Matrix3x3.Translation2D(0, timeAxisHeaderOffset); var m2 = Matrix3x3.Translation2D(0, timeAxisHeaderOffset);
@@ -36,7 +37,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
Render2D.DrawSprite(icon, new Rectangle(new Vector2(4, -Width), Size), _timeline.IsMovingPositionHandle ? style.ProgressNormal : style.Foreground); Render2D.DrawSprite(icon, new Rectangle(new Vector2(4, -Width), Size), _timeline.IsMovingPositionHandle ? style.ProgressNormal : style.Foreground);
Render2D.PopTransform(); Render2D.PopTransform();
Render2D.FillRectangle(new Rectangle(Width * 0.5f, Height + timeAxisHeaderOffset, 1, _timeline.MediaPanel.Height - timeAxisHeaderOffset), _timeline.IsMovingPositionHandle ? style.ProgressNormal : style.Foreground.RGBMultiplied(0.8f)); Render2D.FillRectangle(new Rectangle(Width * 0.5f, Height + timeAxisHeaderOffset, 1, _timeline.MediaPanel.Height - timeAxisHeaderOffset - timeAxisOverlap), _timeline.IsMovingPositionHandle ? style.ProgressNormal : style.Foreground.RGBMultiplied(0.8f));
base.Draw(); base.Draw();
} }

View File

@@ -37,7 +37,8 @@ namespace FlaxEditor.GUI.Timeline.GUI
public override void Draw() public override void Draw()
{ {
var style = Style.Current; var style = Style.Current;
var timeAxisHeaderOffset = -_timeline.MediaBackground.ViewOffset.Y; var timeAxisOverlap = Timeline.HeaderTopAreaHeight * 0.5f;
var timeAxisHeaderOffset = -_timeline.MediaBackground.ViewOffset.Y - timeAxisOverlap;
var moveColor = style.ProgressNormal; var moveColor = style.ProgressNormal;
var thickness = 2.0f; var thickness = 2.0f;

View File

@@ -959,12 +959,12 @@ namespace FlaxEditor.GUI.Timeline
private void UpdatePositionHandle() private void UpdatePositionHandle()
{ {
var handleWidth = 12.0f; var handleWidth = 12.0f;
_positionHandle.Bounds = new Rectangle( var bounds = new Rectangle();
StartOffset * 2.0f - handleWidth * 0.5f + _currentFrame / _framesPerSecond * UnitsPerSecond * Zoom, bounds.Location.X = StartOffset * 2.0f - handleWidth * 0.5f + _currentFrame / _framesPerSecond * UnitsPerSecond * Zoom;
HeaderTopAreaHeight * -0.5f, bounds.Location.Y = 0;
handleWidth, bounds.Size.X = handleWidth;
HeaderTopAreaHeight * 0.5f bounds.Size.Y = HeaderTopAreaHeight * 0.5f;
); _positionHandle.Bounds = bounds;
} }
private void OnFpsPopupShowing(ComboBox comboBox) private void OnFpsPopupShowing(ComboBox comboBox)
@@ -1936,8 +1936,8 @@ namespace FlaxEditor.GUI.Timeline
_background.Bounds = new Rectangle(StartOffset, 0, Duration * UnitsPerSecond * Zoom, height); _background.Bounds = new Rectangle(StartOffset, 0, Duration * UnitsPerSecond * Zoom, height);
var edgeWidth = 6.0f; var edgeWidth = 6.0f;
_leftEdge.Bounds = new Rectangle(_background.Left - edgeWidth * 0.5f + StartOffset, HeaderTopAreaHeight * -0.5f, edgeWidth, height + HeaderTopAreaHeight * 0.5f); _leftEdge.Bounds = new Rectangle(_background.Left - edgeWidth * 0.5f + StartOffset, 0, edgeWidth, height);
_rightEdge.Bounds = new Rectangle(_background.Right - edgeWidth * 0.5f + StartOffset, HeaderTopAreaHeight * -0.5f, edgeWidth, height + HeaderTopAreaHeight * 0.5f); _rightEdge.Bounds = new Rectangle(_background.Right - edgeWidth * 0.5f + StartOffset, 0, edgeWidth, height);
_backgroundScroll.Bounds = new Rectangle(0, 0, _background.Width + 5 * StartOffset, height); _backgroundScroll.Bounds = new Rectangle(0, 0, _background.Width + 5 * StartOffset, height);
} }

View File

@@ -140,6 +140,7 @@ namespace FlaxEngine.GUI
{ {
_targetValue = value; _targetValue = value;
_value = value; _value = value;
SetUpdate(ref _update, null);
OnValueChanged(); OnValueChanged();
} }
} }