{"id":20683166,"url":"https://github.com/chimehq/windowtreatment","last_synced_at":"2025-04-13T06:41:18.299Z","repository":{"id":63906886,"uuid":"186052685","full_name":"ChimeHQ/WindowTreatment","owner":"ChimeHQ","description":"Tools for happier work with NSWindow","archived":false,"fork":false,"pushed_at":"2024-11-19T12:16:14.000Z","size":110,"stargazers_count":63,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T11:43:38.326Z","etag":null,"topics":["appkit","macos","nswindow","swift","swiftui"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChimeHQ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["mattmassicotte"]}},"created_at":"2019-05-10T20:49:21.000Z","updated_at":"2025-01-01T19:54:41.000Z","dependencies_parsed_at":"2025-01-09T18:47:42.224Z","dependency_job_id":null,"html_url":"https://github.com/ChimeHQ/WindowTreatment","commit_stats":{"total_commits":45,"total_committers":2,"mean_commits":22.5,"dds":"0.022222222222222254","last_synced_commit":"6cf36dd6f908aed0dc31aeb27a346303210b2923"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FWindowTreatment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FWindowTreatment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FWindowTreatment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FWindowTreatment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChimeHQ","download_url":"https://codeload.github.com/ChimeHQ/WindowTreatment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248675434,"owners_count":21143763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appkit","macos","nswindow","swift","swiftui"],"created_at":"2024-11-16T22:15:37.828Z","updated_at":"2025-04-13T06:41:18.280Z","avatar_url":"https://github.com/ChimeHQ.png","language":"Swift","funding_links":["https://github.com/sponsors/mattmassicotte"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n[![Build Status][build status badge]][build status]\n[![Platforms][platforms badge]][platforms]\n[![Matrix][matrix badge]][matrix]\n\n\u003c/div\u003e\n\n# WindowTreatment\n\nWindowTreatment is a small set of classes and extensions to aid in working with `NSWindow` and its associated functions.\n\n## Integration\n\nSwift Package Manager:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/ChimeHQ/WindowTreatment\")\n]\n```\n\n## SwiftUI View Modifiers\n\n```swift\nobserveCurrentWindow() // puts the current window object into the environment\nobserveWindowState()   // makes WindowStateKey available in the environment\n```\n\n## Classes\n\n**WindowTitlebarAwareView**\n\nA simple container view that makes it much easier to correctly position content under the titlebar of a host `NSWindow`. This turns out to be a fairly esoteric thing to do, but can be essential when your `NSWindow` has a transparent titlebar.\n\n```swift\nlet titlebarAwareView = WindowTitlebarAwareView()\n\n// myView will always be correctly position below the containing window's\n// titlebar region, and react accordingly if the titlebar size/state changes\n\ntitlebarAwareView.contentView = myView\n// ...\n```\n\n**WindowTitlebarAwareViewController**\n\nA wrapper controller useful in cases where you need to use `WindowTitlebarAwareView` with a system that only accepts `NSViewControllers`, like `NSSplitViewController`.\n\n**WindowStateObserver**\n\nWrappers around observation of `NSWindow` states for `key`, `main`, and tabbing. Very useful for UI updates in response to these changes. Particularly for tab state, which is very challenging to observe correctly in all cases.\n\n**WindowStateAwareView**\n\nSuper-simple class that uses `WindowStateObserver` and provides a nice base for `NSView` subclasses that need to change their appearance depending on host window main/key state.\n\n**ApplicationWindowState**\n\nA class that tracks changes in the application's windows, simplifying logic that depends on the state of all windows.\n\n## NSWindow Extensions\n\nSizing conveniences:\n\n```swift\n// simple method to size a window to pleasing dimensions relative to its screen\n\nwindow.makeReasonableSize()\n```\n\nTitle bar transparency helpers:\n\n```swift\n// This method also handles the height adjustments needed when removing transparency\nwindow.titlebarTransparentWithFullSizeContent = true\n\nwindow.usesFullSizeContentView = true\n```\n\n## NSView Extensions\n\nWindow state:\n\n```swift\nself.windowIsMain\nself.windowIsKey\nself.windowIsOnActiveSpace\n```\n\n## Contributing and Collaboration\n\nI would love to hear from you! Issues or pull requests work great. Both a [Matrix space][matrix] and [Discord][discord] are available for live help, but I have a strong bias towards answering in the form of documentation. You can also find me [here](https://www.massicotte.org/about).\n\nI prefer collaboration, and would love to find ways to work together if you have a similar project.\n\nI prefer indentation with tabs for improved accessibility. But, I'd rather you use the system you want and make a PR than hesitate because of whitespace.\n\nBy participating in this project you agree to abide by the [Contributor Code of Conduct](CODE_OF_CONDUCT.md).\n\n[build status]: https://github.com/ChimeHQ/WindowTreatment/actions\n[build status badge]: https://github.com/ChimeHQ/WindowTreatment/workflows/CI/badge.svg\n[platforms]: https://swiftpackageindex.com/ChimeHQ/WindowTreatment\n[platforms badge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FChimeHQ%2FWindowTreatment%2Fbadge%3Ftype%3Dplatforms\n[matrix]: https://matrix.to/#/%23chimehq%3Amatrix.org\n[matrix badge]: https://img.shields.io/matrix/chimehq%3Amatrix.org?label=Matrix\n[discord]: https://discord.gg/esFpX6sErJ\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchimehq%2Fwindowtreatment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchimehq%2Fwindowtreatment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchimehq%2Fwindowtreatment/lists"}