Color picker fixes#190
Merged
Merged
Conversation
Ensure the ruler color panel is closed and forced to opaque when preferences or the app quits, and add UI tests to verify behavior. Key changes: - AppDelegate: added applicationShouldTerminate to close the color panel on quit and kept the close call in applicationWillTerminate. - PreferencesController: refactored color panel configuration to use NSColorPanel.shared, set isRestorable = false, use NSColor.ignoresAlpha instead of Objective-C runtime hacks, and added configureOpaqueColorPickingAfterPanelUpdates which reapplies configuration on short delayed intervals to handle panel updates. RulerColorWell now orders the color panel front with orderFront and triggers the repeated reconfiguration. closeRulerColorPanel was made non-private and now calls colorPanel.close(). Also deactivate the ruler color well when the preferences window closes. - Tests: added UI tests to assert the color panel hides opacity controls, that closing Preferences closes the ruler color panel, and that the panel does not reopen after relaunch. Helper accessors and wait utilities (waitForNonVisibility, waitForVisibleExistence, openRulerColorPanel) were added to the test suite. These changes fix unreliable alpha control visibility and ensure the color panel doesn't persist unexpectedly across app lifecycle events.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the AppKit shared NSColorPanel behavior used by the ruler color picker so it behaves like a transient companion to Preferences (non-restorable, no alpha controls), and ensures it’s closed when Preferences closes and during app termination. It also adds UI test coverage for these lifecycle expectations and updates the App Store screenshot preview layout/focus behavior.
Changes:
- Configure the shared
NSColorPanelfor opaque picking (no alpha, non-restorable) and close/deactivate it on Preferences close and app termination. - Add UI tests to cover hidden opacity controls, Preferences-close behavior, and quit/relaunch behavior for the color panel.
- Update App Store screenshot preview layout calculations and tweak focus behavior to avoid unwanted focus styling in snapshots.
Reviewed changes
Copilot reviewed 4 out of 8 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| FreeRulerUITests/FreeRulerUITests.swift | Adds UI tests and helpers to validate NSColorPanel opacity UI and lifecycle behavior across prefs close and relaunch. |
| Free Ruler/PreferencesController.swift | Updates shared color panel configuration and lifecycle handling; ensures the panel is treated as transient and opaque. |
| Free Ruler/AppStoreScreenshotPreview.swift | Adjusts screenshot layout math and snapshot window responder handling for updated preview visuals. |
| Free Ruler/AppDelegate.swift | Closes the shared color panel during quit/termination to prevent unintended restoration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes the ruler color picker lifecycle so the shared AppKit color panel is treated as a transient preferences companion instead of being restored on the next app launch.
Changes include:
Validation
xcodebuild -project 'Free Ruler.xcodeproj' -scheme 'Free Ruler' clean build-for-testingxcodebuild -project 'Free Ruler.xcodeproj' -scheme 'Free Ruler' test-without-building -only-testing:FreeRulerUITests/FreeRulerUITests/testClosingPreferencesClosesRulerColorPanelxcodebuild -project 'Free Ruler.xcodeproj' -scheme 'Free Ruler' test-without-building -only-testing:FreeRulerUITests/FreeRulerUITests/testRulerColorPanelDoesNotReopenAfterRelaunchxcodebuild -project 'Free Ruler.xcodeproj' -scheme 'Free Ruler' test-without-building -only-testing:FreeRulerUITests/FreeRulerUITests/testRulerColorPanelHidesOpacityControl