mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-24 11:37:32 +03:00
GH-244 Add controls
This commit is contained in:
parent
7da4ce77a4
commit
c68ee7a602
@ -28,28 +28,33 @@ class GeneralPrefPane: PrefPane {
|
|||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
func paneTitleTextField(title title: String) -> NSTextField {
|
|
||||||
let field = NSTextField(forAutoLayout: ())
|
|
||||||
field.backgroundColor = NSColor.clearColor();
|
|
||||||
field.font = NSFont.boldSystemFontOfSize(16)
|
|
||||||
field.editable = false;
|
|
||||||
field.bordered = false;
|
|
||||||
field.alignment = .Left;
|
|
||||||
|
|
||||||
field.stringValue = title
|
|
||||||
|
|
||||||
return field
|
|
||||||
}
|
|
||||||
|
|
||||||
override func addViews() {
|
override func addViews() {
|
||||||
let paneTitle = paneTitleTextField(title: "General")
|
let paneTitle = paneTitleTextField(title: "General")
|
||||||
|
|
||||||
|
let openUntitledWindowTitle = titleTextField(title: "Open Untitled Window:")
|
||||||
|
let openWhenLaunching = self.checkbox(title: "On Launch",
|
||||||
|
action: #selector(GeneralPrefPane.openUntitledWindowWhenLaunchingAction(_:)))
|
||||||
|
let openOnReactivation = self.checkbox(title: "On Re-Activation",
|
||||||
|
action: #selector(GeneralPrefPane.openUntitledWindowOnReactivation(_:)))
|
||||||
|
|
||||||
self.addSubview(paneTitle)
|
self.addSubview(paneTitle)
|
||||||
|
|
||||||
|
self.addSubview(openUntitledWindowTitle)
|
||||||
|
self.addSubview(openWhenLaunching)
|
||||||
|
self.addSubview(openOnReactivation)
|
||||||
|
|
||||||
paneTitle.autoPinEdgeToSuperviewEdge(.Top, withInset: 18)
|
paneTitle.autoPinEdgeToSuperviewEdge(.Top, withInset: 18)
|
||||||
paneTitle.autoPinEdgeToSuperviewEdge(.Left, withInset: 18)
|
paneTitle.autoPinEdgeToSuperviewEdge(.Left, withInset: 18)
|
||||||
paneTitle.autoPinEdgeToSuperviewEdge(.Bottom, withInset: 18)
|
|
||||||
paneTitle.autoPinEdgeToSuperviewEdge(.Right, withInset: 18)
|
openUntitledWindowTitle.autoAlignAxis(.Baseline, toSameAxisOfView: openWhenLaunching, withOffset: 0)
|
||||||
|
openUntitledWindowTitle.autoPinEdgeToSuperviewEdge(.Left, withInset: 18)
|
||||||
|
|
||||||
|
openWhenLaunching.autoPinEdge(.Top, toEdge: .Bottom, ofView: paneTitle, withOffset: 18)
|
||||||
|
openWhenLaunching.autoPinEdge(.Left, toEdge: .Right, ofView: openUntitledWindowTitle, withOffset: 5)
|
||||||
|
|
||||||
|
openOnReactivation.autoPinEdge(.Top, toEdge: .Bottom, ofView: openWhenLaunching, withOffset: 5)
|
||||||
|
openOnReactivation.autoPinEdge(.Left, toEdge: .Left, ofView: openWhenLaunching)
|
||||||
|
openOnReactivation.autoPinEdgeToSuperviewEdge(.Bottom, withInset: 18)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func subscription(source source: Observable<Any>) -> Disposable {
|
override func subscription(source source: Observable<Any>) -> Disposable {
|
||||||
@ -58,4 +63,20 @@ class GeneralPrefPane: PrefPane {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func updateViews() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Actions
|
||||||
|
extension GeneralPrefPane {
|
||||||
|
|
||||||
|
func openUntitledWindowWhenLaunchingAction(sender: NSButton) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func openUntitledWindowOnReactivation(sender: NSButton) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,3 +57,40 @@ class PrefPane: NSView, ViewComponent {
|
|||||||
self.subject.onNext(event)
|
self.subject.onNext(event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Control Utils
|
||||||
|
extension PrefPane {
|
||||||
|
|
||||||
|
func paneTitleTextField(title title: String) -> NSTextField {
|
||||||
|
let field = defaultTitleTextField()
|
||||||
|
field.font = NSFont.boldSystemFontOfSize(16)
|
||||||
|
field.alignment = .Left;
|
||||||
|
field.stringValue = title
|
||||||
|
return field
|
||||||
|
}
|
||||||
|
|
||||||
|
func titleTextField(title title: String) -> NSTextField {
|
||||||
|
let field = defaultTitleTextField()
|
||||||
|
field.alignment = .Right;
|
||||||
|
field.stringValue = title
|
||||||
|
return field
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkbox(title title: String, action: Selector) -> NSButton {
|
||||||
|
let button = NSButton(forAutoLayout: ())
|
||||||
|
button.title = title
|
||||||
|
button.setButtonType(.SwitchButton)
|
||||||
|
button.bezelStyle = .ThickSquareBezelStyle
|
||||||
|
button.target = self
|
||||||
|
button.action = action
|
||||||
|
return button
|
||||||
|
}
|
||||||
|
|
||||||
|
private func defaultTitleTextField() -> NSTextField {
|
||||||
|
let field = NSTextField(forAutoLayout: ())
|
||||||
|
field.backgroundColor = NSColor.clearColor();
|
||||||
|
field.editable = false;
|
||||||
|
field.bordered = false;
|
||||||
|
return field
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user