mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
fix(ui): panel rails keep clear of an obstacle across the middle of the window
An obstacle that crossed the middle of the window (the World Timeline, the voice control or a card in a window under about 520px tall) was neither above nor below it, so neither rail counted it and panels could be laid out over it. Such an obstacle now puts the panels on whichever side of it has more room. When neither side has room, the rails keep their existing minimum (the right rail's empty band, the left rail's minimum lane height). Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
ec1fc6bc09
commit
8b055a1423
5 files changed
+109
-2
No files matched your search
@@ -286,6 +286,58 @@ test('HUD rail layout constrains an oversized panel to the safe corridor', () =>
|
||||
assert.equal(layout.constrained, true);
|
||||
});
|
||||
|
||||
test('HUD rail layout keeps a short window clear of an obstacle across its midpoint', () => {
|
||||
// 480px window: midpoint 240. Each obstacle is neither wholly above nor
|
||||
// wholly below the midpoint, and must still limit the band.
|
||||
const above = resolveHudRailLayout({
|
||||
viewportHeight: 480,
|
||||
panelHeight: 120,
|
||||
laneLeft: 20,
|
||||
laneRight: 340,
|
||||
baseTop: 40,
|
||||
baseBottom: 460,
|
||||
gap: 10,
|
||||
obstacles: [{ left: 0, right: 400, top: 200, bottom: 300 }],
|
||||
});
|
||||
// Room above: 200 - 10 - 40 = 150; below: 460 - 310 = 150. A tie keeps the
|
||||
// band above the obstacle.
|
||||
assert.equal(above.safeTop, 40);
|
||||
assert.equal(above.safeBottom, 190);
|
||||
assert(above.top + Math.min(120, above.maxHeight) <= 190);
|
||||
|
||||
const below = resolveHudRailLayout({
|
||||
viewportHeight: 480,
|
||||
panelHeight: 120,
|
||||
laneLeft: 20,
|
||||
laneRight: 340,
|
||||
baseTop: 40,
|
||||
baseBottom: 460,
|
||||
gap: 10,
|
||||
obstacles: [{ left: 0, right: 400, top: 120, bottom: 260 }],
|
||||
});
|
||||
// Room above: 70; below: 190. The band goes under the obstacle.
|
||||
assert.equal(below.safeTop, 270);
|
||||
assert.equal(below.safeBottom, 460);
|
||||
assert(below.top >= 270);
|
||||
});
|
||||
|
||||
test('HUD rail layout keeps its zero-height fallback when a straddling obstacle leaves no room', () => {
|
||||
const layout = resolveHudRailLayout({
|
||||
viewportHeight: 480,
|
||||
panelHeight: 120,
|
||||
laneLeft: 20,
|
||||
laneRight: 340,
|
||||
baseTop: 100,
|
||||
baseBottom: 400,
|
||||
gap: 10,
|
||||
obstacles: [{ left: 0, right: 400, top: 80, bottom: 420 }],
|
||||
});
|
||||
assert.equal(layout.maxHeight, 0);
|
||||
assert.equal(layout.constrained, true);
|
||||
assert.equal(layout.safeTop, 100);
|
||||
assert.equal(layout.safeBottom, 100);
|
||||
});
|
||||
|
||||
test('HUD rail layout can anchor controls to the start of the safe corridor', () => {
|
||||
const layout = resolveHudRailLayout({
|
||||
viewportHeight: 1000,
|
||||
|
||||
Reference in new issue
Block a user