1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 11:37:32 +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() {
let fontTitle = NSTextField(forAutoLayout: ())
fontTitle.backgroundColor = NSColor.clearColor();
fontTitle.stringValue = "Default Font:";
fontTitle.editable = false;
fontTitle.bordered = false;
fontTitle.alignment = .Right;
let paneTitle = self.paneTitleTextField(title: "Appearance")
let fontTitle = self.titleTextField(title: "Default Font:")
let fontManager = NSFontManager.sharedFontManager()
let fontPopup = self.fontPopup
@ -85,13 +82,11 @@ class AppearancePrefPane: PrefPane, NSComboBoxDelegate, NSControlTextEditingDele
self.sizes.forEach { string in
sizeCombo.addItemWithObjectValue(string)
}
let ligatureCheckbox = self.ligatureCheckbox
ligatureCheckbox.title = "Use Ligatures"
ligatureCheckbox.setButtonType(.SwitchButton)
ligatureCheckbox.bezelStyle = .ThickSquareBezelStyle
ligatureCheckbox.target = self
ligatureCheckbox.action = #selector(AppearancePrefPane.usesLigaturesAction(_:))
self.configureCheckbox(button: ligatureCheckbox,
title: "Use Ligatures",
action: #selector(AppearancePrefPane.usesLigaturesAction(_:)))
let previewArea = self.previewArea
previewArea.editable = true
@ -113,16 +108,21 @@ class AppearancePrefPane: PrefPane, NSComboBoxDelegate, NSControlTextEditingDele
previewScrollView.borderType = .BezelBorder
previewScrollView.documentView = previewArea
self.addSubview(paneTitle)
self.addSubview(fontTitle)
self.addSubview(fontPopup)
self.addSubview(sizeCombo)
self.addSubview(ligatureCheckbox)
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)
fontPopup.autoPinEdgeToSuperviewEdge(.Top, withInset: 18)
fontPopup.autoPinEdge(.Top, toEdge: .Bottom, ofView: paneTitle, withOffset: 18)
fontPopup.autoPinEdge(.Left, toEdge: .Right, ofView: fontTitle, withOffset: 5)
fontPopup.autoSetDimension(.Width, toSize: 240)

View File

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