Slide 1

Slide 1 text

Sengiri shibuya.swift #3 @nakajijapan OS X App

Slide 2

Slide 2 text

About Me

Slide 3

Slide 3 text

@nakajijapan Software Engineer GMO PEPABO inc. iOS / Web / OS X

Slide 4

Slide 4 text

NKJMultiMovieCaptureView NKJMovieComposer NKJPagerViewController PhotoSlider Teiten

Slide 5

Slide 5 text

GitHub

Slide 6

Slide 6 text

ϋϯυϝΠυ࡞඼Λ ചΕΔɺങ͑Δɻ ࠃ಺࠷େڃͷ ϋϯυϝΠυϚʔέοτ

Slide 7

Slide 7 text

500 ສDL ࠃ಺࠷େͷϋϯυϝΠυϚʔέοτ ࡞඼਺ 209ສ఺ ࡞Ո਺ 17.4ສਓ

Slide 8

Slide 8 text

ͦ΋ͦ΋

Slide 9

Slide 9 text

shibuya.swift ͷ͖͔͚ͬ

Slide 10

Slide 10 text

Swift

Slide 11

Slide 11 text

iOS

Slide 12

Slide 12 text

iOSɺMacɺApple TVɺApple Watch

Slide 13

Slide 13 text

͍Ζ͍Ζ࿩ͦ͏ʂ

Slide 14

Slide 14 text

Talk about

Slide 15

Slide 15 text

Sengiri

Slide 16

Slide 16 text

Sengiri OS X Application

Slide 17

Slide 17 text

ʁ

Slide 18

Slide 18 text

0S X Application

Slide 19

Slide 19 text

Problem

Slide 20

Slide 20 text

͜ͷΞχϝʔγϣϯͳΜ ͔ؾ࣋ͪΑ͘ͳ͍͔Β͜ ͏γϡοͯͯ͠΄͍͠

Slide 21

Slide 21 text

γϡο

Slide 22

Slide 22 text

Case • σβΠφʔ͞ΜͱͷΠϯλϥΫγϣϯνΣοΫ • ϨϏϡʔ࣌ͷόάใࠂ • ιʔε͚ͩ͡Όͳͯ͘ΠϯλϥΫγϣϯ΋ νΣοΫ͢Δ

Slide 23

Slide 23 text

؆୯ʹ఻͍͑ͨ

Slide 24

Slide 24 text

