fix: size grid auto rows after item width resolution
Render auto-width grid children at their resolved track widths before resolving row heights. This keeps wrapped content visible and prevents stale intrinsic heights from clipping the final line. Verification: make grid-tests EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs; make compile EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs; make check EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs.
This commit is contained in:
parent
d4dc572c2d
commit
bfef45f765
23
ebox-grid.el
23
ebox-grid.el
@ -494,6 +494,17 @@ size for start/center/end alignment unless it would overflow its track."
|
|||||||
(align (or (plist-get props :align-items) 'stretch)))
|
(align (or (plist-get props :align-items) 'stretch)))
|
||||||
(ebox-grid--align source width height justify align)))
|
(ebox-grid--align source width height justify align)))
|
||||||
|
|
||||||
|
(defun ebox-grid--sized-rendered-entries (entries rendered widths gap props)
|
||||||
|
"Render ENTRIES at their resolved column widths for later row sizing."
|
||||||
|
(let ((sized (make-hash-table :test 'eq)))
|
||||||
|
(dolist (entry entries)
|
||||||
|
(let* ((node (plist-get entry :node))
|
||||||
|
(width (ebox-grid--entry-size entry widths gap)))
|
||||||
|
(puthash node
|
||||||
|
(ebox-grid--entry-source entry rendered width props)
|
||||||
|
sized)))
|
||||||
|
sized))
|
||||||
|
|
||||||
(defun ebox-grid--entry-at (matrix row column)
|
(defun ebox-grid--entry-at (matrix row column)
|
||||||
"Return entry occupying ROW and COLUMN in MATRIX."
|
"Return entry occupying ROW and COLUMN in MATRIX."
|
||||||
(and (< row (length matrix))
|
(and (< row (length matrix))
|
||||||
@ -631,19 +642,23 @@ size for start/center/end alignment unless it would overflow its track."
|
|||||||
(let* ((widths (ebox-grid--resolve-sizes columns column-count 'columns
|
(let* ((widths (ebox-grid--resolve-sizes columns column-count 'columns
|
||||||
entries rendered (cdr gaps)
|
entries rendered (cdr gaps)
|
||||||
available auto-columns))
|
available auto-columns))
|
||||||
(heights (ebox-grid--resolve-sizes rows row-count 'rows
|
|
||||||
entries rendered (car gaps)
|
|
||||||
height auto-rows))
|
|
||||||
(column-layout
|
(column-layout
|
||||||
(ebox-grid--content-layout
|
(ebox-grid--content-layout
|
||||||
widths (cdr gaps) available
|
widths (cdr gaps) available
|
||||||
(or (plist-get props :justify-content) 'start)))
|
(or (plist-get props :justify-content) 'start)))
|
||||||
|
(sized-rendered
|
||||||
|
(ebox-grid--sized-rendered-entries
|
||||||
|
entries rendered (plist-get column-layout :sizes)
|
||||||
|
(plist-get column-layout :between) props))
|
||||||
|
(heights (ebox-grid--resolve-sizes rows row-count 'rows
|
||||||
|
entries sized-rendered (car gaps)
|
||||||
|
height auto-rows))
|
||||||
(row-layout
|
(row-layout
|
||||||
(ebox-grid--content-layout
|
(ebox-grid--content-layout
|
||||||
heights (car gaps) height
|
heights (car gaps) height
|
||||||
(or (plist-get props :align-content) 'start)))
|
(or (plist-get props :align-content) 'start)))
|
||||||
(body (ebox-grid--render entries matrix column-layout row-layout
|
(body (ebox-grid--render entries matrix column-layout row-layout
|
||||||
props rendered)))
|
props sized-rendered)))
|
||||||
(ebox--render-grid-box node body))))
|
(ebox--render-grid-box node body))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|||||||
@ -51,6 +51,20 @@
|
|||||||
(widths (mapcar #'ebox--string-pixel-width lines)))
|
(widths (mapcar #'ebox--string-pixel-width lines)))
|
||||||
(should (equal widths (make-list (length widths) 120)))))
|
(should (equal widths (make-list (length widths) 120)))))
|
||||||
|
|
||||||
|
(ert-deftest ebox-grid-sizes-auto-row-after-assigned-width-wrap ()
|
||||||
|
"Auto rows should use the height of width-constrained child content."
|
||||||
|
(let* ((node (ebox-grid
|
||||||
|
:width '(40)
|
||||||
|
:grid-template-columns '((38))
|
||||||
|
:border "#334155"
|
||||||
|
(ebox-create
|
||||||
|
:content "WIDE CONTENT WIDE CONTENT WIDE CONTENT WIDE CONTENT"
|
||||||
|
:wrap-mode 'word)))
|
||||||
|
(lines (ebox-string-lines (ebox-render node)))
|
||||||
|
(widths (mapcar #'ebox--string-pixel-width lines)))
|
||||||
|
(should (= (length lines) 2))
|
||||||
|
(should (equal widths (make-list (length widths) 40)))))
|
||||||
|
|
||||||
(ert-deftest ebox-grid-aligns-every-line-before-border-render ()
|
(ert-deftest ebox-grid-aligns-every-line-before-border-render ()
|
||||||
"Grid wrapper borders should stay on one right edge across child lines."
|
"Grid wrapper borders should stay on one right edge across child lines."
|
||||||
(let* ((node (ebox-grid
|
(let* ((node (ebox-grid
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user