Add scrollbar colors to Panel
This commit is contained in:
@@ -17,6 +17,9 @@ namespace FlaxEngine.GUI
|
||||
private ScrollBars _scrollBars;
|
||||
private float _scrollBarsSize = ScrollBar.DefaultSize;
|
||||
private Margin _scrollMargin;
|
||||
private Color _scrollbarTrackColor;
|
||||
private Color _scrollbarThumbColor;
|
||||
private Color _scrollbarThumbSelectedColor;
|
||||
|
||||
/// <summary>
|
||||
/// The cached scroll area bounds. Used to scroll contents of the panel control. Cached during performing layout.
|
||||
@@ -49,7 +52,7 @@ namespace FlaxEngine.GUI
|
||||
/// <summary>
|
||||
/// Gets or sets the scroll bars usage by this panel.
|
||||
/// </summary>
|
||||
[EditorOrder(0), Tooltip("The scroll bars usage.")]
|
||||
[EditorDisplay("Scrollbar Style"), EditorOrder(0), Tooltip("The scroll bars usage.")]
|
||||
public ScrollBars ScrollBars
|
||||
{
|
||||
get => _scrollBars;
|
||||
@@ -73,6 +76,12 @@ namespace FlaxEngine.GUI
|
||||
//VScrollBar.X += VScrollBar.Width;
|
||||
VScrollBar.ValueChanged += () => SetViewOffset(Orientation.Vertical, VScrollBar.Value);
|
||||
}
|
||||
if (VScrollBar != null)
|
||||
{
|
||||
VScrollBar.TrackColor = _scrollbarTrackColor;
|
||||
VScrollBar.ThumbColor = _scrollbarThumbColor;
|
||||
VScrollBar.ThumbSelectedColor = _scrollbarThumbSelectedColor;
|
||||
}
|
||||
}
|
||||
else if (VScrollBar != null)
|
||||
{
|
||||
@@ -94,6 +103,12 @@ namespace FlaxEngine.GUI
|
||||
//HScrollBar.Offsets += new Margin(0, 0, HScrollBar.Height * 0.5f, 0);
|
||||
HScrollBar.ValueChanged += () => SetViewOffset(Orientation.Horizontal, HScrollBar.Value);
|
||||
}
|
||||
if (HScrollBar != null)
|
||||
{
|
||||
HScrollBar.TrackColor = _scrollbarTrackColor;
|
||||
HScrollBar.ThumbColor = _scrollbarThumbColor;
|
||||
HScrollBar.ThumbSelectedColor = _scrollbarThumbSelectedColor;
|
||||
}
|
||||
}
|
||||
else if (HScrollBar != null)
|
||||
{
|
||||
@@ -108,7 +123,7 @@ namespace FlaxEngine.GUI
|
||||
/// <summary>
|
||||
/// Gets or sets the size of the scroll bars.
|
||||
/// </summary>
|
||||
[EditorOrder(5), Tooltip("Scroll bars size.")]
|
||||
[EditorDisplay("Scrollbar Style"), EditorOrder(5), Tooltip("Scroll bars size.")]
|
||||
public float ScrollBarsSize
|
||||
{
|
||||
get => _scrollBarsSize;
|
||||
@@ -124,7 +139,7 @@ namespace FlaxEngine.GUI
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether always show scrollbars. Otherwise show them only if scrolling is available.
|
||||
/// </summary>
|
||||
[EditorOrder(10), Tooltip("Whether always show scrollbars. Otherwise show them only if scrolling is available.")]
|
||||
[EditorDisplay("Scrollbar Style"), EditorOrder(10), Tooltip("Whether always show scrollbars. Otherwise show them only if scrolling is available.")]
|
||||
public bool AlwaysShowScrollbars
|
||||
{
|
||||
get => _alwaysShowScrollbars;
|
||||
@@ -157,7 +172,7 @@ namespace FlaxEngine.GUI
|
||||
/// <summary>
|
||||
/// Gets or sets the scroll margin applies to the child controls area. Can be used to expand the scroll area bounds by adding a margin.
|
||||
/// </summary>
|
||||
[EditorOrder(20), Tooltip("Scroll margin applies to the child controls area. Can be used to expand the scroll area bounds by adding a margin.")]
|
||||
[EditorDisplay("Scrollbar Style"), EditorOrder(20), Tooltip("Scroll margin applies to the child controls area. Can be used to expand the scroll area bounds by adding a margin.")]
|
||||
public Margin ScrollMargin
|
||||
{
|
||||
get => _scrollMargin;
|
||||
@@ -171,6 +186,57 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The color of the scroll bar track.
|
||||
/// </summary>
|
||||
[EditorDisplay("Scrollbar Style"), EditorOrder(30), ExpandGroups]
|
||||
public Color ScrollbarTrackColor
|
||||
{
|
||||
get => _scrollbarTrackColor;
|
||||
set
|
||||
{
|
||||
_scrollbarTrackColor = value;
|
||||
if (VScrollBar != null)
|
||||
VScrollBar.TrackColor = _scrollbarTrackColor;
|
||||
if (HScrollBar != null)
|
||||
HScrollBar.TrackColor = _scrollbarTrackColor;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The color of the scroll bar thumb.
|
||||
/// </summary>
|
||||
[EditorDisplay("Scrollbar Style"), EditorOrder(31)]
|
||||
public Color ScrollbarThumbColor
|
||||
{
|
||||
get => _scrollbarThumbColor;
|
||||
set
|
||||
{
|
||||
_scrollbarThumbColor = value;
|
||||
if (VScrollBar != null)
|
||||
VScrollBar.ThumbColor = _scrollbarThumbColor;
|
||||
if (HScrollBar != null)
|
||||
HScrollBar.ThumbColor = _scrollbarThumbColor;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The color of the scroll bar thumb when selected.
|
||||
/// </summary>
|
||||
[EditorDisplay("Scrollbar Style"), EditorOrder(32)]
|
||||
public Color ScrollbarThumbSelectedColor
|
||||
{
|
||||
get => _scrollbarThumbSelectedColor;
|
||||
set
|
||||
{
|
||||
_scrollbarThumbSelectedColor = value;
|
||||
if (VScrollBar != null)
|
||||
VScrollBar.ThumbSelectedColor = _scrollbarThumbSelectedColor;
|
||||
if (HScrollBar != null)
|
||||
HScrollBar.ThumbSelectedColor = _scrollbarThumbSelectedColor;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Panel"/> class.
|
||||
/// </summary>
|
||||
@@ -187,6 +253,10 @@ namespace FlaxEngine.GUI
|
||||
public Panel(ScrollBars scrollBars, bool autoFocus = false)
|
||||
{
|
||||
AutoFocus = autoFocus;
|
||||
var style = Style.Current;
|
||||
_scrollbarTrackColor = style.BackgroundHighlighted;
|
||||
_scrollbarThumbColor = style.BackgroundNormal;
|
||||
_scrollbarThumbSelectedColor = style.BackgroundSelected;
|
||||
ScrollBars = scrollBars;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user