From c7fcab1358b852ee6a4d6bc65bce2ad6e6253cd5 Mon Sep 17 00:00:00 2001 From: Tae Won Ha Date: Mon, 5 Sep 2016 23:29:32 +0200 Subject: [PATCH] GH-264 Refactor slightly --- VimR/ImageAndTextTableCell.swift | 25 ++++++++++++++++++++++--- VimR/OpenQuicklyWindowComponent.swift | 4 ++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/VimR/ImageAndTextTableCell.swift b/VimR/ImageAndTextTableCell.swift index af121b4d..34c9e75d 100644 --- a/VimR/ImageAndTextTableCell.swift +++ b/VimR/ImageAndTextTableCell.swift @@ -7,9 +7,29 @@ import Cocoa import PureLayout 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: ()) - let imageView: NSImageView = NSImageView(forAutoLayout: ()) + private let textField: NSTextField = NSTextField(forAutoLayout: ()) + private let imageView: NSImageView = NSImageView(forAutoLayout: ()) init(withIdentifier identifier: String) { super.init(frame: CGRect.zero) @@ -32,7 +52,6 @@ class ImageAndTextTableCell: NSView { imageView.autoSetDimension(.Width, toSize: 16) imageView.autoSetDimension(.Height, toSize: 16) -// textField.autoSetDimension(.Height, toSize: 23) textField.autoPinEdgeToSuperviewEdge(.Top, withInset: 2) textField.autoPinEdgeToSuperviewEdge(.Right, withInset: 2) textField.autoPinEdgeToSuperviewEdge(.Bottom, withInset: 2) diff --git a/VimR/OpenQuicklyWindowComponent.swift b/VimR/OpenQuicklyWindowComponent.swift index 9e2fdad6..17b31293 100644 --- a/VimR/OpenQuicklyWindowComponent.swift +++ b/VimR/OpenQuicklyWindowComponent.swift @@ -184,8 +184,8 @@ extension OpenQuicklyWindowComponent { let cell = cachedCell as? ImageAndTextTableCell ?? ImageAndTextTableCell(withIdentifier: "file-view-row") let url = self.fileViewItems[row].url - cell.textField.attributedStringValue = self.rowText(forUrl: url) - cell.imageView.image = self.fileItemService.icon(forUrl: url) + cell.text = self.rowText(forUrl: url) + cell.image = self.fileItemService.icon(forUrl: url) return cell }