mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Re-place video preview when you drag it out of the screen
This commit is contained in:
parent
db7b6afc9b
commit
0af84c8078
1 changed files with 40 additions and 1 deletions
|
|
@ -183,6 +183,11 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
// in mode display_filter_auto_rotate=0, no need to rotate the preview
|
||||
}
|
||||
|
||||
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
|
||||
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
|
||||
[self previewTouchLift];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)callUpdate:(LinphoneCall *)call state:(LinphoneCallState)state animated:(BOOL)animated {
|
||||
|
|
@ -498,7 +503,41 @@ static void hideSpinner(LinphoneCall *call, void *user_data) {
|
|||
#pragma mark VideoPreviewMoving
|
||||
|
||||
- (void)moveVideoPreview:(UIPanGestureRecognizer *)dragndrop {
|
||||
self.videoPreview.center = [dragndrop locationInView:videoPreview.superview];
|
||||
CGPoint center = [dragndrop locationInView:videoPreview.superview];
|
||||
self.videoPreview.center = center;
|
||||
if (dragndrop.state == UIGestureRecognizerStateEnded) {
|
||||
[self previewTouchLift];
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)coerce:(CGFloat)value betweenMin:(CGFloat)min andMax:(CGFloat)max {
|
||||
if (value > max) {
|
||||
value = max;
|
||||
}
|
||||
if (value < min) {
|
||||
value = min;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
- (void)previewTouchLift {
|
||||
CGRect previewFrame = self.videoPreview.frame;
|
||||
previewFrame.origin.x = [self coerce:previewFrame.origin.x
|
||||
betweenMin:5
|
||||
andMax:(self.view.frame.size.width - previewFrame.size.width - 5)];
|
||||
previewFrame.origin.y = [self coerce:previewFrame.origin.y
|
||||
betweenMin:5
|
||||
andMax:(self.view.frame.size.height - previewFrame.size.height - 5)];
|
||||
|
||||
if (!CGRectEqualToRect(previewFrame, self.videoPreview.frame)) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[UIView animateWithDuration:0.3
|
||||
animations:^{
|
||||
LOGI(@"Recentering preview to %@", NSStringFromCGRect(previewFrame));
|
||||
self.videoPreview.frame = previewFrame;
|
||||
}];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue