diff --git a/Source/Engine/UI/GUI/Panels/Panel.cs b/Source/Engine/UI/GUI/Panels/Panel.cs index fb503affa..f2e1a2a46 100644 --- a/Source/Engine/UI/GUI/Panels/Panel.cs +++ b/Source/Engine/UI/GUI/Panels/Panel.cs @@ -14,6 +14,7 @@ namespace FlaxEngine.GUI private bool _alwaysShowScrollbars; private int _layoutUpdateLock; private ScrollBars _scrollBars; + private float _scrollBarsSize = ScrollBar.DefaultSize; private Margin _scrollMargin; /// @@ -64,7 +65,7 @@ namespace FlaxEngine.GUI VScrollBar = GetChild(); if (VScrollBar == null) { - VScrollBar = new VScrollBar(this, Width - ScrollBar.DefaultSize, Height) + VScrollBar = new VScrollBar(this, Width - _scrollBarsSize, Height) { AnchorPreset = AnchorPresets.TopLeft }; @@ -84,7 +85,7 @@ namespace FlaxEngine.GUI HScrollBar = GetChild(); if (HScrollBar == null) { - HScrollBar = new HScrollBar(this, Height - ScrollBar.DefaultSize, Width) + HScrollBar = new HScrollBar(this, Height - _scrollBarsSize, Width) { AnchorPreset = AnchorPresets.TopLeft }; @@ -103,6 +104,22 @@ namespace FlaxEngine.GUI } } + /// + /// Gets or sets the size of the scroll bars. + /// + [EditorOrder(5), Tooltip("Scroll bars size.")] + public float ScrollBarsSize + { + get => _scrollBarsSize; + set + { + if (Mathf.NearEqual(_scrollBarsSize, value)) + return; + _scrollBarsSize = value; + PerformLayout(); + } + } + /// /// Gets or sets a value indicating whether always show scrollbars. Otherwise show them only if scrolling is available. /// @@ -410,7 +427,7 @@ namespace FlaxEngine.GUI if (VScrollBar != null) { float height = Height; - bool vScrollEnabled = (controlsBounds.Bottom > height + 0.01f || controlsBounds.Y < 0.0f) && height > ScrollBar.DefaultSize; + bool vScrollEnabled = (controlsBounds.Bottom > height + 0.01f || controlsBounds.Y < 0.0f) && height > _scrollBarsSize; if (VScrollBar.Enabled != vScrollEnabled) { @@ -432,12 +449,12 @@ namespace FlaxEngine.GUI { VScrollBar.SetScrollRange(scrollBounds.Top, Mathf.Max(Mathf.Max(0, scrollBounds.Top), scrollBounds.Height - height)); } - VScrollBar.Bounds = new Rectangle(Width - ScrollBar.DefaultSize, 0, ScrollBar.DefaultSize, Height); + VScrollBar.Bounds = new Rectangle(Width - _scrollBarsSize, 0, _scrollBarsSize, Height); } if (HScrollBar != null) { float width = Width; - bool hScrollEnabled = (controlsBounds.Right > width + 0.01f || controlsBounds.X < 0.0f) && width > ScrollBar.DefaultSize; + bool hScrollEnabled = (controlsBounds.Right > width + 0.01f || controlsBounds.X < 0.0f) && width > _scrollBarsSize; if (HScrollBar.Enabled != hScrollEnabled) { @@ -459,7 +476,7 @@ namespace FlaxEngine.GUI { HScrollBar.SetScrollRange(scrollBounds.Left, Mathf.Max(Mathf.Max(0, scrollBounds.Left), scrollBounds.Width - width)); } - HScrollBar.Bounds = new Rectangle(0, Height - ScrollBar.DefaultSize, Width - (VScrollBar != null && VScrollBar.Visible ? VScrollBar.Width : 0), ScrollBar.DefaultSize); + HScrollBar.Bounds = new Rectangle(0, Height - _scrollBarsSize, Width - (VScrollBar != null && VScrollBar.Visible ? VScrollBar.Width : 0), _scrollBarsSize); } }