1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-29 00:34:26 +03:00
vimr/VimR/Workspace/WorkspaceTool.swift
2016-09-25 17:50:33 +02:00

53 lines
936 B
Swift

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Cocoa
protocol WorkspaceToolDelegate: class {
func toggle(_ tool: WorkspaceTool)
}
class WorkspaceTool {
// MARK: - API
let title: String
let view: NSView
let button: WorkspaceToolButton
var location = WorkspaceBarLocation.left {
didSet {
self.button.location = self.location
}
}
var isSelected = false {
didSet {
if self.isSelected {
self.button.highlight()
} else {
self.button.dehighlight()
}
}
}
weak var delegate: WorkspaceToolDelegate?
let minimumDimension = CGFloat(30)
var dimension = CGFloat(50)
init(title: String, view: NSView) {
self.title = title
self.view = view
self.button = WorkspaceToolButton(title: title)
self.button.tool = self
}
func toggle() {
self.delegate?.toggle(self)
self.isSelected = !self.isSelected
}
}