The creator (2026-10-21), on Live -> Layers -> webcam -> Properties: "the Y and H boxes under webcam properties should be the same width as the X and W boxes and those widths should be fixed to accomodate the max number of possible digits providing the geometry values" "also the border color drop drown box content should also include the name of the color next to the hex value as they in the drop-down list box" TASK 61 - one fixed width for the four geometry fields. The row is a DockPanel, and WPF sizes an element to its CONTENT unless it is told otherwise, while the LAST child of a DockPanel fills the remaining space. So X/W (not last) were as wide as their text and Y/H (last) stretched across the row - two widths for the same kind of field. Now all four carry Width="44" and the rows set LastChildFill="False" (without it the last field ignores its own Width and fills anyway). 44px is the measured width of "-1920" in the app's font at 11px (the largest geometry value - the master frame is 1920x1080 - plus a sign) plus the field's padding and border. Docs: https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.dockpanel.lastchildfill The guard MEASURES the widest value with WPF's FormattedText instead of asserting a magic number, so a font change cannot silently make the field too narrow: https://learn.microsoft.com/en-us/dotnet/api/system.windows.media.formattedtext TASK 62 - the border field names its colour. SceneElement.BorderColorName carries the palette's name for the current colour ("Crimson") and is raised when the colour changes; it is EMPTY for a custom hex the creator typed, because "no name" is the honest answer. BorderColorPalette.NameOf changed to match (it used to fall back to the hex itself; the TASK 60 test assertion was updated with it). The hex field keeps a fixed width (60) so the name sits right next to the hex instead of drifting to the row's far edge - the same trap as TASK 61. Guards: ytLive.Tests/GeometryFieldWidthTests.cs, ytLive.Tests/BorderColorNameTests.cs Full suite: 435/435 passed, 0 warnings.
51 lines
2.0 KiB
C#
51 lines
2.0 KiB
C#
namespace ytLive.Models;
|
|
|
|
/// <summary>A colour the border picker offers: its hex value and the plain-English
|
|
/// name shown next to it (TASK 60).</summary>
|
|
/// <param name="Hex">The hex value, e.g. <c>#e94560</c>.</param>
|
|
/// <param name="Name">The name the creator reads, e.g. <c>Crimson</c>.</param>
|
|
public readonly record struct NamedColor(string Hex, string Name);
|
|
|
|
/// <summary>The colours the webcam's border-colour drop-down offers — the SINGLE
|
|
/// source of truth for the list and for the names.
|
|
///
|
|
/// <para>TASK 60 (the creator, 2026-10-21): *"in the drop down box, the #hex values are
|
|
/// good, but add a corresponding color name/label next to the value."* The list used to
|
|
/// be a hard-coded array in the click handler, which is why a name could not be added
|
|
/// to it without touching the UI code.</para>
|
|
/// </summary>
|
|
public static class BorderColorPalette
|
|
{
|
|
/// <summary>The offered colours, in menu order.</summary>
|
|
public static IReadOnlyList<NamedColor> All { get; } = new NamedColor[]
|
|
{
|
|
new("#FFFFFF", "White"),
|
|
new("#000000", "Black"),
|
|
new("#FF0000", "Red"),
|
|
new("#00FF00", "Lime"),
|
|
new("#0000FF", "Blue"),
|
|
new("#FFFF00", "Yellow"),
|
|
new("#FF00FF", "Magenta"),
|
|
new("#00FFFF", "Cyan"),
|
|
new("#FF8800", "Orange"),
|
|
new("#8800FF", "Violet"),
|
|
new("#e94560", "Crimson"),
|
|
new("#22c55e", "Emerald"),
|
|
new("#3b82f6", "Azure"),
|
|
new("#f59e0b", "Amber"),
|
|
};
|
|
|
|
/// <summary>The colour's name, or an **empty string** when the palette has no name
|
|
/// for that hex (a custom hex the creator typed) — the caller decides what to show
|
|
/// then, and the border field shows the hex alone.</summary>
|
|
public static string NameOf(string hex)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(hex)) return string.Empty;
|
|
var trimmed = hex.Trim();
|
|
foreach (var colour in All)
|
|
if (string.Equals(colour.Hex, trimmed, StringComparison.OrdinalIgnoreCase))
|
|
return colour.Name;
|
|
return string.Empty;
|
|
}
|
|
}
|