Kaydet (Commit) 1e7bf8de authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Add pan gesture handling

I get exactly the same kind of artefacts as in the Android app, which
I guess is good as it is at least consistent, as the implementation at
the LO layer is identical...

Change-Id: Icf0690fd2c48a133cb66de2ab7977b7088d2199e
üst 7711a60a
...@@ -59,8 +59,10 @@ static View *theView; ...@@ -59,8 +59,10 @@ static View *theView;
self.view->textView.delegate = self; self.view->textView.delegate = self;
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self.view action:@selector(tapGesture:)]; UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self.view action:@selector(tapGesture:)];
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self.view action:@selector(panGesture:)];
[self.window addGestureRecognizer: tapRecognizer]; [self.window addGestureRecognizer: tapRecognizer];
[self.window addGestureRecognizer: panRecognizer];
NSLog(@"statusBarOrientation: %d", [[UIApplication sharedApplication] statusBarOrientation]); NSLog(@"statusBarOrientation: %d", [[UIApplication sharedApplication] statusBarOrientation]);
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
UITextView* textView; UITextView* textView;
} }
- (void)drawRect:(CGRect)rect; - (void)drawRect:(CGRect)rect;
- (void)tapGesture:(UIGestureRecognizer *)gestureRecognizer; - (void)tapGesture:(UITapGestureRecognizer *)gestureRecognizer;
- (void)panGesture:(UIPanGestureRecognizer *)gestureRecognizer;
@end @end
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
// NSLog(@"drawRect: lo_render_windows took %f s", [[NSDate date] timeIntervalSinceDate: startDate]); // NSLog(@"drawRect: lo_render_windows took %f s", [[NSDate date] timeIntervalSinceDate: startDate]);
} }
- (void) tapGesture:(UIGestureRecognizer *)gestureRecognizer - (void)tapGesture:(UITapGestureRecognizer *)gestureRecognizer
{ {
if ([gestureRecognizer state] == UIGestureRecognizerStateEnded) { if ([gestureRecognizer state] == UIGestureRecognizerStateEnded) {
CGPoint location = [gestureRecognizer locationInView: self]; CGPoint location = [gestureRecognizer locationInView: self];
...@@ -57,6 +57,16 @@ ...@@ -57,6 +57,16 @@
NSLog(@"tapGesture: %@", gestureRecognizer); 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);
}
@end @end
// vim:set shiftwidth=4 softtabstop=4 expandtab: // vim:set shiftwidth=4 softtabstop=4 expandtab:
...@@ -49,6 +49,7 @@ void lo_runMain(); ...@@ -49,6 +49,7 @@ void lo_runMain();
void lo_set_view_size(int width, int height); void lo_set_view_size(int width, int height);
void lo_render_windows(CGContextRef context, CGRect rect); void lo_render_windows(CGContextRef context, CGRect rect);
void lo_tap(int x, int y); void lo_tap(int x, int y);
void lo_pan(int x, int y);
void lo_keyboard_input(int c); void lo_keyboard_input(int c);
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -402,6 +402,17 @@ void lo_tap(int x, int y) ...@@ -402,6 +402,17 @@ void lo_tap(int x, int y)
} }
} }
extern "C"
void lo_pan(int x, int y)
{
SalFrame *pFocus = IosSalInstance::getInstance()->getFocusFrame();
if (pFocus) {
SAL_INFO( "vcl.ios", "scroll: " << "(" << x << "," << y << ")" );
ScrollEvent aEvent( x, y );
Application::PostScrollEvent(VCLEVENT_WINDOW_SCROLL, pFocus->GetWindow(), &aEvent);
}
}
extern "C" extern "C"
void lo_keyboard_input(int c) void lo_keyboard_input(int c)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment