A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Accessibility: the focused event card has a 2 px rim (L3) (Refs #2340) (#2437)
Beri889192667d5f
diff --git a/changelog.d/2340-event-card-focus-rim.md b/changelog.d/2340-event-card-focus-rim.mdnew file mode 100644index 000000000..ae24cf80c--- /dev/null+++ b/changelog.d/2340-event-card-focus-rim.md@@ -0,0 +1,4 @@+### Changed++- The decision card's focus ring (and the Capture dialog's, which shares its style) is 2 px instead of 1 px. The extra+ pixel is drawn on the card's trim overlay, so nothing inside the card moves when the focus comes or goes (#2340, L3).diff --git a/unity/Assets/Tests/EditMode/DecisionCardTests.cs b/unity/Assets/Tests/EditMode/DecisionCardTests.csindex e5efe2555..9ee48b663 100644--- a/unity/Assets/Tests/EditMode/DecisionCardTests.cs+++ b/unity/Assets/Tests/EditMode/DecisionCardTests.cs@@ -584,6 +584,50 @@ public class DecisionCardTestsAssert.LessOrEqual(r.Hide.worldBound.yMax, r.CardElement.worldBound.yMax + 0.5f, $"{where}: Hide stays inside the card");}+ /// <summary>#2340 L3: the focused card's rim is 2 px, not the resting 1 px (the card's border and its trim overlay's,+ /// Statecraft.uss .event-card:focus), and the focus coming or going moves nothing inside it, on the one-row HUD, the+ /// two-row HUD and a tight window at 150%, whose paddings and pixel snapping differ.</summary>+ [UnityTest]+ public IEnumerator TheFocusedCardHasATwoPixelRimAndItsContentStaysPut()+ {+ foreach (var (w, h, scale) in new[] { (1920, 1080, 100), (960, 1080, 100), (1920, 900, 150) })+ {+ using var r = new Rig(w, h, "law_of_return", uiScale: scale);+ yield return Frames(5);+ var where = $"{w}x{h} at {scale}%";+ if (scale == 150) Assert.IsTrue(r.Hud.ClassListContains(HudPresenter.TightClass) && r.Hud.ClassListContains(HudPresenter.Scale150Class), $"{where}: precondition, the tight 150% layout");+ var card = r.CardElement;+ var frame = card.Q<UiFrame>();+ Assert.AreSame(card, frame.parent, $"{where}: precondition, the card's own trim overlay");+ Assert.AreSame(card, r.Focused, $"{where}: precondition, the new card has the focus");+ // In screen pixels: the panel scales its units to the window and snaps each border to whole pixels.+ var screenPerUnit = w / r.Root.layout.width;+ foreach (var (side, px) in Rim(card, frame))+ Assert.GreaterOrEqual(px * screenPerUnit, 1.99f, $"{where}: the focused card's {side} rim ({px} panel units, {screenPerUnit} screen px each)");+ var focusedOuter = card.layout; var focusedContent = card.contentRect; var focusedHead = card.Q(className: "event-head").worldBound;++ r.FirstOption.Focus();+ yield return Frames(3);+ Assert.AreSame(r.FirstOption, r.Focused, $"{where}: precondition, the focus moved to an option");+ Assert.AreEqual(0f, frame.resolvedStyle.borderTopWidth, $"{where}: the resting rim is the card's 1 px border alone");+ Same(focusedOuter, card.layout, $"{where}: the card's outer box did not change");+ Same(focusedContent, card.contentRect, $"{where}: the card's content box did not move or change size");+ Same(focusedHead, card.Q(className: "event-head").worldBound, $"{where}: the card's head did not move");+ }++ // The rim on each side: the card's border and, just inside it, its trim overlay's.+ static (string, float)[] Rim(VisualElement card, VisualElement frame)+ {+ IResolvedStyle c = card.resolvedStyle, f = frame.resolvedStyle;+ return new[] { ("top", c.borderTopWidth + f.borderTopWidth), ("right", c.borderRightWidth + f.borderRightWidth),+ ("bottom", c.borderBottomWidth + f.borderBottomWidth), ("left", c.borderLeftWidth + f.borderLeftWidth) };+ }++ // Rects in panel units: the panel's pixel snapping leaves float noise far below a pixel.+ static void Same(Rect a, Rect b, string what) => Assert.IsTrue(Mathf.Abs(a.x - b.x) < 0.01f && Mathf.Abs(a.y - b.y) < 0.01f+ && Mathf.Abs(a.width - b.width) < 0.01f && Mathf.Abs(a.height - b.height) < 0.01f, $"{what}: {a} then {b}");+ }+/// <summary>#1853: a body scrolled down on one card does not carry over: the next card opens at the top of its text.</summary>[UnityTest]public IEnumerator TheNextCardOpensAtTheTopOfItsBody()diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussindex 952e284ca..970edee09 100644--- a/unity/Assets/UI/Statecraft.uss+++ b/unity/Assets/UI/Statecraft.uss@@ -292,8 +292,13 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);the options scroll together (event-scroll, #1853), while the head and the foot with Hide stay in the card. */.event-card { width: 1040px; max-width: 100%; max-height: 100%; flex-shrink: 1; min-height: 0; overflow: hidden; padding: 16px 40px 10px 40px; }.hud-two-row .event-card { padding-left: 16px; padding-right: 16px; }-/* The card takes the keyboard focus when an event opens (EventCardPresenter.FocusCard): a lighter gold edge says so. */+/* The card takes the keyboard focus when an event opens (EventCardPresenter.FocusCard): a lighter gold edge says so.+ #2340 L3: the edge is 2 px when focused, the card's own 1 px border and 1 px more on its trim overlay just inside it.+ The overlay lays nothing out (.ui-frame), so nothing in the card moves when the focus comes or goes; a 2 px border on+ the card itself would take a pixel from its content box, and at 150% UI scale the panel's pixel snapping keeps 1 px+ less padding from giving it back exactly (measured: the content moved by one screen pixel). */.event-card:focus { border-color: var(--gold-light); }+.event-card:focus > .ui-frame { border-width: 1px; border-color: var(--gold-light); }.event-card > * { flex-shrink: 0; }.event-card > .event-scroll { flex-shrink: 1; min-height: 48px; }#event-options { flex-shrink: 0; }