fix: improve acknowledgments tab (closes #4025)
This commit is contained in:
1 parent
42bbd0fe01
commit
db5500f130
1 file changed
+11
-7
@@ -7,17 +7,19 @@ class AcknowledgmentsTab {
|
|||||||
static func initTab() -> NSView {
|
static func initTab() -> NSView {
|
||||||
let textViews: [NSTextView] = ["Contributors", "Acknowledgments"].map {
|
let textViews: [NSTextView] = ["Contributors", "Acknowledgments"].map {
|
||||||
let markdownFileUrl = Bundle.main.url(forResource: $0, withExtension: "md")!
|
let markdownFileUrl = Bundle.main.url(forResource: $0, withExtension: "md")!
|
||||||
let content = try! String(contentsOf: markdownFileUrl, encoding: .utf8)
|
var content = try! String(contentsOf: markdownFileUrl, encoding: .utf8)
|
||||||
|
if content.last == "\n" {
|
||||||
|
content.removeLast()
|
||||||
|
}
|
||||||
let attributedString = Markdown.toAttributedString(content)
|
let attributedString = Markdown.toAttributedString(content)
|
||||||
let textView = NSTextView()
|
let textView = NSTextView()
|
||||||
textView.textContainer!.widthTracksTextView = true
|
textView.textContainer!.widthTracksTextView = true
|
||||||
textView.translatesAutoresizingMaskIntoConstraints = false
|
textView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
textView.drawsBackground = true
|
textView.drawsBackground = false
|
||||||
textView.backgroundColor = .clear
|
|
||||||
textView.isSelectable = true
|
textView.isSelectable = true
|
||||||
textView.isEditable = false
|
textView.isEditable = false
|
||||||
textView.enabledTextCheckingTypes = 0
|
textView.enabledTextCheckingTypes = 0
|
||||||
textView.frame.size.width = 230
|
textView.frame.size.width = 240
|
||||||
textView.textStorage!.setAttributedString(attributedString)
|
textView.textStorage!.setAttributedString(attributedString)
|
||||||
textView.layoutManager!.ensureLayout(for: textView.textContainer!)
|
textView.layoutManager!.ensureLayout(for: textView.textContainer!)
|
||||||
textView.frame = textView.layoutManager!.usedRect(for: textView.textContainer!)
|
textView.frame = textView.layoutManager!.usedRect(for: textView.textContainer!)
|
||||||
@@ -25,13 +27,15 @@ class AcknowledgmentsTab {
|
|||||||
return textView
|
return textView
|
||||||
}
|
}
|
||||||
let subGrid = GridView([textViews])
|
let subGrid = GridView([textViews])
|
||||||
subGrid.column(at: 1).leadingPadding = 20
|
|
||||||
subGrid.fit()
|
subGrid.fit()
|
||||||
|
|
||||||
let scrollView = ScrollView()
|
let scrollView = NSScrollView()
|
||||||
scrollView.translatesAutoresizingMaskIntoConstraints = false
|
scrollView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
scrollView.drawsBackground = false
|
||||||
|
scrollView.hasVerticalScroller = true
|
||||||
|
scrollView.hasHorizontalScroller = false
|
||||||
|
scrollView.documentView = FlippedView(frame: .zero)
|
||||||
scrollView.documentView!.translatesAutoresizingMaskIntoConstraints = false
|
scrollView.documentView!.translatesAutoresizingMaskIntoConstraints = false
|
||||||
scrollView.scrollerKnobStyle = .default
|
|
||||||
scrollView.documentView!.subviews = [subGrid]
|
scrollView.documentView!.subviews = [subGrid]
|
||||||
let totalWidth = subGrid.fittingSize.width
|
let totalWidth = subGrid.fittingSize.width
|
||||||
scrollView.frame.size = NSSize(width: totalWidth, height: maxTabHeight)
|
scrollView.frame.size = NSSize(width: totalWidth, height: maxTabHeight)
|
||||||
|
|||||||
Reference in new issue
Block a user