Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Data grid column identifiers are now the column name (with positional fallback for duplicate names), so saved widths follow the column across schema changes that shift its position. Identifier resolution moved from static `DataGridView` helpers to a `ColumnIdentitySchema` value type owned by the coordinator.
- `ColumnLayoutStorage` singleton replaced by a `ColumnLayoutPersisting` protocol with an injectable `FileColumnLayoutPersister` default. The coordinator depends on the protocol, not the concrete class, so tests can substitute a fake.
- Column layout save/restore on table-switch (`saveColumnLayoutForTable` / `restoreColumnLayoutForTable`) folded into the data grid coordinator's lifecycle (load on column build, persist on resize/move/dismantle). The standalone `MainContentCoordinator+ColumnLayout` extension is gone; only the visibility orchestration remains. Removes the redundant `hasUserResizedColumns` flag and the external save trigger from the binding setter.
- Data grid header sort indicators are drawn inside a custom `NSTableHeaderCell` instead of overlay `NSImageView` subviews, replacing Unicode arrows that were embedded in the column title string. Removing the overlay subviews lets `NSTableHeaderView`'s native cursor management run unimpeded, so the column resize cursor on hover works without any custom cursor handling. The primary sorted column gets the system header tint via `highlightedTableColumn`, and secondary sort columns show a small priority number to the left of the arrow.
- Data grid header sort indicators are drawn inside a custom `NSTableHeaderCell` instead of overlay `NSImageView` subviews, replacing Unicode arrows that were embedded in the column title string. The cell renders ascending/descending chevrons via SF Symbols (`chevron.up`/`chevron.down`) with a hierarchical tint, so they pick up the correct color in light and dark mode. Removing the overlay subviews lets `NSTableHeaderView`'s native cursor management run unimpeded, so the column resize cursor on hover works without any custom cursor handling. The primary sorted column gets the system header tint via `highlightedTableColumn`, and secondary sort columns show a small priority number to the left of the chevron.
- Data grid header divider taps trigger a column resize instead of sorting the adjacent column. `SortableHeaderView` checks if the click landed within 4 pt of a column edge and forwards the event to `NSTableHeaderView`'s native resize handling.
- Data grid column layout persistence routes through a coordinator callback fired from outside SwiftUI's update cycle, removing the `Task`-based `@Binding` mutation inside `updateNSView` and the `isWritingColumnLayout` re-entry guard.
- Data grid cell reuse resets foreign-key arrow and dropdown chevron button context (target, action, row, column) when the button hides, preventing a stale handler from firing the wrong row if the column toggles between FK-eligible and not.
Expand Down
15 changes: 7 additions & 8 deletions TablePro/Views/Results/SortableHeaderCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ final class SortableHeaderCell: NSTableHeaderCell {
width: indicatorSize.width,
height: indicatorSize.height
)
Self.drawTintedIndicator(image: indicatorImage, in: indicatorRect)
Self.drawIndicator(image: indicatorImage, in: indicatorRect)

if let priorityText {
let textOriginX = indicatorOriginX - Self.indicatorSpacing - priorityWidth
Expand Down Expand Up @@ -96,15 +96,14 @@ final class SortableHeaderCell: NSTableHeaderCell {
}

private static func indicatorImage(for direction: SortDirection) -> NSImage? {
switch direction {
case .ascending:
return NSImage(named: NSImage.Name("NSAscendingSortIndicator"))
case .descending:
return NSImage(named: NSImage.Name("NSDescendingSortIndicator"))
}
let symbolName = direction == .ascending ? "chevron.up" : "chevron.down"
let configuration = NSImage.SymbolConfiguration(pointSize: priorityFontSize, weight: .semibold)
.applying(.init(hierarchicalColor: .secondaryLabelColor))
return NSImage(systemSymbolName: symbolName, accessibilityDescription: nil)?
.withSymbolConfiguration(configuration)
}

private static func drawTintedIndicator(image: NSImage?, in rect: NSRect) {
private static func drawIndicator(image: NSImage?, in rect: NSRect) {
guard let image else { return }
image.draw(
in: rect,
Expand Down
Loading