diff --git a/alt-tab-macos.xcodeproj/project.pbxproj b/alt-tab-macos.xcodeproj/project.pbxproj index 4f246989..ca2b7337 100644 --- a/alt-tab-macos.xcodeproj/project.pbxproj +++ b/alt-tab-macos.xcodeproj/project.pbxproj @@ -78,6 +78,7 @@ BF0C828D53D429C2B8B22391 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = BF0C883EBA8FDA9CB61C91FD /* Localizable.strings */; }; BF0C829583ED47E458528F3A /* accessibility@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = BF0C889529FF19620EDAC295 /* accessibility@2x.png */; }; BF0C832C5BF4C8E9C95F7767 /* MissionControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF0C82E4DE5A28800F1DA6E6 /* MissionControl.swift */; }; + BF0C83578F7292F307E30751 /* PopupButtonLikeSystemSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF0C8A479D2B7FB80531F037 /* PopupButtonLikeSystemSettings.swift */; }; BF0C8382435C0087E131BD83 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = BF0C8A900DA32A7F62457CC2 /* InfoPlist.strings */; }; BF0C83AB0186CC48FADF66A7 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = BF0C847B2D68EACFAC1B06D1 /* Localizable.strings */; }; BF0C83E902F75A97E8FD374A /* menubar-2@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = BF0C8D3333653ACAEF730DD8 /* menubar-2@2x.png */; }; @@ -347,6 +348,7 @@ BF0C899605B39AB4EE0E8EB8 /* icon_512x512.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon_512x512.png; sourceTree = ""; }; BF0C89A541FBEA23E7CB1D94 /* lb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = lb; path = Localizable.strings; sourceTree = ""; }; BF0C89F6EA16DD7322626E20 /* FUNDING.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; path = FUNDING.yml; sourceTree = ""; }; + BF0C8A479D2B7FB80531F037 /* PopupButtonLikeSystemSettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PopupButtonLikeSystemSettings.swift; sourceTree = ""; }; BF0C8A50151A4EF88E494357 /* da */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = da; path = InfoPlist.strings; sourceTree = ""; }; BF0C8AF53097C87EDC6F5FA6 /* nb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = nb; path = Localizable.strings; sourceTree = ""; }; BF0C8B15FFB262ECC54B5AA4 /* sl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = sl; path = InfoPlist.strings; sourceTree = ""; }; @@ -1104,6 +1106,7 @@ BF0C8B2C057099EDABE46779 /* Button.swift */, BF0C8343C1F6FCA82552DCB7 /* TableView.swift */, 1C961FB3DCF4906FEEF4A23D /* TableGroupView.swift */, + BF0C8A479D2B7FB80531F037 /* PopupButtonLikeSystemSettings.swift */, ); path = "generic-components"; sourceTree = ""; @@ -1991,6 +1994,7 @@ BF0C86BA26EFA59DEE24C70B /* Support.md in Sources */, 1C96108A0CB2565233FE100B /* TableGroupView.swift in Sources */, 1C9618872DD3863A8EFE8414 /* Appearance.swift in Sources */, + BF0C83578F7292F307E30751 /* PopupButtonLikeSystemSettings.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/ui/App.swift b/src/ui/App.swift index f252fb8f..8281fb18 100644 --- a/src/ui/App.swift +++ b/src/ui/App.swift @@ -84,6 +84,7 @@ class App: AppCenterApplication, NSApplicationDelegate { self.preloadWindows() #if DEBUG self.showPreferencesWindow() + self.preferencesWindow.selectTab("controls") #endif } } diff --git a/src/ui/generic-components/PopupButtonLikeSystemSettings.swift b/src/ui/generic-components/PopupButtonLikeSystemSettings.swift new file mode 100644 index 00000000..db03946e --- /dev/null +++ b/src/ui/generic-components/PopupButtonLikeSystemSettings.swift @@ -0,0 +1,31 @@ +import Cocoa + +class PopupButtonLikeSystemSettings: NSPopUpButton { + convenience init() { + self.init(frame: .zero) + translatesAutoresizingMaskIntoConstraints = false + showsBorderOnlyWhileMouseInside = true +// isBordered = false +// setButtonType(.switch) +// alignment = .right +// let cell = cell! as! NSPopUpButtonCell +// onAction = { _ in self.sizeToFit() } +// cell.bezelStyle = .regularSquare +// cell.arrowPosition = .arrowAtBottom +// cell.imagePosition = .imageOverlaps + } + + override var intrinsicContentSize: NSSize { + let fakePopUpButton = NSPopUpButton() + fakePopUpButton.addItem(withTitle: title) + fakePopUpButton.selectedItem!.image = selectedItem!.image + let fakeCell = fakePopUpButton.cell! as! NSPopUpButtonCell + let currentCell = cell! as! NSPopUpButtonCell + fakeCell.bezelStyle = currentCell.bezelStyle + fakeCell.arrowPosition = currentCell.arrowPosition + fakeCell.imagePosition = currentCell.imagePosition +// fakePopUpButton.showsBorderOnlyWhileMouseInside = true + fakePopUpButton.sizeToFit() + return fakePopUpButton.intrinsicContentSize + } +} diff --git a/src/ui/preferences-window/LabelAndControl.swift b/src/ui/preferences-window/LabelAndControl.swift index 40c96157..a66cfd9d 100644 --- a/src/ui/preferences-window/LabelAndControl.swift +++ b/src/ui/preferences-window/LabelAndControl.swift @@ -254,8 +254,7 @@ class LabelAndControl: NSObject { } static func dropdown_(_ rawName: String, _ macroPreferences: [MacroPreference]) -> NSPopUpButton { - let popUp = NSPopUpButton() - popUp.translatesAutoresizingMaskIntoConstraints = false + let popUp = PopupButtonLikeSystemSettings() popUp.addItems(withTitles: macroPreferences.map { $0.localizedString }) popUp.selectItem(at: defaults.int(rawName)) return popUp