Commit Graph
9 Commits
Author SHA1 Message Date
David Richardson 0a669c840b CPTableView: Distribute user column resize to trailing columns per autoresizing style 2026-11-26 15:58:27 -06:00
David Richardson bb65f7ca80 CPTableView: Pass nil for the table column when context-clicking outside all columns
Right-clicking outside the column bounds previously attempted to retrieve the CPTableColumn at index -1, raising an exception that prevented the contextual menu from displaying. The menu delegate now receives nil for the column parameter in this case, matching the documented delegate contract.

Includes two unit tests covering context clicks on a populated row and outside the column bounds (with the table hosted inside a CPScrollView so the view extends beyond its column widths).
2026-11-25 15:09:03 -06:00
David Richardson 145138ae8b CPTableView: Ignore clicks on control cells in non-editable columns
Previously, clicking a control cell (such as a checkbox) in a
non-editable column mutated its value and committed the change because
-_hitTest: routed non-text-field control cell mouse-downs to the
control without checking whether the column was editable.

Matching AppKit, control cells in non-editable columns no longer handle
the click, allowing the table view to select the row instead.
2026-11-25 09:47:16 -06:00
David Richardson 4f33729e69 CPTableView: Resize columns by column autoresizing style
Previously, CPTableView guessed whether columns had filled the clip
view only for the uniform style, while the first- and last-column-only
styles ignored the heuristic and called _autoResizeFirstColumn or
sizeLastColumnToFit—forcing the columns to the clip view edge rather
than applying the width delta and collapsing trailing gaps (e.g., a
last column of 291 instead of 150). Sequential styles did nothing,
uniform missed the clip view by the intercell spacing, programmatic
table views had no default autoresizing style, and -tile left row
views at their prior width.

Following NSTableView, width changes now distribute across autoresizable
columns according to the column autoresizing style: uniform distributes
whole-point shares and redistributes shares from columns hitting min/max
bounds, sequential starts from the last column, reverse sequential from
the first, and first/last column only resize their respective single
column. The default style is now last column only.

Added -sizeToFit to size visible columns equally to fill the clip view
within each column's min/max bounds, and updated -tile to refresh row
view frames after setting the table view width.

Tests: CPTableViewColumnAutoresizingTest (29 tests).
2026-11-24 17:18:22 -06:00
David Richardson 333e448f44 AppKit: Prevent premature display during CPTableView view enumeration
-_enumerateViewsInRows:columns:usingBlock: and
-_enumerateViewsInRows:tableColumns:usingBlock: previously executed a run loop
pass before visiting views. Running timers, delayed performs, and the display
server mid-operation caused views to render prematurely before load, selection,
or expansion changes completed.

- CPTableView: Restrict -_enumerateViewsInRows:columns:usingBlock: and
  -_enumerateViewsInRows:tableColumns:usingBlock: to enumerating existing
  views without pumping the run loop.

- CPTableView: Call -layoutIfNeeded to complete reloads in
  -enumerateAvailableViewsUsingBlock: and -removeTableColumn:.

- Tests: Update tests affected by the removal of the implicit run loop pass
  and the interaction test helper fix—dispatch events once through the
  application in the interaction test helper (which command-click and
  shift-click tests depend on), force layout prior to assertions in the reload
  and lazy preparation tests, and target clicks below the rows of a
  scroll-view-hosted table in the click-outside tests.
2026-11-18 09:57:41 -06:00
David Richardson 0111408d5f AppKit: Replace legacy CPTableView rendering with view-backed rows and decoration views
Replace the legacy table view rendering methods with a view-backed architecture.
CPTableView now performs no drawing in -drawRect: by default. Subclasses
overriding a layer drawing method (background, selection, grid, or rows)
have that layer and all foreground layers drawn onto a canvas subview,
while column selection and vertical grid lines are presented as views within
a decoration container.

Row views display the state assigned by the table view. Calling
-setNeedsDisplay: flags visual invalidation, prompting the subsequent layout
pass to reconfigure visible row views. Visible rows remain synchronized during
layout, and the rendering state is invalidated whenever rows, columns, or the
exposed rect change.

- Aristo2: Define a group row background color.
- CPTableViewDrawingPassTest: Add unit tests covering the drawing pass.
2026-11-18 09:47:58 -06:00
David Richardson 4f16e876b0 AppKit: Begin double-click editing only when a data source or binding accepts the value
Returning a flag constant instead of evaluating it allowed tables and outlines to initiate double-click edits even when neither the data source nor a binding supported storing the value.

- CPTableView: Evaluate the setObjectValue capability against implemented
  data source methods rather than returning a static flag constant.

- CPTableView: Track click slop on all clicks to ensure bound tables correctly reject edits after pointer movement.

- CPOutlineView: Test whether the outline data source implements -outlineView:setObjectValue:forTableColumn:byItem: rather than inheriting the table view check.

- CPTableViewInteractionTest: Add tests covering read-only data sources, bound tables, and movements within and beyond click slop thresholds.

- CPOutlineViewInteractionTest: Add tests for outline data sources with and without -outlineView:setObjectValue:forTableColumn:byItem:.
2026-11-16 16:39:38 -06:00
David Richardson 18ac703f4e AppKit: Add previously missing public CPTableRowView with AppKit's row view API
- Replace _CPTableRowView with CPTableRowView: state properties, background colour with application and default values, viewAtColumn: and numberOfColumns

- Set all row view state from table view in one method at attach, selection change, full update and drop target change

- Write row view look in layoutSubviews instead of in setters

- Add rowViewAtRow:makeIfNecessary:, enumerateAvailableRowViewsUsingBlock:, didAddRowView:forRow: and didRemoveRowView:forRow:

- Accept row views in rowForView:

- Add tableView:rowViewForRow:, tableView:didAddRowView:forRow: and tableView:didRemoveRowView:forRow: delegate methods, and outline view equivalents

- Keep row views apart from data view loading, so column changes no longer recycle them

- Keep private row views below last row, reuse table-made row views from pool and delegate row views by identifier

- Return no unfocused selection colour for missing or CSS-based selection colour instead of raising

- Add CPTableRowView tests
2026-11-16 10:55:44 -06:00
David Richardson d2c365ef21 AppKit: Divide CPTableView into core file and category files
- Move class, instance variables, initialization and display attributes to CPTableViewCore.j

- Move columns, selection, layout, views, drawing, tracking, dragging, responder and editing methods to categories, one file each

- Move existing data source, delegate, bindings and coding categories to files of their own

- Move _CPTableRowView and CPTableCellView to files of their own

- Import all files from CPTableView.j

- Make data source and delegate flag constants global for use across files
2026-11-16 10:14:00 -06:00