From 080b3b11367744a6aaf0da0171e4259fd20b7775 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 4 Aug 2021 16:58:24 +0200 Subject: [PATCH] Fix camera previews placement on camera cuts track #519 --- .../GUI/Timeline/Tracks/CameraCutTrack.cs | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/Source/Editor/GUI/Timeline/Tracks/CameraCutTrack.cs b/Source/Editor/GUI/Timeline/Tracks/CameraCutTrack.cs index 05f0c42ae..b188371d8 100644 --- a/Source/Editor/GUI/Timeline/Tracks/CameraCutTrack.cs +++ b/Source/Editor/GUI/Timeline/Tracks/CameraCutTrack.cs @@ -226,14 +226,47 @@ namespace FlaxEditor.GUI.Timeline.Tracks private void UpdateUI() { - var width = Mathf.Min(CameraCutThumbnailRenderer.Width, (Width - 6.0f) * 0.5f); - for (int i = 0; i < _thumbnails.Length; i++) + if (_thumbnails == null) + return; + var width = Width - (_thumbnails.Length + 1) * 2; + if (width < 10.0f) + { + for (int i = 0; i < _thumbnails.Length; i++) + { + var image = _thumbnails[i]; + if (image != null) + image.Visible = false; + } + return; + } + var count = Mathf.Min(Mathf.FloorToInt(width / CameraCutThumbnailRenderer.Width), _thumbnails.Length); + if (count == 0 && _thumbnails.Length != 0) + { + var image = _thumbnails[0]; + if (image != null) + { + image.Width = Mathf.Min(CameraCutThumbnailRenderer.Width, width); + image.SetAnchorPreset(image.AnchorPreset, false); + image.Visible = true; + } + return; + } + for (int i = 0; i < count; i++) { var image = _thumbnails[i]; if (image != null) { - image.Width = width; - image.Visible = width >= 10.0f; + image.Width = CameraCutThumbnailRenderer.Width; + image.SetAnchorPreset(image.AnchorPreset, false); + image.Visible = true; + } + } + for (int i = count; i < _thumbnails.Length; i++) + { + var image = _thumbnails[i]; + if (image != null) + { + image.Visible = false; } } }