Add zoom support (using double tap/pinch/pan gestures)

Conflicts:

	submodules/linphone
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2012-04-17 11:16:07 +02:00
parent 67de7391bd
commit ef0b1edba1
6 changed files with 83 additions and 4 deletions

View file

@ -91,6 +91,7 @@
UIActionSheet* visibleActionSheet;
NSTimer* hideControlsTimer;
float zoomLevel, cx, cy;
}
-(void)displayStatus:(NSString*) message;

View file

@ -243,6 +243,9 @@ void addAnimationFadeTransition(UIView* view, float duration) {
-(void) enableVideoDisplay {
[self orientationChanged:nil];
zoomLevel = 1;
cx = cy = 0.5;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[videoGroup setAlpha:1.0];
@ -368,6 +371,66 @@ void addAnimationFadeTransition(UIView* view, float duration) {
}
}
-(void) zoomInOut:(UITapGestureRecognizer*) reco {
if (zoomLevel != 1)
zoomLevel = 1;
else
zoomLevel = 2;
if (zoomLevel != 1) {
CGPoint point = [reco locationInView:videoGroup];
cx = point.x / videoGroup.frame.size.width;
cy = 1 - point.y / videoGroup.frame.size.height;
} else {
cx = cy = 0.5;
}
linphone_call_zoom_video(linphone_core_get_current_call([LinphoneManager getLc]), zoomLevel, cx, cy);
}
-(void) videoPan:(UIPanGestureRecognizer*) reco {
if (zoomLevel <= 1.0)
return;
float x,y;
CGPoint translation = [reco translationInView:videoGroup];
if ([reco state] == UIGestureRecognizerStateEnded) {
cx -= translation.x / videoGroup.frame.size.width;
cy += translation.y / videoGroup.frame.size.height;
x = cx;
y = cy;
} else if ([reco state] == UIGestureRecognizerStateChanged) {
x = cx - translation.x / videoGroup.frame.size.width;
y = cy + translation.y / videoGroup.frame.size.height;
} else {
return;
}
linphone_call_zoom_video(linphone_core_get_current_call([LinphoneManager getLc]), zoomLevel, x, y);
}
-(void) pinch:(UIPinchGestureRecognizer*) reco {
float s = zoomLevel;
CGPoint point = [reco locationInView:videoGroup];
// float ccx = cx + (point.x / videoGroup.frame.size.width - 0.5) / s;
// float ccy = cy - (point.y / videoGroup.frame.size.height - 0.5) / s;
if ([reco state] == UIGestureRecognizerStateEnded) {
zoomLevel = MAX(MIN(zoomLevel * reco.scale, 3.0), 1.0);
s = zoomLevel;
// cx = ccx;
// cy = ccy;
} else if ([reco state] == UIGestureRecognizerStateChanged) {
s = zoomLevel * reco.scale;
s = MAX(MIN(s, 3.0), 1.0);
} else if ([reco state] == UIGestureRecognizerStateBegan) {
} else {
return;
}
linphone_call_zoom_video(linphone_core_get_current_call([LinphoneManager getLc]), s, cx, cy);
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
@ -413,10 +476,25 @@ void addAnimationFadeTransition(UIView* view, float duration) {
}
UITapGestureRecognizer* singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showControls:)];
[singleFingerTap setNumberOfTapsRequired:1];
[videoGroup addGestureRecognizer:singleFingerTap];
UITapGestureRecognizer* doubleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomInOut:)];
[doubleFingerTap setNumberOfTapsRequired:2];
[doubleFingerTap setNumberOfTouchesRequired:1];
[videoGroup addGestureRecognizer:doubleFingerTap];
UIPanGestureRecognizer* pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(videoPan:)];
[videoGroup addGestureRecognizer:pan];
UIPinchGestureRecognizer* pinchReco = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinch:)];
[videoGroup addGestureRecognizer:pinchReco];
videoGroup.alpha = 0;
[singleFingerTap release];
[doubleFingerTap release];
[pan release];
[pinchReco release];
cx = cy = 0.5;
mVideoShown=FALSE;
mIncallViewIsReady=FALSE;

View file

@ -1623,7 +1623,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 3.1;
LIBRARY_SEARCH_PATHS = "";
LINK_WITH_STANDARD_LIBRARIES = YES;
PROVISIONING_PROFILE = "7EBE410C-11B9-4346-9977-2C3BEE43ED16";
PROVISIONING_PROFILE = "32E63D15-36ED-474A-8157-8DD0770DF063";
SDKROOT = iphoneos;
};
name = DistributionAdhoc;

@ -1 +1 @@
Subproject commit 014f5a021ad4a0c024088edbb721f144a6f96699
Subproject commit 8483ca292c10e4bca3331040dd9babf8431d0393

@ -1 +1 @@
Subproject commit 2111e92a393cd0cbf3934ea1de406904f0d34bca
Subproject commit 02369158f50408f4d805fe0284a37aa8fe953105

@ -1 +1 @@
Subproject commit 391b6d6b0fdf6854e5a25f287c4d8461730a1d40
Subproject commit 498a7c526192392e402e72b7e9f2c6c381bdb7fd