diff --git a/CHANGELOG.md b/CHANGELOG.md index 27bb34fe3..21a151f98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### Fixed - Use code signing on all Windows executables (`ErsatzTV-Windows.exe`, `ErsatzTV.exe`, `ErsatzTV.Scanner.exe`) +- Respect `z_index` (draw order) on all graphics element types ## [26.1.1] - 2026-01-08 ### Fixed diff --git a/ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElement.cs b/ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElement.cs index 3d959507b..fa95a2b9e 100644 --- a/ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElement.cs +++ b/ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElement.cs @@ -7,7 +7,7 @@ namespace ErsatzTV.Infrastructure.Streaming.Graphics; public abstract class GraphicsElement : IGraphicsElement { - public int ZIndex { get; protected set; } + public abstract int ZIndex { get; } public bool IsFinished { get; set; } diff --git a/ErsatzTV.Infrastructure/Streaming/Graphics/Image/ImageElement.cs b/ErsatzTV.Infrastructure/Streaming/Graphics/Image/ImageElement.cs index c69fffd57..127205a56 100644 --- a/ErsatzTV.Infrastructure/Streaming/Graphics/Image/ImageElement.cs +++ b/ErsatzTV.Infrastructure/Streaming/Graphics/Image/ImageElement.cs @@ -11,6 +11,8 @@ public class ImageElement(ImageGraphicsElement imageGraphicsElement, ILogger log private Option _maybeOpacityExpression; private float _opacity; + public override int ZIndex { get; } = imageGraphicsElement.ZIndex ?? 0; + public override async Task InitializeAsync(GraphicsEngineContext context, CancellationToken cancellationToken) { try @@ -26,8 +28,6 @@ public class ImageElement(ImageGraphicsElement imageGraphicsElement, ILogger log _opacity = (imageGraphicsElement.OpacityPercent ?? 100) / 100.0f; } - ZIndex = imageGraphicsElement.ZIndex ?? 0; - foreach (Expression expression in _maybeOpacityExpression) { expression.EvaluateFunction += OpacityExpressionHelper.EvaluateFunction; diff --git a/ErsatzTV.Infrastructure/Streaming/Graphics/Image/WatermarkElement.cs b/ErsatzTV.Infrastructure/Streaming/Graphics/Image/WatermarkElement.cs index 112da270b..44eedcec6 100644 --- a/ErsatzTV.Infrastructure/Streaming/Graphics/Image/WatermarkElement.cs +++ b/ErsatzTV.Infrastructure/Streaming/Graphics/Image/WatermarkElement.cs @@ -29,6 +29,8 @@ public class WatermarkElement : ImageElementBase public bool IsValid => _imagePath != null && _watermark != null; + public override int ZIndex { get; } + public override async Task InitializeAsync(GraphicsEngineContext context, CancellationToken cancellationToken) { try diff --git a/ErsatzTV.Infrastructure/Streaming/Graphics/Motion/MotionElement.cs b/ErsatzTV.Infrastructure/Streaming/Graphics/Motion/MotionElement.cs index 2d76fba7a..87598aa79 100644 --- a/ErsatzTV.Infrastructure/Streaming/Graphics/Motion/MotionElement.cs +++ b/ErsatzTV.Infrastructure/Streaming/Graphics/Motion/MotionElement.cs @@ -30,6 +30,8 @@ public class MotionElement( private TimeSpan _endTime; private MotionElementState _state; + public override int ZIndex { get; } = motionElement.ZIndex ?? 0; + public void Dispose() { GC.SuppressFinalize(this); diff --git a/ErsatzTV.Infrastructure/Streaming/Graphics/Script/ScriptElement.cs b/ErsatzTV.Infrastructure/Streaming/Graphics/Script/ScriptElement.cs index 78805643f..51c5e632a 100644 --- a/ErsatzTV.Infrastructure/Streaming/Graphics/Script/ScriptElement.cs +++ b/ErsatzTV.Infrastructure/Streaming/Graphics/Script/ScriptElement.cs @@ -27,6 +27,8 @@ public class ScriptElement(ScriptGraphicsElement scriptElement, ILogger logger) private int _repeatCount; private long _totalBytes; + public override int ZIndex { get; } = scriptElement.ZIndex ?? 0; + public void Dispose() { logger.LogDebug( diff --git a/ErsatzTV.Infrastructure/Streaming/Graphics/Subtitle/SubtitleElement.cs b/ErsatzTV.Infrastructure/Streaming/Graphics/Subtitle/SubtitleElement.cs index c3f18d8e0..43d1e9ed5 100644 --- a/ErsatzTV.Infrastructure/Streaming/Graphics/Subtitle/SubtitleElement.cs +++ b/ErsatzTV.Infrastructure/Streaming/Graphics/Subtitle/SubtitleElement.cs @@ -30,6 +30,8 @@ public class SubtitleElement( private SKBitmap _videoFrame; private bool _isFinished; + public override int ZIndex { get; } = subtitleElement.ZIndex ?? 0; + public void Dispose() { GC.SuppressFinalize(this); diff --git a/ErsatzTV.Infrastructure/Streaming/Graphics/Text/TextElement.cs b/ErsatzTV.Infrastructure/Streaming/Graphics/Text/TextElement.cs index 57f4988e0..0d3b47133 100644 --- a/ErsatzTV.Infrastructure/Streaming/Graphics/Text/TextElement.cs +++ b/ErsatzTV.Infrastructure/Streaming/Graphics/Text/TextElement.cs @@ -21,6 +21,8 @@ public partial class TextElement( private Option _maybeOpacityExpression; private float _opacity; + public override int ZIndex { get; } = textElement.ZIndex ?? 0; + public void Dispose() { GC.SuppressFinalize(this); @@ -44,8 +46,6 @@ public partial class TextElement( _opacity = (textElement.OpacityPercent ?? 100) / 100.0f; } - ZIndex = textElement.ZIndex ?? 0; - if (!string.IsNullOrWhiteSpace(textElement.IncludeFontsFrom)) { if (Directory.Exists(textElement.IncludeFontsFrom))