Skip to content

Commit da8d44f

Browse files
Merge pull request #98 from peterklingelhofer/feature/Correct-max-window-height-responsive-settings
feat(swift): Responsive settings window max height
2 parents 8bc8a09 + c702f89 commit da8d44f

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

swift/exhale.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@
490490
CODE_SIGN_ENTITLEMENTS = exhale/exhale.entitlements;
491491
CODE_SIGN_STYLE = Automatic;
492492
COMBINE_HIDPI_IMAGES = YES;
493-
CURRENT_PROJECT_VERSION = 205;
493+
CURRENT_PROJECT_VERSION = 206;
494494
DEAD_CODE_STRIPPING = YES;
495495
DEVELOPMENT_ASSET_PATHS = "\"exhale/Preview Content\"";
496496
DEVELOPMENT_TEAM = VZCHHV7VNW;
@@ -505,7 +505,7 @@
505505
"@executable_path/../Frameworks",
506506
);
507507
MACOSX_DEPLOYMENT_TARGET = 11.0;
508-
MARKETING_VERSION = 2.0.5;
508+
MARKETING_VERSION = 2.0.6;
509509
PRODUCT_BUNDLE_IDENTIFIER = peterklingelhofer.exhale;
510510
PRODUCT_NAME = "$(TARGET_NAME)";
511511
SUPPORTED_PLATFORMS = macosx;
@@ -524,7 +524,7 @@
524524
CODE_SIGN_ENTITLEMENTS = exhale/exhale.entitlements;
525525
CODE_SIGN_STYLE = Automatic;
526526
COMBINE_HIDPI_IMAGES = YES;
527-
CURRENT_PROJECT_VERSION = 205;
527+
CURRENT_PROJECT_VERSION = 206;
528528
DEAD_CODE_STRIPPING = YES;
529529
DEVELOPMENT_ASSET_PATHS = "\"exhale/Preview Content\"";
530530
DEVELOPMENT_TEAM = VZCHHV7VNW;
@@ -539,7 +539,7 @@
539539
"@executable_path/../Frameworks",
540540
);
541541
MACOSX_DEPLOYMENT_TARGET = 11.0;
542-
MARKETING_VERSION = 2.0.5;
542+
MARKETING_VERSION = 2.0.6;
543543
PRODUCT_BUNDLE_IDENTIFIER = peterklingelhofer.exhale;
544544
PRODUCT_NAME = "$(TARGET_NAME)";
545545
SUPPORTED_PLATFORMS = macosx;

swift/exhale/AppDelegate.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,14 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
166166

167167
// Initialize the Settings Window
168168
settingsWindow = NSWindow(
169-
contentRect: NSRect(x: 0, y: 0, width: 246, height: 870),
169+
contentRect: NSRect(x: 0, y: 0, width: 246, height: 300),
170170
styleMask: [.titled, .closable, .miniaturizable, .resizable],
171171
backing: .buffered,
172172
defer: false
173173
)
174174
settingsWindow.setValue("SettingsWindow3", forKey: "frameAutosaveName")
175175
settingsWindow.delegate = self
176176
settingsWindow.minSize = NSSize(width: 246, height: 300)
177-
settingsWindow.maxSize = NSSize(width: 246, height: 870)
178177
let visualEffect = NSVisualEffectView()
179178
visualEffect.material = .hudWindow
180179
visualEffect.blendingMode = .behindWindow
@@ -220,6 +219,14 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
220219
hostingView.trailingAnchor.constraint(equalTo: visualEffect.trailingAnchor),
221220
])
222221

222+
// Compute max height dynamically from the SwiftUI content's intrinsic size
223+
// so we never need to hardcode a pixel value when settings are added/removed.
224+
let fittingSize = hostingView.fittingSize
225+
let titleBarHeight: CGFloat = 28
226+
let idealHeight = ceil(fittingSize.height + titleBarHeight)
227+
settingsWindow.maxSize = NSSize(width: 246, height: idealHeight)
228+
settingsWindow.setContentSize(NSSize(width: 246, height: fittingSize.height))
229+
223230
settingsWindow.title = "exhale"
224231
toggleSettings(nil)
225232
setUpStatusItem()
@@ -442,7 +449,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
442449
x: screenOrigin.x + x,
443450
y: screenOrigin.y + y,
444451
width: min(w, 246),
445-
height: min(h, 870)
452+
height: min(h, settingsWindow.maxSize.height)
446453
)
447454
settingsWindow.setFrame(restoredFrame, display: true)
448455
}

0 commit comments

Comments
 (0)