Part 1 - background box. TextGraphicsElement gains element-level background_color, background_opacity_percent, background_padding, background_corner_radius, border_color and border_width; TextElement draws a rounded rect behind the text block and insets the text into it. Element level rather than per-style because the engine lays the whole element out as one RichTextKit TextBlock and rasterises it into one bitmap, so one box per element is the only shape the renderer can express. width_percent keeps bounding the visible element, so the insets are subtracted from the text's wrap/scale budget. The seeded on-now-next.yml adopts it. The halo drops from 2px to 1px rather than to zero, and the box carries a low-alpha white border: rendered against real frames, a 65% black fill is legible on bright and midtone content but vanishes entirely into dark content, which is why the issue asked for an *outlined* box. The halo still matters because the fill is translucent. Because #74's seeder writes the template only when absent, an already-seeded install would never have seen any of this. GraphicsElementSeeder now keeps every default it has shipped as a verbatim fingerprint and rewrites the file only when it still matches one (line-endings normalised), so an untouched install upgrades and an operator-edited one is left alone. The V1 fingerprint was checked byte-for-byte against the live install before being trusted - a fingerprint that matches nothing in the field is a permanent silent no-op. Part 2 - on by default. New channels get the built-in element from CreateChannelHandler (CreateChannel carries no graphics field and the SPA's channel editor is update-only, so the server is the only place a create-time default can live). Pre-existing channels get a one-time AttachOnNowNextByDefault backfill. The marker is written on the first run even when nothing was attached: the tempting alternative - stay armed until the element row exists - would fire on a later boot and re-attach the overlay to a channel the operator had cleared in between. HLS Direct is excluded at both sites, where the overlay cannot render at all. Resolves the issue's open question: [vge] in a filter graph does not imply a graphics element is bound. Watermarks fall back onto the graphics engine whenever they cannot use ffmpeg's native overlay shortcut, so a watermark alone produces that stage. Tests assert rendered pixels, because every failure mode here is a silent no-op that a model-level test cannot see. 13 clause mutations were executed against them; each reddened only its own clause. Decisions-Edit: yes Refs: #732
117 lines
4.0 KiB
C#
117 lines
4.0 KiB
C#
using ErsatzTV.FFmpeg.State;
|
|
using YamlDotNet.Serialization;
|
|
|
|
namespace ErsatzTV.Core.Graphics;
|
|
|
|
public class TextGraphicsElement : BaseGraphicsElement
|
|
{
|
|
[YamlMember(Alias = "opacity_percent", ApplyNamingConventions = false)]
|
|
public int? OpacityPercent { get; set; }
|
|
|
|
[YamlMember(Alias = "opacity_expression", ApplyNamingConventions = false)]
|
|
public string OpacityExpression { get; set; }
|
|
|
|
public WatermarkLocation Location { get; set; }
|
|
|
|
[YamlMember(Alias = "horizontal_margin_percent", ApplyNamingConventions = false)]
|
|
public double? HorizontalMarginPercent { get; set; }
|
|
|
|
[YamlMember(Alias = "vertical_margin_percent", ApplyNamingConventions = false)]
|
|
public double? VerticalMarginPercent { get; set; }
|
|
|
|
[YamlMember(Alias = "width_percent", ApplyNamingConventions = false)]
|
|
public double? WidthPercent { get; set; }
|
|
|
|
[YamlMember(Alias = "text_fit", ApplyNamingConventions = false)]
|
|
public TextFit Fit { get; set; } = TextFit.None;
|
|
|
|
[YamlMember(Alias = "text_align", ApplyNamingConventions = false)]
|
|
public TextAlignment Align { get; set; } = TextAlignment.Left;
|
|
|
|
[YamlMember(Alias = "z_index", ApplyNamingConventions = false)]
|
|
public int? ZIndex { get; set; }
|
|
|
|
// Background box (ersatztv#732). Element-level, not per-style: the graphics engine renders one
|
|
// TextBlock into one bitmap, so a single box behind the whole element is the only shape the
|
|
// renderer can express. Unset background_color means no box at all -- the pre-#732 behavior.
|
|
[YamlMember(Alias = "background_color", ApplyNamingConventions = false)]
|
|
public string BackgroundColor { get; set; }
|
|
|
|
[YamlMember(Alias = "background_opacity_percent", ApplyNamingConventions = false)]
|
|
public int? BackgroundOpacityPercent { get; set; }
|
|
|
|
[YamlMember(Alias = "background_padding", ApplyNamingConventions = false)]
|
|
public double? BackgroundPadding { get; set; }
|
|
|
|
[YamlMember(Alias = "background_corner_radius", ApplyNamingConventions = false)]
|
|
public double? BackgroundCornerRadius { get; set; }
|
|
|
|
[YamlMember(Alias = "border_color", ApplyNamingConventions = false)]
|
|
public string BorderColor { get; set; }
|
|
|
|
[YamlMember(Alias = "border_width", ApplyNamingConventions = false)]
|
|
public double? BorderWidth { get; set; }
|
|
|
|
public List<StyleDefinition> Styles { get; set; } = [];
|
|
|
|
[YamlMember(Alias = "base_style", ApplyNamingConventions = false)]
|
|
public string BaseStyle { get; set; }
|
|
|
|
[YamlMember(Alias = "include_fonts_from", ApplyNamingConventions = false)]
|
|
public string IncludeFontsFrom { get; set; }
|
|
|
|
[YamlMember(Alias = "epg_entries", ApplyNamingConventions = false)]
|
|
public int EpgEntries { get; set; }
|
|
|
|
public string Text { get; set; }
|
|
}
|
|
|
|
public enum TextFit
|
|
{
|
|
None,
|
|
Wrap,
|
|
Scale
|
|
}
|
|
|
|
public enum TextAlignment
|
|
{
|
|
Left,
|
|
Center,
|
|
Right
|
|
}
|
|
|
|
public class StyleDefinition
|
|
{
|
|
public string Name { get; set; }
|
|
|
|
[YamlMember(Alias = "font_size", ApplyNamingConventions = false)]
|
|
public float? FontSize { get; set; }
|
|
|
|
[YamlMember(Alias = "font_weight", ApplyNamingConventions = false)]
|
|
public int? FontWeight { get; set; }
|
|
|
|
[YamlMember(Alias = "font_italic", ApplyNamingConventions = false)]
|
|
public bool? FontItalic { get; set; }
|
|
|
|
[YamlMember(Alias = "font_family", ApplyNamingConventions = false)]
|
|
public string FontFamily { get; set; }
|
|
|
|
[YamlMember(Alias = "text_color", ApplyNamingConventions = false)]
|
|
public string TextColor { get; set; }
|
|
|
|
[YamlMember(Alias = "letter_spacing", ApplyNamingConventions = false)]
|
|
public float? LetterSpacing { get; set; }
|
|
|
|
[YamlMember(Alias = "line_height", ApplyNamingConventions = false)]
|
|
public float? LineHeight { get; set; }
|
|
|
|
[YamlMember(Alias = "halo_color", ApplyNamingConventions = false)]
|
|
public string HaloColor { get; set; }
|
|
|
|
[YamlMember(Alias = "halo_width", ApplyNamingConventions = false)]
|
|
public float? HaloWidth { get; set; }
|
|
|
|
[YamlMember(Alias = "halo_blur", ApplyNamingConventions = false)]
|
|
public float? HaloBlur { get; set; }
|
|
}
|