Restore the previous style for the file importer group cell, plus refactor the attribute strings styles.
This commit is contained in:
3 files changed
+25
-38
No files matched your search
@@ -187,10 +187,10 @@
|
|||||||
<rect key="frame" x="302" y="1" width="86" height="17"/>
|
<rect key="frame" x="302" y="1" width="86" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<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"/>
|
<rect key="frame" x="0.0" y="0.0" width="86" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
<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"/>
|
<font key="font" metaFont="system"/>
|
||||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" 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"/>
|
<rect key="frame" x="391" y="1" width="82" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<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"/>
|
<rect key="frame" x="0.0" y="0.0" width="82" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
<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"/>
|
<font key="font" metaFont="system"/>
|
||||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
|||||||
@@ -9,56 +9,39 @@ import Cocoa
|
|||||||
|
|
||||||
// MARK: - Attributed styles
|
// 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
|
let ps = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
|
||||||
ps.headIndent = -10.0
|
ps.firstLineHeadIndent = firstLineHeadIndent
|
||||||
ps.alignment = NSTextAlignment.right
|
ps.headIndent = headIndent
|
||||||
|
ps.alignment = aligment
|
||||||
|
|
||||||
if #available(macOS 10.11, *) {
|
if #available(macOS 10.11, *) {
|
||||||
return [NSAttributedStringKey.font: NSFont.monospacedDigitSystemFont(ofSize: NSFont.smallSystemFontSize,
|
return [NSAttributedStringKey.font: NSFont.monospacedDigitSystemFont(ofSize: size,
|
||||||
weight: NSFont.Weight.bold),
|
weight: bold ? NSFont.Weight.bold : NSFont.Weight.regular),
|
||||||
NSAttributedStringKey.paragraphStyle: ps,
|
NSAttributedStringKey.paragraphStyle: ps,
|
||||||
NSAttributedStringKey.foregroundColor: NSColor.gray]
|
NSAttributedStringKey.foregroundColor: NSColor.gray]
|
||||||
}
|
}
|
||||||
else {
|
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.paragraphStyle: ps,
|
||||||
NSAttributedStringKey.foregroundColor: NSColor.gray]
|
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
|
private let detailBoldAttr = { () -> [NSAttributedStringKey : Any] in
|
||||||
let ps = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
|
return monospaceAttributes(size: NSFont.smallSystemFontSize, aligment: NSTextAlignment.left, bold: true)
|
||||||
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]
|
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
private let detailMonospacedAttr = { () -> [NSAttributedStringKey : Any] in
|
private let detailMonospacedAttr = { () -> [NSAttributedStringKey : Any] in
|
||||||
let ps = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
|
return monospaceAttributes(size: NSFont.smallSystemFontSize, aligment: NSTextAlignment.right, bold: false)
|
||||||
ps.headIndent = -10.0
|
}()
|
||||||
ps.alignment = NSTextAlignment.right
|
|
||||||
|
|
||||||
if #available(macOS 10.11, *) {
|
private let groupRowAttr = { () -> [NSAttributedStringKey : Any] in
|
||||||
return [NSAttributedStringKey.font: NSFont.monospacedDigitSystemFont(ofSize: NSFont.smallSystemFontSize,
|
return monospaceAttributes(size: NSFont.systemFontSize, aligment: NSTextAlignment.left, firstLineHeadIndent: 24, bold: true)
|
||||||
weight: NSFont.Weight.regular),
|
|
||||||
NSAttributedStringKey.paragraphStyle: ps]
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return [NSAttributedStringKey.font: NSFont.boldSystemFont(ofSize: NSFont.smallSystemFontSize),
|
|
||||||
NSAttributedStringKey.paragraphStyle: ps]
|
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
extension String {
|
extension String {
|
||||||
@@ -75,4 +58,8 @@ extension String {
|
|||||||
return NSAttributedString(string: self, attributes: detailMonospacedAttr)
|
return NSAttributedString(string: self, attributes: detailMonospacedAttr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func groupAttributedString() -> NSAttributedString {
|
||||||
|
return NSAttributedString(string: self, attributes: groupRowAttr)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -403,7 +403,7 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
|||||||
switch items[row] {
|
switch items[row] {
|
||||||
case .file(let importer):
|
case .file(let importer):
|
||||||
let groupCell = tableView.makeView(withIdentifier: trackNameColumn, owner:self) as? NSTableCellView
|
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
|
return groupCell
|
||||||
|
|
||||||
case .track(let settings):
|
case .track(let settings):
|
||||||
|
|||||||
Reference in new issue
Block a user