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-11-27 18:41:52 +03:00
|
|
|
let workspace = Workspace(mainView: DummyView(NSColor.white))
|
2016-09-18 21:49:42 +03:00
|
|
|
self.workspace = workspace
|
|
|
|
|
|
|
|
contentView.addSubview(workspace)
|
|
|
|
workspace.autoPinEdgesToSuperviewEdges()
|
2016-11-23 21:46:55 +03:00
|
|
|
|
2016-11-27 18:41:52 +03:00
|
|
|
workspace.append(tool: WorkspaceTool(title: "Top-1", view: DummyToolView(NSColor.yellow)), location: .top)
|
|
|
|
workspace.append(tool: WorkspaceTool(title: "Right-1", view: DummyToolView(NSColor.magenta)), location: .right)
|
|
|
|
workspace.append(tool: WorkspaceTool(title: "Right-2", view: DummyToolView(NSColor.black)), location: .right)
|
|
|
|
let tool = WorkspaceTool(title: "Left-1", view: DummyToolView(NSColor.green))
|
|
|
|
workspace.append(tool: tool, location: .left)
|
|
|
|
workspace.append(tool: WorkspaceTool(title: "Left-2", view: DummyToolView(NSColor.red)), location: .left)
|
|
|
|
workspace.append(tool: WorkspaceTool(title: "Left-3", view: DummyToolView(NSColor.gray)), location: .left)
|
|
|
|
workspace.append(tool: WorkspaceTool(title: "Bottom-1", view: DummyToolView(NSColor.cyan)), location: .bottom)
|
|
|
|
workspace.append(tool: WorkspaceTool(title: "Bottom-2", view: DummyToolView(NSColor.blue)), location: .bottom)
|
|
|
|
|
|
|
|
let left = workspace.bars[.left]!
|
|
|
|
left.toggle(tool)
|
2016-11-23 21:59:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-27 18:41:52 +03:00
|
|
|
class DummyToolView: NSView {
|
|
|
|
|
|
|
|
required init?(coder: NSCoder) {
|
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
|
}
|
2016-11-23 21:59:15 +03:00
|
|
|
|
|
|
|
init(_ color: NSColor) {
|
|
|
|
super.init(frame: .zero)
|
|
|
|
self.configureForAutoLayout()
|
|
|
|
self.wantsLayer = true
|
2016-11-27 18:41:52 +03:00
|
|
|
|
|
|
|
let innerToolbar = InnerToolBar(forAutoLayout:())
|
|
|
|
let dummyView = DummyView(color)
|
|
|
|
|
|
|
|
self.addSubview(innerToolbar)
|
|
|
|
self.addSubview(dummyView)
|
|
|
|
|
|
|
|
innerToolbar.autoPinEdge(toSuperviewEdge: .top)
|
|
|
|
innerToolbar.autoPinEdge(toSuperviewEdge: .right)
|
|
|
|
innerToolbar.autoPinEdge(toSuperviewEdge: .left)
|
|
|
|
|
|
|
|
dummyView.autoPinEdge(.top, to: .bottom, of: innerToolbar)
|
|
|
|
dummyView.autoPinEdge(toSuperviewEdge: .right)
|
|
|
|
dummyView.autoPinEdge(toSuperviewEdge: .left)
|
2016-11-23 21:59:15 +03:00
|
|
|
}
|
2016-11-27 18:41:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
class DummyView: NSView {
|
|
|
|
|
2016-11-23 21:59:15 +03:00
|
|
|
required init?(coder: NSCoder) {
|
|
|
|
fatalError("init(coder:) has not been implemented")
|
2016-09-18 21:49:42 +03:00
|
|
|
}
|
|
|
|
|
2016-11-27 18:41:52 +03:00
|
|
|
init(_ color: NSColor) {
|
|
|
|
super.init(frame: .zero)
|
|
|
|
self.configureForAutoLayout()
|
|
|
|
self.wantsLayer = true
|
|
|
|
self.layer?.backgroundColor = color.cgColor
|
|
|
|
}
|
|
|
|
|
2016-11-23 21:59:15 +03:00
|
|
|
override func mouseDown(with event: NSEvent) {
|
|
|
|
NSLog("mouse down")
|
2016-09-18 21:49:42 +03:00
|
|
|
}
|
|
|
|
}
|