diff --git a/Sources/TinyHand/OverlayController.swift b/Sources/TinyHand/OverlayController.swift index 4829a77..08bbc4f 100644 --- a/Sources/TinyHand/OverlayController.swift +++ b/Sources/TinyHand/OverlayController.swift @@ -484,7 +484,7 @@ final class OverlayController { let near = f.insetBy(dx: -80, dy: 0).union(f.offsetBy(dx: 0, dy: 90)).insetBy(dx: 0, dy: -10).contains(mouse) let needsPermission = !inputTap.isInstalled let drawing = armView.ink.isDrawing - toolbar.setRevealed(!drawing && (near || Date() < revealUntil || needsPermission)) + toolbar.setRevealed(needsPermission || (Preferences.showToolbar && !drawing && (near || Date() < revealUntil))) let menuLikely = !menuRects.isEmpty || ownMenuOpen || Date() < menuOpeningUntil || Date().timeIntervalSince(lastButtonEvent) < 2 diff --git a/Sources/TinyHand/Preferences.swift b/Sources/TinyHand/Preferences.swift index e18b2a2..6eff8f7 100644 --- a/Sources/TinyHand/Preferences.swift +++ b/Sources/TinyHand/Preferences.swift @@ -144,6 +144,11 @@ enum Preferences { set { set(newValue.rawValue, "inkChoice") } } + static var showToolbar: Bool { + get { defaults.object(forKey: "showToolbar") as? Bool ?? true } + set { set(newValue, "showToolbar") } + } + static var showInkButton: Bool { get { defaults.object(forKey: "showInkButton") as? Bool ?? true } set { set(newValue, "showInkButton") } @@ -182,7 +187,7 @@ enum Preferences { static func resetAll() { for key in ["shortcut.toggle", "shortcut.clear", "pointerSize", "showShadow", "fadeSeconds", "sound.hands", "sound.laser", "interactKey", "interactKeepsHand", "doubleShiftClickThrough", "pinnedStyles", "pointerStyle", - "inkChoice", "showInkButton", "tapSound"] { + "inkChoice", "showInkButton", "showToolbar", "tapSound"] { defaults.removeObject(forKey: key) } NotificationCenter.default.post(name: changed, object: nil) diff --git a/Sources/TinyHand/SettingsView.swift b/Sources/TinyHand/SettingsView.swift index a065a52..4b62fc9 100644 --- a/Sources/TinyHand/SettingsView.swift +++ b/Sources/TinyHand/SettingsView.swift @@ -582,6 +582,7 @@ private struct PointersPage: View { RoundedRectangle(cornerRadius: 14, style: .continuous) .fill(Color.primary.opacity(0.045)) ) + .opacity(Preferences.showToolbar ? 1 : 0.45) .background(GeometryReader { g in Color.clear .onAppear { rowFrame = g.frame(in: .named("pointersPage")) } @@ -603,6 +604,18 @@ private struct PointersPage: View { Text(message).font(.system(size: 12)).foregroundColor(.red).padding(.horizontal, 4) } } + Card(title: "Toolbar") { + Row("Show the toolbar", detail: Preferences.showToolbar + ? "Pops up when the pointer turns on and near the bottom of the screen." + : "Stays hidden. Press Esc to exit, or use the menu bar.") { + Toggle("", isOn: model.binding({ Preferences.showToolbar }, { Preferences.showToolbar = $0 })) + .toggleStyle(.switch).labelsHidden().focusable(false) + } + Row("Ink button", detail: "Change the colour while you present.") { + Toggle("", isOn: model.binding({ Preferences.showInkButton }, { Preferences.showInkButton = $0 })) + .toggleStyle(.switch).labelsHidden().focusable(false) + } + } YourHands(model: model) } .coordinateSpace(name: "pointersPage") @@ -989,10 +1002,6 @@ private struct DrawingPage: View { .fixedSize() .focusable(false) } - Row("Ink button in the toolbar", detail: "Change the colour while you present.") { - Toggle("", isOn: model.binding({ Preferences.showInkButton }, { Preferences.showInkButton = $0 })) - .toggleStyle(.switch).labelsHidden().focusable(false) - } } } }