import Foundation /// What a capture takes a picture of. /// /// The choice belongs to the session being captured into: it is stored once and copied /// to the next session, so a review run keeps capturing the same kind of thing until /// the user says otherwise. Choosing anything other than `.area` never clears the saved /// area — it comes back when Area is chosen again. public enum CaptureScope: String, Codable, Sendable, CaseIterable { case area case window case browser case screen /// Label for the segmented control and the window's menu. public var displayName: String { switch self { case .area: return "Area" case .window: return "Window" case .browser: return "Browser" case .screen: return "Screen" } } /// The longer menu item wording (window picker). public var menuTitle: String { switch self { case .area: return "Saved Area" case .window: return "Front Window" case .browser: return "Browser Page" case .screen: return "Whole Screen" } } /// Sentence shown under the control: what pressing Capture will take. public func targetDescription(savedArea: CaptureRegion?) -> String { switch self { case .area: guard let savedArea else { return "No area saved yet — choose one first" } return savedArea.summary case .window: return "The frontmost window when you capture" case .browser: return "The frontmost browser window when you capture" case .screen: guard let savedArea else { return "The display with the frontmost window" } return "All of Display \(savedArea.displayNumber)" } } } /// Persistence for the capture choice. Stored separately from the chosen area so /// switching scope never destroys the area. public enum CaptureSettings { public static let scopeKey = "ai.flowmaster.shotdeck.captureScope" public static let askOnNewSessionKey = "ai.flowmaster.shotdeck.askScopeOnNewSession" public static func scope(defaults: UserDefaults = .standard) -> CaptureScope { guard let raw = defaults.string(forKey: scopeKey), let scope = CaptureScope(rawValue: raw) else { return .area } return scope } public static func setScope(_ scope: CaptureScope, defaults: UserDefaults = .standard) { defaults.set(scope.rawValue, forKey: scopeKey) } /// Whether "New Session…" asks what to capture before starting. Off means it /// starts immediately with the current choice. public static func askOnNewSession(defaults: UserDefaults = .standard) -> Bool { guard defaults.object(forKey: askOnNewSessionKey) != nil else { return true } return defaults.bool(forKey: askOnNewSessionKey) } public static func setAskOnNewSession(_ value: Bool, defaults: UserDefaults = .standard) { defaults.set(value, forKey: askOnNewSessionKey) } }