// // LibraryView.swift // DocHub // // Created by Tristan Juricek on 6/12/14. // Copyright (c) 2014 Perforce. All rights reserved. // import Foundation import AppKit // The left panel of the main window, this really is the "library style" menu // that is the root of all navigation in the application. class LibraryView : NSView { var delegate:LibraryViewDelegate? let scrollView:NSScrollView let libraryToolbarView:LibraryToolbarView let libraryListView:LibraryListView let backgroundColor = NSColor(SRGBRed: 0.95, green: 0.94, blue: 0.95, alpha: 1.0) let toolbarHeight = 39 init(frame:NSRect) { let scrollRect = NSRect(x: 0, y: toolbarHeight, width: Int(frame.size.width), height: (Int(frame.size.height) - toolbarHeight)) scrollView = NSScrollView(frame: scrollRect) scrollView.hasHorizontalScroller = false scrollView.hasVerticalScroller = true scrollView.borderType = NSBorderType.NoBorder scrollView.backgroundColor = backgroundColor libraryListView = LibraryListView(frame: NSRect(x:0, y:0, width: scrollRect.width, height: scrollRect.height)) scrollView.documentView = libraryListView let toolbarRect = NSRect(x: 0, y: 0, width: Int(frame.size.width), height: toolbarHeight) libraryToolbarView = LibraryToolbarView(frame:toolbarRect) super.init(frame:frame) autoresizesSubviews = true addSubview(scrollView) addSubview(libraryToolbarView) } override func resizeSubviewsWithOldSize(oldBoundsSize: NSSize) { let scrollSize = NSSize(width:frame.width, height:frame.height - CGFloat(toolbarHeight)) scrollView.setFrameSize(scrollSize) libraryListView.setFrameSize(NSSize(width: frame.width, height: libraryListView.frame.size.height)) libraryToolbarView.setFrameSize(NSSize(width: frame.width, height: CGFloat(toolbarHeight))) } }