1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 11:37:32 +03:00

GH-264 Refactor slightly

This commit is contained in:
Tae Won Ha 2016-09-05 23:29:32 +02:00
parent be88e129d7
commit c7fcab1358
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
2 changed files with 24 additions and 5 deletions

View File

@ -7,9 +7,29 @@ import Cocoa
import PureLayout import PureLayout
class ImageAndTextTableCell: NSView { class ImageAndTextTableCell: NSView {
var text: NSAttributedString {
get {
return self.textField.attributedStringValue
}
set {
self.textField.attributedStringValue = newValue
}
}
var image: NSImage? {
get {
return self.imageView.image
}
set {
self.imageView.image = newValue
}
}
let textField: NSTextField = NSTextField(forAutoLayout: ()) private let textField: NSTextField = NSTextField(forAutoLayout: ())
let imageView: NSImageView = NSImageView(forAutoLayout: ()) private let imageView: NSImageView = NSImageView(forAutoLayout: ())
init(withIdentifier identifier: String) { init(withIdentifier identifier: String) {
super.init(frame: CGRect.zero) super.init(frame: CGRect.zero)
@ -32,7 +52,6 @@ class ImageAndTextTableCell: NSView {
imageView.autoSetDimension(.Width, toSize: 16) imageView.autoSetDimension(.Width, toSize: 16)
imageView.autoSetDimension(.Height, toSize: 16) imageView.autoSetDimension(.Height, toSize: 16)
// textField.autoSetDimension(.Height, toSize: 23)
textField.autoPinEdgeToSuperviewEdge(.Top, withInset: 2) textField.autoPinEdgeToSuperviewEdge(.Top, withInset: 2)
textField.autoPinEdgeToSuperviewEdge(.Right, withInset: 2) textField.autoPinEdgeToSuperviewEdge(.Right, withInset: 2)
textField.autoPinEdgeToSuperviewEdge(.Bottom, withInset: 2) textField.autoPinEdgeToSuperviewEdge(.Bottom, withInset: 2)

View File

@ -184,8 +184,8 @@ extension OpenQuicklyWindowComponent {
let cell = cachedCell as? ImageAndTextTableCell ?? ImageAndTextTableCell(withIdentifier: "file-view-row") let cell = cachedCell as? ImageAndTextTableCell ?? ImageAndTextTableCell(withIdentifier: "file-view-row")
let url = self.fileViewItems[row].url let url = self.fileViewItems[row].url
cell.textField.attributedStringValue = self.rowText(forUrl: url) cell.text = self.rowText(forUrl: url)
cell.imageView.image = self.fileItemService.icon(forUrl: url) cell.image = self.fileItemService.icon(forUrl: url)
return cell return cell
} }