From 7ed4eb619a5e0613ceef76c3714446579e8f36cd Mon Sep 17 00:00:00 2001
From: Tae Won Ha <h@taewon.de>
Date: Sun, 27 Nov 2016 21:37:30 +0100
Subject: [PATCH] GH-293 Use font awesome

---
 Cartfile                              |  1 +
 Cartfile.resolved                     |  1 +
 VimR-Workspace-Demo/AppDelegate.swift |  6 ++++-
 VimR.xcodeproj/project.pbxproj        | 14 ++++++++++++
 VimR/Workspace/InnterToolBar.swift    | 33 ++++++++++++++++++---------
 5 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/Cartfile b/Cartfile
index fba439d5..c9b74a5a 100644
--- a/Cartfile
+++ b/Cartfile
@@ -2,3 +2,4 @@ github "ReactiveX/RxSwift" "3.0.1"
 github "PureLayout/PureLayout" == 3.0.2
 github "eonil/FileSystemEvents" "master"
 github "sparkle-project/Sparkle" == 1.14.0
+github "qvacua/CocoaFontAwesome" "master"
diff --git a/Cartfile.resolved b/Cartfile.resolved
index ef518a20..aa24ee56 100644
--- a/Cartfile.resolved
+++ b/Cartfile.resolved
@@ -1,3 +1,4 @@
+github "qvacua/CocoaFontAwesome" "d9173438ef45c1217b10717b92c493bde6635685"
 github "eonil/FileSystemEvents" "aa5c6af1fd35939f9aca3b9eba3b672bfa549b3a"
 github "Quick/Nimble" "v5.1.0"
 github "PureLayout/PureLayout" "v3.0.2"
diff --git a/VimR-Workspace-Demo/AppDelegate.swift b/VimR-Workspace-Demo/AppDelegate.swift
index acfa07d7..88a3fd1e 100644
--- a/VimR-Workspace-Demo/AppDelegate.swift
+++ b/VimR-Workspace-Demo/AppDelegate.swift
@@ -30,12 +30,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {
     workspace.autoPinEdgesToSuperviewEdges()
 
     workspace.append(tool: WorkspaceTool(title: "Top-1", view: DummyToolView(NSColor.yellow)), location: .top)
+
     workspace.append(tool: WorkspaceTool(title: "Right-1", view: DummyToolView(NSColor.magenta)), location: .right)
     workspace.append(tool: WorkspaceTool(title: "Right-2", view: DummyToolView(NSColor.black)), location: .right)
-    let tool = WorkspaceTool(title: "Left-1", view: DummyToolView(NSColor.green))
+
+    let tool = WorkspaceTool(title: "Left-1", view: DummyToolView(NSColor.green), minimumDimension: 200)
     workspace.append(tool: tool, location: .left)
+
     workspace.append(tool: WorkspaceTool(title: "Left-2", view: DummyToolView(NSColor.red)), location: .left)
     workspace.append(tool: WorkspaceTool(title: "Left-3", view: DummyToolView(NSColor.gray)), location: .left)
+
     workspace.append(tool: WorkspaceTool(title: "Bottom-1", view: DummyToolView(NSColor.cyan)), location: .bottom)
     workspace.append(tool: WorkspaceTool(title: "Bottom-2", view: DummyToolView(NSColor.blue)), location: .bottom)
 
diff --git a/VimR.xcodeproj/project.pbxproj b/VimR.xcodeproj/project.pbxproj
index a701fdbc..170f66a1 100644
--- a/VimR.xcodeproj/project.pbxproj
+++ b/VimR.xcodeproj/project.pbxproj
@@ -43,6 +43,8 @@
 		4B2A2BFE1D0351810074CE9A /* SwiftNeoVim.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B2A2BF71D0351810074CE9A /* SwiftNeoVim.framework */; };
 		4B2A2BFF1D0351810074CE9A /* SwiftNeoVim.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4B2A2BF71D0351810074CE9A /* SwiftNeoVim.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
 		4B2A2C091D0352CB0074CE9A /* NeoVimUiBridgeProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B2A2C061D0352CB0074CE9A /* NeoVimUiBridgeProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		4B337FBB1DEB76F20020ADD2 /* CocoaFontAwesome.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B337FBA1DEB76F20020ADD2 /* CocoaFontAwesome.framework */; };
