feat(signage): menus play whole rounds, seconds fields with − / +, widget limit setting, widgets as big as their content (owner review 6)
- A menu board with pages plays whole rounds (menuMs rounds its seconds up); the editor says how long it really plays under "Seconds on screen", the card and the playlist total use it. - Seconds on screen / per page: shared NumberInput (− / +, may be emptied: an error under the field and Save blocked until filled; 1 s at least, server ge=1). - Performance (Signage -> Message & settings): widgets per slide (signage.max_widgets, 10 recommended, up to 50), checked by the server (signage.too_many_widgets) and the editor. - Text, clock, date, QR, weather, logo placed by hand: the box is exactly the content (its height x text size sets the size, the width follows; handles scale keeping the shape; text size grows the box); a slide's widget may run off the slide while 5 % stays on it. - Slider: the value as close to the slider as the frame's padding; floor and table-colour sliders use the shared Slider. Timeline cards' ring no longer clipped; larger playlist buttons. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,9 +10,13 @@
|
||||
// Owner review 5 (2026-11-21): widgets inside a stack's parts too. Pick the stack, then click a
|
||||
// widget in it: it moves and sizes inside its place (it can't leave the stack; its box is % of its
|
||||
// place). The picked widget is a path: "2", or "2.1.0" (stack 2, part 1, its first widget).
|
||||
// Owner review 6: a text, clock, QR… placed by hand is exactly as big as what it shows (its box is
|
||||
// its content: sized by its handles keeping its shape; its text size makes it bigger too); a slide's
|
||||
// widget may be moved off the slide as long as a strip of it stays to grab it back.
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { boxFromRect, moveBox, resizeBox, snapBox, stackOf, widgetAt } from './signageLogic'
|
||||
import { TIGHT } from '@xenia/signage'
|
||||
import { boxFromRect, moveBox, moveLoose, resizeBox, scaleBox, snapBox, stackOf, widgetAt } from './signageLogic'
|
||||
|
||||
const HANDLES = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w']
|
||||
const CURSOR = { n: 'ns-resize', s: 'ns-resize', e: 'ew-resize', w: 'ew-resize', nw: 'nwse-resize', se: 'nwse-resize', ne: 'nesw-resize', sw: 'nesw-resize' }
|
||||
@@ -46,9 +50,10 @@ export default function WidgetCanvas({ boxRef, widgets, selected, onSelect, onPl
|
||||
|
||||
const sel = selected != null ? String(selected) : null
|
||||
// a widget's box in its own frame: the slide's (%), or its place's for a widget in a stack
|
||||
const tight = path => TIGHT.includes(widgetAt(widgets, path)?.kind)
|
||||
const own = path => {
|
||||
const w = widgetAt(widgets, path)
|
||||
if (w?.position === 'custom' && w.box) return w.box
|
||||
if (w?.position === 'custom' && w.box && !tight(path)) return w.box
|
||||
const r = rects[path]
|
||||
const place = stackOf(path) != null ? rects[`place:${path}`] : null
|
||||
if (!r || stackOf(path) == null) return r || null
|
||||
@@ -63,6 +68,16 @@ export default function WidgetCanvas({ boxRef, widgets, selected, onSelect, onPl
|
||||
return { x: place.x + b.x * place.w / 100, y: place.y + b.y * place.h / 100, w: b.w * place.w / 100, h: b.h * place.h / 100 }
|
||||
}
|
||||
|
||||
// what is stored for a tight widget: where it sits and its height before its text size (the
|
||||
// height scaled as the drawn one was, so it never creeps); others: the box as drawn
|
||||
const stored = (path, from, to) => {
|
||||
const w = widgetAt(widgets, path)
|
||||
if (!tight(path)) return to
|
||||
const ts = (w.text_size || 100) / 100
|
||||
const h0 = w.position === 'custom' && w.box ? w.box.h : from.h / ts
|
||||
return { ...to, h: Math.max(1, Math.round(h0 * (to.h / from.h) * 100) / 100) }
|
||||
}
|
||||
|
||||
const start = (e, path, handle = null) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
@@ -84,11 +99,12 @@ export default function WidgetCanvas({ boxRef, widgets, selected, onSelect, onPl
|
||||
moved = true
|
||||
const dx = (ev.clientX - x0) / width * 100
|
||||
const dy = (ev.clientY - y0) / height * 100
|
||||
const next = handle ? resizeBox(base, handle, dx, dy) : moveBox(base, dx, dy)
|
||||
if (inside) { onPlace(path, next); return }
|
||||
const shaped = tight(path)
|
||||
const next = handle ? (shaped ? scaleBox(base, handle, dx, dy) : resizeBox(base, handle, dx, dy)) : inside ? moveBox(base, dx, dy) : moveLoose(base, dx, dy)
|
||||
if (inside || (handle && shaped)) { onPlace(path, stored(path, base, next)); return }
|
||||
const snapped = snapBox(next, handle)
|
||||
setGuides(snapped.guides)
|
||||
onPlace(path, snapped.box)
|
||||
onPlace(path, stored(path, base, snapped.box))
|
||||
}
|
||||
const up = () => {
|
||||
window.removeEventListener('pointermove', move)
|
||||
@@ -112,7 +128,7 @@ export default function WidgetCanvas({ boxRef, widgets, selected, onSelect, onPl
|
||||
if (!d) return
|
||||
e.preventDefault()
|
||||
const base = own(sel)
|
||||
if (base) onPlace(sel, moveBox(base, d[0], d[1]))
|
||||
if (base) onPlace(sel, stored(sel, base, (stackOf(sel) != null ? moveBox : moveLoose)(base, d[0], d[1])))
|
||||
}
|
||||
window.addEventListener('keydown', on)
|
||||
return () => window.removeEventListener('keydown', on)
|
||||
|
||||
Reference in New Issue
Block a user