This commit is contained in:
A. Vatsaev 2016-12-05 23:20:22 +01:00
parent 1c98a4b4d9
commit 1678ee140a
14 changed files with 49 additions and 30 deletions

View file

@ -15,9 +15,6 @@
A362A10D1DCE6D6B00737197 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A362A10B1DCE6D6B00737197 /* Main.storyboard */; };
A3826CDA1DCE79B900B7C41E /* NyanCatCanvas.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3826CD91DCE79B900B7C41E /* NyanCatCanvas.swift */; };
A3826CDC1DCE7B5000B7C41E /* NyanCatCanvas.xib in Resources */ = {isa = PBXBuildFile; fileRef = A3826CDB1DCE7B5000B7C41E /* NyanCatCanvas.xib */; };
A3A050DC1DCE96BD009D9775 /* nyan_music.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = A3A050DB1DCE96BD009D9775 /* nyan_music.mp3 */; };
A3A050E01DCE9E03009D9775 /* icon.png in Resources */ = {isa = PBXBuildFile; fileRef = A3A050DF1DCE9E03009D9775 /* icon.png */; };
A3A050E41DCEAB08009D9775 /* nyan_long@2x.gif in Resources */ = {isa = PBXBuildFile; fileRef = A3A050E31DCEAB08009D9775 /* nyan_long@2x.gif */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -31,9 +28,6 @@
A362A10E1DCE6D6B00737197 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A3826CD91DCE79B900B7C41E /* NyanCatCanvas.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NyanCatCanvas.swift; sourceTree = "<group>"; };
A3826CDB1DCE7B5000B7C41E /* NyanCatCanvas.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NyanCatCanvas.xib; sourceTree = "<group>"; };
A3A050DB1DCE96BD009D9775 /* nyan_music.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = nyan_music.mp3; sourceTree = "<group>"; };
A3A050DF1DCE9E03009D9775 /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon.png; sourceTree = "<group>"; };
A3A050E31DCEAB08009D9775 /* nyan_long@2x.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = "nyan_long@2x.gif"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -84,8 +78,6 @@
children = (
A34053A11DCF56600081ABF1 /* ic_volume_off_3x.png */,
A34053A31DCF56640081ABF1 /* ic_volume_up_3x.png */,
A3A050E31DCEAB08009D9775 /* nyan_long@2x.gif */,
A3A050DF1DCE9E03009D9775 /* icon.png */,
);
name = img;
sourceTree = "<group>";
@ -93,7 +85,6 @@
A3A050DA1DCE96B2009D9775 /* sound */ = {
isa = PBXGroup;
children = (
A3A050DB1DCE96BD009D9775 /* nyan_music.mp3 */,
);
name = sound;
sourceTree = "<group>";
@ -159,12 +150,9 @@
buildActionMask = 2147483647;
files = (
A3826CDC1DCE7B5000B7C41E /* NyanCatCanvas.xib in Resources */,
A3A050E01DCE9E03009D9775 /* icon.png in Resources */,
A3A050DC1DCE96BD009D9775 /* nyan_music.mp3 in Resources */,
A362A10A1DCE6D6B00737197 /* Assets.xcassets in Resources */,
A362A10D1DCE6D6B00737197 /* Main.storyboard in Resources */,
A34053A21DCF56600081ABF1 /* ic_volume_off_3x.png in Resources */,
A3A050E41DCEAB08009D9775 /* nyan_long@2x.gif in Resources */,
A34053A41DCF56640081ABF1 /* ic_volume_up_3x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;

View file

@ -21,39 +21,33 @@
"scale" : "2x"
},
{
"size" : "128x128",
"idiom" : "mac",
"filename" : "touchbar_nyancat_icon_128@2x.png",
"size" : "128x128",
"scale" : "1x"
},
{
"size" : "128x128",
"idiom" : "mac",
"filename" : "touchbar_nyancat_icon_256@2x-2.png",
"size" : "128x128",
"scale" : "2x"
},
{
"size" : "256x256",
"idiom" : "mac",
"filename" : "touchbar_nyancat_icon_256@2x-1.png",
"size" : "256x256",
"scale" : "1x"
},
{
"size" : "256x256",
"idiom" : "mac",
"filename" : "touchbar_nyancat_icon_512@2x-2.png",
"size" : "256x256",
"scale" : "2x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "touchbar_nyancat_icon_512@2x-1.png",
"size" : "512x512",
"scale" : "1x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "touchbar_nyancat_icon@2x 2.png",
"size" : "512x512",
"scale" : "2x"
}
],

Binary file not shown.

Before

Width:  |  Height:  |  Size: 295 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 KiB

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2657" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2659" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaDFRPlugin" version="7104"/>
@ -16,7 +16,7 @@
<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="196" y="240" width="480" height="270"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="878"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1028"/>
<value key="minSize" type="size" width="480" height="270"/>
<value key="maxSize" type="size" width="480" height="270"/>
</window>
@ -113,6 +113,7 @@
</view>
<connections>
<outlet property="bkg" destination="iUM-SV-UtP" id="Y8L-Wa-nPi"/>
<outlet property="muteBtn" destination="uCH-1A-AJh" id="AdG-ie-hNs"/>
<outlet property="sound_btn" destination="Uwj-zc-KXn" id="jky-Ou-f9G"/>
</connections>
</viewController>

View file

@ -9,6 +9,9 @@
import Cocoa
class NyanCatCanvas: NSImageView {
var imageLoaded:Bool = false;
var xPosition: CGFloat = 0 {
didSet {
@ -20,9 +23,14 @@ class NyanCatCanvas: NSImageView {
super.draw(dirtyRect)
// Drawing code here.
self.animates = true
self.image = NSImage(named: "nyan_long@2x.gif")!
if(!self.imageLoaded){
self.downloadImage()
}
self.canDrawSubviewsIntoLayer = true
self.frame = CGRect(x: xPosition, y: 0, width: 685, height: 30)
}
@ -32,6 +40,33 @@ class NyanCatCanvas: NSImageView {
//super.touchesBegan(with: event)
}
override func didAddSubview(_ subview: NSView) {
}
func downloadImage() {
let url = URL(string: "https://i.imgur.com/7pgdK28.gif")
getDataFromUrl(url: url!) { (data, response, error) in
guard let data = data, error == nil else { return }
DispatchQueue.main.async() { () -> Void in
self.image = NSImage(data: data)
self.imageLoaded = true;
}
}
}
func getDataFromUrl(url: URL, completion: @escaping (_ data: Data?, _ response: URLResponse?, _ error: Error?) -> Void) {
URLSession.shared.dataTask(with: url) {
(data, response, error) in
completion(data, response, error)
}.resume()
}
override func touchesMoved(with event: NSEvent) {
if #available(OSX 10.12.1, *) {
let current = event.allTouches().first?.location(in: self).x ?? 0

View file

@ -15,6 +15,7 @@ class NyanCatViewController: NSViewController , NSTouchBarDelegate{
var audio_player: AVAudioPlayer?
@IBOutlet weak var muteBtn: NSButton!
//NOTE: I fucking love Swift's computed properties!
var sound: Bool = true {
@ -35,7 +36,6 @@ class NyanCatViewController: NSViewController , NSTouchBarDelegate{
var sound_btn_image_on: NSImage?
var sound_btn_image_off: NSImage?
@IBOutlet weak var sound_btn: NSButtonCell!
@IBOutlet weak var bkg: NSView!
@ -44,6 +44,7 @@ class NyanCatViewController: NSViewController , NSTouchBarDelegate{
super.viewDidLoad()
self.view.wantsLayer = true
self.muteBtn.isHidden = true
}
@ -72,7 +73,7 @@ class NyanCatViewController: NSViewController , NSTouchBarDelegate{
}catch{}
sound = true
//sound = true
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.