Roll out "modern" HTML/CSS render style to every widget except photos
Extends weather's experimental Chromium+Jinja2 render style to battery, text, tasks, static image, whiteboard, and calendar (all four view modes -- agenda/today_tomorrow/week/month), and gives the photos widget its own genuinely independent palette + dithering strength. Photos: Frame.photo_palette_rgb/photo_dither_strength (mirroring the existing palette_rgb/dither_strength), with a second "Photos configuration" card in Advanced Configuration. widgets/photos.py's render() quantizes itself against these before returning -- no render_panel changes needed, since photos is the only widget that genuinely needs a different reference palette and can carry that itself, the same way modern-style widgets already self-dither via ordered_dither. Battery/text/tasks/static image/whiteboard: same render_style pattern weather established (render_style column, html_render.py build function, Jinja2 template, dialog toggle). Static image/whiteboard get their first-ever visual chrome (a rounded-corner shadowed card, shared framed_image.html.jinja) since classic draws them with zero frame at all. Fixed the same "preview endpoint bypasses render_style" bug weather originally shipped with, for tasks/static/whiteboard/ calendar's preview endpoints. Calendar: own module (app/calendar_html_render.py, mirroring calendar_render.py's separation from the simpler widgets) covering all four view modes, not just agenda -- reuses calendar_render's own private helpers so event colors/times/weather/month-grid math match classic exactly. Found and fixed two real cross-day layout bugs along the way: a per-day header height that varied based on whether that specific day had a weather entry (misaligning where every other day's event rows started across the week/month grid), and regular-weight small text being fragile under Bayer ordered dithering (out-of-month day numbers degraded into unrecognizable speckle) -- fixed by using bold everywhere and de-emphasizing via size instead of weight/gray, since gray text has the same dithering fragility this project's PIL renderers already avoid for exactly this reason. Migrations 32-38 (Frame's two new columns, then one render_style column per widget config table). 452 tests passing, including new dispatch/ migration coverage per widget type and a dedicated photos test proving photo_palette_rgb produces genuinely independent quantization from the frame's main palette_rgb.
This commit is contained in:
@@ -814,6 +814,72 @@ def _migration_31(conn) -> None:
|
||||
conn.execute(text("ALTER TABLE weather_widget_configs ADD COLUMN render_style TEXT NOT NULL DEFAULT 'classic'"))
|
||||
|
||||
|
||||
def _migration_32(conn) -> None:
|
||||
"""Photos widget's own independent palette/dithering (models.Frame.
|
||||
photo_palette_rgb/photo_dither_strength -- see widgets/photos.py's
|
||||
render()). NULL/1.0 defaults reproduce the exact previous rendering
|
||||
(same reference palette/strength as the main fields) until a frame's
|
||||
Configuration tab sets them differently.
|
||||
|
||||
Guarded per-column, same reasoning as migration 30/31's own comments."""
|
||||
existing = {c["name"] for c in inspect(conn).get_columns("frames")}
|
||||
if "photo_palette_rgb" not in existing:
|
||||
conn.execute(text("ALTER TABLE frames ADD COLUMN photo_palette_rgb TEXT"))
|
||||
if "photo_dither_strength" not in existing:
|
||||
conn.execute(text("ALTER TABLE frames ADD COLUMN photo_dither_strength REAL NOT NULL DEFAULT 1.0"))
|
||||
|
||||
|
||||
def _migration_33(conn) -> None:
|
||||
"""Battery widget render style (models.BatteryWidgetConfig.
|
||||
render_style) -- same shape as migration 31's weather one. Every
|
||||
existing battery widget defaults to "classic", no behavior change."""
|
||||
existing = {c["name"] for c in inspect(conn).get_columns("battery_widget_configs")}
|
||||
if "render_style" not in existing:
|
||||
conn.execute(text("ALTER TABLE battery_widget_configs ADD COLUMN render_style TEXT NOT NULL DEFAULT 'classic'"))
|
||||
|
||||
|
||||
def _migration_34(conn) -> None:
|
||||
"""Text widget render style (models.TextWidgetConfig.render_style) --
|
||||
same shape as migration 31/33. Every existing text widget defaults to
|
||||
"classic", no behavior change."""
|
||||
existing = {c["name"] for c in inspect(conn).get_columns("text_widget_configs")}
|
||||
if "render_style" not in existing:
|
||||
conn.execute(text("ALTER TABLE text_widget_configs ADD COLUMN render_style TEXT NOT NULL DEFAULT 'classic'"))
|
||||
|
||||
|
||||
def _migration_35(conn) -> None:
|
||||
"""Tasks widget render style (models.TaskWidgetConfig.render_style)
|
||||
-- same shape as migration 31/33/34. Every existing tasks widget
|
||||
defaults to "classic", no behavior change."""
|
||||
existing = {c["name"] for c in inspect(conn).get_columns("task_widget_configs")}
|
||||
if "render_style" not in existing:
|
||||
conn.execute(text("ALTER TABLE task_widget_configs ADD COLUMN render_style TEXT NOT NULL DEFAULT 'classic'"))
|
||||
|
||||
|
||||
def _migration_36(conn) -> None:
|
||||
"""Static image widget render style (models.StaticWidgetConfig.
|
||||
render_style) -- same shape as migration 31/33/34/35."""
|
||||
existing = {c["name"] for c in inspect(conn).get_columns("static_widget_configs")}
|
||||
if "render_style" not in existing:
|
||||
conn.execute(text("ALTER TABLE static_widget_configs ADD COLUMN render_style TEXT NOT NULL DEFAULT 'classic'"))
|
||||
|
||||
|
||||
def _migration_37(conn) -> None:
|
||||
"""Whiteboard widget render style (models.WhiteboardWidgetConfig.
|
||||
render_style) -- same shape as migration 36."""
|
||||
existing = {c["name"] for c in inspect(conn).get_columns("whiteboard_widget_configs")}
|
||||
if "render_style" not in existing:
|
||||
conn.execute(text("ALTER TABLE whiteboard_widget_configs ADD COLUMN render_style TEXT NOT NULL DEFAULT 'classic'"))
|
||||
|
||||
|
||||
def _migration_38(conn) -> None:
|
||||
"""Calendar widget render style (models.CalendarWidgetConfig.
|
||||
render_style) -- same shape as migration 31/33/34/35/36/37."""
|
||||
existing = {c["name"] for c in inspect(conn).get_columns("calendar_widget_configs")}
|
||||
if "render_style" not in existing:
|
||||
conn.execute(text("ALTER TABLE calendar_widget_configs ADD COLUMN render_style TEXT NOT NULL DEFAULT 'classic'"))
|
||||
|
||||
|
||||
MIGRATIONS = [
|
||||
(1, _migration_1),
|
||||
(2, _migration_2),
|
||||
@@ -846,6 +912,13 @@ MIGRATIONS = [
|
||||
(29, _migration_29),
|
||||
(30, _migration_30),
|
||||
(31, _migration_31),
|
||||
(32, _migration_32),
|
||||
(33, _migration_33),
|
||||
(34, _migration_34),
|
||||
(35, _migration_35),
|
||||
(36, _migration_36),
|
||||
(37, _migration_37),
|
||||
(38, _migration_38),
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user