Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Macterm/App/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,32 @@ enum WindowGlassStyle: String, CaseIterable, Identifiable {
}
}

/// How a hidden sidebar appears while the pointer rests at the window's
/// leading edge. The normal pinned sidebar always remains a native split-view
/// column; this only controls the temporary hover peek.
enum SidebarPeekStyle: String, CaseIterable, Identifiable {
case resizeTerminal = "resize_content"
case overlayTerminal = "overlay_on_hover"

var id: String { rawValue }

var displayName: String {
switch self {
case .resizeTerminal: "Resize terminal"
case .overlayTerminal: "Overlay terminal"
}
}

var explanation: String {
switch self {
case .resizeTerminal:
"Slides the native sidebar column out and temporarily resizes the terminal."
case .overlayTerminal:
"Shows a floating Liquid Glass sidebar over the terminal without changing its size."
}
}
}

/// Single observable source of truth for UserDefaults-backed preferences.
///
/// Macterm only stores app-shaped state here (window opacity/blur, quick
Expand Down Expand Up @@ -132,6 +158,12 @@ final class Preferences {
didSet { defaults.set(paneDimOpacity, forKey: Keys.paneDimOpacity) }
}

/// Presentation used by `peekSidebarWhenHidden`. The pinned sidebar is
/// always the native split-view column.
var sidebarPeekStyle: SidebarPeekStyle {
didSet { defaults.set(sidebarPeekStyle.rawValue, forKey: Keys.sidebarPeekStyle) }
}

// MARK: - Sidebar icons

var projectIconSymbol: String {
Expand Down Expand Up @@ -543,6 +575,8 @@ final class Preferences {
paneDimOpacity = Self.clampPaneDimOpacity(
(defaults.object(forKey: Keys.paneDimOpacity) as? Double) ?? 0.2
)
sidebarPeekStyle = (defaults.string(forKey: Keys.sidebarPeekStyle))
.flatMap(SidebarPeekStyle.init(rawValue:)) ?? .resizeTerminal
windowOpacity = (defaults.object(forKey: Keys.windowOpacity) as? Double) ?? 1.0
windowBlurRadius = defaults.integer(forKey: Keys.windowBlurRadius)
windowGlassEnabled = defaults.object(forKey: Keys.windowGlassEnabled) as? Bool ?? false
Expand Down Expand Up @@ -659,6 +693,7 @@ final class Preferences {
static let autoTiling = "macterm.autoTiling.enabled"
static let terminalScrollSpeed = "macterm.terminal.scrollSpeed"
static let paneDimOpacity = "macterm.pane.dimOpacity"
static let sidebarPeekStyle = "macterm.sidebar.presentation"
static let windowOpacity = "macterm.window.opacity"
static let windowBlurRadius = "macterm.window.blurRadius"
static let windowGlassEnabled = "macterm.window.glassEnabled"
Expand Down
26 changes: 21 additions & 5 deletions Macterm/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,8 @@ private struct AppearanceSettings: View {
private var paneDimOpacity: Double = Preferences.shared.paneDimOpacity
@State
private var adaptiveTerminalChrome: Bool = Preferences.shared.adaptiveTerminalChromeEnabled
@State
private var sidebarPeekStyle: SidebarPeekStyle = Preferences.shared.sidebarPeekStyle
/// Inverted view of `Preferences.hideTitleBar`: the control reads as
/// "Show toolbar" (on by default), the preference stores the hide.
@State
Expand Down Expand Up @@ -722,6 +724,25 @@ private struct AppearanceSettings: View {
}

Section("Sidebar") {
Toggle("Peek sidebar when hidden", isOn: $peekSidebarWhenHidden)
.onChange(of: peekSidebarWhenHidden) { _, v in Preferences.shared.peekSidebarWhenHidden = v }
Text("Shows the hidden sidebar while the pointer rests at the window's left edge.")
.settingsCaption()

Group {
Picker("Peek style", selection: $sidebarPeekStyle) {
ForEach(SidebarPeekStyle.allCases) { style in
Text(style.displayName).tag(style)
}
}
.onChange(of: sidebarPeekStyle) { _, style in
Preferences.shared.sidebarPeekStyle = style
}
Text(sidebarPeekStyle.explanation)
.settingsCaption()
}
.disabled(!peekSidebarWhenHidden)

Picker("Project icon", selection: $projectIconSymbol) {
ForEach(Preferences.projectIconChoices, id: \.self) { name in
iconPickerLabel(name).tag(name)
Expand Down Expand Up @@ -761,11 +782,6 @@ private struct AppearanceSettings: View {
.onChange(of: showNewProjectButton) { _, v in Preferences.shared.showNewProjectButton = v }
Text("When hidden, create projects via the command palette or context menu.")
.settingsCaption()

Toggle("Peek sidebar when hidden", isOn: $peekSidebarWhenHidden)
.onChange(of: peekSidebarWhenHidden) { _, v in Preferences.shared.peekSidebarWhenHidden = v }
Text("Slides the hidden sidebar out while the pointer rests at the window's left edge.")
.settingsCaption()
}

Section("Toolbar") {
Expand Down
Loading