fix: center bullets and checkboxes in the marker column

This commit is contained in:
2026-10-19 21:00:43 +02:00
parent 07dae870f7
commit 9e92dc3d7f
3 changed files with 40 additions and 7 deletions
+5 -3
View File
@@ -19,7 +19,7 @@ private final class ListAttachment: NSTextAttachment {
let cell = ListAttachmentCell(textCell: isTask ? "" : (source.length == 1 ? "•" : source.string))
cell.attributedStringValue = NSAttributedString(string: cell.stringValue,
attributes: [.font: NotesAppearance.font, .foregroundColor: SunsetPalette.accent])
cell.alignment = .right
cell.alignment = source.length == 1 ? .center : .right
attachmentCell = cell
bounds = NSRect(x: 0, y: -4, width: 22, height: 21)
}
@@ -35,7 +35,8 @@ private final class ListAttachmentCell: NSTextAttachmentCell {
guard !stringValue.isEmpty else { return }
let label = attributedStringValue
let size = label.size()
label.draw(at: NSPoint(x: cellFrame.maxX - 4 - size.width,
let x = alignment == .center ? cellFrame.midX - size.width / 2 : cellFrame.maxX - 4 - size.width
label.draw(at: NSPoint(x: x,
y: cellFrame.midY - size.height / 2))
}
}
@@ -617,7 +618,8 @@ final class NotesTextView: NSTextView, @MainActor NSLayoutManagerDelegate {
let glyphs = layoutManager.glyphRange(forCharacterRange: task.range, actualCharacterRange: nil)
let rect = layoutManager.boundingRect(forGlyphRange: glyphs, in: textContainer)
.offsetBy(dx: textContainerOrigin.x, dy: textContainerOrigin.y)
checkbox.setFrameOrigin(NSPoint(x: rect.maxX - 18, y: rect.midY - checkbox.frame.height / 2))
checkbox.setFrameOrigin(NSPoint(x: rect.midX - checkbox.frame.width / 2,
y: rect.midY - checkbox.frame.height / 2))
}
}