Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sources/engine/Stride.UI/Controls/Button.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ public ISpriteProvider MouseOverImage
}
}

/// <summary>
/// Gets or set the color used to tint the image. Default value is White.
/// </summary>
/// <remarks>The initial image color is multiplied by this color.</remarks>
/// <userdoc>The color used to tint the image. The default value is white.</userdoc>
[DataMember]
[Display(category: AppearanceCategory)]
public Color Color { get; set; } = Color.White;

/// <summary>
/// Gets or sets a value that describes how the button image should be stretched to fill the destination rectangle.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion sources/engine/Stride.UI/Controls/ImageElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ISpriteProvider Source
}

/// <summary>
/// Gets or set the color used to tint the image. Default value is White/>.
/// Gets or set the color used to tint the image. Default value is White.
/// </summary>
/// <remarks>The initial image color is multiplied by this color.</remarks>
/// <userdoc>The color used to tint the image. The default value is white.</userdoc>
Expand Down
10 changes: 10 additions & 0 deletions sources/engine/Stride.UI/Controls/ToggleButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Diagnostics;

using Stride.Core;
using Stride.Core.Mathematics;
using Stride.Engine;
using Stride.Graphics;
using Stride.UI.Attributes;
Expand Down Expand Up @@ -194,6 +195,15 @@ internal ISpriteProvider ToggleButtonImageProvider
/// </summary>
internal Sprite ToggleButtonImage => ToggleButtonImageProvider?.GetSprite();

/// <summary>
/// Gets or set the color used to tint the image. Default value is White.
/// </summary>
/// <remarks>The initial image color is multiplied by this color.</remarks>
/// <userdoc>The color used to tint the image. The default value is white.</userdoc>
[DataMember]
[Display(category: AppearanceCategory)]
public Color Color { get; set; } = Color.White;

/// <summary>
/// Determines whether the control supports two or three states.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override void RenderColor(UIElement element, UIRenderingContext context)
if (sprite?.Texture == null)
return;

var color = element.RenderOpacity * Color.White;
var color = element.RenderOpacity * button.Color;
Batch.DrawImage(sprite.Texture, ref element.WorldMatrixInternal, ref sprite.RegionInternal, ref element.RenderSizeInternal, ref sprite.BordersInternal, ref color, context.DepthBias, sprite.Orientation);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override void RenderColor(UIElement element, UIRenderingContext context)
if (sprite?.Texture == null)
return;

var color = toggleButton.RenderOpacity * Color.White;
var color = toggleButton.RenderOpacity * toggleButton.Color;
Batch.DrawImage(sprite.Texture, ref element.WorldMatrixInternal, ref sprite.RegionInternal, ref element.RenderSizeInternal, ref sprite.BordersInternal, ref color, context.DepthBias, sprite.Orientation);
}
}
Expand Down
Loading