diff --git a/Source/Editor/GUI/CurveEditor.cs b/Source/Editor/GUI/CurveEditor.cs index 3499ef5d3..1ad94a9d8 100644 --- a/Source/Editor/GUI/CurveEditor.cs +++ b/Source/Editor/GUI/CurveEditor.cs @@ -1384,9 +1384,7 @@ namespace FlaxEditor.GUI // Calculate bounds var bounds = _points[0].Bounds; for (var i = 1; i < _points.Count; i++) - { bounds = Rectangle.Union(bounds, _points[i].Bounds); - } // Adjust contents bounds to fill the curve area if (EnablePanning != UseMode.Off || !ShowCollapsed) @@ -2116,9 +2114,7 @@ namespace FlaxEditor.GUI // Calculate bounds var bounds = _points[0].Bounds; for (int i = 1; i < _points.Count; i++) - { bounds = Rectangle.Union(bounds, _points[i].Bounds); - } // Adjust contents bounds to fill the curve area if (EnablePanning != UseMode.Off || !ShowCollapsed) diff --git a/Source/Engine/UI/GUI/Panels/Panel.cs b/Source/Engine/UI/GUI/Panels/Panel.cs index 6549f94da..3923e7108 100644 --- a/Source/Engine/UI/GUI/Panels/Panel.cs +++ b/Source/Engine/UI/GUI/Panels/Panel.cs @@ -553,7 +553,12 @@ namespace FlaxEngine.GUI if (vScrollEnabled) { - VScrollBar.SetScrollRange(scrollBounds.Top, Mathf.Max(Mathf.Max(0, scrollBounds.Top), scrollBounds.Height - height)); + float max; + if (scrollBounds.Top < 0) + max = Mathf.Max(scrollBounds.Bottom, scrollBounds.Top + scrollBounds.Height - height); + else + max = Mathf.Max(scrollBounds.Top, scrollBounds.Height - height); + VScrollBar.SetScrollRange(scrollBounds.Top, max); } VScrollBar.Bounds = new Rectangle(Width - _scrollBarsSize, 0, _scrollBarsSize, Height); } @@ -580,7 +585,12 @@ namespace FlaxEngine.GUI if (hScrollEnabled) { - HScrollBar.SetScrollRange(scrollBounds.Left, Mathf.Max(Mathf.Max(0, scrollBounds.Left), scrollBounds.Width - width)); + float max; + if (scrollBounds.Left < 0) + max = Mathf.Max(scrollBounds.Right, scrollBounds.Left + scrollBounds.Width - width); + else + max = Mathf.Max(scrollBounds.Left, scrollBounds.Width - width); + HScrollBar.SetScrollRange(scrollBounds.Left, max); } HScrollBar.Bounds = new Rectangle(0, Height - _scrollBarsSize, Width - (VScrollBar != null && VScrollBar.Visible ? VScrollBar.Width : 0), _scrollBarsSize); } @@ -596,17 +606,29 @@ namespace FlaxEngine.GUI // Calculate scroll area bounds var totalMin = Float2.Zero; var totalMax = Float2.Zero; + var hasTotal = false; for (int i = 0; i < _children.Count; i++) { var c = _children[i]; if (c.Visible && c.IsScrollable) { - var min = Float2.Zero; - var max = c.Size; - Matrix3x3.Transform2D(ref min, ref c._cachedTransform, out min); - Matrix3x3.Transform2D(ref max, ref c._cachedTransform, out max); - Float2.Min(ref min, ref totalMin, out totalMin); - Float2.Max(ref max, ref totalMax, out totalMax); + var upperLeft = Float2.Zero; + var bottomRight = c.Size; + Matrix3x3.Transform2D(ref upperLeft, ref c._cachedTransform, out upperLeft); + Matrix3x3.Transform2D(ref bottomRight, ref c._cachedTransform, out bottomRight); + Float2.Min(ref upperLeft, ref bottomRight, out var min); + Float2.Max(ref upperLeft, ref bottomRight, out var max); + if (hasTotal) + { + Float2.Min(ref min, ref totalMin, out totalMin); + Float2.Max(ref max, ref totalMax, out totalMax); + } + else + { + totalMin = min; + totalMax = max; + hasTotal = true; + } } }