Add support for font size and color in Header attribute

This commit is contained in:
Wojtek Figat
2022-04-15 19:16:50 +02:00
parent ddb9b327d4
commit 3c841b1be1
5 changed files with 28 additions and 4 deletions

View File

@@ -715,7 +715,7 @@ namespace FlaxEditor.CustomEditors.Editors
// Header
if (item.Header != null)
itemLayout.Header(item.Header.Text);
itemLayout.Header(item.Header);
try
{

View File

@@ -274,6 +274,16 @@ namespace FlaxEditor.CustomEditors
return element;
}
internal LabelElement Header(HeaderAttribute header)
{
var element = Header(header.Text);
if (header.FontSize != -1)
element.Label.Font = new FontReference(element.Label.Font.Font, header.FontSize);
if (header.Color != 0)
element.Label.TextColor = Color.FromRGBA(header.Color);
return element;
}
/// <summary>
/// Adds new text box element.
/// </summary>

View File

@@ -317,7 +317,7 @@ namespace FlaxEditor.Surface
// Header
if (e.Header != null)
itemLayout.Header(e.Header.Text);
itemLayout.Header(e.Header);
// Values container
var valueType = new ScriptType(e.Type);

View File

@@ -410,7 +410,7 @@ namespace FlaxEditor.Surface
// Header
var header = (HeaderAttribute)attributes.FirstOrDefault(x => x is HeaderAttribute);
if (header != null)
itemLayout.Header(header.Text);
itemLayout.Header(header);
var propertyValue = new CustomValueContainer
(

View File

@@ -17,6 +17,16 @@ namespace FlaxEngine
/// </summary>
public string Text;
/// <summary>
/// The custom header font size.
/// </summary>
public int FontSize;
/// <summary>
/// The custom header color (as 32-bit uint).
/// </summary>
public uint Color;
private HeaderAttribute()
{
}
@@ -25,9 +35,13 @@ namespace FlaxEngine
/// Initializes a new instance of the <see cref="HeaderAttribute"/> class.
/// </summary>
/// <param name="text">The header text.</param>
public HeaderAttribute(string text)
/// <param name="fontSize">The header text font size (-1 to use default which is 14).</param>
/// <param name="color">The header color (as 32-bit uint, 0 to use default).</param>
public HeaderAttribute(string text, int fontSize = -1, uint color = 0)
{
Text = text;
FontSize = fontSize;
Color = color;
}
}
}