Add per-widget border option (style, thickness, palette color)
A Widget-level property (border_style/border_thickness/border_color_index), not a per-type config field, since every widget type can have one -- drawn once centrally in device.py's _render_widgets before compositing, using an exact panel palette color so it never dithers. Styles: solid, dashed, dotted, and a fancy double-line picture-frame-mat look. Configurable from a shared "Border" card in every widget's gear-icon dialog.
This commit is contained in:
+31
-2
@@ -385,8 +385,9 @@ def _migration_17(conn) -> None:
|
||||
"SELECT COALESCE(MAX(sort_order), 0) FROM widgets WHERE frame_id = :frame_id"
|
||||
), {"frame_id": row["frame_id"]}).scalar()
|
||||
result = conn.execute(text(
|
||||
"INSERT INTO widgets (frame_id, widget_type, x, y, w, h, sort_order, created_at) "
|
||||
"VALUES (:frame_id, 'tasks', :x, :y, :w, :h, :sort_order, :created_at)"
|
||||
"INSERT INTO widgets (frame_id, widget_type, x, y, w, h, sort_order, created_at, "
|
||||
"border_style, border_thickness, border_color_index) "
|
||||
"VALUES (:frame_id, 'tasks', :x, :y, :w, :h, :sort_order, :created_at, 'none', 3, 0)"
|
||||
), {"frame_id": row["frame_id"], "x": x, "y": y, "w": w, "h": h,
|
||||
"sort_order": max_sort + 1, "created_at": now})
|
||||
new_widget_id = result.lastrowid
|
||||
@@ -677,6 +678,33 @@ def _migration_25(conn) -> None:
|
||||
))
|
||||
|
||||
|
||||
def _migration_26(conn) -> None:
|
||||
"""Per-widget border (see models.Widget.border_style/border_thickness/
|
||||
border_color_index, image_pipeline.draw_widget_border) -- a shared
|
||||
property on the widgets table itself, not a per-type config table,
|
||||
since every widget type can have one regardless of widget_type.
|
||||
border_style defaults to 'none' so existing widgets keep rendering
|
||||
exactly as before until someone opts in via a widget's dialog.
|
||||
|
||||
Guarded per-column (unlike every earlier ALTER TABLE ADD COLUMN
|
||||
migration in this file) because widgets is the one table
|
||||
test_migrations.py's upgrade-path tests deliberately leave un-dropped
|
||||
across a simulated old-schema_version replay (see those tests' own
|
||||
comments: it hasn't changed shape since migration 16 created it, so
|
||||
reusing the fresh-install create_all() copy -- which, unlike this
|
||||
ALTER, already reflects models.py's current border_* columns -- was
|
||||
safe up to now). Without the guard, replaying this migration in that
|
||||
scenario re-adds a column that's already there and SQLite raises
|
||||
"duplicate column name"."""
|
||||
existing = {c["name"] for c in inspect(conn).get_columns("widgets")}
|
||||
if "border_style" not in existing:
|
||||
conn.execute(text("ALTER TABLE widgets ADD COLUMN border_style TEXT NOT NULL DEFAULT 'none'"))
|
||||
if "border_thickness" not in existing:
|
||||
conn.execute(text("ALTER TABLE widgets ADD COLUMN border_thickness INTEGER NOT NULL DEFAULT 3"))
|
||||
if "border_color_index" not in existing:
|
||||
conn.execute(text("ALTER TABLE widgets ADD COLUMN border_color_index INTEGER NOT NULL DEFAULT 0"))
|
||||
|
||||
|
||||
MIGRATIONS = [
|
||||
(1, _migration_1),
|
||||
(2, _migration_2),
|
||||
@@ -703,6 +731,7 @@ MIGRATIONS = [
|
||||
(23, _migration_23),
|
||||
(24, _migration_24),
|
||||
(25, _migration_25),
|
||||
(26, _migration_26),
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user