Skip to content

feat(windows-ui): embed widgets in table cells - #7075

Merged
proggeramlug merged 3 commits into
mainfrom
fix/6616-windows-table-widget-cells
Jul 30, 2026
Merged

feat(windows-ui): embed widgets in table cells#7075
proggeramlug merged 3 commits into
mainfrom
fix/6616-windows-table-widget-cells

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve primitive string cells on the native ListView text path
  • cache widget-valued render results and embed their HWNDs over ListView subitem bounds
  • reposition and clip widget cells after painting, scrolling, resizing, and header changes
  • forward embedded Button/TextField/control notifications through the normal Perry dispatcher
  • detach cached widget HWNDs safely when rows or sort order invalidate cell content

Verification

  • cargo check --tests --target x86_64-pc-windows-msvc -p perry-ui-windows
  • cargo test -p perry-ui-test
  • cargo fmt --all -- --check

Closes #6616

Summary by CodeRabbit

  • New Features
    • Windows table cells now support view-backed rendering, allowing renderers to return rich widget content such as images, buttons, stacks, and other embedded controls.
    • Embedded widgets stay aligned and correctly positioned as the table scrolls, resizes, repaints, or changes column widths.
    • Interactive controls within cells remain functional, including callback handling during table updates.
  • Documentation
    • Added a changelog entry documenting the Windows table cell rich widget support.
  • Tests
    • Added unit tests covering widget-content decoding and cell-content draining behavior.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e877e808-0b61-45f5-8a91-68e50c8b5392

📥 Commits

Reviewing files that changed from the base of the PR and between 8a27cc6 and a739dbd.

📒 Files selected for processing (1)
  • crates/perry-ui-windows/src/widgets/table.rs

📝 Walkthrough

Walkthrough

Windows table cells now cache text or embedded widget handles. Widget HWNDs are clipped, positioned over ListView subitems, realigned during table changes, detached during cache invalidation, and handled through display notifications and cleanup tests.

Changes

Win32 table widget cells

Layer / File(s) Summary
Cell content rendering
crates/perry-ui-windows/src/widgets/table.rs, changelog.d/7075-windows-table-widget-cells.md
Cell caching stores Text(String) or Widget(i64), and render results decode into the matching variant.
Widget layout and lifecycle
crates/perry-ui-windows/src/widgets/table.rs
ListView subclass notifications, clipping, column resizing, row updates, and destruction maintain embedded widget HWND positions and cleanup.
ListView cell response and tests
crates/perry-ui-windows/src/widgets/table.rs
Display handling returns cached text, lays out widget cells, and tests widget-handle decoding and cache draining.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RenderClosure
  participant TableEntry
  participant ListView
  participant TableSubclass
  participant WidgetHWND
  RenderClosure->>TableEntry: return text or widget
  TableEntry->>ListView: provide cached text or empty cell text
  ListView->>TableSubclass: emit paint, scroll, resize, or notify message
  TableSubclass->>WidgetHWND: position or hide widget HWND
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: embedding widgets in Windows table cells.
Description check ✅ Passed The description is mostly complete, with a clear summary and verification, though some template sections remain unfilled.
Linked Issues check ✅ Passed The changes address #6616 by supporting widget-valued Windows table cells with embedded HWNDs and scroll/resize relayout.
Out of Scope Changes check ✅ Passed The PR stays focused on Windows table-cell widget embedding, with only a small changelog entry and targeted table/test changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/6616-windows-table-widget-cells

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
crates/perry-ui-windows/src/widgets/table.rs (1)

312-326: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Add a reentrancy guard around layout_widget_cells.

WM_PAINT/WM_NOTIFYlayout_widget_cellsSetWindowPos/ShowWindow → invalidation → WM_PAINT/LVN_GETDISPINFOlayout_widget_cells again. handle_dispinfo (Line 751) also calls it per widget cell, so a single repaint can re-run full layout many times. A thread-local in-progress flag (and skipping layout for WM_PAINT when nothing moved) would bound the work.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/perry-ui-windows/src/widgets/table.rs` around lines 312 - 326, In the
window procedure flow around DefSubclassProc and layout_widget_cells, add a
thread-local reentrancy guard so nested WM_PAINT/WM_NOTIFY-triggered layout
calls are skipped while layout is already in progress. Ensure the guard is
reliably cleared after layout completes, and avoid running WM_PAINT layout when
no widget movement requires it, while preserving layout_widget_cells calls from
handle_dispinfo for legitimate outer layouts.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/perry-ui-windows/src/widgets/table.rs`:
- Around line 228-260: Update the table widget visibility and bounds logic
around cell_rect and the visible check to exclude the column-header band: obtain
the header with LVM_GETHEADER, convert its GetWindowRect coordinates into table
client coordinates, and clip or skip cells intersecting that region. Preserve
hiding for non-visible cells and ensure repositioned child widgets cannot paint
over the header even when rows are partially scrolled.
- Around line 299-310: Update the WM_NCDESTROY handling in table_subclass_proc
to remove the table entry from TABLES and drain its cell_cache rather than
cloning values while retaining the entry. Pass the drained widget contents to
detach_widget_cells, ensuring is_registered and layout_widget_cells can no
longer observe the destroyed table.

---

Nitpick comments:
In `@crates/perry-ui-windows/src/widgets/table.rs`:
- Around line 312-326: In the window procedure flow around DefSubclassProc and
layout_widget_cells, add a thread-local reentrancy guard so nested
WM_PAINT/WM_NOTIFY-triggered layout calls are skipped while layout is already in
progress. Ensure the guard is reliably cleared after layout completes, and avoid
running WM_PAINT layout when no widget movement requires it, while preserving
layout_widget_cells calls from handle_dispinfo for legitimate outer layouts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1c582c3e-09d3-45d9-bb44-6d0fd9bf6b2b

📥 Commits

Reviewing files that changed from the base of the PR and between 9a3967b and 8a27cc6.

📒 Files selected for processing (2)
  • changelog.d/7075-windows-table-widget-cells.md
  • crates/perry-ui-windows/src/widgets/table.rs

Comment thread crates/perry-ui-windows/src/widgets/table.rs Outdated
Comment thread crates/perry-ui-windows/src/widgets/table.rs
@proggeramlug

Copy link
Copy Markdown
Contributor Author

Also addressed the review nit in a739dbd: embedded-cell layout now has a thread-local RAII reentrancy guard, preventing synchronous SetWindowPos/paint notifications from recursively rerunning a full table layout.

@proggeramlug
proggeramlug merged commit 2608a9b into main Jul 30, 2026
7 checks passed
@proggeramlug
proggeramlug deleted the fix/6616-windows-table-widget-cells branch July 30, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

windows-ui: Table cells are text-only — non-Text widgets render as literal [widget]

1 participant