summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorptyl@cloudon.com <ptyl@cloudon.com>2013-09-01 19:22:23 +0300
committerTor Lillqvist <tml@collabora.com>2013-10-09 14:37:46 +0000
commit4e7495ac2cb6b015ad492def45fd24f4ba0f54f8 (patch)
treea23c409bd5bf2f2a54a26a50b4c7e29054af666d /ios
parentff3b823ef4b867263711703fab596584314e4f58 (diff)
Fix for iOS scroll by pixels, and pinch to zoom
Minor further changes by tml to match the coding style of surrounding code mainly. Change-Id: Ied6087a264f1c6b00763ea36fba9808329afede4 Reviewed-on: https://gerrit.libreoffice.org/5742 Tested-by: Tor Lillqvist <tml@collabora.com> Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'ios')
-rw-r--r--ios/experimental/LibreOffice/LibreOffice/View.m42
1 files changed, 35 insertions, 7 deletions
diff --git a/ios/experimental/LibreOffice/LibreOffice/View.m b/ios/experimental/LibreOffice/LibreOffice/View.m
index 8c490cb88cec..4e347a24f599 100644
--- a/ios/experimental/LibreOffice/LibreOffice/View.m
+++ b/ios/experimental/LibreOffice/LibreOffice/View.m
@@ -50,21 +50,49 @@
{
if ([gestureRecognizer state] == UIGestureRecognizerStateEnded) {
CGPoint location = [gestureRecognizer locationInView: self];
+
NSLog(@"tapGesture: at: (%d,%d)", (int)location.x, (int)location.y);
+
lo_tap(location.x, location.y);
+
[self->textView becomeFirstResponder];
- } else
+ } else {
NSLog(@"tapGesture: %@", gestureRecognizer);
+ }
}
- (void)panGesture:(UIPanGestureRecognizer *)gestureRecognizer
{
- if ([gestureRecognizer state] == UIGestureRecognizerStateEnded) {
- CGPoint translation = [gestureRecognizer translationInView: self];
- NSLog(@"panGesture: pan: (%d,%d)", (int)translation.x, (int)translation.y);
- lo_pan(translation.x, translation.y);
- } else
- NSLog(@"panGesture: %@", gestureRecognizer);
+ static CGFloat previousX = 0.0f, previousY = 0.0f;
+
+ CGPoint translation = [gestureRecognizer translationInView: self];
+
+ if (gestureRecognizer.state != UIGestureRecognizerStateBegan) {
+ int deltaX = translation.x - previousX;
+ int deltaY = translation.y - previousY;
+
+ NSLog(@"panGesture: pan (delta): (%d,%d)", deltaX, deltaY);
+
+ lo_pan(deltaX, deltaY);
+ }
+
+ previousX = translation.x;
+ previousY = translation.y;
+}
+
+- (void)pinchGesture:(UIPinchGestureRecognizer *)gestureRecognizer
+{
+ CGPoint location = [gestureRecognizer locationInView: self];
+ CGFloat scale = gestureRecognizer.scale;
+
+ NSLog(@"pinchGesture: pinch: (%f) cords (%d,%d)", (float)scale, (int)location.x, (int)location.y );
+
+ lo_zoom((int)location.x, (int)location.y, (float)scale);
+
+ // to reset the gesture scaling
+ if (gestureRecognizer.state==UIGestureRecognizerStateEnded) {
+ lo_zoom(1, 1, 0.0f);
+ }
}
@end