Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Keep event photos at 16:9 after card padding changes (#1075)

Aviel Cohen119e29f7992e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 66a7af814..b612c67f6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ checks this (see `CONTRIBUTING.md`).
## [Unreleased]
### Fixed
+- The event photograph keeps its 16:9 header when card padding changes without an outer resize (#649).
- The map info panel formats armistice zone and line dates in the selected UI language, reusing the existing date strings and isolating Hebrew dates inside English fallback rows; English output and agreement data are unchanged (refs #558).
## [0.1.4] - 2026-10-22
diff --git a/unity/Assets/Scripts/UI/EventCardPresenter.cs b/unity/Assets/Scripts/UI/EventCardPresenter.cs
index 2991f6883..084550bdb 100644
--- a/unity/Assets/Scripts/UI/EventCardPresenter.cs
+++ b/unity/Assets/Scripts/UI/EventCardPresenter.cs
@@ -456,7 +456,13 @@ namespace Statecraft.Game.UI
if (h < needs - 0.5f) SetPhotoShown(false);
}
- void OnPhotoGeometry(GeometryChangedEvent evt) => FitPhoto();
+ void OnPhotoGeometry(GeometryChangedEvent evt)
+ {
+ // A padding change can resize the header without changing the card's outer rectangle (#649).
+ // The existing width guard prevents the height update from chasing its own geometry events.
+ OnCardGeometry(evt);
+ FitPhoto();
+ }
/// <summary>The decision layer changed size (the window did; the card's content never moves it, as the layer is pinned
/// to the window on every side). A shown photograph is checked again; a dropped one comes back only when the room now
diff --git a/unity/Assets/Tests/EditMode/DecisionCardTests.cs b/unity/Assets/Tests/EditMode/DecisionCardTests.cs
index c00b2b639..97c768dfa 100644
--- a/unity/Assets/Tests/EditMode/DecisionCardTests.cs
+++ b/unity/Assets/Tests/EditMode/DecisionCardTests.cs
@@ -88,6 +88,30 @@ public class DecisionCardTests
static readonly (int w, int h)[] Tiers = { (1920, 1080), (960, 1080) };
+ [UnityTest]
+ public IEnumerator ThePhotoAspectFollowsPaddingWithoutAnOuterResize()
+ {
+ using var r = new Rig(1024, 1024, "law_of_return", photos: true);
+ yield return Frames(6);
+ var card = r.CardElement;
+ var photo = r.Root.Q("event-photo");
+ Assert.IsTrue(r.Card.PhotoAlt != null, "precondition: the photograph shows");
+ Assert.AreEqual(16f, card.resolvedStyle.paddingLeft, 0.5f, "precondition: the two-row padding");
+ Assert.AreEqual(photo.layout.width / EventCardPresenter.MediaAspect, photo.layout.height, 2.5f,
+ "precondition: the settled header has its aspect ratio");
+ var outer = card.layout;
+ var before = photo.layout.width;
+
+ // #649: the one-row padding takes 48 px from the content, without changing the card's outer width.
+ card.style.paddingLeft = 40f;
+ card.style.paddingRight = 40f;
+ yield return Frames(6);
+ Assert.AreEqual(outer.width, card.layout.width, 0.5f, "the outer width did not change");
+ Assert.AreEqual(before - 48f, photo.layout.width, 1.5f, "the header follows the new content width (panel pixel rounding)");
+ Assert.AreEqual(photo.layout.width / EventCardPresenter.MediaAspect, photo.layout.height, 2.5f,
+ $"header {photo.layout.width}x{photo.layout.height}, card {card.layout}, original {outer}");
+ }
+
/// <summary>#380: the taller two- and three-row bars raise the centred card (the event layer keeps room at its bottom), and
/// the backdrop must still reach the window's bottom and right edges, so no strip of map stays live under an open card.</summary>
[UnityTest]