1111import Cocoa
1212
1313@objc ( SBSourceListViewItem) class SBSourceListViewItem : NSTableCellView {
14- // https://developer.apple.com/design/human-interface-guidelines/sidebars#macOS
15- // Our row height comes from our hosting NSOutlineView's delegate
16- // Small: 16px icons, subheading text; Medium: 20px icons, body text
17- // XXX: Resize to match system sidebar size
18-
1914 var resource : SBResource ! {
2015 objectValue as? SBResource
2116 }
@@ -96,11 +91,12 @@ import Cocoa
9691 imageView. image = self . icon
9792 self . imageView = imageView
9893 self . addSubview ( imageView)
99- // 28 high sidebar, 4 point to be centered
100- imageView. topAnchor. constraint ( equalTo: self . topAnchor, constant: 4.0 ) . isActive = true
94+ // image always has a vertical inset of 4px (i.e. medium 28pt row height, 20pt image)
95+ // https://developer.apple.com/design/human-interface-guidelines/sidebars#macOS
96+ imageView. topAnchor. constraint ( equalTo: self . topAnchor, constant: 10.0 ) . isActive = true
97+ imageView. bottomAnchor. constraint ( equalTo: self . bottomAnchor, constant: - 4.0 ) . isActive = true
98+ imageView. widthAnchor. constraint ( equalTo: self . heightAnchor) . isActive = true
10199 imageView. leadingAnchor. constraint ( equalTo: self . leadingAnchor) . isActive = true
102- imageView. widthAnchor. constraint ( equalToConstant: 20 ) . isActive = true
103- imageView. heightAnchor. constraint ( equalToConstant: 20 ) . isActive = true
104100
105101 let textField = NSTextField ( )
106102 textField. translatesAutoresizingMaskIntoConstraints = false
@@ -114,11 +110,10 @@ import Cocoa
114110 // XXX: Seet it here as bindings will set this
115111 textField. target = self
116112 textField. action = #selector( SBSourceListViewItem . renameItem ( _: ) )
117- textField. font = NSFont . preferredFont ( forTextStyle: . body)
118113 self . textField = textField
119114 self . addSubview ( textField)
120115 textField. centerYAnchor. constraint ( equalTo: imageView. centerYAnchor) . isActive = true
121- textField. leadingAnchor. constraint ( equalTo: imageView. trailingAnchor, constant : 4.0 ) . isActive = true
116+ textField. leadingAnchor. constraint ( equalTo: imageView. trailingAnchor) . isActive = true
122117 // XXX: For some reason, this anchor breaks the editing mode for the text field
123118 //textField.trailingAnchor.constraint(equalTo: self.trailingAnchor).isActive = true
124119 }
0 commit comments