{"id":18031766,"url":"https://github.com/dagronf/dsfbrowserview","last_synced_at":"2025-03-27T05:30:58.390Z","repository":{"id":149491746,"uuid":"397449681","full_name":"dagronf/DSFBrowserView","owner":"dagronf","description":"A modern-ish NSBrowser-style control allowing complex row views (macOS, Swift). Compatible back to macOS 10.11","archived":false,"fork":false,"pushed_at":"2021-11-29T01:29:08.000Z","size":49,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T04:31:40.695Z","etag":null,"topics":["control","macos","nsbrowser","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dagronf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2021-08-18T02:32:08.000Z","updated_at":"2024-12-12T13:39:22.000Z","dependencies_parsed_at":"2023-05-01T05:32:34.828Z","dependency_job_id":null,"html_url":"https://github.com/dagronf/DSFBrowserView","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFBrowserView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFBrowserView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFBrowserView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFBrowserView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dagronf","download_url":"https://codeload.github.com/dagronf/DSFBrowserView/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245791341,"owners_count":20672665,"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":["control","macos","nsbrowser","swift"],"created_at":"2024-10-30T10:10:42.840Z","updated_at":"2025-03-27T05:30:58.385Z","avatar_url":"https://github.com/dagronf.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DSFBrowserView\n\nA modern-ish NSBrowser-style control allowing complex row views.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/tag/dagronf/DSFBrowserView\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/macOS-10.11+-red\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Swift-5.1-orange.svg\" /\u003e\n    \u003ca href=\"https://swift.org/package-manager\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat\" alt=\"Swift Package Manager\" /\u003e\u003c/a\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-MIT-lightgrey\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n   \u003ca href=\"https://github.com/dagronf/dagronf.github.io/blob/master/art/projects/DSFBrowserView/main.gif?raw=true\"\u003e\n      \u003cimg src=\"https://github.com/dagronf/dagronf.github.io/blob/master/art/projects/DSFBrowserView/main.gif?raw=true\" alt=\"Swift Package Manager\" width=\"400\"/\u003e\u003c/a\u003e\n   \u003c/a\u003e\n\u003c/p\u003e\n\n## Why?\n\nI use an NSBrowser for one of my apps and got frustrated with the limitations of what could be displayed within the browser columns.  Well, you CAN tweak the output BUT you have to do a lot of your own drawing code in a custom NSCell. Boo!\n\nThis implementation follows the model of the modern NSTableView, using `NSView`s to display browser cells and allowing the user to customise the cell views depending on need.\n\n## Installation\n\nUse Swift Package Manager.\n\nAdd `https://github.com/dagronf/DSFBrowserView` to your project.\n\n## Usage\n\nYou can find a basic demo in the `Demos` subfolder.\n\n### Creation\n\nThe basic behaviour of the control is similar to NSBrowser. Assign a delegate and provide the data when asked.\n\n```swift\nlet browserView = DSFBrowserView()  // Or load from XIB\n\n// Add columns to the browser\nbrowserView.addColumn(\"Heading 1\", allowMultipleSelection: false, allowEmptySelection: true)\nbrowserView.addColumn(\"Heading 2\", allowMultipleSelection: false, allowEmptySelection: true)\nbrowserView.addColumn(\"Heading 3\", allowMultipleSelection: true, allowEmptySelection: true)\n\n// Some additional visual stuff...\nbrowserView.autohidesScrollers = true\nbrowserView.hideSeparators = false\n\n// And tell the browser to update itself\nbrowserView.reloadData()\n```\n\n### Providing data to the control\n\nThe delegate is asked for content to display in the control.\n\n#### Data Source\n\n```swift\nfunc rootItem(for browser: DSFBrowserView) -\u003e Any?\n```\n\nReturn the root element of the browser view. This might be an array of objects (for example)\n\n```swift\nfunc browserView(_ browser: DSFBrowserView, numberOfChildrenOfItem item: Any?) -\u003e Int\n```\n\nReturn the number of children for `item`.\n\n```swift\nfunc browserView(_ browser: DSFBrowserView, child index: Int, ofItem item: Any?) -\u003e Any\n```\n\nReturn the child item at index `index` for `item`.\n\n```swift\nfunc browserView(_ browser: DSFBrowserView, viewForItem item: Any?, column: Int, row: Int) -\u003e NSView?\n```\n\nReturn a view that represents `item`.  Row and column are provided for informational purposes only.\n\n#### Delegate\n\n```swift\nfunc browserView(_ browser: DSFBrowserView, selectionDidChange selections: [[Any]])\n```\n\nCalled when the selection changes within the control. \n\n```swift\nfunc browserView(_ browser: DSFBrowserView, pasteboardWriterForItem item: Any) -\u003e NSPasteboardWriting?\n```\nCalled when the user starts to drag an item within a column. Return `nil` to cancel the drag\n\n#### Legacy (10.12 and earlier)\n\n```swift\nfunc browserView(_ browser: DSFBrowserView, heightOfViewForItem item: Any?) -\u003e CGFloat\n```\n\nIf you are targeting 10.12 or earlier, AutoLayout isn't supported for table view cells. You will need to provide a height to use for the view being displayed for `item`.\n\n## Screenshots\n\n\u003cp align=\"center\"\u003e\n   \u003ca href=\"https://github.com/dagronf/dagronf.github.io/blob/master/art/projects/DSFBrowserView/moviedb.jpg?raw=true\"\u003e\n      \u003cimg src=\"https://github.com/dagronf/dagronf.github.io/blob/master/art/projects/DSFBrowserView/moviedb.jpg?raw=true\" alt=\"Swift Package Manager\" width=\"700\"/\u003e\u003c/a\u003e\n   \u003c/a\u003e\n\u003c/p\u003e\n\n# License\n\nMIT. Use it and abuse it for anything you want, just attribute my work. Let me know if you do use it somewhere, I'd love to hear about it!\n\n```\nMIT License\n\nCopyright (c) 2021 Darren Ford\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdagronf%2Fdsfbrowserview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdagronf%2Fdsfbrowserview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdagronf%2Fdsfbrowserview/lists"}