1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-04-09 15:39:08 +00:00

It's a bit jarring, but ensures volume control shows and hides according to mouse cursor.

This commit is contained in:
Thomas Harte 2020-03-22 16:25:07 -04:00
parent 7398cb44e2
commit 442ce403f9
5 changed files with 26 additions and 2 deletions
OSBindings/Mac
Clock Signal.xcodeproj/xcshareddata/xcschemes
Clock Signal

@ -67,7 +67,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableASanStackUseAfterReturn = "YES"

@ -29,7 +29,7 @@
<openGLView hidden="YES" wantsLayer="YES" useAuxiliaryDepthBufferStencil="NO" allowOffline="YES" wantsBestResolutionOpenGLSurface="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DEG-fq-cjd" customClass="CSOpenGLView">
<rect key="frame" x="0.0" y="0.0" width="600" height="450"/>
</openGLView>
<box boxType="custom" cornerRadius="4" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="4ap-Gi-2AO">
<box hidden="YES" boxType="custom" cornerRadius="4" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="4ap-Gi-2AO">
<rect key="frame" x="150" y="20" width="300" height="48"/>
<view key="contentView" id="gwO-Ty-LCX">
<rect key="frame" x="1" y="1" width="298" height="46"/>

@ -722,4 +722,14 @@ class MachineDocument:
machine.setVolume(sender.floatValue);
}
}
func openGLViewDidShowOSMouseCursor(_ view: CSOpenGLView) {
// The OS mouse cursor became visible, so show the volume controls.
volumeView.isHidden = false
}
func openGLViewWillHideOSMouseCursor(_ view: CSOpenGLView) {
// The OS mouse cursor will be hidden, so hide the volume controls.
volumeView.isHidden = true
}
}

@ -50,6 +50,18 @@ typedef NS_ENUM(NSInteger, CSOpenGLViewRedrawEvent) {
*/
- (void)openGLViewDidReleaseMouse:(nonnull CSOpenGLView *)view;
/*!
Announces that the OS mouse cursor is now being displayed again, after having been invisible.
@param view The view making the announcement.
*/
- (void)openGLViewDidShowOSMouseCursor:(nonnull CSOpenGLView *)view;
/*!
Announces that the OS mouse cursor will now be hidden.
@param view The view making the announcement.
*/
- (void)openGLViewWillHideOSMouseCursor:(nonnull CSOpenGLView *)view;
@end
@protocol CSOpenGLViewResponderDelegate <NSObject>

@ -288,10 +288,12 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
- (void)scheduleMouseHide {
if(!self.shouldCaptureMouse) {
[self.delegate openGLViewDidShowOSMouseCursor:self];
[_mouseHideTimer invalidate];
_mouseHideTimer = [NSTimer scheduledTimerWithTimeInterval:3.0 repeats:NO block:^(NSTimer * _Nonnull timer) {
[NSCursor setHiddenUntilMouseMoves:YES];
[self.delegate openGLViewWillHideOSMouseCursor:self];
}];
}
}