call: autohide controls ui
This commit adds a hide timeout on call controls when mouse is not moving.
This leaves a clean view to display the call.
Issue: #78354
Change-Id: I58e7cb14beec89fd9be68ce144057d8f476a8d98
diff --git a/src/CurrentCallVC.h b/src/CurrentCallVC.h
index 7000c55..2e4e2cf 100644
--- a/src/CurrentCallVC.h
+++ b/src/CurrentCallVC.h
@@ -36,7 +36,7 @@
class Call;
-@interface CurrentCallVC : NSViewController <NSSplitViewDelegate, FullScreenDelegate> {
+@interface CurrentCallVC : NSViewController <NSSplitViewDelegate, CallDelegate> {
}
diff --git a/src/CurrentCallVC.mm b/src/CurrentCallVC.mm
index d4e7026..fdb0a9d 100644
--- a/src/CurrentCallVC.mm
+++ b/src/CurrentCallVC.mm
@@ -71,6 +71,7 @@
@property (unsafe_unretained) IBOutlet NSButton *muteAudioButton;
@property (unsafe_unretained) IBOutlet NSButton *muteVideoButton;
@property (unsafe_unretained) IBOutlet NSButton *addContactButton;
+@property (unsafe_unretained) IBOutlet NSView *headerContainer;
@property (unsafe_unretained) IBOutlet ITProgressIndicator *loadingIndicator;
@@ -102,8 +103,7 @@
@implementation CurrentCallVC
@synthesize personLabel, actionHash, stateLabel, holdOnOffButton, hangUpButton,
recordOnOffButton, pickUpButton, chatButton, timeSpentLabel,
- muteVideoButton, muteAudioButton, controlsPanel, videoView,
- videoLayer, previewLayer, previewView, splitView, loadingIndicator;
+ muteVideoButton, muteAudioButton, controlsPanel, headerContainer, videoView, videoLayer, previewLayer, previewView, splitView, loadingIndicator;
@synthesize previewHolder;
@synthesize videoHolder;
@@ -179,8 +179,8 @@
break;
case Call::State::OVER:
[videoView setShouldAcceptInteractions:NO];
- if(videoView.isInFullScreenMode)
- [videoView exitFullScreenModeWithOptions:nil];
+ if(self.splitView.isInFullScreenMode)
+ [self.splitView exitFullScreenModeWithOptions:nil];
break;
case Call::State::FAILURE:
[videoView setShouldAcceptInteractions:NO];
@@ -235,7 +235,7 @@
[loadingIndicator setLengthOfLine:2];
[loadingIndicator setInnerMargin:30];
- [self.videoView setFullScreenDelegate:self];
+ [self.videoView setCallDelegate:self];
[self connect];
}
@@ -430,6 +430,10 @@
[animation setDuration:0.2f];
[animation setTimingFunction:[CAMediaTimingFunction functionWithControlPoints:.7 :0.9 :1 :1]];
[CATransaction setCompletionBlock:^{
+
+ // when call comes in we want to show the controls/header
+ [self mouseIsMoving:YES];
+
[self connectVideoSignals];
/* check if text media is already present */
if (CallModel::instance()->selectedCall()->hasMedia(Media::Media::Type::TEXT, Media::Media::Direction::IN)) {
@@ -642,7 +646,7 @@
}
-# pragma mark - FullScreenDelegate
+# pragma mark - CallnDelegate
- (void) callShouldToggleFullScreen
{
@@ -658,4 +662,10 @@
}
}
+-(void) mouseIsMoving:(BOOL) move
+{
+ [[controlsPanel animator] setAlphaValue:move]; // fade out
+ [[headerContainer animator] setAlphaValue:move];
+}
+
@end
diff --git a/src/views/CallView.h b/src/views/CallView.h
index b15d525..eac0984 100644
--- a/src/views/CallView.h
+++ b/src/views/CallView.h
@@ -29,12 +29,13 @@
*/
#import <Cocoa/Cocoa.h>
-@protocol FullScreenDelegate;
-@protocol FullScreenDelegate
+@protocol CallDelegate;
+@protocol CallDelegate
@optional
-(void) callShouldToggleFullScreen;
+-(void) mouseIsMoving:(BOOL) move;
@end
@@ -54,6 +55,6 @@
/**
* Delegate to inform about desire to move
*/
-@property (nonatomic) id <FullScreenDelegate> fullScreenDelegate;
+@property (nonatomic) id <CallDelegate> callDelegate;
@end
diff --git a/src/views/CallView.mm b/src/views/CallView.mm
index 8fe60c6..e75ef3a 100644
--- a/src/views/CallView.mm
+++ b/src/views/CallView.mm
@@ -59,6 +59,17 @@
{
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
}
+
+ [self.window setAcceptsMouseMovedEvents:YES];
+
+ NSTrackingAreaOptions options = (NSTrackingActiveAlways | NSTrackingInVisibleRect | NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved);
+
+ NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:frame
+ options:options
+ owner:self
+ userInfo:nil];
+
+ [self addTrackingArea:area];
return self;
}
@@ -178,6 +189,21 @@
[NSMenu popUpContextMenu:contextualMenu withEvent:theEvent forView:self];
}
+- (void)mouseMoved:(NSEvent *)theEvent
+{
+ [NSObject cancelPreviousPerformRequestsWithTarget:self]; // cancel showContextualMenu
+ [self performSelector:@selector(mouseIdle:) withObject:theEvent afterDelay:3];
+ if (self.callDelegate)
+ [self.callDelegate mouseIsMoving:YES];
+}
+
+- (void) mouseIdle:(NSEvent *)theEvent
+{
+ if (self.callDelegate && shouldAcceptInteractions)
+ [self.callDelegate mouseIsMoving:NO];
+}
+
+
- (void)mouseUp:(NSEvent *)theEvent
{
if([theEvent clickCount] == 1 && shouldAcceptInteractions) {
@@ -189,8 +215,8 @@
else if([theEvent clickCount] == 2)
{
[NSObject cancelPreviousPerformRequestsWithTarget:self]; // cancel showContextualMenu
- if(self.fullScreenDelegate)
- [self.fullScreenDelegate callShouldToggleFullScreen];
+ if(self.callDelegate)
+ [self.callDelegate callShouldToggleFullScreen];
}
}
diff --git a/ui/CurrentCall.xib b/ui/CurrentCall.xib
index 91e3591..ff13abc 100644
--- a/ui/CurrentCall.xib
+++ b/ui/CurrentCall.xib
@@ -11,6 +11,7 @@
<outlet property="chatVC" destination="LWe-df-dS6" id="SMR-T0-fYe"/>
<outlet property="controlsPanel" destination="Eoi-B8-iL6" id="4xn-3b-SNn"/>
<outlet property="hangUpButton" destination="Kjq-iM-NBL" id="Puz-4L-Okl"/>
+ <outlet property="headerContainer" destination="d0X-cW-Xgz" id="7RM-kh-vCm"/>
<outlet property="holdOnOffButton" destination="anb-Y8-JQi" id="HSl-pE-Kwg"/>
<outlet property="loadingIndicator" destination="JwW-2h-DyZ" id="EEb-50-oSJ"/>
<outlet property="muteAudioButton" destination="tQl-cT-0Lb" id="qV4-Ef-UTx"/>