// // 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 super.init() } // 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 = NSLocalizedString("Back", comment: "Back") backItem.image = NSImage(named: "icon_back16.png") return backItem } func createNext() -> NSToolbarItem { let nextItem = NSToolbarItem(itemIdentifier: DocHubNextToolbarItemIdentifier) nextItem.label = NSLocalizedString("Next", comment: "Next") nextItem.image = NSImage(named: "icon_next16.png") return nextItem } func createLibrary() -> NSToolbarItem { let libraryItem = LibraryItem(itemIdentifier: DocHubLibraryToolbarItemIdentifier) libraryItem.label = NSLocalizedString("Library", comment: "Library") libraryItem.paletteLabel = NSLocalizedString("Toggle Library", comment: "Toggle Library") libraryItem.toolTip = NSLocalizedString("Open or close the leftmost panel", comment: "Open or close the leftmost panel") 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 ] } class LibraryItem : NSToolbarItem { init(itemIdentifier: String!) { super.init(itemIdentifier: itemIdentifier) } override var minSize: NSSize { willSet(newSize) { if (newSize.height < 32) { self.image = NSImage(named: "icon-library24.png") } else { self.image = NSImage(named: "icon-library.png") } } } } }
# | 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. |