feat(signage): slides keep their shape on any screen, custom shapes (21:9, 16:10…), Calibrate the picture edge by edge with presets

A slide is drawn at its playlist's shape, as large as fits the screen's picture,
the bands in its own background (or stretched, the screen's choice). Playlists and
library slides may have a shape of their own (aspect, Alembic 0045). Signage ->
Screens -> Calibrate the picture: the TV outlines its area with arrows and its size,
each edge moves pixel by pixel or a preset centres a shape; the TV follows live
(signage.calibrate) and reports its window (POST /screen/viewport). Plan 6R.13, F-110.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 13:04:24 +02:00
co-authored by Claude Opus 5.5
parent d5c19e17ce
commit 1c8d45e00c
32 changed files with 917 additions and 103 deletions
+40 -1
View File
@@ -1605,7 +1605,17 @@
"defaultHint": "Όταν δεν ταιριάζει καμία γραμμή προγράμματος: μια λίστα ή μία διαφάνεια μόνη της.",
"aPlaylist": "Λίστα",
"aSlide": "Διαφάνεια",
"nowSlide": "Τώρα: {{name}} (η διαφάνεια προεπιλογής της)"
"nowSlide": "Τώρα: {{name}} (η διαφάνεια προεπιλογής της)",
"fit": "Διαφάνειες άλλου σχήματος",
"fitHint": "Διαφάνεια φτιαγμένη για άλλο σχήμα από την εικόνα αυτής της οθόνης.",
"fits": {
"keep": "Κρατούν το σχήμα τους (λωρίδες)",
"stretch": "Τέντωμα σε όλη την εικόνα"
},
"pictureWhole": "Η εικόνα γεμίζει όλο το παράθυρο της τηλεόρασης.",
"pictureCut": "Η εικόνα είναι βαθμονομημένη (άκρες μετακινημένες προς τα μέσα).",
"pictureWindow": "Η εικόνα γεμίζει όλο το παράθυρο της τηλεόρασης: {{w}} × {{h}} px, {{shape}}.",
"pictureOf": "Η εικόνα: {{w}} × {{h}} px ({{shape}}) από το παράθυρο {{ww}} × {{wh}} της τηλεόρασης."
},
"schedules": {
"new": "Νέο πρόγραμμα",
@@ -1789,6 +1799,35 @@
"empty": "Συμπληρώστε έναν αριθμό (1 ή περισσότερα).",
"backTo": "Πίσω στα {{n}}",
"warning": "Πάνω από {{n}} widgets μπορεί να κάνουν τις τηλεοράσεις να κολλάνε (διαφάνειες που αλλάζουν αργά, βίντεο που κόβονται). Ελέγξτε τις οθόνες σας αφού τα προσθέσετε."
},
"shape": {
"custom": "Δικό του σχήμα {{shape}}",
"own": "Δικό του σχήμα (21:9, 16:10…)",
"hint": "Για οθόνες που δεν είναι 16:9. Οι διαφάνειες φτιάχνονται και προβάλλονται σε αυτό το σχήμα.",
"width": "Πλάτος",
"height": "Ύψος",
"invalid": "Από 1:4 έως 4:1, ακέραιοι έως 99.",
"use": "Χρήση {{shape}}"
},
"calibrate": {
"open": "Βαθμονόμηση εικόνας",
"title": "Βαθμονόμηση εικόνας: {{name}}",
"intro": "Η τηλεόραση δείχνει τώρα τις άκρες της εικόνας με τέσσερα βέλη προς τα έξω. Μετακινήστε κάθε άκρη μέχρι το βέλος της να ακουμπά την άκρη της οθόνης ή διαλέξτε σχήμα. Οι αλλαγές φαίνονται αμέσως στην τηλεόραση.",
"window": "Το παράθυρο της τηλεόρασης: {{w}} × {{h}} px ({{shape}}).",
"waiting": "Αναμονή για το μέγεθος της τηλεόρασης… Είναι ανοιχτή και δείχνει ψηφιακή σήμανση;",
"presets": "Σχήματα",
"full": "Όλη η οθόνη",
"step": "Κάθε κλικ μετακινεί",
"edges": {
"top": "Πάνω άκρη μέσα",
"right": "Δεξιά άκρη μέσα",
"bottom": "Κάτω άκρη μέσα",
"left": "Αριστερή άκρη μέσα"
},
"picture": "Η εικόνα: {{w}} × {{h}} px ({{shape}})",
"outside": "Έξω από την εικόνα η τηλεόραση μένει μαύρη.",
"reset": "Ξανά όλη η οθόνη",
"done": "Τέλος"
}
},
"overview": {
+24
View File
@@ -572,7 +572,31 @@
"180": "Ανάποδα",
"270": "90° αριστερά"
}
},
"fit": {
"label": "Διαφάνειες άλλου σχήματος",
"hint": "Να κρατούν το σχήμα τους (λωρίδες με το φόντο της διαφάνειας) ή να τεντώνονται σε όλη την εικόνα.",
"choices": {
"keep": "Κρατούν το σχήμα τους",
"stretch": "Τέντωμα σε όλη την εικόνα"
}
},
"area_left": {
"label": "Περιοχή εικόνας: αριστερή άκρη (px)",
"hint": "Ρυθμίζεται από Ψηφιακή σήμανση → Οθόνες → Βαθμονόμηση εικόνας."
},
"area_top": {
"label": "Περιοχή εικόνας: πάνω άκρη (px)"
},
"area_right": {
"label": "Περιοχή εικόνας: δεξιά άκρη (px)"
},
"area_bottom": {
"label": "Περιοχή εικόνας: κάτω άκρη (px)"
}
},
"config_groups": {
"picture": "Η εικόνα"
}
},
"staff_planning": {
+4
View File
@@ -487,6 +487,10 @@
"spicy": "Καυτερό",
"vegetarian": "Χορτοφαγικό",
"vegan": "Vegan"
},
"calibrate": {
"title": "Βαθμονόμηση εικόνας: {{name}}",
"hint": "Στον διαχειριστή (Ψηφιακή σήμανση → Οθόνες) μετακινήστε κάθε άκρη μέχρι τα βέλη να ακουμπούν τις άκρες της οθόνης."
}
},
"menuTablet": {
+40 -1
View File
@@ -1605,7 +1605,17 @@
"defaultHint": "When no schedule line matches: a playlist, or one slide shown alone.",
"aPlaylist": "Playlist",
"aSlide": "Slide",
"nowSlide": "Now: {{name}} (its default slide)"
"nowSlide": "Now: {{name}} (its default slide)",
"fit": "Slides of another shape",
"fitHint": "A slide built for another shape than this screen's picture.",
"fits": {
"keep": "Keep their shape (bands)",
"stretch": "Stretch to fill"
},
"pictureWhole": "The picture fills the TV's whole window.",
"pictureCut": "The picture is calibrated (edges moved in).",
"pictureWindow": "The picture fills the TV's whole window: {{w}} × {{h}} px, {{shape}}.",
"pictureOf": "The picture: {{w}} × {{h}} px ({{shape}}) of the TV's {{ww}} × {{wh}} window."
},
"schedules": {
"new": "New schedule",
@@ -1789,6 +1799,35 @@
"empty": "Fill in a number (1 or more).",
"backTo": "Back to {{n}}",
"warning": "More than {{n}} widgets can make the TVs stutter (slides turning late, videos jerking). Check your screens after you add them."
},
"shape": {
"custom": "Own shape {{shape}}",
"own": "A shape of its own (21:9, 16:10…)",
"hint": "For screens that aren't 16:9. The slides are built and shown at this shape.",
"width": "Width",
"height": "Height",
"invalid": "Between 1:4 and 4:1, whole numbers up to 99.",
"use": "Use {{shape}}"
},
"calibrate": {
"open": "Calibrate the picture",
"title": "Calibrate the picture: {{name}}",
"intro": "The TV now shows its picture's edges with four arrows pointing out. Move each edge until its arrow just touches the edge of the screen, or pick a shape. Changes show on the TV at once.",
"window": "The TV's window: {{w}} × {{h}} px ({{shape}}).",
"waiting": "Waiting for the TV to tell its size… Is it on and showing signage?",
"presets": "Shapes",
"full": "Whole screen",
"step": "Each click moves",
"edges": {
"top": "Top edge in",
"right": "Right edge in",
"bottom": "Bottom edge in",
"left": "Left edge in"
},
"picture": "The picture: {{w}} × {{h}} px ({{shape}})",
"outside": "Outside the picture the TV stays black.",
"reset": "Whole screen again",
"done": "Done"
}
},
"overview": {
+24
View File
@@ -572,7 +572,31 @@
"180": "Upside down",
"270": "90° left"
}
},
"fit": {
"label": "Slides of another shape",
"hint": "Keep their shape (bands in the slide's own background), or stretch them over the whole picture.",
"choices": {
"keep": "Keep their shape",
"stretch": "Stretch to fill"
}
},
"area_left": {
"label": "Picture area: left edge (px)",
"hint": "Set with Signage → Screens → Calibrate the picture."
},
"area_top": {
"label": "Picture area: top edge (px)"
},
"area_right": {
"label": "Picture area: right edge (px)"
},
"area_bottom": {
"label": "Picture area: bottom edge (px)"
}
},
"config_groups": {
"picture": "The picture"
}
},
"staff_planning": {
+4
View File
@@ -487,6 +487,10 @@
"spicy": "Spicy",
"vegetarian": "Vegetarian",
"vegan": "Vegan"
},
"calibrate": {
"title": "Calibrating the picture of {{name}}",
"hint": "In the manager (Signage → Screens), move each edge until the arrows touch the edges of the screen."
}
},
"menuTablet": {
+2 -1
View File
@@ -6,7 +6,8 @@
"description": "Signage slides as the TVs draw them, and the player's pure logic (schedule pick, slide windows, menu pages): one implementation for the terminal's player and the manager's previews (plan steps 5.5a-5.6a).",
"main": "src/index.js",
"exports": {
".": "./src/index.js"
".": "./src/index.js",
"./logic": "./src/logic.js"
},
"dependencies": {
"@xenia/i18n": "^0.0.0",
+19
View File
@@ -46,6 +46,25 @@ function EmbeddedSlide({ slide, media, venue, now }) {
)
}
/**
* What fills the bands around a slide that keeps its shape on a screen of another shape (6R.13):
* the slide's own background colour; a photo background fills them blurred and darker, so the
* slide's edge doesn't show a seam.
*/
export function Backdrop({ slide, media }) {
const c = slide?.content || {}
if (slide?.kind === 'image' || slide?.kind === 'video') {
return <div className="absolute inset-0" style={{ background: c.background_colour || '#000' }} data-testid="signage-backdrop" />
}
const bg = c.background || {}
const m = bg.kind === 'media' ? media(bg.media_id) : null
return (
<div className="absolute inset-0 overflow-hidden" style={{ background: bg.colour || '#111827' }} data-testid="signage-backdrop">
{m && <img src={m.src} alt="" className="absolute inset-0 w-full h-full" style={{ objectFit: 'cover', filter: 'blur(24px) brightness(0.6)', transform: 'scale(1.1)' }} />}
</div>
)
}
function ImageSlide({ content, media }) {
const m = content.media_id ? media(content.media_id) : null
return (
+1 -1
View File
@@ -5,4 +5,4 @@ export * from './logic.js'
export { cq, CQ_BOX, CQ_NATIVE } from './cq.js'
export { BADGE_ICONS } from './badges.js'
export { Background, BlankSlide, MenuSlide, TextSlide, Widgets } from './Slides.jsx'
export { SlideView } from './SlideView.jsx'
export { Backdrop, SlideView } from './SlideView.jsx'
+87 -4
View File
@@ -134,13 +134,24 @@ export function slideMs(slide) {
return Math.max(1, slide.duration_s || 10) * 1000
}
/** The frame's size and turn for a screen: CSS for the box that holds the slides. */
export function frameStyle(rotation) {
/**
* The frame's size and turn for a screen: CSS for the box that holds the slides. `size` (6R.13):
* the picture area in px it fills (its parent), else the whole window.
*/
export function frameStyle(rotation, size) {
const r = Number(rotation) || 0
const W = size ? `${size.width}px` : '100vw'
const H = size ? `${size.height}px` : '100vh'
if (r === 90 || r === 270) {
return { width: '100vh', height: '100vw', transform: `translate(-50%, -50%) rotate(${r}deg)`, top: '50%', left: '50%', position: 'absolute', containerType: 'size' }
return { width: H, height: W, transform: `translate(-50%, -50%) rotate(${r}deg)`, top: '50%', left: '50%', position: 'absolute', containerType: 'size' }
}
return { width: '100vw', height: '100vh', transform: r === 180 ? 'rotate(180deg)' : undefined, top: 0, left: 0, position: 'absolute', containerType: 'size' }
return { width: W, height: H, transform: r === 180 ? 'rotate(180deg)' : undefined, top: 0, left: 0, position: 'absolute', containerType: 'size' }
}
/** The frame's own width × height (after its turn) for a picture area. */
export function frameSize(rotation, size) {
const r = Number(rotation) || 0
return r === 90 || r === 270 ? { w: size.height, h: size.width } : { w: size.width, h: size.height }
}
/** Every media address a playlist (or a schedule's playlists) needs, to keep on the device. */
@@ -425,3 +436,75 @@ export function priceChars(groups, format) {
for (const g of groups || []) for (const it of g.items || []) if (it.price != null) n = Math.max(n, String(format(it.price)).length)
return n
}
// ── slide shapes and the screen's picture area (6R.13, owner 2026-11-22) ─────────
/** Shapes offered for a playlist / a library slide beyond landscape and portrait (and the calibration presets). */
export const SHAPES = ['16:9', '16:10', '21:9', '32:9', '4:3', '5:4', '1:1', '9:16', '10:16', '3:4']
/** "21:9" → [21, 9]; anything else → null. Shapes from 1:4 to 4:1. */
export function parseAspect(a) {
const m = /^(\d{1,2}):(\d{1,2})$/.exec(String(a || ''))
if (!m) return null
const w = Number(m[1])
const h = Number(m[2])
if (!w || !h || w / h > 4 || h / w > 4) return null
return [w, h]
}
/** What a playlist / library slide is built for: its custom shape ("21:9"), else landscape / portrait. */
export const shapeOf = x => (x && parseAspect(x.aspect) ? x.aspect : x?.orientation === 'portrait' ? 'portrait' : 'landscape')
/** Width ÷ height of a shape ("landscape", "portrait" or "W:H"). */
export function shapeRatio(shape) {
if (shape === 'portrait') return 9 / 16
const a = parseAspect(shape)
return a ? a[0] / a[1] : 16 / 9
}
/** The size a slide of this shape is laid out at (its long side 1920 px, as the editor's previews). */
export function canvasOf(shape) {
const r = shapeRatio(shape)
return r >= 1 ? { w: 1920, h: Math.round(1920 / r) } : { w: Math.round(1920 * r), h: 1920 }
}
/** The largest box of `ratio` (w ÷ h) inside W × H, centred: { left, top, width, height } in px. */
export function fitBox(W, H, ratio) {
if (!(W > 0) || !(H > 0) || !(ratio > 0)) return { left: 0, top: 0, width: Math.max(0, W || 0), height: Math.max(0, H || 0) }
let width = W
let height = W / ratio
if (height > H) { height = H; width = H * ratio }
return { left: (W - width) / 2, top: (H - height) / 2, width, height }
}
/** A screen's picture area in its window: the window minus the calibrated insets (never smaller than 50 px). */
export function pictureArea(win, area = {}) {
const l = Math.max(0, area.left || 0)
const t = Math.max(0, area.top || 0)
const width = Math.max(50, win.w - l - Math.max(0, area.right || 0))
const height = Math.max(50, win.h - t - Math.max(0, area.bottom || 0))
return { left: l, top: t, width, height }
}
/**
* Calibration presets (6R.13): the insets that leave the largest box of a shape in the middle of
* the window ("full": the whole window). → { left, top, right, bottom } in whole px.
*/
export function presetInsets(win, shape) {
if (shape === 'full' || !win?.w || !win?.h) return { left: 0, top: 0, right: 0, bottom: 0 }
const b = fitBox(win.w, win.h, shapeRatio(shape))
const left = Math.floor(b.left)
const top = Math.floor(b.top)
return { left, top, right: Math.max(0, win.w - left - Math.round(b.width)), bottom: Math.max(0, win.h - top - Math.round(b.height)) }
}
/** "1920 × 1080" → its nearest named shape ("16:9") when within 2 % (a "21:9" monitor is really 64:27), else "W:H" reduced (e.g. "43:18"). */
export function shapeName(w, h) {
if (!(w > 0) || !(h > 0)) return ''
const r = w / h
const near = SHAPES.find(s => Math.abs(shapeRatio(s) - r) / r < 0.02)
if (near) return near
const g = (a, b) => (b ? g(b, a % b) : a)
const d = g(Math.round(w), Math.round(h)) || 1
return `${Math.round(w) / d}:${Math.round(h) / d}`
}
+27
View File
@@ -243,3 +243,30 @@ test('container units: an older browser gets calc() of the variables the compat
assert.deepEqual(CQ_BOX, { 'data-cq': '' })
} finally { delete globalThis.CSS }
})
test('slide shapes: custom ratios, the canvas, the box a slide keeps on any screen (6R.13)', async () => {
const { canvasOf, fitBox, parseAspect, pictureArea, presetInsets, shapeName, shapeOf, shapeRatio } = await import('../src/logic.js')
assert.deepEqual(parseAspect('21:9'), [21, 9])
assert.equal(parseAspect('9:1'), null)
assert.equal(parseAspect('16x9'), null)
assert.equal(shapeOf({ orientation: 'portrait' }), 'portrait')
assert.equal(shapeOf({ orientation: 'landscape', aspect: '21:9' }), '21:9')
assert.equal(shapeOf({ orientation: 'landscape', aspect: 'nope' }), 'landscape')
assert.equal(shapeRatio('landscape'), 16 / 9)
assert.deepEqual(canvasOf('landscape'), { w: 1920, h: 1080 })
assert.deepEqual(canvasOf('portrait'), { w: 1080, h: 1920 })
assert.deepEqual(canvasOf('21:9'), { w: 1920, h: 823 })
// a 16:9 slide on a 21:9 monitor: full height, bands left and right
const b = fitBox(2560, 1080, 16 / 9)
assert.deepEqual([Math.round(b.left), b.top, Math.round(b.width), b.height], [320, 0, 1920, 1080])
// on 16:10: full width, bands above and below
const c = fitBox(1920, 1200, 16 / 9)
assert.deepEqual([c.left, c.top, c.width, c.height], [0, 60, 1920, 1080])
// calibration: the window minus the insets; the presets centre a shape
assert.deepEqual(pictureArea({ w: 1920, h: 1080 }, { left: 10, top: 0, right: 30, bottom: 20 }), { left: 10, top: 0, width: 1880, height: 1060 })
assert.deepEqual(presetInsets({ w: 2560, h: 1080 }, '16:9'), { left: 320, top: 0, right: 320, bottom: 0 })
assert.deepEqual(presetInsets({ w: 1920, h: 1080 }, 'full'), { left: 0, top: 0, right: 0, bottom: 0 })
assert.equal(shapeName(2560, 1080), '21:9')
assert.equal(shapeName(1920, 1200), '16:10')
assert.equal(shapeName(1000, 300), '10:3')
})