diff --git a/Aerial.xcodeproj/project.pbxproj b/Aerial.xcodeproj/project.pbxproj index a13a7aa4..8bc4981f 100644 --- a/Aerial.xcodeproj/project.pbxproj +++ b/Aerial.xcodeproj/project.pbxproj @@ -48,6 +48,10 @@ 03510C7121834FC7008F74F2 /* IOBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 03510C6E21834F38008F74F2 /* IOBridge.m */; }; 03510C732185EF76008F74F2 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 03510C722185EF76008F74F2 /* CoreLocation.framework */; }; 03510C772185EF8F008F74F2 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 03510C722185EF76008F74F2 /* CoreLocation.framework */; }; + 0354D0E923F6C31800D86F9E /* InfoSettingsTableSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0354D0E823F6C31800D86F9E /* InfoSettingsTableSource.swift */; }; + 0354D0EA23F6C3EE00D86F9E /* InfoSettingsTableSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0354D0E823F6C31800D86F9E /* InfoSettingsTableSource.swift */; }; + 0354D0EC23F6CB7B00D86F9E /* InfoSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0354D0EB23F6CB7B00D86F9E /* InfoSettingsView.swift */; }; + 0354D0ED23F6CB7B00D86F9E /* InfoSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0354D0EB23F6CB7B00D86F9E /* InfoSettingsView.swift */; }; 035A92A6225F8C480095AB85 /* de.json in Resources */ = {isa = PBXBuildFile; fileRef = 035A92A4225F8C480095AB85 /* de.json */; }; 035A92A7225F8C480095AB85 /* de.json in Resources */ = {isa = PBXBuildFile; fileRef = 035A92A4225F8C480095AB85 /* de.json */; }; 035A92A8225F8C480095AB85 /* he.json in Resources */ = {isa = PBXBuildFile; fileRef = 035A92A5225F8C480095AB85 /* he.json */; }; @@ -235,6 +239,8 @@ 03510C6D21834F38008F74F2 /* Aerial-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Aerial-Bridging-Header.h"; sourceTree = ""; }; 03510C6E21834F38008F74F2 /* IOBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IOBridge.m; sourceTree = ""; }; 03510C722185EF76008F74F2 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; + 0354D0E823F6C31800D86F9E /* InfoSettingsTableSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoSettingsTableSource.swift; sourceTree = ""; }; + 0354D0EB23F6CB7B00D86F9E /* InfoSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoSettingsView.swift; sourceTree = ""; }; 035A92A4225F8C480095AB85 /* de.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = de.json; sourceTree = ""; }; 035A92A5225F8C480095AB85 /* he.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = he.json; sourceTree = ""; }; 035A92AB226754760095AB85 /* ar.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = ar.json; sourceTree = ""; }; @@ -407,6 +413,7 @@ FAC36F441BE1756D007F2A20 /* CheckCellView.swift */, 03D1E78622842FB300D10CF7 /* DisplayView.swift */, 034F29B623A7A93D004B34D5 /* InfoTableSource.swift */, + 0354D0E823F6C31800D86F9E /* InfoSettingsTableSource.swift */, 038C584623A9304800224630 /* InfoContainerView.swift */, 038C584923A9394000224630 /* InfoCommonView.swift */, 03A596D823AB8F000097EA66 /* InfoLocationView.swift */, @@ -414,6 +421,7 @@ 03A596D423AA752F0097EA66 /* InfoClockView.swift */, 038D2EE323B6565900CD91F7 /* InfoBatteryView.swift */, 036A57D723F470940009DC02 /* InfoCountdownView.swift */, + 0354D0EB23F6CB7B00D86F9E /* InfoSettingsView.swift */, ); path = PrefPanel; sourceTree = ""; @@ -1041,6 +1049,7 @@ 03A2CB9D216BB1490061E8E8 /* VideoManager.swift in Sources */, 03608A2A22A56094008F08A2 /* PWC+LogPanel.swift in Sources */, 03E289D5239A79C400C06EC5 /* AutoUpdates.swift in Sources */, + 0354D0ED23F6CB7B00D86F9E /* InfoSettingsView.swift in Sources */, 03608A2722A55C03008F08A2 /* PWC+Advanced.swift in Sources */, 03E87314216760B7002B469B /* TimeManagement.swift in Sources */, 038C584B23A9394000224630 /* InfoCommonView.swift in Sources */, @@ -1069,6 +1078,7 @@ 038D2EE223B6523800CD91F7 /* BatteryLayer.swift in Sources */, 03BF51C023A275D9008AD373 /* MessageLayer.swift in Sources */, 035D5250239AA31A00DC29DC /* AerialView+Player.swift in Sources */, + 0354D0EA23F6C3EE00D86F9E /* InfoSettingsTableSource.swift in Sources */, 0395834A217F442A008E8F9C /* Solar.swift in Sources */, FAB22A7F1BE17D7D0065C0F5 /* AssetLoaderDelegate.swift in Sources */, FAC36F601BE175CF007F2A20 /* AppDelegate.swift in Sources */, @@ -1140,6 +1150,7 @@ 03BF51C223A2978B008AD373 /* ClockLayer.swift in Sources */, FAC36F591BE1756D007F2A20 /* AerialVideo.swift in Sources */, 03893CB3217749F0008E7125 /* ErrorLog.swift in Sources */, + 0354D0EC23F6CB7B00D86F9E /* InfoSettingsView.swift in Sources */, 032D1161239A7D82007E7756 /* Battery.swift in Sources */, 038D2EE423B6565900CD91F7 /* InfoBatteryView.swift in Sources */, 03608A2322A55BF1008F08A2 /* PWC+Updates.swift in Sources */, @@ -1170,6 +1181,7 @@ 03233B68217272640077D3F9 /* PoiStringProvider.swift in Sources */, 038D2EE123B6523800CD91F7 /* BatteryLayer.swift in Sources */, FA36BD3F1BE57F8E00D5E03B /* VideoDownload.swift in Sources */, + 0354D0E923F6C31800D86F9E /* InfoSettingsTableSource.swift in Sources */, 03E8730C2165013C002B469B /* DownloadManager.swift in Sources */, 03608A2622A55C03008F08A2 /* PWC+Advanced.swift in Sources */, 036A57D823F470940009DC02 /* InfoCountdownView.swift in Sources */, diff --git a/Aerial/Source/Controllers/PWC Tabs/PWC+Advanced.swift b/Aerial/Source/Controllers/PWC Tabs/PWC+Advanced.swift index db47dca2..b104d3c1 100644 --- a/Aerial/Source/Controllers/PWC Tabs/PWC+Advanced.swift +++ b/Aerial/Source/Controllers/PWC Tabs/PWC+Advanced.swift @@ -28,28 +28,11 @@ extension PreferencesWindowController { let poisp = PoiStringProvider.sharedInstance languagePopup.selectItem(at: poisp.getLanguagePosition()) - // Margins override - if preferences.overrideMargins { - changeCornerMargins.state = .on - marginHorizontalTextfield.isEnabled = true - marginVerticalTextfield.isEnabled = true - editMarginButton.isEnabled = true - } - - marginHorizontalTextfield.stringValue = String(preferences.marginX!) - marginVerticalTextfield.stringValue = String(preferences.marginY!) - secondaryMarginHorizontalTextfield.stringValue = String(preferences.marginX!) - secondaryMarginVerticalTextfield.stringValue = String(preferences.marginY!) - - fadeInOutTextModePopup.selectItem(at: preferences.fadeModeText!) +// secondaryMarginHorizontalTextfield.stringValue = String(preferences.marginX!) +// secondaryMarginVerticalTextfield.stringValue = String(preferences.marginY!) - shadowRadiusFormatter.allowsFloats = false - shadowRadiusTextField.stringValue = String(PrefsInfo.shadowRadius) } // MARK: - Advanced panel - @IBAction func shadowRadiusChange(_ sender: NSTextField) { - PrefsInfo.shadowRadius = Int(sender.intValue) - } @IBAction func logButtonClick(_ sender: NSButton) { logTableView.reloadData() @@ -181,38 +164,4 @@ extension PreferencesWindowController { } } - // MARK: - Fades - @IBAction func fadeInOutTextModePopupChange(_ sender: NSPopUpButton) { - debugLog("UI fadeInOutTextMode: \(sender.indexOfSelectedItem)") - preferences.fadeModeText = sender.indexOfSelectedItem - preferences.synchronize() - } - - // MARK: - Margins - @IBAction func changeMarginsToCornerClick(_ sender: NSButton) { - let onState = sender.state == .on - debugLog("UI changeMarginsToCorner: \(onState)") - - marginHorizontalTextfield.isEnabled = onState - marginVerticalTextfield.isEnabled = onState - preferences.overrideMargins = onState - } - - @IBAction func marginXChange(_ sender: NSTextField) { - preferences.marginX = Int(sender.stringValue) - if sender == secondaryMarginHorizontalTextfield { - marginHorizontalTextfield.stringValue = sender.stringValue - } - - debugLog("UI marginXChange: \(sender.stringValue)") - } - - @IBAction func marginYChange(_ sender: NSTextField) { - preferences.marginY = Int(sender.stringValue) - if sender == secondaryMarginVerticalTextfield { - marginVerticalTextfield.stringValue = sender.stringValue - } - - debugLog("UI marginYChange: \(sender.stringValue)") - } } diff --git a/Aerial/Source/Controllers/PWC Tabs/PWC+Info.swift b/Aerial/Source/Controllers/PWC Tabs/PWC+Info.swift index 284ce572..6c050278 100644 --- a/Aerial/Source/Controllers/PWC Tabs/PWC+Info.swift +++ b/Aerial/Source/Controllers/PWC Tabs/PWC+Info.swift @@ -30,6 +30,20 @@ extension PreferencesWindowController { infoTableView.dataSource = infoSource infoTableView.delegate = infoSource infoTableView.registerForDraggedTypes([NSPasteboard.PasteboardType(rawValue: "private.table-row")]) + + infoSettingsSource = InfoSettingsTableSource() + infoSettingsSource?.setController(self) + infoSettingsTableView.dataSource = infoSettingsSource + infoSettingsTableView.delegate = infoSettingsSource + } + + func drawInfoSettingsPanel() { + resetInfoPanel() + + // Add the common block of features (enabled, font, position, screen) + infoContainerView.addSubview(infoSettingsView) + infoBox.title = "Advanced text settings" + infoSettingsView.setStates() } // We dynamically change the content here, based on what's selected diff --git a/Aerial/Source/Controllers/PreferencesWindowController.swift b/Aerial/Source/Controllers/PreferencesWindowController.swift index 620387c9..191ff7ab 100644 --- a/Aerial/Source/Controllers/PreferencesWindowController.swift +++ b/Aerial/Source/Controllers/PreferencesWindowController.swift @@ -82,8 +82,13 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo // Info tab (replaces text) @IBOutlet var infoTableView: NSTableView! + @IBOutlet var infoSettingsTableView: NSTableView! @IBOutlet var infoContainerView: InfoContainerView! + @IBOutlet var infoBox: NSBox! + + @IBOutlet var infoSettingsView: InfoSettingsView! + @IBOutlet var infoCommonView: InfoCommonView! @IBOutlet var infoLocationView: InfoLocationView! @@ -92,16 +97,11 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo @IBOutlet var infoBatteryView: InfoBatteryView! @IBOutlet var infoCountdownView: InfoCountdownView! - // Text tab - @IBOutlet weak var fadeInOutTextModePopup: NSPopUpButton! // Todo remap those - @IBOutlet var changeCornerMargins: NSButton! - @IBOutlet var marginHorizontalTextfield: NSTextField! - @IBOutlet var marginVerticalTextfield: NSTextField! + @IBOutlet var secondaryMarginHorizontalTextfield: NSTextField! @IBOutlet var secondaryMarginVerticalTextfield: NSTextField! - @IBOutlet var editMarginButton: NSButton! @IBOutlet var editMarginsPanel: NSPanel! @IBOutlet var editExtraMessagePanel: NSPanel! @@ -177,8 +177,6 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo @IBOutlet weak var showLogBottomClick: NSButton! @IBOutlet weak var logToDiskCheckbox: NSButton! - @IBOutlet var shadowRadiusTextField: NSTextField! - @IBOutlet var shadowRadiusFormatter: NumberFormatter! @IBOutlet var videoVersionsLabel: NSTextField! @IBOutlet var moveOldVideosButton: NSButton! @IBOutlet var trashOldVideosButton: NSButton! @@ -228,6 +226,7 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo // Info tab var infoSource: InfoTableSource? + var infoSettingsSource: InfoSettingsTableSource? @IBOutlet var displayView: DisplayView! public var appMode: Bool = false diff --git a/Aerial/Source/Models/ManifestLoader.swift b/Aerial/Source/Models/ManifestLoader.swift index 29f3c959..0b27380f 100644 --- a/Aerial/Source/Models/ManifestLoader.swift +++ b/Aerial/Source/Models/ManifestLoader.swift @@ -149,7 +149,6 @@ class ManifestLoader { // MARK: - Playlist generation func generatePlaylist(isRestricted: Bool, restrictedTo: String) { - print("genplaylist") // Start fresh playlist = [AerialVideo]() playlistIsRestricted = isRestricted diff --git a/Aerial/Source/Models/Prefs/Preferences.swift b/Aerial/Source/Models/Prefs/Preferences.swift index b96c3873..3240608e 100644 --- a/Aerial/Source/Models/Prefs/Preferences.swift +++ b/Aerial/Source/Models/Prefs/Preferences.swift @@ -27,7 +27,7 @@ final class Preferences { // case manualSunrise = "manualSunrise" // case manualSunset = "manualSunset" // case fadeMode = "fadeMode" - case fadeModeText = "fadeModeText" +// case fadeModeText = "fadeModeText" case descriptionCorner = "descriptionCorner" case debugMode = "debugMode" @@ -46,9 +46,9 @@ final class Preferences { case overrideDimInMinutes = "overrideDimInMinutes" // case solarMode = "solarMode" - case overrideMargins = "overrideMargins" - case marginX = "marginX" - case marginY = "marginY" +// case overrideMargins = "overrideMargins" +// case marginX = "marginX" +// case marginY = "marginY" // case darkModeNightOverride = "darkModeNightOverride" case newVideosMode = "newVideosMode" @@ -146,7 +146,7 @@ final class Preferences { // defaultValues[.manualSunset] = "19:00" defaultValues[.multiMonitorMode] = MultiMonitorMode.mainOnly // defaultValues[.fadeMode] = FadeMode.t1 - defaultValues[.fadeModeText] = FadeMode.t1 +// defaultValues[.fadeModeText] = FadeMode.t1 defaultValues[.descriptionCorner] = DescriptionCorner.bottomLeft defaultValues[.debugMode] = true defaultValues[.logToDisk] = true @@ -162,9 +162,9 @@ final class Preferences { defaultValues[.dimInMinutes] = 30 defaultValues[.overrideDimInMinutes] = false // defaultValues[.solarMode] = SolarMode.official - defaultValues[.overrideMargins] = false - defaultValues[.marginX] = 50 - defaultValues[.marginY] = 50 +// defaultValues[.overrideMargins] = false +// defaultValues[.marginX] = 50 +// defaultValues[.marginY] = 50 // defaultValues[.overrideOnBattery] = false // defaultValues[.powerSavingOnLowBattery] = false // defaultValues[.alternateVideoFormat] = AlternateVideoFormat.powerSaving @@ -440,14 +440,14 @@ final class Preferences { } } - var overrideMargins: Bool { - get { - return value(forIdentifier: .overrideMargins) - } - set { - setValue(forIdentifier: .overrideMargins, value: newValue) - } - } +// var overrideMargins: Bool { +// get { +// return value(forIdentifier: .overrideMargins) +// } +// set { +// setValue(forIdentifier: .overrideMargins, value: newValue) +// } +// } var dimInMinutes: Int? { get { @@ -458,23 +458,23 @@ final class Preferences { } } - var marginX: Int? { - get { - return optionalValue(forIdentifier: .marginX) - } - set { - setValue(forIdentifier: .marginX, value: newValue) - } - } - - var marginY: Int? { - get { - return optionalValue(forIdentifier: .marginY) - } - set { - setValue(forIdentifier: .marginY, value: newValue) - } - } +// var marginX: Int? { +// get { +// return optionalValue(forIdentifier: .marginX) +// } +// set { +// setValue(forIdentifier: .marginX, value: newValue) +// } +// } +// +// var marginY: Int? { +// get { +// return optionalValue(forIdentifier: .marginY) +// } +// set { +// setValue(forIdentifier: .marginY, value: newValue) +// } +// } // var solarMode: Int? { // get { @@ -728,15 +728,15 @@ final class Preferences { // setValue(forIdentifier: .fadeMode, value: newValue) // } // } - - var fadeModeText: Int? { - get { - return optionalValue(forIdentifier: .fadeModeText) - } - set { - setValue(forIdentifier: .fadeModeText, value: newValue) - } - } +// +// var fadeModeText: Int? { +// get { +// return optionalValue(forIdentifier: .fadeModeText) +// } +// set { +// setValue(forIdentifier: .fadeModeText, value: newValue) +// } +// } // var timeMode: Int? { // get { diff --git a/Aerial/Source/Models/Prefs/PrefsInfo.swift b/Aerial/Source/Models/Prefs/PrefsInfo.swift index 1d81314e..d3344792 100644 --- a/Aerial/Source/Models/Prefs/PrefsInfo.swift +++ b/Aerial/Source/Models/Prefs/PrefsInfo.swift @@ -163,10 +163,37 @@ struct PrefsInfo { showSeconds: true)) static var countdown: Countdown + // MARK: - Advanced text settings + + // Text fade in/out mode + @SimpleStorage(key: "fadeModeText", defaultValue: FadeMode.t1.rawValue) + static var intFadeModeText: Int + + // We wrap in a separate value, as we can't store an enum as a Codable in + // macOS < 10.15 + static var fadeModeText: FadeMode { + get { + return FadeMode(rawValue: intFadeModeText)! + } + set(value) { + intFadeModeText = value.rawValue + } + } + + // Override margins + @SimpleStorage(key: "overrideMargins", defaultValue: false) + static var overrideMargins: Bool + + @SimpleStorage(key: "marginX", defaultValue: 50) + static var marginX: Int + @SimpleStorage(key: "marginY", defaultValue: 50) + static var marginY: Int + // Shadow radius (common) @SimpleStorage(key: "shadowRadius", defaultValue: 20) static var shadowRadius: Int + // MARK: - Helpers // Helper to quickly access a given struct (read-only as we return a copy of the struct) static func ofType(_ type: InfoType) -> CommonInfo { switch type { diff --git a/Aerial/Source/Views/AerialView.swift b/Aerial/Source/Views/AerialView.swift index ca3bae04..8898a71c 100644 --- a/Aerial/Source/Views/AerialView.swift +++ b/Aerial/Source/Views/AerialView.swift @@ -59,13 +59,12 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate { } static var textFadeDuration: Double { - let preferences = Preferences.sharedInstance - switch preferences.fadeModeText { - case FadeMode.t0_5.rawValue: + switch PrefsInfo.fadeModeText { + case .t0_5: return 0.5 - case FadeMode.t1.rawValue: + case .t1: return 1 - case FadeMode.t2.rawValue: + case .t2: return 2 default: return 0.10 @@ -373,7 +372,6 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate { // MARK: - playNextVideo() func playNextVideo() { - print("playnext") let notificationCenter = NotificationCenter.default // Clear everything layerManager.clearLayerAnimations(player: self.player!) diff --git a/Aerial/Source/Views/Layers/AnimationLayer.swift b/Aerial/Source/Views/Layers/AnimationLayer.swift index 529e127d..4e1f4b69 100644 --- a/Aerial/Source/Views/Layers/AnimationLayer.swift +++ b/Aerial/Source/Views/Layers/AnimationLayer.swift @@ -222,8 +222,8 @@ class AnimationLayer: CATextLayer { // Calculate bounding box let rect = str.boundingRect(with: boundingRect, options: [.truncatesLastVisibleLine, .usesLineFragmentOrigin]) - // Last line won't appear if we don't adjust - return CGRect(x: rect.origin.x, y: rect.origin.y, width: rect.width, height: rect.height + 10) + // Last line won't appear if we don't adjust a bit (why!?) + return CGRect(x: rect.origin.x, y: rect.origin.y, width: rect.width+10, height: rect.height + 10) } // Get the font and font size @@ -246,12 +246,11 @@ class AnimationLayer: CATextLayer { return 10 } - let preferences = Preferences.sharedInstance var mx: CGFloat = 50 // We may override margins - if preferences.overrideMargins { - mx = CGFloat(preferences.marginX!) + if PrefsInfo.overrideMargins { + mx = CGFloat(PrefsInfo.marginX) } return mx @@ -270,12 +269,11 @@ class AnimationLayer: CATextLayer { return offsets.corner[forCorner]! } - let preferences = Preferences.sharedInstance var my: CGFloat = 50 // We may override margins - if preferences.overrideMargins { - my = CGFloat(preferences.marginY!) + if PrefsInfo.overrideMargins { + my = CGFloat(PrefsInfo.marginY) } offsets.corner[forCorner] = my diff --git a/Aerial/Source/Views/Layers/UpdatesLayer.swift b/Aerial/Source/Views/Layers/UpdatesLayer.swift index 6b8af29e..612bb8bb 100644 --- a/Aerial/Source/Views/Layers/UpdatesLayer.swift +++ b/Aerial/Source/Views/Layers/UpdatesLayer.swift @@ -41,7 +41,6 @@ class UpdatesLayer: AnimationLayer { } override func setupForVideo(video: AerialVideo, player: AVPlayer) { - print("sfv") if !wasSetup { setupUpdateLayer() } diff --git a/Aerial/Source/Views/PrefPanel/InfoCommonView.swift b/Aerial/Source/Views/PrefPanel/InfoCommonView.swift index 2c44df5c..2af91964 100644 --- a/Aerial/Source/Views/PrefPanel/InfoCommonView.swift +++ b/Aerial/Source/Views/PrefPanel/InfoCommonView.swift @@ -12,8 +12,6 @@ class InfoCommonView: NSView { var forType: InfoType = .location var controller: PreferencesWindowController? - @IBOutlet var descriptionLabel: NSTextField! - @IBOutlet var enabledButton: NSButton! @IBOutlet var fontLabel: NSTextField! @@ -46,22 +44,22 @@ class InfoCommonView: NSView { switch forType { case .location: - descriptionLabel.stringValue = "Localized information about the video location." + controller.infoBox.title = "Video location information" posRandom.isHidden = false case .message: - descriptionLabel.stringValue = "Add a custom message (e-mail, name...)." + controller.infoBox.title = "Custom message" posRandom.isHidden = true case .clock: - descriptionLabel.stringValue = "Add a clock." + controller.infoBox.title = "Clock" posRandom.isHidden = true case .battery: - descriptionLabel.stringValue = "Show current battery status." + controller.infoBox.title = "Battery status" posRandom.isHidden = true case .updates: - descriptionLabel.stringValue = "Display a message if a new version is available" + controller.infoBox.title = "Updates notifications" posRandom.isHidden = true case .countdown: - descriptionLabel.stringValue = "Display a countdown to a time/date" + controller.infoBox.title = "Countdown to a time/date" posRandom.isHidden = true } } diff --git a/Aerial/Source/Views/PrefPanel/InfoSettingsTableSource.swift b/Aerial/Source/Views/PrefPanel/InfoSettingsTableSource.swift new file mode 100644 index 00000000..625682f0 --- /dev/null +++ b/Aerial/Source/Views/PrefPanel/InfoSettingsTableSource.swift @@ -0,0 +1,56 @@ +// +// InfoSettingsTableSource.swift +// Aerial +// +// Created by Guillaume Louel on 14/02/2020. +// Copyright © 2020 Guillaume Louel. All rights reserved. +// + +import Cocoa + +class InfoSettingsTableSource: NSTableView, NSTableViewDataSource, NSTableViewDelegate { + var controller: PreferencesWindowController? + + func setController(_ controller: PreferencesWindowController) { + self.controller = controller + } + + override func draw(_ dirtyRect: NSRect) { + super.draw(dirtyRect) + } + + func numberOfRows(in tableView: NSTableView) -> Int { + return 1 + } + + func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat { + return 30 + } + + func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { + let cid = NSUserInterfaceItemIdentifier(rawValue: "InfoSettingsCellID") + + if let cell = tableView.makeView(withIdentifier: cid, owner: self) as? NSTableCellView { + cell.textField?.stringValue = "Text settings" + + if #available(OSX 10.12.2, *) { + cell.imageView?.image = NSImage(named: NSImage.touchBarTextBoxTemplateName) + } else { + // Fallback on earlier versions + cell.imageView?.image = NSImage(named: NSImage.fontPanelName) + } + return cell + } + + return nil + } + + // This is where selection happens + func tableViewSelectionDidChange(_ notification: Notification) { + let tableView = notification.object as! NSTableView + if tableView.selectedRow >= 0 { + controller!.drawInfoSettingsPanel() + controller!.infoTableView.deselectAll(controller!) + } + } +} diff --git a/Aerial/Source/Views/PrefPanel/InfoSettingsView.swift b/Aerial/Source/Views/PrefPanel/InfoSettingsView.swift new file mode 100644 index 00000000..6e3b31af --- /dev/null +++ b/Aerial/Source/Views/PrefPanel/InfoSettingsView.swift @@ -0,0 +1,83 @@ +// +// InfoSettingsView.swift +// Aerial +// +// Created by Guillaume Louel on 14/02/2020. +// Copyright © 2020 Guillaume Louel. All rights reserved. +// + +import Cocoa + +class InfoSettingsView: NSView { + @IBOutlet weak var fadeInOutTextModePopup: NSPopUpButton! + + @IBOutlet var changeCornerMargins: NSButton! + @IBOutlet var marginHorizontalTextfield: NSTextField! + @IBOutlet var marginVerticalTextfield: NSTextField! + @IBOutlet var editMarginButton: NSButton! + + @IBOutlet var shadowRadiusTextField: NSTextField! + @IBOutlet var shadowRadiusFormatter: NumberFormatter! + + func setStates() { + //messageTextField.stringValue = PrefsInfo.message.message + // Margins override + if PrefsInfo.overrideMargins { + changeCornerMargins.state = .on + marginHorizontalTextfield.isEnabled = true + marginVerticalTextfield.isEnabled = true + editMarginButton.isEnabled = true + } + + marginHorizontalTextfield.stringValue = String(PrefsInfo.marginX) + marginVerticalTextfield.stringValue = String(PrefsInfo.marginY) + + fadeInOutTextModePopup.selectItem(at: PrefsInfo.fadeModeText.rawValue) + + shadowRadiusFormatter.allowsFloats = false + shadowRadiusTextField.stringValue = String(PrefsInfo.shadowRadius) + } + + // MARK: - Shadows + @IBAction func shadowRadiusChange(_ sender: NSTextField) { + PrefsInfo.shadowRadius = Int(sender.intValue) + } + + // MARK: - Fades + @IBAction func fadeInOutTextModePopupChange(_ sender: NSPopUpButton) { + debugLog("UI fadeInOutTextMode: \(sender.indexOfSelectedItem)") +// preferences.fadeModeText = sender.indexOfSelectedItem +// preferences.synchronize() + PrefsInfo.fadeModeText = FadeMode(rawValue: sender.indexOfSelectedItem)! + + } + + // MARK: - Margins + @IBAction func changeMarginsToCornerClick(_ sender: NSButton) { + let onState = sender.state == .on + debugLog("UI changeMarginsToCorner: \(onState)") + + marginHorizontalTextfield.isEnabled = onState + marginVerticalTextfield.isEnabled = onState + PrefsInfo.overrideMargins = onState +// preferences.overrideMargins = onState + } + + @IBAction func marginXChange(_ sender: NSTextField) { + PrefsInfo.marginX = Int(sender.stringValue) ?? 50 +// if sender == secondaryMarginHorizontalTextfield { +// marginHorizontalTextfield.stringValue = sender.stringValue +// } + + debugLog("UI marginXChange: \(sender.stringValue)") + } + + @IBAction func marginYChange(_ sender: NSTextField) { + PrefsInfo.marginY = Int(sender.stringValue) ?? 50 +// if sender == secondaryMarginVerticalTextfield { +// marginVerticalTextfield.stringValue = sender.stringValue +// } + + debugLog("UI marginYChange: \(sender.stringValue)") + } +} diff --git a/Aerial/Source/Views/PrefPanel/InfoTableSource.swift b/Aerial/Source/Views/PrefPanel/InfoTableSource.swift index 647217f2..25214e26 100644 --- a/Aerial/Source/Views/PrefPanel/InfoTableSource.swift +++ b/Aerial/Source/Views/PrefPanel/InfoTableSource.swift @@ -59,11 +59,12 @@ class InfoTableSource: NSTableView, NSTableViewDataSource, NSTableViewDelegate { // This is where selection happens func tableViewSelectionDidChange(_ notification: Notification) { let tableView = notification.object as! NSTableView - print("selrow \(tableView.selectedRow)") if tableView.selectedRow < 0 { - controller!.resetInfoPanel() + //controller!.resetInfoPanel() } else { controller!.drawInfoPanel(forType: PrefsInfo.layers[tableView.selectedRow]) + controller!.infoSettingsTableView.deselectAll(controller!) + } } diff --git a/Resources/PreferencesWindow.xib b/Resources/PreferencesWindow.xib index 13706b99..752f2894 100644 --- a/Resources/PreferencesWindow.xib +++ b/Resources/PreferencesWindow.xib @@ -25,7 +25,7 @@ - + @@ -50,7 +50,6 @@ - @@ -66,12 +65,15 @@ + - + + + @@ -86,8 +88,8 @@ - - + + @@ -124,8 +126,6 @@ - - @@ -168,22 +168,22 @@ - + - + - + - + - + @@ -195,7 +195,7 @@ - + @@ -209,7 +209,7 @@ - + @@ -232,7 +232,7 @@ - + @@ -251,13 +251,13 @@ - + - + @@ -266,7 +266,7 @@ - + @@ -276,7 +276,7 @@ - + @@ -329,7 +329,7 @@ - + @@ -353,7 +353,7 @@ - + @@ -373,7 +373,7 @@ - + - + - + @@ -587,7 +587,7 @@ is disabled - + @@ -619,7 +619,7 @@ is disabled - + @@ -644,7 +644,7 @@ is disabled - + @@ -661,7 +661,7 @@ is disabled - + @@ -777,18 +777,18 @@ is disabled - + - - + + - - + + - - + + @@ -807,16 +807,16 @@ is disabled - + - + - + @@ -845,16 +845,16 @@ is disabled - + - + - + @@ -884,20 +884,85 @@ is disabled - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -928,7 +993,7 @@ is disabled - + @@ -955,7 +1020,7 @@ is disabled - + @@ -964,7 +1029,7 @@ is disabled - + @@ -980,7 +1045,7 @@ is disabled - + @@ -989,22 +1054,22 @@ is disabled - + - + - + - + @@ -1013,7 +1078,7 @@ is disabled - + @@ -1037,7 +1102,7 @@ is disabled - + @@ -1046,12 +1111,12 @@ is disabled - + - + @@ -1074,19 +1139,8 @@ is disabled - - + @@ -1099,7 +1153,7 @@ is disabled - + @@ -1132,7 +1186,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - + @@ -1148,7 +1202,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) + - + - + @@ -1176,7 +1241,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - + @@ -1262,7 +1327,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - + @@ -1271,7 +1336,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - + @@ -1280,7 +1345,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - + @@ -1289,7 +1354,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - + @@ -1297,7 +1362,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - + @@ -1500,11 +1565,11 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - + - + @@ -1531,7 +1596,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - + @@ -1712,10 +1777,6 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - - - - @@ -1746,7 +1807,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - + @@ -1766,7 +1827,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - + @@ -1775,7 +1836,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - + @@ -1817,7 +1878,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - + @@ -1825,130 +1886,6 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2009,7 +1946,7 @@ Gw - + @@ -2540,7 +2477,7 @@ You can still decide to disable Aerial when running on battery, or if your batte - + @@ -2556,7 +2493,7 @@ You can still decide to disable Aerial when running on battery, or if your batte - + @@ -2565,7 +2502,7 @@ You can still decide to disable Aerial when running on battery, or if your batte - + @@ -2582,7 +2519,7 @@ You can still decide to disable Aerial when running on battery, or if your batte - + @@ -2591,7 +2528,7 @@ You can still decide to disable Aerial when running on battery, or if your batte - + @@ -2636,7 +2573,7 @@ You can still decide to disable Aerial when running on battery, or if your batte - + @@ -2667,7 +2604,7 @@ You can still decide to disable Aerial when running on battery, or if your batte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - - + @@ -3128,19 +3001,72 @@ After changing the folder, please close System Preferences for this to be taken - - + + - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3148,7 +3074,6 @@ After changing the folder, please close System Preferences for this to be taken - @@ -3163,14 +3088,14 @@ After changing the folder, please close System Preferences for this to be taken - + - + @@ -3182,7 +3107,7 @@ After changing the folder, please close System Preferences for this to be taken + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3290,6 +3355,7 @@ After changing the folder, please close System Preferences for this to be taken + - \ No newline at end of file +