feat: row-spanning overlays (:spans) — clock, pie, flank, vector image#6
Merged
Conversation
Add a `:spans' option to `svg-line-image' / `svg-line-define': a list of centred overlays drawn once over a row range, on top of the rows (whose `:center' should be empty there to avoid collision). Span types: - (:clock (A . B) COLOR ACCENT) — analog clock showing the current time - (:pie (A . B) FRAC FILL BG) — progress pie - (:flank (A . B) LEFT RIGHT [COLOR GAP GLYPH-SIZE]) — two text clusters flanking the centred overlay; each side a string or a (TIME . GLYPH) cons with the glyph drawn larger (default 1.7x) so squat Nerd-Font weather/icon glyphs read at text scale - (:image (A . B) SVG [ALIGN GAP]) — splice an svg.el DOM / SVG string as a transformed <g> (stays vector/sharp, unlike a rasterised <image>) Supporting helpers: svg-line--draw-clock, svg-line--draw-pie-at (extracted from the inline :pie run), svg-line--parse-svg, svg-line--attr-num, svg-line--splice-svg (deep-copies children so a cached/shared input DOM is never aliased into the rendered tree), plus svg-line--embed-image / --svg-intrinsic-size for the raster alternative. Also: :seg runs gain :bg (a persistent background pill) and :weight.
There was a problem hiding this comment.
Pull request overview
Adds support for row-spanning, centered overlays in the lines layout via a new :spans option, enabling single overlay renderings across a row range (clock/pie/flank/image) and extending segment styling.
Changes:
- Add
:spanssupport tosvg-line-image/ spec plumbing, rendering overlays on top of a row range. - Extract pie rendering into
svg-line--draw-pie-atand add new overlay helpers (clock + SVG parsing/splicing). - Extend
:segruns with:bg(persistent pill) and:weight(font weight) support.
Comments suppressed due to low confidence (1)
svg-line.el:541
- The public
svg-line-imagedocstring doesn’t mention the newSPANSkeyword argument, and it also doesn’t document the newly supported(:seg STR PLIST)styling keys (:bg/:weight). Please update the docstring so callers can discover these options via help.
(icon-scale 0.74)
(spans nil))
"Build a `lines'-layout SVG from ROWS.
Each ROW is either a cons (LEFT . RIGHT) -- left- and right-aligned content --
or a vector [LEFT CENTER RIGHT] which adds horizontally-centred content.
Each of LEFT, CENTER and RIGHT is either:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+645
to
+651
| (let* ((rng (nth 1 span)) | ||
| (a (if (consp rng) (car rng) 0)) | ||
| (b (if (consp rng) (cdr rng) (1- (length rows)))) | ||
| (sh (* lh (1+ (- b a)))) | ||
| (cx (/ width 2)) | ||
| (cy (round (+ (* lh a) (/ sh 2.0)))) | ||
| (r (max 3 (round (* (/ sh 2.0) 0.86))))) |
Comment on lines
+708
to
+717
| (let* ((attrs (cadr dom)) | ||
| (iw (max 1 (round (svg-line--attr-num (cdr (assq 'width attrs)))))) | ||
| (ih (max 1 (round (svg-line--attr-num (cdr (assq 'height attrs)))))) | ||
| (scale (/ (float sh) ih)) | ||
| (dw (max 1 (round (* iw scale)))) | ||
| (ix (pcase align | ||
| ('left (+ pad gap)) | ||
| ('right (max pad (- width dw gap))) | ||
| (_ (round (- cx (/ dw 2.0)))))) | ||
| (iy (round (- cy (/ sh 2.0))))) |
Comment on lines
+639
to
+643
| ;; Centred, row-spanning overlays drawn once over a row range, on top of | ||
| ;; the rows (whose `:center' should be empty there to avoid collision). | ||
| ;; SPEC: (:clock (ROW-A . ROW-B) COLOR ACCENT) or | ||
| ;; (:pie (ROW-A . ROW-B) FRACTION FILL BG). Rows 0-indexed, inclusive. | ||
| (dolist (span spans) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
:spansoption tosvg-line-image/svg-line-define: a list of centred overlays drawn once over a row range, on top of the rows.Span types
(:clock (A . B) COLOR ACCENT)— analog clock showing the current time(:pie (A . B) FRAC FILL BG)— progress pie(:flank (A . B) LEFT RIGHT [COLOR GAP GLYPH-SIZE])— two text clusters flanking the centred overlay; each side a string or a(TIME . GLYPH)cons, glyph drawn larger (default 1.7×) so squat Nerd-Font glyphs read at text scale(:image (A . B) SVG [ALIGN GAP])— splice an svg.el DOM / SVG string as a transformed<g>(stays vector/sharp, unlike a rasterised<image>)Helpers:
svg-line--draw-clock,svg-line--draw-pie-at(extracted from the inline:pierun),svg-line--parse-svg,svg-line--attr-num,svg-line--splice-svg(deep-copies children so a cached/shared input DOM is never aliased), plussvg-line--embed-image/--svg-intrinsic-sizefor the raster alternative.Also:
:segruns gain:bg(persistent background pill) and:weight.