Add has border and border thickness options.
This commit is contained in:
@@ -84,17 +84,23 @@ namespace FlaxEngine.GUI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorDisplay("Border Style"), EditorOrder(2010), ExpandGroups]
|
[EditorDisplay("Border Style"), EditorOrder(2010), ExpandGroups]
|
||||||
public bool HasBorder { get; set; } = true;
|
public bool HasBorder { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the border thickness.
|
||||||
|
/// </summary>
|
||||||
|
[EditorDisplay("Border Style"), EditorOrder(2011), Limit(0)]
|
||||||
|
public float BorderThickness { get; set; } = 1.0f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the color of the border.
|
/// Gets or sets the color of the border.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorDisplay("Border Style"), EditorOrder(2011), ExpandGroups]
|
[EditorDisplay("Border Style"), EditorOrder(2012)]
|
||||||
public Color BorderColor { get; set; }
|
public Color BorderColor { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the border color when button is highlighted.
|
/// Gets or sets the border color when button is highlighted.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorDisplay("Border Style"), EditorOrder(2012)]
|
[EditorDisplay("Border Style"), EditorOrder(2013)]
|
||||||
public Color BorderColorHighlighted { get; set; }
|
public Color BorderColorHighlighted { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -252,7 +258,7 @@ namespace FlaxEngine.GUI
|
|||||||
else
|
else
|
||||||
Render2D.FillRectangle(clientRect, backgroundColor);
|
Render2D.FillRectangle(clientRect, backgroundColor);
|
||||||
if (HasBorder)
|
if (HasBorder)
|
||||||
Render2D.DrawRectangle(clientRect, borderColor);
|
Render2D.DrawRectangle(clientRect, borderColor, BorderThickness);
|
||||||
|
|
||||||
// Draw text
|
// Draw text
|
||||||
Render2D.DrawText(_font?.GetFont(), TextMaterial, _text, clientRect, textColor, TextAlignment.Center, TextAlignment.Center);
|
Render2D.DrawText(_font?.GetFont(), TextMaterial, _text, clientRect, textColor, TextAlignment.Center, TextAlignment.Center);
|
||||||
|
|||||||
@@ -107,17 +107,29 @@ namespace FlaxEngine.GUI
|
|||||||
CacheBox();
|
CacheBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets whether to have a border.
|
||||||
|
/// </summary>
|
||||||
|
[EditorDisplay("Border Style"), EditorOrder(2010), Tooltip("Whether to have a border."), ExpandGroups]
|
||||||
|
public bool HasBorder { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the border thickness.
|
||||||
|
/// </summary>
|
||||||
|
[EditorDisplay("Border Style"), EditorOrder(2011), Tooltip("The thickness of the border."), Limit(0)]
|
||||||
|
public float BorderThickness { get; set; } = 1.0f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the color of the border.
|
/// Gets or sets the color of the border.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorDisplay("Border Style"), EditorOrder(2010), ExpandGroups]
|
[EditorDisplay("Border Style"), EditorOrder(2012)]
|
||||||
public Color BorderColor { get; set; }
|
public Color BorderColor { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the border color when checkbox is hovered.
|
/// Gets or sets the border color when checkbox is hovered.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorDisplay("Border Style"), EditorOrder(2011)]
|
[EditorDisplay("Border Style"), EditorOrder(2013)]
|
||||||
public Color BorderColorHighlighted { get; set; }
|
public Color BorderColorHighlighted { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -221,12 +233,15 @@ namespace FlaxEngine.GUI
|
|||||||
bool enabled = EnabledInHierarchy;
|
bool enabled = EnabledInHierarchy;
|
||||||
|
|
||||||
// Border
|
// Border
|
||||||
Color borderColor = BorderColor;
|
if (HasBorder)
|
||||||
if (!enabled)
|
{
|
||||||
borderColor *= 0.5f;
|
Color borderColor = BorderColor;
|
||||||
else if (_isPressed || _mouseOverBox || IsNavFocused)
|
if (!enabled)
|
||||||
borderColor = BorderColorHighlighted;
|
borderColor *= 0.5f;
|
||||||
Render2D.DrawRectangle(_box.MakeExpanded(-2.0f), borderColor);
|
else if (_isPressed || _mouseOverBox || IsNavFocused)
|
||||||
|
borderColor = BorderColorHighlighted;
|
||||||
|
Render2D.DrawRectangle(_box.MakeExpanded(-2.0f), borderColor, BorderThickness);
|
||||||
|
}
|
||||||
|
|
||||||
// Icon
|
// Icon
|
||||||
if (_state != CheckBoxState.Default)
|
if (_state != CheckBoxState.Default)
|
||||||
|
|||||||
@@ -155,7 +155,8 @@ namespace FlaxEngine.GUI
|
|||||||
if (IsMouseOver || IsNavFocused)
|
if (IsMouseOver || IsNavFocused)
|
||||||
backColor = BackgroundSelectedColor;
|
backColor = BackgroundSelectedColor;
|
||||||
Render2D.FillRectangle(rect, backColor);
|
Render2D.FillRectangle(rect, backColor);
|
||||||
Render2D.DrawRectangle(rect, IsFocused ? BorderSelectedColor : BorderColor);
|
if (HasBorder)
|
||||||
|
Render2D.DrawRectangle(rect, IsFocused ? BorderSelectedColor : BorderColor, BorderThickness);
|
||||||
|
|
||||||
// Apply view offset and clip mask
|
// Apply view offset and clip mask
|
||||||
if (ClipText)
|
if (ClipText)
|
||||||
|
|||||||
@@ -270,16 +270,28 @@ namespace FlaxEngine.GUI
|
|||||||
[EditorDisplay("Background Style"), EditorOrder(2002), Tooltip("The speed of the selection background flashing animation.")]
|
[EditorDisplay("Background Style"), EditorOrder(2002), Tooltip("The speed of the selection background flashing animation.")]
|
||||||
public float BackgroundSelectedFlashSpeed { get; set; } = 6.0f;
|
public float BackgroundSelectedFlashSpeed { get; set; } = 6.0f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets whether to have a border.
|
||||||
|
/// </summary>
|
||||||
|
[EditorDisplay("Border Style"), EditorOrder(2010), Tooltip("Whether to have a border."), ExpandGroups]
|
||||||
|
public bool HasBorder { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the border thickness.
|
||||||
|
/// </summary>
|
||||||
|
[EditorDisplay("Border Style"), EditorOrder(2011), Tooltip("The thickness of the border."), Limit(0)]
|
||||||
|
public float BorderThickness { get; set; } = 1.0f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the color of the border (Transparent if not used).
|
/// Gets or sets the color of the border (Transparent if not used).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorDisplay("Border Style"), EditorOrder(2010), Tooltip("The color of the border (Transparent if not used)."), ExpandGroups]
|
[EditorDisplay("Border Style"), EditorOrder(2012), Tooltip("The color of the border (Transparent if not used).")]
|
||||||
public Color BorderColor { get; set; }
|
public Color BorderColor { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the color of the border when control is focused (Transparent if not used).
|
/// Gets or sets the color of the border when control is focused (Transparent if not used).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorDisplay("Border Style"), EditorOrder(2011), Tooltip("The color of the border when control is focused (Transparent if not used)")]
|
[EditorDisplay("Border Style"), EditorOrder(2013), Tooltip("The color of the border when control is focused (Transparent if not used)")]
|
||||||
public Color BorderSelectedColor { get; set; }
|
public Color BorderSelectedColor { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user