diff --git a/CodeEdit/Info.plist b/CodeEdit/Info.plist
index a87c12e0f6..1d038ddc13 100644
--- a/CodeEdit/Info.plist
+++ b/CodeEdit/Info.plist
@@ -45,6 +45,6 @@
GitHash
- f757c49a7b8bb16b2a531a8c7e7a6a77435484c4
+ cdaf6b982864a55727edc3b1b3201e689bc2ff6d
diff --git a/CodeEdit/NavigatorSidebar/ProjectNavigator/OutlineView/OutlineTableViewCell.swift b/CodeEdit/NavigatorSidebar/ProjectNavigator/OutlineView/OutlineTableViewCell.swift
index bb2e23b88c..9f9b5f90ac 100644
--- a/CodeEdit/NavigatorSidebar/ProjectNavigator/OutlineView/OutlineTableViewCell.swift
+++ b/CodeEdit/NavigatorSidebar/ProjectNavigator/OutlineView/OutlineTableViewCell.swift
@@ -23,7 +23,7 @@ class OutlineTableViewCell: NSTableCellView {
self.label.drawsBackground = false
self.label.isBordered = false
self.label.isEditable = false
- self.label.font = .preferredFont(forTextStyle: .subheadline)
+ self.label.font = .labelFont(ofSize: fontSize)
self.addSubview(label)
self.textField = label
@@ -32,21 +32,21 @@ class OutlineTableViewCell: NSTableCellView {
self.icon = NSImageView(frame: .zero)
self.icon.translatesAutoresizingMaskIntoConstraints = false
- self.icon.symbolConfiguration = .init(textStyle: .callout, scale: .medium)
+ self.icon.symbolConfiguration = .init(pointSize: fontSize, weight: .regular, scale: .medium)
self.addSubview(icon)
self.imageView = icon
// Icon constraints
- self.icon.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 0).isActive = true
+ self.icon.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: -2).isActive = true
self.icon.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
- self.icon.widthAnchor.constraint(equalToConstant: 21).isActive = true
+ self.icon.widthAnchor.constraint(equalToConstant: 25).isActive = true
self.icon.heightAnchor.constraint(equalToConstant: frameRect.height).isActive = true
// Label constraints
- self.label.leadingAnchor.constraint(equalTo: icon.trailingAnchor, constant: 2).isActive = true
+ self.label.leadingAnchor.constraint(equalTo: icon.trailingAnchor, constant: 1).isActive = true
self.label.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
}
@@ -54,4 +54,14 @@ class OutlineTableViewCell: NSTableCellView {
fatalError()
}
+ /// Returns the font size for the current row height. Defaults to `13.0`
+ private var fontSize: Double {
+ switch self.frame.height {
+ case 20: return 11
+ case 22: return 13
+ case 24: return 14
+ default: return 13
+ }
+ }
+
}
diff --git a/CodeEdit/NavigatorSidebar/ProjectNavigator/OutlineView/OutlineView.swift b/CodeEdit/NavigatorSidebar/ProjectNavigator/OutlineView/OutlineView.swift
index 9ce09f583c..7742c638bf 100644
--- a/CodeEdit/NavigatorSidebar/ProjectNavigator/OutlineView/OutlineView.swift
+++ b/CodeEdit/NavigatorSidebar/ProjectNavigator/OutlineView/OutlineView.swift
@@ -31,7 +31,20 @@ struct OutlineView: NSViewControllerRepresentable {
func updateNSViewController(_ nsViewController: OutlineViewController, context: Context) {
nsViewController.iconColor = prefs.preferences.general.fileIconStyle
nsViewController.updateSelection()
+ nsViewController.rowHeight = rowHeight
return
}
+ /// Returns the row height depending on the `projectNavigatorSize` in `AppPreferences`.
+ ///
+ /// * `small`: 20
+ /// * `medium`: 22
+ /// * `large`: 24
+ private var rowHeight: Double {
+ switch prefs.preferences.general.projectNavigatorSize {
+ case .small: return 20
+ case .medium: return 22
+ case .large: return 24
+ }
+ }
}
diff --git a/CodeEdit/NavigatorSidebar/ProjectNavigator/OutlineView/OutlineViewController.swift b/CodeEdit/NavigatorSidebar/ProjectNavigator/OutlineView/OutlineViewController.swift
index 7de89efdae..3370e765f0 100644
--- a/CodeEdit/NavigatorSidebar/ProjectNavigator/OutlineView/OutlineViewController.swift
+++ b/CodeEdit/NavigatorSidebar/ProjectNavigator/OutlineView/OutlineViewController.swift
@@ -35,6 +35,13 @@ class OutlineViewController: NSViewController {
var iconColor: AppPreferences.FileIconStyle = .color
+ var rowHeight: Double = 22 {
+ didSet {
+ outlineView.rowHeight = rowHeight
+ outlineView.reloadData()
+ }
+ }
+
/// Setup the ``scrollView`` and ``outlineView``
override func loadView() {
self.scrollView = NSScrollView()
@@ -136,7 +143,7 @@ extension OutlineViewController: NSOutlineViewDelegate {
guard let tableColumn = tableColumn else { return nil }
- let frameRect = NSRect(x: 0, y: 0, width: tableColumn.width, height: 17)
+ let frameRect = NSRect(x: 0, y: 0, width: tableColumn.width, height: rowHeight)
let view = OutlineTableViewCell(frame: frameRect)
@@ -166,7 +173,7 @@ extension OutlineViewController: NSOutlineViewDelegate {
}
func outlineView(_ outlineView: NSOutlineView, heightOfRowByItem item: Any) -> CGFloat {
- return 22 // This can be changed to 20 to match Xcodes row height.
+ return rowHeight // This can be changed to 20 to match Xcodes row height.
}
func outlineViewItemDidExpand(_ notification: Notification) {
diff --git a/CodeEditModules/Modules/AppPreferences/src/Model/AppPreferences.swift b/CodeEditModules/Modules/AppPreferences/src/Model/AppPreferences.swift
index 01ddb238b4..69f16ad94b 100644
--- a/CodeEditModules/Modules/AppPreferences/src/Model/AppPreferences.swift
+++ b/CodeEditModules/Modules/AppPreferences/src/Model/AppPreferences.swift
@@ -61,6 +61,9 @@ public extension AppPreferences {
/// The reopen behavior of the app
public var reopenBehavior: ReopenBehavior = .welcome
+ /// The size of the project navigators rows.
+ public var projectNavigatorSize: ProjectNavigatorSize = .medium
+
/// Default initializer
public init() {}
@@ -71,6 +74,8 @@ public extension AppPreferences {
self.fileIconStyle = try container.decodeIfPresent(FileIconStyle.self, forKey: .fileIconStyle) ?? .color
self.reopenBehavior = try container.decodeIfPresent(ReopenBehavior.self,
forKey: .reopenBehavior) ?? .welcome
+ self.projectNavigatorSize = try container.decodeIfPresent(ProjectNavigatorSize.self,
+ forKey: .projectNavigatorSize) ?? .medium
}
}
@@ -116,6 +121,20 @@ public extension AppPreferences {
case newDocument
}
+ /// The size of the project navigators rows.
+ ///
+ /// To match Xcode's settings the row height should be:
+ /// * ``small``: `20pt` (fontSize: `11pt`)
+ /// * ``medium``: `22pt` (fontSize: `13pt`)
+ /// * ``small``: `24pt` (fontSize: `14pt`)
+ ///
+ /// - note: This should be implemented for all lists in a `NavigatorSidebar`
+ enum ProjectNavigatorSize: String, Codable {
+ case small
+ case medium
+ case large
+ }
+
}
public extension AppPreferences {
diff --git a/CodeEditModules/Modules/AppPreferences/src/Sections/GeneralPreferences/GeneralPreferencesView.swift b/CodeEditModules/Modules/AppPreferences/src/Sections/GeneralPreferences/GeneralPreferencesView.swift
index 658c5fa682..9981afd312 100644
--- a/CodeEditModules/Modules/AppPreferences/src/Sections/GeneralPreferences/GeneralPreferencesView.swift
+++ b/CodeEditModules/Modules/AppPreferences/src/Sections/GeneralPreferences/GeneralPreferencesView.swift
@@ -51,6 +51,16 @@ public struct GeneralPreferencesView: View {
.tag(AppPreferences.ReopenBehavior.newDocument)
}
}
+ PreferencesSection("Project Navigator Size") {
+ Picker("Project Navigator Size", selection: $prefs.preferences.general.projectNavigatorSize) {
+ Text("Small")
+ .tag(AppPreferences.ProjectNavigatorSize.small)
+ Text("Medium")
+ .tag(AppPreferences.ProjectNavigatorSize.medium)
+ Text("Large")
+ .tag(AppPreferences.ProjectNavigatorSize.large)
+ }
+ }
}
}
}