Skip to content

Pilot: TableView instead of DataGrid in the OCR subtitle grid - #13001

Merged
niksedk merged 4 commits into
mainfrom
experiment/tableview-ocr
Jul 30, 2026
Merged

Pilot: TableView instead of DataGrid in the OCR subtitle grid#13001
niksedk merged 4 commits into
mainfrom
experiment/tableview-ocr

Conversation

@niksedk

@niksedk niksedk commented Jul 30, 2026

Copy link
Copy Markdown
Member

Second TableView pilot after #12704 (Show history), this time on the opposite end of the spectrum: the OCR subtitle grid is SE's heaviest — virtualized template columns with a per-row bitmap — and the one where DataGrid scrolling feels worst. The point of this branch is to compare scrolling behaviour by eye.

What changed

  • DataGridTableView in OcrWindow.MakeSubtitleView. Template columns (Forced checkbox, image thumbnail, formatted text) carry over via TableViewColumn.CellTemplate — with a template set, the cell's content is the row item, so the existing FuncDataTemplate<OcrSubtitleItem>s work unchanged. Text columns (#, Show, Duration) use TableViewColumn.Binding with the same converters.
  • The Forced column is added conditionally (TableViewColumn has no IsVisible), matching the old static IsVisible = vm.HasForcedSubtitles.
  • OcrViewModel.SubtitleGrid is now typed TableView. SelectedItems/SelectedIndex/Focus are inherited from ListBox and unchanged; ScrollIntoView(item, null) became ScrollIntoView(index).
  • Ctrl+plus/minus image zoom got simpler: TableView rows auto-size to content, so changing the bound ImageMaxHeight/ImageMaxWidth re-measures rows directly — the CalculateRowHeight()RowHeight dance is gone.
  • DataGridCheckboxMultiSelect is dropped: extended selection (shift/ctrl-click, cmd-click on macOS, shift+arrows) is native ListBox behaviour with SelectionMode.Multiple. The Mac ctrl+click context-menu handlers, the flyout, and all VM event handlers carry over unchanged.
  • Cell/header themes use the Pilot: TableView instead of DataGrid in Show history #12704 helpers, so grid lines honour the "Show grid lines" setting.

Known losses to judge

  • Column sorting is gone — TableView has none (the DataGrid had CanUserSortColumns = true).
  • Row heights are now per-row content heights rather than one uniform RowHeight, which is exactly the variable-height virtualization scenario worth stress-testing with scrolling.

Verified headlessly (5 new tests): columns declared and bound; rows realize with the image and text cell templates resolving (fake IOcrSubtitle with real SKBitmaps); selection round-trips both ways between grid and VM; a 2000-item source stays virtualized and ScrollIntoView(1999) realizes the far end; multi-select surfaces in SelectedItems. All 165 OCR UI tests pass.

To judge by eye: open a Blu-ray sup / VobSub, scroll with wheel, scrollbar drag, and keyboard; try Ctrl+plus/minus image zoom mid-list; check the OCR run auto-follow (SelectAndScrollToRow) tracks smoothly.

🤖 Generated with Claude Code

niksedk and others added 4 commits July 30, 2026 15:57
Second TableView pilot after Show history (#12704), targeting SE's
heaviest grid - virtualized template columns with a bitmap per row -
to judge TableView's scrolling against DataGrid's.

DataGrid -> TableView mapping: template columns carry over via
TableViewColumn.CellTemplate (cell content is the row item), text
columns via Binding; the Forced column is added conditionally since
TableViewColumn has no IsVisible; extended selection (shift/ctrl-click,
shift+arrows) is native ListBox behavior, replacing
DataGridCheckboxMultiSelect; ScrollIntoView takes an index; rows
auto-size to content, so the Ctrl+plus/minus image zoom no longer
needs the CalculateRowHeight/RowHeight dance. Column sorting is lost -
TableView has none.

Verified headlessly: columns declared and bound, rows realize with
image and text cell templates resolving, selection round-trips both
ways, 2000-item source stays virtualized and ScrollIntoView(1999)
realizes the far end, multi-select surfaces in SelectedItems.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
TableView has no content-based column sizing - its layout helper
treats GridLength.Auto as 1* - so the Auto columns from the previous
commit all came out equal-width. Give the narrow columns pixel widths
measured from their widest content (# from the item count, Show from
the last start time, Duration from the max duration, each vs the
header). The image column is sized from ImageMaxWidth and follows the
Ctrl+plus/minus zoom via PropertyChanged; Text keeps the star width.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The header's right border was tied to the vertical grid-lines setting,
so with grid lines off/horizontal the column headers ran together.
Draw it unconditionally, like the header's bottom line - matching
DataGrid, whose header separators are always on regardless of the
grid-lines setting.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The TableView header was hard-coded transparent while DataGrid headers
get a themed background. Default to the Fluent DataGridColumnHeader
Background resource (falling back to transparent when absent), and give
the three custom themes that restyle DataGridColumnHeader - lighter
dark, classic gray, pastel - a matching TableViewColumnHeader style
with the same brushes. App styles outrank the control theme, so the
per-theme overrides win where they apply.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@niksedk
niksedk merged commit 702be38 into main Jul 30, 2026
1 of 2 checks passed
@niksedk
niksedk deleted the experiment/tableview-ocr branch July 30, 2026 15:48
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.

1 participant