diff --git a/sources/engine/Stride.UI/Controls/Button.cs b/sources/engine/Stride.UI/Controls/Button.cs index c117f323be..a82d2d5cf0 100644 --- a/sources/engine/Stride.UI/Controls/Button.cs +++ b/sources/engine/Stride.UI/Controls/Button.cs @@ -109,6 +109,15 @@ public ISpriteProvider MouseOverImage } } + /// + /// Gets or set the color used to tint the image. Default value is White. + /// + /// The initial image color is multiplied by this color. + /// The color used to tint the image. The default value is white. + [DataMember] + [Display(category: AppearanceCategory)] + public Color Color { get; set; } = Color.White; + /// /// Gets or sets a value that describes how the button image should be stretched to fill the destination rectangle. /// diff --git a/sources/engine/Stride.UI/Controls/ImageElement.cs b/sources/engine/Stride.UI/Controls/ImageElement.cs index 051b7007bc..d8a5270dfc 100644 --- a/sources/engine/Stride.UI/Controls/ImageElement.cs +++ b/sources/engine/Stride.UI/Controls/ImageElement.cs @@ -44,7 +44,7 @@ public ISpriteProvider Source } /// - /// 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. /// /// The initial image color is multiplied by this color. /// The color used to tint the image. The default value is white. diff --git a/sources/engine/Stride.UI/Controls/ToggleButton.cs b/sources/engine/Stride.UI/Controls/ToggleButton.cs index 0fbb272380..ef0c934ccf 100644 --- a/sources/engine/Stride.UI/Controls/ToggleButton.cs +++ b/sources/engine/Stride.UI/Controls/ToggleButton.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using Stride.Core; +using Stride.Core.Mathematics; using Stride.Engine; using Stride.Graphics; using Stride.UI.Attributes; @@ -194,6 +195,15 @@ internal ISpriteProvider ToggleButtonImageProvider /// internal Sprite ToggleButtonImage => ToggleButtonImageProvider?.GetSprite(); + /// + /// Gets or set the color used to tint the image. Default value is White. + /// + /// The initial image color is multiplied by this color. + /// The color used to tint the image. The default value is white. + [DataMember] + [Display(category: AppearanceCategory)] + public Color Color { get; set; } = Color.White; + /// /// Determines whether the control supports two or three states. /// diff --git a/sources/engine/Stride.UI/Renderers/DefaultButtonRenderer.cs b/sources/engine/Stride.UI/Renderers/DefaultButtonRenderer.cs index c3e27d739a..04ae5a0bf8 100644 --- a/sources/engine/Stride.UI/Renderers/DefaultButtonRenderer.cs +++ b/sources/engine/Stride.UI/Renderers/DefaultButtonRenderer.cs @@ -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); } } diff --git a/sources/engine/Stride.UI/Renderers/DefaultToggleButtonRenderer.cs b/sources/engine/Stride.UI/Renderers/DefaultToggleButtonRenderer.cs index 5c747cbbf4..76a7191721 100644 --- a/sources/engine/Stride.UI/Renderers/DefaultToggleButtonRenderer.cs +++ b/sources/engine/Stride.UI/Renderers/DefaultToggleButtonRenderer.cs @@ -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); } }