diff --git a/Aural.xcodeproj/project.xcworkspace/xcuserdata/kven.xcuserdatad/UserInterfaceState.xcuserstate b/Aural.xcodeproj/project.xcworkspace/xcuserdata/kven.xcuserdatad/UserInterfaceState.xcuserstate index b2aa1f593..c16b1e548 100644 Binary files a/Aural.xcodeproj/project.xcworkspace/xcuserdata/kven.xcuserdatad/UserInterfaceState.xcuserstate and b/Aural.xcodeproj/project.xcworkspace/xcuserdata/kven.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Source/UI/CompactPlayer/Lyrics/CompactPlayerLyricsViewController.swift b/Source/UI/CompactPlayer/Lyrics/CompactPlayerLyricsViewController.swift index f1a452c85..d82d8a6ec 100644 --- a/Source/UI/CompactPlayer/Lyrics/CompactPlayerLyricsViewController.swift +++ b/Source/UI/CompactPlayer/Lyrics/CompactPlayerLyricsViewController.swift @@ -16,19 +16,21 @@ class CompactPlayerLyricsViewController: LyricsViewController { override var nibName: NSNib.Name? {"CompactPlayerLyrics"} - private static var columnBounds = NSMakeRect(.zero, .zero, 270, .greatestFiniteMagnitude) + override var lineBreakMode: NSLineBreakMode {.byWordWrapping} // Adjust row height based on if the text wraps over to the next line override func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat { guard let text = self.timedLyrics?.lines[row].content else {return 30} - // Set the key and value within the virtual text fields (which are not displayed) prototypeTextField.font = systemFontScheme.lyricsHighlightFont prototypeTextField.stringValue = text + let columnWidth = tableView.tableColumn(withIdentifier: .cid_lyricsLine)?.width ?? 270 + let columnBounds = NSMakeRect(.zero, .zero, columnWidth, .greatestFiniteMagnitude) + // And then compute row height from their cell sizes - let rowHeight = prototypeTextField.cell!.cellSize(forBounds: Self.columnBounds).height + let rowHeight = prototypeTextField.cell!.cellSize(forBounds: columnBounds).height // The desired row height is the maximum of the two heights, plus some padding return max(30, rowHeight + 5) diff --git a/Source/UI/Lyrics/LyricsViewController+Timed.swift b/Source/UI/Lyrics/LyricsViewController+Timed.swift index 20377e601..3851df5b8 100644 --- a/Source/UI/Lyrics/LyricsViewController+Timed.swift +++ b/Source/UI/Lyrics/LyricsViewController+Timed.swift @@ -156,6 +156,8 @@ extension LyricsViewController: NSTableViewDelegate { private static let rowHeight: CGFloat = 30 + @objc var lineBreakMode: NSLineBreakMode {.byTruncatingTail} + func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat { Self.rowHeight } @@ -187,7 +189,7 @@ extension LyricsViewController: NSTableViewDelegate { } cell.textField?.show() -// cell.textField?.lineBreakMode = .byWordWrapping + cell.textField?.lineBreakMode = self.lineBreakMode return cell } @@ -201,7 +203,6 @@ extension LyricsViewController: NSTableViewDelegate { cell.text = line.content cell.textFont = systemFontScheme.lyricsHighlightFont cell.textColor = systemColorScheme.primarySelectedTextColor - cell.textField?.lineBreakMode = .byWordWrapping return } @@ -216,17 +217,11 @@ extension LyricsViewController: NSTableViewDelegate { let preSegmentRange = NSMakeRange(0, segmentLoc) let subString = line.content.substring(range: preSegmentRange.intRange) - let attrStr = subString.attributed(font: systemFontScheme.lyricsHighlightFont, color: systemColorScheme.primarySelectedTextColor) -// attrStr.addAttribute(.paragraphStyle, value: NSMutableParagraphStyle.byWordWrapping, range: NSMakeRange(0, attrStr.length)) - mutStr = mutStr + attrStr + mutStr = mutStr + subString.attributed(font: systemFontScheme.lyricsHighlightFont, color: systemColorScheme.primarySelectedTextColor) } let subString = line.content.substring(range: segment.range.intRange) - - let attrStr = subString.attributed(font: systemFontScheme.lyricsHighlightFont, color: systemColorScheme.activeControlColor) -// attrStr.addAttribute(.paragraphStyle, value: NSMutableParagraphStyle.byWordWrapping, range: NSMakeRange(0, attrStr.length)) - - mutStr = mutStr + attrStr + mutStr = mutStr + subString.attributed(font: systemFontScheme.lyricsHighlightFont, color: systemColorScheme.activeControlColor) let segmentLen = segment.range.length let segmentEnd = segmentLoc + segmentLen @@ -237,15 +232,9 @@ extension LyricsViewController: NSTableViewDelegate { let postSegmentRange = NSMakeRange(segmentEnd, contentLength - segmentEnd) let subString = line.content.substring(range: postSegmentRange.intRange) - let attrStr = subString.attributed(font: systemFontScheme.lyricsHighlightFont, color: systemColorScheme.primarySelectedTextColor) -// attrStr.addAttribute(.paragraphStyle, value: NSMutableParagraphStyle.byWordWrapping, range: NSMakeRange(0, attrStr.length)) - - mutStr = mutStr + attrStr + mutStr = mutStr + subString.attributed(font: systemFontScheme.lyricsHighlightFont, color: systemColorScheme.primarySelectedTextColor) } - mutStr.addAttribute(.paragraphStyle, value: NSMutableParagraphStyle.byWordWrapping, range: NSMakeRange(0, mutStr.length)) - -// cell.textField?.lineBreakMode = .byWordWrapping cell.attributedText = mutStr } @@ -254,6 +243,5 @@ extension LyricsViewController: NSTableViewDelegate { cell.text = line.content cell.textFont = isCurrentLine ? systemFontScheme.lyricsHighlightFont : systemFontScheme.prominentFont cell.textColor = isCurrentLine ? systemColorScheme.activeControlColor : systemColorScheme.secondaryTextColor - cell.textField?.lineBreakMode = .byWordWrapping } }