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

Use nib for the main window

- this way we get the cascading for free...
- add some helping text in the app window
This commit is contained in:
Tae Won Ha 2016-07-11 17:56:55 +02:00
parent c54e673e9c
commit a59f5e3176
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
5 changed files with 76 additions and 32 deletions

View File

@ -31,6 +31,7 @@
4B570DC21D303CAF006EDC21 /* NeoVimAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B570DC01D303CAF006EDC21 /* NeoVimAgent.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B570DC31D303CAF006EDC21 /* NeoVimAgent.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B570DC11D303CAF006EDC21 /* NeoVimAgent.m */; };
4B854A1D1D31447C00E08DE1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B854A1C1D31447C00E08DE1 /* main.m */; };
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, ); }; };
4B9A15251D2993DA009F9F67 /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B56F29C1D29926600C1F92E /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
4B9A15261D2993DF009F9F67 /* SwiftNeoVim.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B2A2BF71D0351810074CE9A /* SwiftNeoVim.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@ -179,6 +180,7 @@
4B7BD3321D32530900AAA45E /* Logging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Logging.h; sourceTree = "<group>"; };
4B854A1A1D31447C00E08DE1 /* NeoVimServer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = NeoVimServer; sourceTree = BUILT_PRODUCTS_DIR; };
4B854A1C1D31447C00E08DE1 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
4B97E2CD1D33F53D00FC0660 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainWindow.xib; sourceTree = "<group>"; };
4BCADE071D11ED12004DAD0F /* CocoaExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CocoaExtensions.swift; sourceTree = "<group>"; };
4BCF638F1D323CFD00F15CE4 /* nvim */ = {isa = PBXFileReference; lastKnownFileType = folder; name = nvim; path = neovim/src/nvim; sourceTree = SOURCE_ROOT; };
4BD3BF921D32A95800082605 /* MainWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainWindowController.swift; sourceTree = "<group>"; };
@ -337,6 +339,17 @@
path = NeoVimServer;
sourceTree = "<group>";
};
4B97E2CF1D33F92200FC0660 /* resources */ = {
isa = PBXGroup;
children = (
4BEBA50C1CFF374B00673FDF /* MainMenu.xib */,
4B97E2CE1D33F53D00FC0660 /* MainWindow.xib */,
4BEBA50A1CFF374B00673FDF /* Assets.xcassets */,
4BEBA50F1CFF374B00673FDF /* Info.plist */,
);
name = resources;
sourceTree = "<group>";
};
4BDCFADC1D3145EA00F62670 /* lib */ = {
isa = PBXGroup;
children = (
@ -383,9 +396,7 @@
4BEBA5081CFF374B00673FDF /* AppDelegate.swift */,
4BD3BF961D32B0DB00082605 /* MainWindowManager.swift */,
4BD3BF921D32A95800082605 /* MainWindowController.swift */,
4BEBA50A1CFF374B00673FDF /* Assets.xcassets */,
4BEBA50C1CFF374B00673FDF /* MainMenu.xib */,
4BEBA50F1CFF374B00673FDF /* Info.plist */,
4B97E2CF1D33F92200FC0660 /* resources */,
4B2A2C0D1D0353750074CE9A /* Bridge.h */,
);
path = nvox;
@ -602,6 +613,7 @@
files = (
4BEBA50B1CFF374B00673FDF /* Assets.xcassets in Resources */,
4BEBA50E1CFF374B00673FDF /* MainMenu.xib in Resources */,
4B97E2CC1D33F53D00FC0660 /* MainWindow.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -715,6 +727,14 @@
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
4B97E2CE1D33F53D00FC0660 /* MainWindow.xib */ = {
isa = PBXVariantGroup;
children = (
4B97E2CD1D33F53D00FC0660 /* Base */,
);
name = MainWindow.xib;
sourceTree = "<group>";
};
4BEBA50C1CFF374B00673FDF /* MainMenu.xib */ = {
isa = PBXVariantGroup;
children = (

View File

@ -687,17 +687,27 @@
</menuItem>
</items>
</menu>
<window title="nvox" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
<window title="VimR" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="430" height="332"/>
<rect key="contentRect" x="335" y="390" width="165" height="125"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
<value key="minSize" type="size" width="240" height="140"/>
<view key="contentView" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="430" height="332"/>
<rect key="frame" x="0.0" y="0.0" width="165" height="125"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Z3E-Xb-Y41">
<rect key="frame" x="18" y="20" width="129" height="85"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Very early release of VimR with NeoVim backend⌘-N to get started!" id="SJI-z6-rr0">
<font key="font" metaFont="systemBold"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
<point key="canvasLocation" x="308" y="401"/>
<point key="canvasLocation" x="-33.5" y="178.5"/>
</window>
</objects>
</document>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="MainWindowController" customModule="nvox" customModuleProvider="target">
<connections>
<outlet property="window" destination="QvC-M9-y7g" id="Xb2-mB-2h2"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="VimR" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="140" y="800" width="320" height="240"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
<value key="minSize" type="size" width="280" height="120"/>
<view key="contentView" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="320" height="240"/>
<autoresizingMask key="autoresizingMask"/>
</view>
<connections>
<outlet property="delegate" destination="-2" id="zSW-LT-joY"/>
</connections>
<point key="canvasLocation" x="483.5" y="413.5"/>
</window>
</objects>
</document>

View File

@ -12,30 +12,17 @@ class MainWindowController: NSWindowController, NSWindowDelegate {
return self.neoVimView.uuid
}
weak var mainWindowManager: MainWindowManager?
private weak var mainWindowManager: MainWindowManager?
private let neoVimView = NeoVimView(forAutoLayout: ())
init(contentRect: CGRect, manager: MainWindowManager) {
func setup(manager manager: MainWindowManager) {
self.mainWindowManager = manager
let style = NSTitledWindowMask | NSUnifiedTitleAndToolbarWindowMask | NSTexturedBackgroundWindowMask |
NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask
let window = NSWindow(contentRect: contentRect, styleMask: style, backing: .Buffered, defer: true)
super.init(window: window)
window.delegate = self
window.hasShadow = true
window.title = "nvox"
window.opaque = false
window.animationBehavior = .DocumentWindow
self.addViews()
self.window?.makeFirstResponder(self.neoVimView)
}
func windowWillClose(notification: NSNotification) {
self.neoVimView.cleanUp()
self.mainWindowManager?.closeMainWindow(self)
@ -45,8 +32,4 @@ class MainWindowController: NSWindowController, NSWindowDelegate {
self.window?.contentView?.addSubview(self.neoVimView)
self.neoVimView.autoPinEdgesToSuperviewEdges()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

View File

@ -10,11 +10,11 @@ class MainWindowManager {
private var mainWindowControllers: [String: MainWindowController] = [:]
func newMainWindow() {
let mainWindowController = MainWindowController(contentRect: CGRect(x: 100, y: 100, width: 320, height: 240),
manager: self)
mainWindowController.showWindow(self)
let mainWindowController = MainWindowController(windowNibName: "MainWindow")
self.mainWindowControllers[mainWindowController.uuid] = mainWindowController
mainWindowController.setup(manager: self)
mainWindowController.showWindow(self)
}
func closeMainWindow(mainWindowController: MainWindowController) {