Skip to content

Commit

Permalink
Merge pull request #1 from mzp/keep-an-eye-on-idol
Browse files Browse the repository at this point in the history
Add "Viewer Above Other Apps" menu item
  • Loading branch information
banjun authored Nov 5, 2017
2 parents 961d736 + a63b82e commit 37c5f1c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions PhotoStudioPlayer/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

@objc var viewerAboveOtherApps = false {
didSet {
NotificationCenter.default.post(name: AppDelegate.AppGlobalStateDidChange, object: self)
}
}

func applicationDidFinishLaunching(_ aNotification: Notification) {
}
}
7 changes: 7 additions & 0 deletions PhotoStudioPlayer/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,13 @@ DQ
<action selector="toggleFullScreen:" target="Ady-hI-5gd" id="dU3-MA-1Rq"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="JBn-BL-tys"/>
<menuItem title="Viewer Above Other Apps" id="XJm-T0-exO" userLabel="Viewer Above Other Apps">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<binding destination="Voe-Tx-rLC" name="value" keyPath="viewerAboveOtherApps" id="Nrt-A4-6p3"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
Expand Down
9 changes: 9 additions & 0 deletions PhotoStudioPlayer/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ViewController: NSViewController, AVCaptureVideoDataOutputSampleBufferDele

NotificationCenter.default.addObserver(forName: AppDelegate.AppGlobalStateDidChange, object: nil, queue: nil) { [weak self] _ in
self?.readyCaptureFrameIfNeeded()
self?.changeWindowLevelIfNeeded()
}
}

Expand Down Expand Up @@ -125,6 +126,14 @@ class ViewController: NSViewController, AVCaptureVideoDataOutputSampleBufferDele
}
}

private func changeWindowLevelIfNeeded() {
if appDelegate.viewerAboveOtherApps {
view.window?.level = .floating
} else {
view.window?.level = .normal
}
}

@IBAction func captureCurrentFrame(_ sender: AnyObject?) {
videoDataQueue.sync {numberOfCapturesNeeded += 1}
}
Expand Down

0 comments on commit 37c5f1c

Please sign in to comment.