1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-25 23:02:35 +03:00
vimr/VimR-Workspace-Demo/AppDelegate.swift

49 lines
1.8 KiB
Swift
Raw Normal View History

2016-09-18 21:49:42 +03:00
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Cocoa
import PureLayout
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
2016-09-25 18:50:33 +03:00
fileprivate var workspace: Workspace = Workspace(mainView: NSView())
2016-09-18 21:49:42 +03:00
2016-09-25 18:50:33 +03:00
@IBAction func toggleBars(_ sender: AnyObject!) {
2016-09-18 21:49:42 +03:00
workspace.toggleAllTools()
}
2016-09-25 18:50:33 +03:00
@IBAction func toggleButtons(_ sender: AnyObject!) {
2016-09-18 21:49:42 +03:00
workspace.toggleToolButtons()
}
2016-09-25 18:50:33 +03:00
func applicationDidFinishLaunching(_ aNotification: Notification) {
2016-09-18 21:49:42 +03:00
let contentView = self.window.contentView!
2016-09-25 18:50:33 +03:00
let workspace = Workspace(mainView: self.view(NSColor.yellow))
2016-09-18 21:49:42 +03:00
self.workspace = workspace
contentView.addSubview(workspace)
workspace.autoPinEdgesToSuperviewEdges()
workspace.append(tool: WorkspaceTool(title: "Top-1", view: self.view(NSColor.white)), location: .top)
workspace.append(tool: WorkspaceTool(title: "Right-1", view: self.view(NSColor.white)), location: .right)
workspace.append(tool: WorkspaceTool(title: "Right-2", view: self.view(NSColor.green)), location: .right)
2016-09-25 18:50:33 +03:00
workspace.append(tool: WorkspaceTool(title: "Left-1", view: self.view(NSColor.white)), location: .left)
workspace.append(tool: WorkspaceTool(title: "Left-2", view: self.view(NSColor.green)), location: .left)
workspace.append(tool: WorkspaceTool(title: "Left-3", view: self.view(NSColor.magenta)), location: .left)
workspace.append(tool: WorkspaceTool(title: "Bottom-1", view: self.view(NSColor.white)), location: .bottom)
workspace.append(tool: WorkspaceTool(title: "Bottom-2", view: self.view(NSColor.green)), location: .bottom)
2016-09-18 21:49:42 +03:00
}
2016-09-25 18:50:33 +03:00
fileprivate func view(_ color: NSColor) -> NSView {
2016-09-18 21:49:42 +03:00
let view = NSView(forAutoLayout: ())
view.wantsLayer = true
2016-09-25 18:50:33 +03:00
view.layer?.backgroundColor = color.cgColor
2016-09-18 21:49:42 +03:00
return view
}
}