feat(signage): look rows that wrap, one colour field with opacity, badges' text, several widgets per stack part, pages up to 2200 px (owner review 4)
- Menu text look: each field names its part ("Headings size"), rows wrap in aligned columns on
alternating bands; names align left / right; line and letter spacing as lists (Auto default);
each field changes only itself (followers frozen before the other changes); badge colour +
badge text colour (auto: readableOn); "Reset the look" with a question.
- ColourField everywhere in signage: a Popover panel (new @xenia/ui Popover, portal, kept in the
window) with 12 presets, picker, opacity (#rrggbbaa) and typed code; HEX accepts 8 digits.
- Stacks: Cell.widgets (a stored `widget` still reads), several widgets per part laid across the
stack's direction; extras by path stack.part.place; Add a widget adds, each removable / ordered.
- Page rule: --x-page-max is 2200px (no longer follows the window height).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -49,7 +49,7 @@ from services.ws_bus import broadcast_sync
|
||||
router = APIRouter()
|
||||
KEY = "signage.manage"
|
||||
MESSAGE = "signage.message"
|
||||
HEX = r"^#[0-9a-fA-F]{6}$"
|
||||
HEX = r"^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$" # #rrggbb, or #rrggbbaa (see-through, 2026-11-21)
|
||||
TIME = r"^([01]\d|2[0-3]):[0-5]\d$"
|
||||
DATE = r"^\d{4}-\d{2}-\d{2}$"
|
||||
Orientation = Literal["landscape", "portrait"]
|
||||
@@ -133,7 +133,8 @@ class MenuList(_Strict):
|
||||
page_seconds: int = Field(default=10, ge=3, le=120)
|
||||
font: Font = "sans"
|
||||
text_colour: str = Field(default="#ffffff", pattern=HEX)
|
||||
accent_colour: str = Field(default="#f59e0b", pattern=HEX) # prices, headings, badges
|
||||
accent_colour: str = Field(default="#f59e0b", pattern=HEX) # badges, page dots (headings and prices unless their own)
|
||||
badge_text_colour: Optional[str] = Field(default=None, pattern=HEX) # None: white or black, to read on the badge
|
||||
text_size: int = Field(default=100, ge=50, le=250)
|
||||
# the look of each part (owner review 3, 2026-11-21)
|
||||
heading_style: TextStyle = Field(default_factory=TextStyle)
|
||||
@@ -188,16 +189,28 @@ class Box(_Strict):
|
||||
|
||||
class Cell(_Strict):
|
||||
"""A part of a stack (2026-11-21): its share of the stack (the parts' shares are weights; the
|
||||
editor keeps them adding up to 100) and what it shows: a widget (another stack too, one level
|
||||
deep) or a slide of the Slides library, drawn whole inside the part; or nothing."""
|
||||
editor keeps them adding up to 100) and what it shows: widgets (another stack too, one level
|
||||
deep; several share the part, one over the other in a side-by-side stack, side by side in the
|
||||
other), or a slide of the Slides library, drawn whole inside the part; or nothing."""
|
||||
share: float = Field(default=50, ge=1, le=100)
|
||||
widget: Optional["Widget"] = None
|
||||
widgets: List["Widget"] = Field(default_factory=list, max_length=6)
|
||||
slide_id: Optional[int] = None
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def _one_widget(cls, v):
|
||||
# a part held one widget (`widget`) until owner review 4 (2026-11-21)
|
||||
if isinstance(v, dict) and "widget" in v:
|
||||
v = dict(v)
|
||||
w = v.pop("widget")
|
||||
if w is not None:
|
||||
v["widgets"] = [w, *(v.get("widgets") or [])]
|
||||
return v
|
||||
|
||||
@model_validator(mode="after")
|
||||
def _one(self):
|
||||
if self.widget is not None and self.slide_id is not None:
|
||||
raise ValueError("a part shows a widget or a slide, not both")
|
||||
if self.widgets and self.slide_id is not None:
|
||||
raise ValueError("a part shows widgets or a slide, not both")
|
||||
self.share = round(self.share, 2)
|
||||
return self
|
||||
|
||||
@@ -461,20 +474,26 @@ def media_ids(value) -> list[int]:
|
||||
|
||||
|
||||
def walk_widgets(widgets, prefix: str = ""):
|
||||
"""Every widget of a slide, inside stacks too, with its path ("2", "2.0", "2.1.1": the widget's
|
||||
index, then its part's): → (path, widget, None), and (path, None, slide id) for a part that
|
||||
shows a library slide. The editor and the player find a widget's extras by its path."""
|
||||
"""Every widget of a slide, inside stacks too, with its path ("2"; "2.1.0": the widget's index,
|
||||
then its part's, then its place in the part): → (path, widget, None), and ("2.1", None, slide
|
||||
id) for a part that shows a library slide. The editor and the player find a widget's extras by its path."""
|
||||
for i, w in enumerate(widgets or []):
|
||||
yield from _walk_one(w, f"{prefix}{i}")
|
||||
|
||||
|
||||
def cell_widgets(c: dict) -> list:
|
||||
"""A part's widgets (stored before owner review 4 as one `widget`)."""
|
||||
return c.get("widgets") or ([c["widget"]] if c.get("widget") else [])
|
||||
|
||||
|
||||
def _walk_one(w: dict, path: str):
|
||||
yield path, w, None
|
||||
for j, c in enumerate(w.get("cells") or []):
|
||||
cp = f"{path}.{j}"
|
||||
if c.get("widget"):
|
||||
yield from _walk_one(c["widget"], cp)
|
||||
elif c.get("slide_id"):
|
||||
ws = cell_widgets(c)
|
||||
for k, cw in enumerate(ws):
|
||||
yield from _walk_one(cw, f"{cp}.{k}")
|
||||
if not ws and c.get("slide_id"):
|
||||
yield cp, None, c["slide_id"]
|
||||
|
||||
|
||||
@@ -542,7 +561,7 @@ def _content(db, kind: str, raw: dict | None) -> dict:
|
||||
raise XeniaError("media.not_a_picture")
|
||||
for path, w, sid in found:
|
||||
# a stack inside a stack, not deeper (2026-11-21)
|
||||
if w and w.get("kind") == "stack" and path.count(".") > 1:
|
||||
if w and w.get("kind") == "stack" and path.count(".") > 2:
|
||||
raise XeniaError("signage.content_invalid", field=f"widgets.{path}", reason="a stack goes at most one stack deep")
|
||||
if sid and db.get(SignageSavedSlide, sid) is None:
|
||||
raise XeniaError("signage.slide_unknown", slide_id=sid)
|
||||
|
||||
Reference in New Issue
Block a user