GIF (SBQIJDT*OUFSDIBOHF'PSNBU

Slide 25

Slide 25 text

ࠓ·Ͱ • QuickTimeΛىಈ • ۣܗͯ͠࿥ըྖҬΛઃఆ • ࿥ը • GIFʹม׵͢ΔΞϓϦΛىಈ • αΠζௐ੔ͯ͠ม׵ • อଘ

Slide 26

Slide 26 text

໘౗ष͍

Slide 27

Slide 27 text

!LJDIJLVDIJ licecap!!!!!!!

Slide 28

Slide 28 text

ࠓ·Ͱ 2 • licecapΛىಈ • ۣܗͯ͠࿥ըྖҬΛઃఆ • ϑΝΠϧ໊ɾϑϨʔϜϨʔτΛܾఆ͢Δ • ࿥ը • อଘ

Slide 29

Slide 29 text

΋͏Ұา

Slide 30

Slide 30 text

Goal • ࣗಈͰτοϓ΢Οϯυ΢͕ۣܗ • ۃྗγϣʔτΧοτͰ׬݁

Slide 31

Slide 31 text

Goal Stop SFDPSE Crop Record

Slide 32

Slide 32 text

ͳ͍ʂ

Slide 33

Slide 33 text

ཉ͔ͬͨ͠Β ࡞Ε͹͍͍

Slide 34

Slide 34 text

iOS?

Slide 35

Slide 35 text

Study

Slide 36

Slide 36 text

Mac Developer Library Document

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

Teiten Teiten is an app that fixed-point observation a lot earnestly yourself by using a PC camera. http://teiten.nakajijapan.net/

Slide 39

Slide 39 text

ಈըΛషΔ

Slide 40

Slide 40 text

Story

Slide 41

Slide 41 text

Story • ͲͷΑ͏ʹ࡞੒͍ͯ͘͠ͷ͔ • OS XͳΒͰ͸ͷ஌ࣝ

Slide 42

Slide 42 text

Screen Capture

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

Screen Capture • AVCaptureScreenInput • CGDirectDisplayID

Slide 45

Slide 45 text

Screen Capture "7$BQUVSF4FTTJPO AVCaptureDevice AVCaptureMovieFileOutput AVCaptureDeviceInput

Slide 46

Slide 46 text

Screen Capture "7$BQUVSF4FTTJPO AVCaptureScreenInput AVCaptureMovieFileOutput

Slide 47

Slide 47 text

Screen Capture let displayID = CGMainDisplayID() let captureInput = AVCaptureScreenInput(displayID: displayID) self.captureSession = AVCaptureSession() self.captureSession.addInput(captureInput) (snip…) self.captureSession.startRunning()

Slide 48

Slide 48 text

CGDirectDisplayID

Slide 49

Slide 49 text

Quartz Display Services Reference

Slide 50

Slide 50 text

Quartz Display Services Reference • provides direct access to certain low- level features in the OS X window server related to the configuration and control of display hardware.

Slide 51

Slide 51 text

CGMainDisplayID()

Slide 52

Slide 52 text

Stop Recording

Slide 53

Slide 53 text

Goal Stop SFDPSE Crop Record

Slide 54

Slide 54 text

QuickTime Player

Slide 55

Slide 55 text

NSMenu • ϝΠϯɺεςʔλεϝχϡʔ؅ཧ͢Δ • ࿥ըఀࢭ࣌ͷΠϯλʔϑΣʔεͱͯ͠ ༻ҙ͢Δ

Slide 56

Slide 56 text

Stop Recording • NSMenu • NSMenuDelegate • menuWillOpen(menu:NSMenu)

Slide 57

Slide 57 text

Stop Recording • NSMenuItem • Customize with view • NSProgressIndicator

Slide 58

Slide 58 text

Crop Window

Slide 59

Slide 59 text

Goal Stop SFDPSE Crop Record

Slide 60

Slide 60 text

Crop Window • ෆཁͳΠϯλʔϑΣʔεͷআ֎͢Δ • ࿥ը։࢝લ • windowͷҠಈΛڐՄ͢Δ • ࿥ը։࢝ޙ • Ϛ΢εΠϕϯτΛಁաʹ͢Δ

Slide 61

Slide 61 text

Crop Window SFDPSE

Slide 62

Slide 62 text

Crop Window എܠΛಁա WindowͷελΠϧͷઃఆ

Slide 63

Slide 63 text

Crop Window backgroundColor = NSColor.clearColor() opaque = false hasShadow = false self.styleMask = NSBorderlessWindowMask | NSResizableWindowMask

Slide 64

Slide 64 text

NSWindow.h /* NSWindow.h Application Kit Copyright (c) 1994-2015, Apple Inc. All rights reserved. */ public var NSBorderlessWindowMask: Int { get } public var NSTitledWindowMask: Int { get } public var NSClosableWindowMask: Int { get } public var NSMiniaturizableWindowMask: Int { get } public var NSResizableWindowMask: Int { get }

Slide 65

Slide 65 text

Crop Window • NSWindowController • NSWindow • NSViewController • NSView

Slide 66

Slide 66 text

ཧ૝ Stop SFDPSE Crop cmd-t Record

Slide 67

Slide 67 text

Crop Window • NSWindow • ignoresMouseEvents = true

Slide 68

Slide 68 text

Knowledge

Slide 69

Slide 69 text

NSWindowController

Slide 70

Slide 70 text

NSWindowController • manages a window, usually a window stored in a nib file. • Loading and displaying the window • Closing the window when appropriate • Customizing the window’s title • Storing the window’s frame (size and location) in the defaults database • Cascading the window in relation to other document windows of the application

Slide 71

Slide 71 text

NSViewController

Slide 72

Slide 72 text

• A view controller manages a view, typically loaded from a nib file. NSViewController

Slide 73

Slide 73 text

OS X 10.10 Yosemite Release Notes Cocoa Application Framework

Slide 74

Slide 74 text

Big Update!!!

Slide 75

Slide 75 text

Big Update!!!

Slide 76

Slide 76 text

NSViewController • Added OS X 10.5 • Prior to OS X 10.10 • View Controllers were not part of the responder chain. • View life cycle methods such as viewDidLoad(), viewWillAppear() • Cocoa did not provide any container view controllers • NSWindow’s contentViewController was not available • OS X 10.10 Yosemite Release Notes Cocoa Application Framework • Almost the same feature UIViewController for iOS • Storyboards • Container

Slide 77

Slide 77 text

NSViewController Window Window Window Window

Slide 78

Slide 78 text

NSViewController Window

Slide 79

Slide 79 text

Convert GIF

Slide 80

Slide 80 text

Convert GIF • AVAssetImageGenerator • CGImageDestinationSetProperties • CGImageDestinationCreateWithURL • CGImageDestinationAddImage

Slide 81

Slide 81 text

Convert GIF AVAssetImageGenerator AVAsset GIF CGImageDestinationAddImage

Slide 82

Slide 82 text

Regift

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

Pull request

Slide 85

Slide 85 text

Demo

Slide 86

Slide 86 text

More Simple

Slide 87

Slide 87 text

More Simple • Shortcut • Automatically crop a top window

Slide 88

Slide 88 text

More Simple • Shortcut

Slide 89

Slide 89 text

More Simple • Automatically crop a top window • MainScreen͔ΒWindow৘ใΛऔಘ • layer͔Βτοϓʹ͋ΔWindowΛಛ ఆ͢Δ

Slide 90

Slide 90 text

Quartz Window Services Reference

Slide 91

Slide 91 text

Quartz Window Services Reference • provides information about the windows managed by the OS X window server.

Slide 92

Slide 92 text

Quartz Window Services Reference let windowInfosRef = CGWindowListCopyWindowInfo( [CGWindowListOption.OptionOnScreenOnly, CGWindowListOption.OptionOnScreenBelowWindow], windowID ) var items = [Dictionary]() for i in 0.. = CFArrayGetValueAtIndex(windowInfosRef, i) let lineRef = unsafeBitCast(lineUnsafePointer, CFDictionaryRef.self) let dictionary = lineRef as Dictionary print((dictionary[kCGWindowLayer as String] as! NSNumber).integerValue) items.append(dictionary) }

Slide 93

Slide 93 text

Quartz Window Services Reference var topWindow:Dictionary let items = self.windowListAboveWindowID(CGWindowID(0)) for i in 0..

Slide 94

Slide 94 text

Demo

Slide 95

Slide 95 text

Task

Slide 96

Slide 96 text

Task • Icon • HotKey • Not good design • Border • Beep Sound

Slide 97

Slide 97 text

Sengiri

Slide 98

Slide 98 text

Sengiri is • OS X Application • ࠷খݶͷૢ࡞ͰGIFಈըΛ࡞੒͢Δ • ࢓ࣄޮ཰Խπʔϧ • OSS (coming soon…)

Slide 99

Slide 99 text

try! Swift

Slide 100

Slide 100 text

Thanks.