+		4B337FBC1DEB76F20020ADD2 /* CocoaFontAwesome.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B337FBA1DEB76F20020ADD2 /* CocoaFontAwesome.framework */; };
 		4B37ADB91D6E471B00970D55 /* vimr in Resources */ = {isa = PBXBuildFile; fileRef = 4B37ADB81D6E471B00970D55 /* vimr */; };
 		4B3965361DEB21300082D3C1 /* InnterToolBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B3965351DEB21300082D3C1 /* InnterToolBar.swift */; };
 		4B3965371DEB21300082D3C1 /* InnterToolBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B3965351DEB21300082D3C1 /* InnterToolBar.swift */; };
@@ -88,6 +90,10 @@
 		4B81B3D91DE882D500ED1672 /* AppKitCommons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B6A70931D60E04200E12030 /* AppKitCommons.swift */; };
 		4B854A1D1D31447C00E08DE1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B854A1C1D31447C00E08DE1 /* main.m */; };
 		4B8AC0441DBCB3A2007CCC9B /* NeoVimObjectsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8AC0431DBCB3A1007CCC9B /* NeoVimObjectsExtensions.swift */; };
+		4B91FFF31DEB772200447068 /* CocoaFontAwesome.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B337FBA1DEB76F20020ADD2 /* CocoaFontAwesome.framework */; };
+		4B91FFF41DEB772200447068 /* CocoaFontAwesome.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4B337FBA1DEB76F20020ADD2 /* CocoaFontAwesome.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
+		4B91FFF51DEB772B00447068 /* CocoaFontAwesome.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B337FBA1DEB76F20020ADD2 /* CocoaFontAwesome.framework */; };
+		4B91FFF61DEB772B00447068 /* CocoaFontAwesome.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4B337FBA1DEB76F20020ADD2 /* CocoaFontAwesome.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
 		4B97E2CC1D33F53D00FC0660 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B97E2CE1D33F53D00FC0660 /* MainWindow.xib */; };
 		4B9A15241D2993DA009F9F67 /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B56F29B1D29926600C1F92E /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
 		4B9A15261D2993DF009F9F67 /* SwiftNeoVim.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B2A2BF71D0351810074CE9A /* SwiftNeoVim.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@@ -186,6 +192,7 @@
 			files = (
 				4BDD056B1DB0CACB00D1B405 /* Sparkle.framework in Embed Frameworks */,
 				4BDF50121D760B7200D8FBC3 /* EonilFileSystemEvents.framework in Embed Frameworks */,
+				4B91FFF61DEB772B00447068 /* CocoaFontAwesome.framework in Embed Frameworks */,
 				4B2A2BFF1D0351810074CE9A /* SwiftNeoVim.framework in Embed Frameworks */,
 				4B2A2BEF1D02261F0074CE9A /* RxSwift.framework in Embed Frameworks */,
 				4B401B161D0454E900D99EDC /* PureLayout.framework in Embed Frameworks */,
@@ -201,6 +208,7 @@
 			dstSubfolderSpec = 10;
 			files = (
 				4B6423AD1D8EFE9800FC78C8 /* PureLayout.framework in Embed Frameworks */,
+				4B91FFF41DEB772200447068 /* CocoaFontAwesome.framework in Embed Frameworks */,
 			);
 			name = "Embed Frameworks";
 			runOnlyForDeploymentPostprocessing = 0;
@@ -297,6 +305,7 @@
 		4B2A2BFB1D0351810074CE9A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		4B2A2C061D0352CB0074CE9A /* NeoVimUiBridgeProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NeoVimUiBridgeProtocol.h; sourceTree = "<group>"; };
 		4B2A2C0D1D0353750074CE9A /* Bridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Bridge.h; sourceTree = "<group>"; };
+		4B337FBA1DEB76F20020ADD2 /* CocoaFontAwesome.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CocoaFontAwesome.framework; path = Carthage/Build/Mac/CocoaFontAwesome.framework; sourceTree = SOURCE_ROOT; };
 		4B37ADB81D6E471B00970D55 /* vimr */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = vimr; sourceTree = "<group>"; };
 		4B37ADBA1D6EC11600970D55 /* TestPane.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestPane.swift; sourceTree = "<group>"; };
 		4B3965351DEB21300082D3C1 /* InnterToolBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = InnterToolBar.swift; path = Workspace/InnterToolBar.swift; sourceTree = "<group>"; };
@@ -412,6 +421,8 @@
 			buildActionMask = 2147483647;
 			files = (
 				4B6423AC1D8EFE9800FC78C8 /* PureLayout.framework in Frameworks */,
