Restore the previous style for the file importer group cell, plus refactor the attribute strings styles.

This commit is contained in:
Damiano Galassi committed 2017-11-01 09:36:20 +01:00
1 parent fb9fe6a969
commit 891c09970d
3 files changed
+26 -39

No files matched your search

+4 -4
View File
@@ -187,10 +187,10 @@
<rect key="frame" x="302" y="1" width="86" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="25J-SB-aeF">
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="25J-SB-aeF">
<rect key="frame" x="0.0" y="0.0" width="86" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="right" title="Lang" id="j7R-zS-fPy">
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="right" title="Lang" usesSingleLineMode="YES" id="j7R-zS-fPy">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
@@ -220,10 +220,10 @@
<rect key="frame" x="391" y="1" width="82" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="HCv-KV-l7J">
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="HCv-KV-l7J">
<rect key="frame" x="0.0" y="0.0" width="82" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="right" title="Info" id="gDY-tC-Ecv">
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="right" title="Info" usesSingleLineMode="YES" id="gDY-tC-Ecv">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+21 -34
View File
@@ -9,56 +9,39 @@ import Cocoa
// MARK: - Attributed styles
private let detailBoldMonospacedAttr = { () -> [NSAttributedStringKey : Any] in
private func monospaceAttributes(size: CGFloat, aligment: NSTextAlignment, headIndent: CGFloat = -10.0, firstLineHeadIndent: CGFloat = 0, bold: Bool) -> [NSAttributedStringKey : Any] {
let ps = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
ps.headIndent = -10.0
ps.alignment = NSTextAlignment.right
ps.firstLineHeadIndent = firstLineHeadIndent
ps.headIndent = headIndent
ps.alignment = aligment
if #available(macOS 10.11, *) {
return [NSAttributedStringKey.font: NSFont.monospacedDigitSystemFont(ofSize: NSFont.smallSystemFontSize,
weight: NSFont.Weight.bold),
return [NSAttributedStringKey.font: NSFont.monospacedDigitSystemFont(ofSize: size,
weight: bold ? NSFont.Weight.bold : NSFont.Weight.regular),
NSAttributedStringKey.paragraphStyle: ps,
NSAttributedStringKey.foregroundColor: NSColor.gray]
}
else {
return [NSAttributedStringKey.font: NSFont.boldSystemFont(ofSize: NSFont.smallSystemFontSize),
return [NSAttributedStringKey.font: bold ? NSFont.boldSystemFont(ofSize: size) : NSFont.systemFont(ofSize: size),
NSAttributedStringKey.paragraphStyle: ps,
NSAttributedStringKey.foregroundColor: NSColor.gray]
}
}
private let detailBoldMonospacedAttr = { () -> [NSAttributedStringKey : Any] in
return monospaceAttributes(size: NSFont.smallSystemFontSize, aligment: NSTextAlignment.right, bold: true)
}()
private let detailBoldAttr = { () -> [NSAttributedStringKey : Any] in
let ps = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
ps.headIndent = -10.0
ps.alignment = NSTextAlignment.left
if #available(macOS 10.11, *) {
return [NSAttributedStringKey.font: NSFont.monospacedDigitSystemFont(ofSize: NSFont.smallSystemFontSize,
weight: NSFont.Weight.bold),
NSAttributedStringKey.paragraphStyle: ps,
NSAttributedStringKey.foregroundColor: NSColor.gray]
}
else {
return [NSAttributedStringKey.font: NSFont.boldSystemFont(ofSize: NSFont.smallSystemFontSize),
NSAttributedStringKey.paragraphStyle: ps,
NSAttributedStringKey.foregroundColor: NSColor.gray]
}
return monospaceAttributes(size: NSFont.smallSystemFontSize, aligment: NSTextAlignment.left, bold: true)
}()
private let detailMonospacedAttr = { () -> [NSAttributedStringKey : Any] in
let ps = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
ps.headIndent = -10.0
ps.alignment = NSTextAlignment.right
return monospaceAttributes(size: NSFont.smallSystemFontSize, aligment: NSTextAlignment.right, bold: false)
}()
if #available(macOS 10.11, *) {
return [NSAttributedStringKey.font: NSFont.monospacedDigitSystemFont(ofSize: NSFont.smallSystemFontSize,
weight: NSFont.Weight.regular),
NSAttributedStringKey.paragraphStyle: ps]
}
else {
return [NSAttributedStringKey.font: NSFont.boldSystemFont(ofSize: NSFont.smallSystemFontSize),
NSAttributedStringKey.paragraphStyle: ps]
}
private let groupRowAttr = { () -> [NSAttributedStringKey : Any] in
return monospaceAttributes(size: NSFont.systemFontSize, aligment: NSTextAlignment.left, firstLineHeadIndent: 24, bold: true)
}()
extension String {
@@ -74,5 +57,9 @@ extension String {
func monospacedAttributedString() -> NSAttributedString {
return NSAttributedString(string: self, attributes: detailMonospacedAttr)
}
func groupAttributedString() -> NSAttributedString {
return NSAttributedString(string: self, attributes: groupRowAttr)
}
}
+1 -1
View File
@@ -403,7 +403,7 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
switch items[row] {
case .file(let importer):
let groupCell = tableView.makeView(withIdentifier: trackNameColumn, owner:self) as? NSTableCellView
groupCell?.textField?.stringValue = importer.fileURL.lastPathComponent
groupCell?.textField?.attributedStringValue = importer.fileURL.lastPathComponent.groupAttributedString()
return groupCell
case .track(let settings):