1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-28 11:35:35 +03:00

GH-244 Refactor slightly Appearance pref pane

This commit is contained in:
Tae Won Ha 2016-08-14 15:44:53 +02:00
parent 32623a1d56
commit 983710fef4
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
2 changed files with 21 additions and 21 deletions

View File

@ -64,12 +64,9 @@ class AppearancePrefPane: PrefPane, NSComboBoxDelegate, NSControlTextEditingDele
} }
override func addViews() { override func addViews() {
let fontTitle = NSTextField(forAutoLayout: ()) let paneTitle = self.paneTitleTextField(title: "Appearance")
fontTitle.backgroundColor = NSColor.clearColor();
fontTitle.stringValue = "Default Font:"; let fontTitle = self.titleTextField(title: "Default Font:")
fontTitle.editable = false;
fontTitle.bordered = false;
fontTitle.alignment = .Right;
let fontManager = NSFontManager.sharedFontManager() let fontManager = NSFontManager.sharedFontManager()
let fontPopup = self.fontPopup let fontPopup = self.fontPopup
@ -87,11 +84,9 @@ class AppearancePrefPane: PrefPane, NSComboBoxDelegate, NSControlTextEditingDele
} }
let ligatureCheckbox = self.ligatureCheckbox let ligatureCheckbox = self.ligatureCheckbox
ligatureCheckbox.title = "Use Ligatures" self.configureCheckbox(button: ligatureCheckbox,
ligatureCheckbox.setButtonType(.SwitchButton) title: "Use Ligatures",
ligatureCheckbox.bezelStyle = .ThickSquareBezelStyle action: #selector(AppearancePrefPane.usesLigaturesAction(_:)))
ligatureCheckbox.target = self
ligatureCheckbox.action = #selector(AppearancePrefPane.usesLigaturesAction(_:))
let previewArea = self.previewArea let previewArea = self.previewArea
previewArea.editable = true previewArea.editable = true
@ -113,16 +108,21 @@ class AppearancePrefPane: PrefPane, NSComboBoxDelegate, NSControlTextEditingDele
previewScrollView.borderType = .BezelBorder previewScrollView.borderType = .BezelBorder
previewScrollView.documentView = previewArea previewScrollView.documentView = previewArea
self.addSubview(paneTitle)
self.addSubview(fontTitle) self.addSubview(fontTitle)
self.addSubview(fontPopup) self.addSubview(fontPopup)
self.addSubview(sizeCombo) self.addSubview(sizeCombo)
self.addSubview(ligatureCheckbox) self.addSubview(ligatureCheckbox)
self.addSubview(previewScrollView) self.addSubview(previewScrollView)
fontTitle.autoPinEdgeToSuperviewEdge(.Left, withInset: 18) paneTitle.autoPinEdgeToSuperviewEdge(.Top, withInset: 18)
paneTitle.autoPinEdgeToSuperviewEdge(.Left, withInset: 18)
fontTitle.autoPinEdge(.Left, toEdge: .Left, ofView: paneTitle)
fontTitle.autoAlignAxis(.Baseline, toSameAxisOfView: fontPopup) fontTitle.autoAlignAxis(.Baseline, toSameAxisOfView: fontPopup)
fontPopup.autoPinEdgeToSuperviewEdge(.Top, withInset: 18) fontPopup.autoPinEdge(.Top, toEdge: .Bottom, ofView: paneTitle, withOffset: 18)
fontPopup.autoPinEdge(.Left, toEdge: .Right, ofView: fontTitle, withOffset: 5) fontPopup.autoPinEdge(.Left, toEdge: .Right, ofView: fontTitle, withOffset: 5)
fontPopup.autoSetDimension(.Width, toSize: 240) fontPopup.autoSetDimension(.Width, toSize: 240)

View File

@ -92,20 +92,20 @@ class GeneralPrefPane: PrefPane {
// MARK: - Actions // MARK: - Actions
extension GeneralPrefPane { extension GeneralPrefPane {
private func generalPrefData() -> GeneralPrefData { private func publishData() {
return GeneralPrefData(openNewWindowWhenLaunching: self.openNewWindowWhenLaunching, self.publish(
event: GeneralPrefData(openNewWindowWhenLaunching: self.openNewWindowWhenLaunching,
openNewWindowOnReactivation: self.openNewWindowOnReactivation) openNewWindowOnReactivation: self.openNewWindowOnReactivation)
)
} }
func openUntitledWindowWhenLaunchingAction(sender: NSButton) { func openUntitledWindowWhenLaunchingAction(sender: NSButton) {
NSLog("\(#function)")
self.openNewWindowWhenLaunching = self.openWhenLaunchingCheckbox.state == NSOnState ? true : false self.openNewWindowWhenLaunching = self.openWhenLaunchingCheckbox.state == NSOnState ? true : false
self.publish(event: generalPrefData()) self.publishData()
} }
func openUntitledWindowOnReactivation(sender: NSButton) { func openUntitledWindowOnReactivation(sender: NSButton) {
NSLog("\(#function)")
self.openNewWindowOnReactivation = self.openOnReactivationCheckbox.state == NSOnState ? true : false self.openNewWindowOnReactivation = self.openOnReactivationCheckbox.state == NSOnState ? true : false
self.publish(event: generalPrefData()) self.publishData()
} }
} }