1
1
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:
Tae Won Ha 2016-08-14 15:01:28 +02:00
parent 7da4ce77a4
commit c68ee7a602
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
2 changed files with 73 additions and 15 deletions

View File

@ -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) {
}
} }

View File

@ -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
}
}