Skip to content
Snippets Groups Projects
Commit 2aa39237 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk
Browse files

UI: call view fixes

Change-Id: I561174a9b114833ba8c501c45c65995fd3b6d5b1
parent fbe1b2f8
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,7 @@ extern "C" {
// Header info
@property (unsafe_unretained) IBOutlet NSView* headerContainer;
@property (unsafe_unretained) IBOutlet NSView* headerGradientView;
@property (unsafe_unretained) IBOutlet NSTextField* timeSpentLabel;
// info
......@@ -80,6 +81,7 @@ extern "C" {
// Call Controls
@property (unsafe_unretained) IBOutlet GradientView* controlsPanel;
@property (unsafe_unretained) IBOutlet NSStackView* controlsStackView;
@property (unsafe_unretained) IBOutlet IconButton* holdOnOffButton;
@property (unsafe_unretained) IBOutlet IconButton* hangUpButton;
......@@ -116,11 +118,10 @@ lrc::api::AVModel* mediaModel;
NSInteger const PREVIEW_WIDTH = 185;
NSInteger const PREVIEW_HEIGHT = 130;
NSInteger const HIDE_PREVIEW_BUTTON_MIN_SIZE = 25;
NSInteger const HIDE_PREVIEW_BUTTON_MAX_SIZE = 35;
NSInteger const HIDE_PREVIEW_BUTTON_SIZE = 25;
NSInteger const PREVIEW_MARGIN = 20;
@synthesize holdOnOffButton, hangUpButton, recordOnOffButton, pickUpButton, chatButton, transferButton, addParticipantButton, timeSpentLabel, muteVideoButton, muteAudioButton, controlsPanel, headerContainer, videoView, previewView, splitView, loadingIndicator, backgroundImage, bluerBackgroundEffect, hidePreviewButton, hidePreviewBackground, movableBaseForView, infoContainer, contactPhoto, contactNameLabel, callStateLabel, contactIdLabel, cancelCallButton;
@synthesize holdOnOffButton, hangUpButton, recordOnOffButton, pickUpButton, chatButton, transferButton, addParticipantButton, timeSpentLabel, muteVideoButton, muteAudioButton, controlsPanel, headerContainer, videoView, previewView, splitView, loadingIndicator, backgroundImage, bluerBackgroundEffect, hidePreviewButton, hidePreviewBackground, movableBaseForView, infoContainer, contactPhoto, contactNameLabel, callStateLabel, contactIdLabel, cancelCallButton, headerGradientView, controlsStackView;
@synthesize renderConnections;
CVPixelBufferPoolRef pixelBufferPoolDistantView;
......@@ -172,7 +173,8 @@ CVPixelBufferRef pixelBufferPreview;
movableBaseForView.frame = CGRectMake(previewOrigin.x, previewOrigin.y, PREVIEW_WIDTH, PREVIEW_HEIGHT);
self.movableBaseForView.movable = true;
previewView.frame = movableBaseForView.bounds;
hidePreviewBackground.frame = [self frameForExpendPreviewButton: false];;
hidePreviewBackground.frame = [self frameForExpendPreviewButton];
hidePreviewButton.contentTintColor = [NSColor blackColor];
}
- (void)awakeFromNib
......@@ -188,19 +190,25 @@ CVPixelBufferRef pixelBufferPreview;
[loadingIndicator setInnerMargin:59];
[self.videoView setCallDelegate:self];
CGColor* color = [[[NSColor blackColor] colorWithAlphaComponent:0.2] CGColor];
[headerContainer.layer setBackgroundColor:color];
[bluerBackgroundEffect setWantsLayer:YES];
bluerBackgroundEffect.alphaValue = 0.6;
[backgroundImage setWantsLayer: YES];
backgroundImage.layer.contentsGravity = kCAGravityResizeAspectFill;
movableBaseForView.wantsLayer = YES;
movableBaseForView.layer.cornerRadius = 4;
movableBaseForView.layer.masksToBounds = true;
movableBaseForView.shadow = [[NSShadow alloc] init];
movableBaseForView.layer.shadowOpacity = 0.6;
movableBaseForView.layer.shadowColor = [[NSColor blackColor] CGColor];
movableBaseForView.layer.shadowOffset = NSMakeSize(0, -3);
movableBaseForView.layer.shadowRadius = 10;
previewView.wantsLayer = YES;
previewView.layer.cornerRadius = 5;
previewView.layer.masksToBounds = true;
hidePreviewBackground.wantsLayer = YES;
hidePreviewBackground.layer.cornerRadius = 5;
hidePreviewBackground.layer.maskedCorners = kCALayerMinXMinYCorner;
hidePreviewBackground.layer.masksToBounds = true;
movableBaseForView.hostingView = self.videoView;
[movableBaseForView setAutoresizingMask: NSViewNotSizable | NSViewMaxXMargin | NSViewMaxYMargin | NSViewMinXMargin | NSViewMinYMargin];
[previewView setAutoresizingMask: NSViewNotSizable | NSViewMaxXMargin | NSViewMaxYMargin | NSViewMinXMargin | NSViewMinYMargin];
[hidePreviewBackground setAutoresizingMask: NSViewNotSizable | NSViewMaxXMargin | NSViewMaxYMargin | NSViewMinXMargin | NSViewMinYMargin];
}
-(void) updateDurationLabel
......@@ -279,7 +287,9 @@ CVPixelBufferRef pixelBufferPreview;
case Status::INCOMING_RINGING:
[infoContainer setHidden: NO];
[headerContainer setHidden:YES];
[headerGradientView setHidden:YES];
[controlsPanel setHidden:YES];
[controlsStackView setHidden:YES];
break;
/*case Status::CONFERENCE:
[self setupConference:currentCall];
......@@ -287,7 +297,9 @@ CVPixelBufferRef pixelBufferPreview;
case Status::PAUSED:
[infoContainer setHidden: NO];
[headerContainer setHidden:NO];
[headerGradientView setHidden:NO];
[controlsPanel setHidden:NO];
[controlsStackView setHidden:NO];
[backgroundImage setHidden:NO];
[bluerBackgroundEffect setHidden:NO];
if(!currentCall.isAudioOnly) {
......@@ -309,7 +321,9 @@ CVPixelBufferRef pixelBufferPreview;
break;
case Status::IN_PROGRESS:
[headerContainer setHidden:NO];
[headerGradientView setHidden:NO];
[controlsPanel setHidden:NO];
[controlsStackView setHidden:NO];
if(currentCall.isAudioOnly) {
[self setUpAudioOnlyView];
} else {
......@@ -366,12 +380,12 @@ CVPixelBufferRef pixelBufferPreview;
backgroundImage.layer.contents = bluredImage;
[backgroundImage setHidden:NO];
} else {
contactNameLabel.textColor = [NSColor darkGrayColor];
contactNameLabel.textColor = [NSColor darkGrayColor];
contactIdLabel.textColor = [NSColor darkGrayColor];
callStateLabel.textColor = [NSColor darkGrayColor];
contactNameLabel.textColor = [NSColor textColor];
contactNameLabel.textColor = [NSColor textColor];
contactIdLabel.textColor = [NSColor textColor];
callStateLabel.textColor = [NSColor textColor];
backgroundImage.layer.contents = nil;
[bluerBackgroundEffect setFillColor:[NSColor ringGreyHighlight]];
[bluerBackgroundEffect setFillColor:[NSColor windowBackgroundColor]];
[bluerBackgroundEffect setAlphaValue:1];
[backgroundImage setHidden:YES];
}
......@@ -879,16 +893,16 @@ CVPixelBufferRef pixelBufferPreview;
}
- (IBAction)hidePreview:(id)sender {
CGRect previewFrame = previewView.frame;
CGRect newPreviewFrame, bcHidePreviewFrame;
if (previewFrame.size.width > HIDE_PREVIEW_BUTTON_MAX_SIZE) {
CGRect newPreviewFrame;//, bcHidePreviewFrame;
if (previewFrame.size.width > HIDE_PREVIEW_BUTTON_SIZE) {
self.movableBaseForView.movable = false;
newPreviewFrame = self.getVideoPreviewCollapsedSize;
bcHidePreviewFrame = [self frameForExpendPreviewButton: true];
// bcHidePreviewFrame = [self frameForExpendPreviewButton: true];
hidePreviewButton.image = [NSImage imageNamed: NSImageNameTouchBarEnterFullScreenTemplate];
} else {
self.movableBaseForView.movable = true;
newPreviewFrame = CGRectMake(0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT);
bcHidePreviewFrame = [self frameForExpendPreviewButton: false];
// bcHidePreviewFrame = [self frameForExpendPreviewButton: false];
hidePreviewButton.image = [NSImage imageNamed: NSImageNameTouchBarExitFullScreenTemplate];
}
[NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
......@@ -896,7 +910,7 @@ CVPixelBufferRef pixelBufferPreview;
context.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseOut];
previewView.animator.frame = newPreviewFrame;
} completionHandler: nil];
hidePreviewBackground.frame = bcHidePreviewFrame;
// hidePreviewBackground.frame = bcHidePreviewFrame;
}
#pragma mark - NSSplitViewDelegate
......@@ -936,7 +950,9 @@ CVPixelBufferRef pixelBufferPreview;
-(void) mouseIsMoving:(BOOL) move
{
[[controlsPanel animator] setAlphaValue:move];// fade out
[[controlsStackView animator] setAlphaValue:move];
[[headerContainer animator] setAlphaValue:move];
[[headerGradientView animator] setAlphaValue:move];
}
- (BOOL)splitView:(NSSplitView *)splitView shouldHideDividerAtIndex:(NSInteger)dividerIndex
......@@ -968,26 +984,25 @@ CVPixelBufferRef pixelBufferPreview;
CGPoint origin;
switch (movableBaseForView.closestCorner) {
case TOP_LEFT:
origin = CGPointMake(0, movableBaseForView.frame.size.height - HIDE_PREVIEW_BUTTON_MAX_SIZE);
origin = CGPointMake(0, movableBaseForView.frame.size.height - HIDE_PREVIEW_BUTTON_SIZE);
break;
case BOTTOM_LEFT:
origin = CGPointMake(0, 0);
break;
case TOP_RIGHT:
origin = CGPointMake(movableBaseForView.frame.size.width - HIDE_PREVIEW_BUTTON_MAX_SIZE, movableBaseForView.frame.size.height - HIDE_PREVIEW_BUTTON_MAX_SIZE);
origin = CGPointMake(movableBaseForView.frame.size.width - HIDE_PREVIEW_BUTTON_SIZE, movableBaseForView.frame.size.height - HIDE_PREVIEW_BUTTON_SIZE);
break;
case BOTTOM_RIGHT:
origin = CGPointMake(movableBaseForView.frame.size.width - HIDE_PREVIEW_BUTTON_MAX_SIZE, 0);
origin = CGPointMake(movableBaseForView.frame.size.width - HIDE_PREVIEW_BUTTON_SIZE, 0);
break;
}
return CGRectMake(origin.x, origin.y, HIDE_PREVIEW_BUTTON_MAX_SIZE, HIDE_PREVIEW_BUTTON_MAX_SIZE);
return CGRectMake(origin.x, origin.y, HIDE_PREVIEW_BUTTON_SIZE, HIDE_PREVIEW_BUTTON_SIZE);
}
-(CGRect) frameForExpendPreviewButton:(BOOL)collapsed {
CGFloat size = collapsed ? HIDE_PREVIEW_BUTTON_MAX_SIZE : HIDE_PREVIEW_BUTTON_MIN_SIZE;
CGPoint origin = CGPointMake(self.previewView.frame.size.width - size,
self.previewView.frame.size.height - size);
return CGRectMake(origin.x, origin.y, size, size);
-(CGRect) frameForExpendPreviewButton {
CGPoint origin = CGPointMake(self.previewView.frame.size.width - HIDE_PREVIEW_BUTTON_SIZE,
self.previewView.frame.size.height - HIDE_PREVIEW_BUTTON_SIZE);
return CGRectMake(origin.x, origin.y, HIDE_PREVIEW_BUTTON_SIZE, HIDE_PREVIEW_BUTTON_SIZE);
}
@end
......@@ -34,12 +34,12 @@
[aGradient drawInRect: dirtyRect angle: angle];
}
- (nullable NSView *)hitTest:(NSPoint)point {
NSView *view = [super hitTest:point];
if ([view isKindOfClass:[NSButton class]]) {
return view;
}
return nil;
}
//- (nullable NSView *)hitTest:(NSPoint)point {
// NSView *view = [super hitTest:point];
// if ([view isKindOfClass:[NSButton class]]) {
// return view;
// }
// return nil;
//}
@end
......@@ -66,58 +66,8 @@ BOOL movingToCorner;
self.frame = CGRectMake(newOrigin.x, newOrigin.y, size.width, size.height);
}
- (void)viewDidMoveToWindow {
[self.window setAcceptsMouseMovedEvents:YES];
NSTrackingAreaOptions options = (NSTrackingActiveAlways | NSTrackingInVisibleRect | NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved);
NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:self.frame
options:options
owner:self
userInfo:nil];
[self addTrackingArea:area];
}
- (void)mouseEntered:(NSEvent *)event {
if (!movable || movingFromCorner) {
return;
}
CGPoint currentOrigin = self.frame.origin;
CGPoint cornerPoint = [self pointForCorner: self.closestCorner];
if (currentOrigin.x != cornerPoint.x || currentOrigin.y != cornerPoint.y) {
return;
}
movingFromCorner = true;
auto currentSize = self.frame.size;
CGPoint newOrigin = [self pointToMoveFromCorner: self.closestCorner];
auto currentFrame = self.frame;
auto newFrame = currentFrame;
newFrame.origin = newOrigin;
[NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
context.duration = 0.1f;
context.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseOut];
self.animator.frame = newFrame;
} completionHandler:^{
movingFromCorner = false;
}];
}
- (void)mouseExited:(NSEvent *)event {
if(movingToCorner) {
return;
}
CGPoint currentOrigin = self.frame.origin;
CGPoint cornerPoint = [self pointToMoveFromCorner: self.closestCorner];
if ((currentOrigin.x != cornerPoint.x) || (currentOrigin.y != cornerPoint.y)) {
return;
}
movingToCorner = true;
[self moveToCornerWithDuration:0.1];
}
- (void)mouseUp:(NSEvent *)event {
[self moveToCornerWithDuration:0.3];
[self moveToCornerWithDuration:0.2];
}
-(void) moveToCornerWithDuration:(CGFloat) duration {
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment