Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Sengiri - OS X Application -

Sengiri - OS X Application -

nakajijapan

March 01, 2016
Tweet

More Decks by nakajijapan

Other Decks in Technology

Transcript

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

    View full-size slide

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

    View full-size slide

  3. NKJMultiMovieCaptureView
    NKJMovieComposer
    NKJPagerViewController
    PhotoSlider
    Teiten

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  6. shibuya.swift
    ͷ͖͔͚ͬ

    View full-size slide

  7. iOSɺMacɺApple
    TVɺApple Watch

    View full-size slide

  8. ͍Ζ͍Ζ࿩ͦ͏ʂ

    View full-size slide

  9. Sengiri
    OS X Application

    View full-size slide

  10. 0S X
    Application

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  13. ؆୯ʹ఻͍͑ͨ

    View full-size slide

  14. GIF
    (SBQIJDT*OUFSDIBOHF'PSNBU

    View full-size slide

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

    View full-size slide

  16. !LJDIJLVDIJ
    licecap!!!!!!!

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  19. Goal
    Stop
    SFDPSE
    Crop
    Record

    View full-size slide

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

    View full-size slide

  21. Mac Developer
    Library Document

    View full-size slide

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

    View full-size slide

  23. ಈըΛషΔ

    View full-size slide

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

    View full-size slide

  25. Screen Capture

    View full-size slide

  26. Screen Capture
    • AVCaptureScreenInput
    • CGDirectDisplayID

    View full-size slide

  27. Screen Capture
    "7$BQUVSF4FTTJPO
    AVCaptureDevice
    AVCaptureMovieFileOutput
    AVCaptureDeviceInput

    View full-size slide

  28. Screen Capture
    "7$BQUVSF4FTTJPO
    AVCaptureScreenInput
    AVCaptureMovieFileOutput

    View full-size slide

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

    View full-size slide

  30. CGDirectDisplayID

    View full-size slide

  31. Quartz Display
    Services Reference

    View full-size slide

  32. 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.

    View full-size slide

  33. CGMainDisplayID()

    View full-size slide

  34. Stop Recording

    View full-size slide

  35. Goal
    Stop
    SFDPSE
    Crop
    Record

    View full-size slide

  36. QuickTime Player

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  40. Goal
    Stop
    SFDPSE
    Crop
    Record

    View full-size slide

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

    View full-size slide

  42. Crop Window
    SFDPSE

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  45. 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 }

    View full-size slide

  46. Crop Window
    • NSWindowController
    • NSWindow
    • NSViewController
    • NSView

    View full-size slide

  47. ཧ૝
    Stop
    SFDPSE
    Crop
    cmd-t
    Record

    View full-size slide

  48. Crop Window
    • NSWindow
    • ignoresMouseEvents = true

    View full-size slide

  49. NSWindowController

    View full-size slide

  50. 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

    View full-size slide

  51. NSViewController

    View full-size slide

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

    View full-size slide

  53. OS X 10.10 Yosemite
    Release Notes Cocoa
    Application Framework

    View full-size slide

  54. Big Update!!!

    View full-size slide

  55. Big Update!!!

    View full-size slide

  56. 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

    View full-size slide

  57. NSViewController
    Window
    Window
    Window
    Window

    View full-size slide

  58. NSViewController
    Window

    View full-size slide

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

    View full-size slide

  60. Convert GIF
    AVAssetImageGenerator
    AVAsset
    GIF
    CGImageDestinationAddImage

    View full-size slide

  61. Pull request

    View full-size slide

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

    View full-size slide

  63. More Simple
    • Shortcut

    View full-size slide

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

    View full-size slide

  65. Quartz Window
    Services Reference

    View full-size slide

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

    View full-size slide

  67. Quartz Window Services Reference
    let windowInfosRef = CGWindowListCopyWindowInfo(
    [CGWindowListOption.OptionOnScreenOnly, CGWindowListOption.OptionOnScreenBelowWindow],
    windowID
    )
    var items = [Dictionary]()
    for i in 0..let lineUnsafePointer:UnsafePointer = 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)
    }

    View full-size slide

  68. Quartz Window Services Reference
    var topWindow:Dictionary
    let items = self.windowListAboveWindowID(CGWindowID(0))
    for i in 0..if items[i].isNormalWindow() {
    let item = items[i]
    topWindow = item
    break
    }
    }
    TFMGMBZFS$(8JOEPX-FWFM'PS,FZ /PSNBM8JOEPX-FWFM,FZ

    View full-size slide

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

    View full-size slide

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

    View full-size slide