// // DocHubToolbar.swift // DocHub // // Created by Tristan Juricek on 6/13/14. // Copyright (c) 2014 Perforce. All rights reserved. // import Foundation import AppKit // ToolbarIDs that I would make class properties let DocHubBackToolbarItemIdentifier = "DocHubBackToolbarItemIdentifier" let DocHubNextToolbarItemIdentifier = "DocHubNextToolbarItemIdentifier" let DocHubLibraryToolbarItemIdentifier = "DocHubLibraryToolbarItemIdentifier" // Defines the application toobar for DocHub. Should really only be one per // window. @objc class DocHubToolbarDelegate : NSObject, NSToolbarDelegate { let controller:AnyObject! init(mainController:AnyObject!) { controller = mainController } // Create a new toolbar item for the particular ID func toolbar(toolbar: NSToolbar!, itemForItemIdentifier itemIdentifier: String!, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem! { var toolbarItem:NSToolbarItem? = nil switch(itemIdentifier) { case DocHubBackToolbarItemIdentifier: toolbarItem = createBack(); case DocHubNextToolbarItemIdentifier: toolbarItem = createNext(); case DocHubLibraryToolbarItemIdentifier: toolbarItem = createLibrary(); default: assert(false, "illegal toolbar item") } return toolbarItem! } func createBack() -> NSToolbarItem { let backItem = NSToolbarItem(itemIdentifier: DocHubBackToolbarItemIdentifier) backItem.label = "Back" backItem.image = NSImage(named: "icon_back16.png") return backItem } func createNext() -> NSToolbarItem { let nextItem = NSToolbarItem(itemIdentifier: DocHubNextToolbarItemIdentifier) nextItem.label = "Next" nextItem.image = NSImage(named: "icon_next16.png") return nextItem } func createLibrary() -> NSToolbarItem { let libraryItem = NSToolbarItem(itemIdentifier: DocHubLibraryToolbarItemIdentifier) libraryItem.label = "Library" libraryItem.paletteLabel = "Toggle Library" libraryItem.toolTip = "Open or close the leftmost panel" libraryItem.image = NSImage(named: "icon-library.png") libraryItem.enabled = true libraryItem.target = controller libraryItem.action = "toggleLibrary" return libraryItem } // Sent to discover the allowed item identifiers for a toolbar. func toolbarAllowedItemIdentifiers(toolbar: NSToolbar!) -> AnyObject[]! { return [ DocHubBackToolbarItemIdentifier, DocHubNextToolbarItemIdentifier, DocHubLibraryToolbarItemIdentifier ] } // Sent to discover the default item identifiers for a toolbar. func toolbarDefaultItemIdentifiers(toolbar: NSToolbar!) -> AnyObject[]! { return [ DocHubBackToolbarItemIdentifier, DocHubNextToolbarItemIdentifier, DocHubLibraryToolbarItemIdentifier ] } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#6 | 9553 | tjuricek |
Adjust the library toolbar icon to act like a toggle switch, similar to XCode 6's toolbar buttons. I'm not 100% sure about the placement of the left 3 buttons, so this may end up requiring a lot of custom views to be more consistent with the inconsistency that is 10.10. |
||
#5 | 9469 | tjuricek | Add sheet view for collecting Perforce connection information. | ||
#4 | 9440 | tjuricek | Tightened up the display of the toolbar icon by subclassing and specifying a 24px render instead of letting the 32px scale down | ||
#3 | 9438 | tjuricek |
Updated style of the library toolbar icon to match more of the Yosemite look and feel. Removed the "back/next" buttons. We should probably use a single view for them, and bring them back when they'll actually be used. |
||
#2 | 9433 | tjuricek | Setup the library toggle mechanism to the toolbar. | ||
#1 | 9432 | tjuricek | Added framework for a standard toolbar. |