+				4B337FBC1DEB76F20020ADD2 /* CocoaFontAwesome.framework in Frameworks */,
+				4B91FFF31DEB772200447068 /* CocoaFontAwesome.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -444,6 +455,8 @@
 			files = (
 				4B2A2BFE1D0351810074CE9A /* SwiftNeoVim.framework in Frameworks */,
 				4BDD056A1DB0CAB700D1B405 /* Sparkle.framework in Frameworks */,
+				4B337FBB1DEB76F20020ADD2 /* CocoaFontAwesome.framework in Frameworks */,
+				4B91FFF51DEB772B00447068 /* CocoaFontAwesome.framework in Frameworks */,
 				4B2A2BEE1D02261F0074CE9A /* RxSwift.framework in Frameworks */,
 				4B401B141D0454DC00D99EDC /* PureLayout.framework in Frameworks */,
 				4BDF50081D7607BF00D8FBC3 /* EonilFileSystemEvents.framework in Frameworks */,
@@ -522,6 +535,7 @@
 		4B2A2BE61D0225840074CE9A /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				4B337FBA1DEB76F20020ADD2 /* CocoaFontAwesome.framework */,
 				4BDD05691DB0CAB700D1B405 /* Sparkle.framework */,
 				4BDF50071D7607BF00D8FBC3 /* EonilFileSystemEvents.framework */,
 				4B56F29B1D29926600C1F92E /* Nimble.framework */,
diff --git a/VimR/Workspace/InnterToolBar.swift b/VimR/Workspace/InnterToolBar.swift
index d1f12125..402a15ee 100644
--- a/VimR/Workspace/InnterToolBar.swift
+++ b/VimR/Workspace/InnterToolBar.swift
@@ -5,6 +5,7 @@
 
 import Cocoa
 import PureLayout
+import CocoaFontAwesome
 
 /**
  This class is the base class for inner toolbars for workspace tools. It's got two default buttons:
@@ -15,6 +16,7 @@ class InnerToolBar: NSView {
 
   static fileprivate let separatorColor = NSColor.controlShadowColor
   static fileprivate let separatorThickness = CGFloat(1)
+  static fileprivate let iconDimension = CGFloat(18)
 
   required init?(coder: NSCoder) {
     fatalError("init(coder:) has not been implemented")
@@ -51,31 +53,40 @@ class InnerToolBar: NSView {
     }
   }
 
+  fileprivate func configureToStandardIconButton(button: NSButton, image: NSImage?) {
+    button.image = image
+    button.imagePosition = .imageOnly
+    button.isBordered = false
+    // The following disables the square appearing when pushed.
+    (button.cell as? NSButtonCell)?.highlightsBy = .contentsCellMask
+  }
+
   fileprivate func addViews() {
     let close = self.closeButton
     let cog = self.cogButton
 
-    close.imagePosition = .imageOnly
-    close.isBordered = false
+    self.configureToStandardIconButton(button: close,
+                                       image: NSImage.fontAwesomeIcon(code: "fa-times-circle",
+                                                                      textColor: .darkGray,
+                                                                      dimension: InnerToolBar.iconDimension))
 
-    cog.imagePosition = .imageOnly
-    cog.isBordered = false
+    self.configureToStandardIconButton(button: cog,
+                                       image: NSImage.fontAwesomeIcon(name: .cog,
+                                                                      textColor: .darkGray,
+                                                                      dimension: InnerToolBar.iconDimension))
 
     self.addSubview(close)
     self.addSubview(cog)
 
     close.autoPinEdge(toSuperviewEdge: .top, withInset: 2)
     close.autoPinEdge(toSuperviewEdge: .right, withInset: 2)
-    close.autoSetDimension(.width, toSize: 18)
-    close.autoSetDimension(.height, toSize: 18)
+    close.autoSetDimension(.width, toSize: InnerToolBar.iconDimension)
+    close.autoSetDimension(.height, toSize: InnerToolBar.iconDimension)
 
     cog.autoPinEdge(toSuperviewEdge: .top, withInset: 2)
     cog.autoPinEdge(.right, to: .left, of: close, withOffset: -2)
-    cog.autoSetDimension(.width, toSize: 18)
-    cog.autoSetDimension(.height, toSize: 18)
-
-    close.image = NSImage(named: NSImageNameStopProgressTemplate)
-    cog.image = NSImage(named: NSImageNameActionTemplate)
+    cog.autoSetDimension(.width, toSize: InnerToolBar.iconDimension)
+    cog.autoSetDimension(.height, toSize: InnerToolBar.iconDimension)
   }
 
   fileprivate func bottomSeparatorRect() -> CGRect {