Sengiri - OS X Application -

Sengiri - OS X Application -

A77456b262557e22986345f6d0555c58?s=128

nakajijapan

March 01, 2016
Tweet

Transcript

  1. Sengiri shibuya.swift #3 @nakajijapan OS X App

  2. About Me

  3. @nakajijapan Software Engineer GMO PEPABO inc. iOS / Web /

    OS X
  4. NKJMultiMovieCaptureView NKJMovieComposer NKJPagerViewController PhotoSlider Teiten

  5. GitHub

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

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

  8. ͦ΋ͦ΋

  9. shibuya.swift ͷ͖͔͚ͬ

  10. Swift

  11. iOS

  12. iOSɺMacɺApple TVɺApple Watch

  13. ͍Ζ͍Ζ࿩ͦ͏ʂ

  14. Talk about

  15. Sengiri

  16. Sengiri OS X Application

  17. ʁ

  18. 0S X Application

  19. Problem

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

  21. γϡο

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

  23. ؆୯ʹ఻͍͑ͨ

  24. GIF (SBQIJDT*OUFSDIBOHF'PSNBU

  25. ࠓ·Ͱ • QuickTimeΛىಈ • ۣܗͯ͠࿥ըྖҬΛઃఆ • ࿥ը • GIFʹม׵͢ΔΞϓϦΛىಈ •

    αΠζௐ੔ͯ͠ม׵ • อଘ
  26. ໘౗ष͍

  27. !LJDIJLVDIJ licecap!!!!!!!

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

    • อଘ
  29. ΋͏Ұา

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

  31. Goal Stop SFDPSE Crop Record

  32. ͳ͍ʂ

  33. ཉ͔ͬͨ͠Β ࡞Ε͹͍͍

  34. iOS?

  35. Study

  36. Mac Developer Library Document

  37. None
  38. Teiten Teiten is an app that fixed-point observation a lot

    earnestly yourself by using a PC camera. http://teiten.nakajijapan.net/
  39. ಈըΛషΔ

  40. Story

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

  42. Screen Capture

  43. None
  44. Screen Capture • AVCaptureScreenInput • CGDirectDisplayID

  45. Screen Capture "7$BQUVSF4FTTJPO AVCaptureDevice AVCaptureMovieFileOutput AVCaptureDeviceInput

  46. Screen Capture "7$BQUVSF4FTTJPO AVCaptureScreenInput AVCaptureMovieFileOutput

  47. Screen Capture let displayID = CGMainDisplayID() let captureInput = AVCaptureScreenInput(displayID:

    displayID) self.captureSession = AVCaptureSession() self.captureSession.addInput(captureInput) (snip…) self.captureSession.startRunning()
  48. CGDirectDisplayID

  49. Quartz Display Services Reference

  50. 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.
  51. CGMainDisplayID()

  52. Stop Recording

  53. Goal Stop SFDPSE Crop Record

  54. QuickTime Player

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

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

  57. Stop Recording • NSMenuItem • Customize with view • NSProgressIndicator

  58. Crop Window

  59. Goal Stop SFDPSE Crop Record

  60. Crop Window • ෆཁͳΠϯλʔϑΣʔεͷআ֎͢Δ • ࿥ը։࢝લ • windowͷҠಈΛڐՄ͢Δ • ࿥ը։࢝ޙ

    • Ϛ΢εΠϕϯτΛಁաʹ͢Δ
  61. Crop Window SFDPSE

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

  63. Crop Window backgroundColor = NSColor.clearColor() opaque = false hasShadow =

    false self.styleMask = NSBorderlessWindowMask | NSResizableWindowMask
  64. 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 }
  65. Crop Window • NSWindowController • NSWindow • NSViewController • NSView

  66. ཧ૝ Stop SFDPSE Crop cmd-t Record

  67. Crop Window • NSWindow • ignoresMouseEvents = true

  68. Knowledge

  69. NSWindowController

  70. 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
  71. NSViewController

  72. • A view controller manages a view, typically loaded from

    a nib file. NSViewController
  73. OS X 10.10 Yosemite Release Notes Cocoa Application Framework

  74. Big Update!!!

  75. Big Update!!!

  76. 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
  77. NSViewController Window Window Window Window

  78. NSViewController Window

  79. Convert GIF

  80. Convert GIF • AVAssetImageGenerator • CGImageDestinationSetProperties • CGImageDestinationCreateWithURL • CGImageDestinationAddImage

  81. Convert GIF AVAssetImageGenerator AVAsset GIF CGImageDestinationAddImage

  82. Regift

  83. None
  84. Pull request

  85. Demo

  86. More Simple

  87. More Simple • Shortcut • Automatically crop a top window

  88. More Simple • Shortcut

  89. More Simple • Automatically crop a top window • MainScreen͔ΒWindow৘ใΛऔಘ

    • layer͔Βτοϓʹ͋ΔWindowΛಛ ఆ͢Δ
  90. Quartz Window Services Reference

  91. Quartz Window Services Reference • provides information about the windows

    managed by the OS X window server.
  92. Quartz Window Services Reference let windowInfosRef = CGWindowListCopyWindowInfo( [CGWindowListOption.OptionOnScreenOnly, CGWindowListOption.OptionOnScreenBelowWindow],

    windowID ) var items = [Dictionary<NSObject, AnyObject>]() for i in 0..<CFArrayGetCount(windowInfosRef) { let lineUnsafePointer:UnsafePointer<Void> = CFArrayGetValueAtIndex(windowInfosRef, i) let lineRef = unsafeBitCast(lineUnsafePointer, CFDictionaryRef.self) let dictionary = lineRef as Dictionary<NSObject, AnyObject> print((dictionary[kCGWindowLayer as String] as! NSNumber).integerValue) items.append(dictionary) }
  93. Quartz Window Services Reference var topWindow:Dictionary<NSObject, AnyObject> let items =

    self.windowListAboveWindowID(CGWindowID(0)) for i in 0..<items.count { if items[i].isNormalWindow() { let item = items[i] topWindow = item break } } TFMGMBZFS$(8JOEPX-FWFM'PS,FZ /PSNBM8JOEPX-FWFM,FZ
  94. Demo

  95. Task

  96. Task • Icon • HotKey • Not good design •

    Border • Beep Sound
  97. Sengiri

  98. Sengiri is • OS X Application • ࠷খݶͷૢ࡞ͰGIFಈըΛ࡞੒͢Δ • ࢓ࣄޮ཰Խπʔϧ

    • OSS (coming soon…)
  99. try! Swift

  100. Thanks.