[Libreoffice-commits] core.git: include/osl ios/experimental vcl/ios

ptyl at cloudon.com ptyl at cloudon.com
Fri Oct 11 01:20:11 PDT 2013


 include/osl/detail/ios-bootstrap.h                     |    3 +
 ios/experimental/LibreOffice/LibreOffice/AppDelegate.m |    2 +
 ios/experimental/LibreOffice/LibreOffice/View.h        |    2 +
 ios/experimental/LibreOffice/LibreOffice/View.m        |   17 ++++++++++
 vcl/ios/iosinst.cxx                                    |   28 +++++++++++++++++
 5 files changed, 52 insertions(+)

New commits:
commit da69a3ef5c395a3772a1c999aae5f172fc139d1e
Author: ptyl at cloudon.com <ptyl at cloudon.com>
Date:   Wed Sep 11 16:25:04 2013 +0300

    iOS experimental app support for selection marking via long press gesture
    
    Change-Id: Ib7a71797a2dc967f9d8ddd60fdc10c78201a87c8
    Reviewed-on: https://gerrit.libreoffice.org/5911
    Reviewed-by: Tor Lillqvist <tml at collabora.com>
    Tested-by: Tor Lillqvist <tml at collabora.com>

diff --git a/include/osl/detail/ios-bootstrap.h b/include/osl/detail/ios-bootstrap.h
index 42c38e4..0225c9a 100644
--- a/include/osl/detail/ios-bootstrap.h
+++ b/include/osl/detail/ios-bootstrap.h
@@ -41,6 +41,8 @@ extern "C" {
 
 /* 1) */
 
+typedef enum { DOWN, MOVE, UP} LOMouseButtonState;
+
 void lo_damaged(CGRect rect);
 
 /* 2) */
@@ -51,6 +53,7 @@ void lo_render_windows(CGContextRef context, CGRect rect);
 void lo_tap(int x, int y);
 void lo_pan(int deltaX, int deltaY);
 void lo_zoom(int x, int y, float scale);
+void lo_mouse_drag(int x, int y, LOMouseButtonState state);
 void lo_keyboard_input(int c);
 
 #ifdef __cplusplus
diff --git a/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m b/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m
index b0857ce..7e3a0a9 100644
--- a/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m
+++ b/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m
@@ -60,9 +60,11 @@ static View *theView;
 
     UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self.view action:@selector(tapGesture:)];
     UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self.view action:@selector(panGesture:)];
+    UILongPressGestureRecognizer * longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self.view action:@selector(longPressGesture:)];
 
     [self.window addGestureRecognizer: tapRecognizer];
     [self.window addGestureRecognizer: panRecognizer];
+    [self.window addGestureRecognizer: longPressRecognizer];
 
     NSLog(@"statusBarOrientation: %ld", (long) [[UIApplication sharedApplication] statusBarOrientation]);
 
diff --git a/ios/experimental/LibreOffice/LibreOffice/View.h b/ios/experimental/LibreOffice/LibreOffice/View.h
index 4abe2baa..7fd47d1 100644
--- a/ios/experimental/LibreOffice/LibreOffice/View.h
+++ b/ios/experimental/LibreOffice/LibreOffice/View.h
@@ -17,6 +17,8 @@
 - (void)drawRect:(CGRect)rect;
 - (void)tapGesture:(UITapGestureRecognizer *)gestureRecognizer;
 - (void)panGesture:(UIPanGestureRecognizer *)gestureRecognizer;
+- (void)longPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer;
+
 
 @end
 
diff --git a/ios/experimental/LibreOffice/LibreOffice/View.m b/ios/experimental/LibreOffice/LibreOffice/View.m
index 4e347a2..a047bb0 100644
--- a/ios/experimental/LibreOffice/LibreOffice/View.m
+++ b/ios/experimental/LibreOffice/LibreOffice/View.m
@@ -95,6 +95,23 @@
     }
 }
 
+- (void)longPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer
+{
+    CGPoint point = [gestureRecognizer locationInView:self];
+
+    UIGestureRecognizerState state = gestureRecognizer.state;
+
+    NSLog(@"longPressGesture: state %d cords (%d,%d)",state ,(int)point.x,(int)point.y);
+
+    if (state == UIGestureRecognizerStateBegan) {
+        lo_mouse_drag(point.x, point.y, DOWN);
+    } else if (state == UIGestureRecognizerStateChanged) {
+        lo_mouse_drag(point.x, point.y, MOVE);
+    } else if (state == UIGestureRecognizerStateEnded) {
+        lo_mouse_drag(point.x, point.y, UP);
+    }
+}
+
 @end
 
 // vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/vcl/ios/iosinst.cxx b/vcl/ios/iosinst.cxx
index e7cec9f..3605288 100644
--- a/vcl/ios/iosinst.cxx
+++ b/vcl/ios/iosinst.cxx
@@ -426,6 +426,34 @@ void lo_tap(int x, int y)
 }
 
 extern "C"
+void lo_mouse_drag(int x, int y, LOMouseButtonState state)
+{
+    SalFrame *pFocus = IosSalInstance::getInstance()->getFocusFrame();
+
+    if (pFocus) {
+        MouseEvent aEvent;
+        sal_uLong nEvent;
+
+        switch(state) {
+        case DOWN:
+            aEvent = MouseEvent(Point(x, y), 1, MOUSE_SIMPLECLICK, MOUSE_LEFT);
+            nEvent = VCLEVENT_WINDOW_MOUSEBUTTONDOWN;
+            break;
+        case MOVE:
+            aEvent = MouseEvent(Point(x, y), 1, MOUSE_SIMPLEMOVE, MOUSE_LEFT);
+            nEvent = VCLEVENT_WINDOW_MOUSEMOVE;
+            break;
+        case UP:
+            aEvent = MouseEvent(Point(x, y), 1, MOUSE_SIMPLECLICK, MOUSE_LEFT);
+            nEvent = VCLEVENT_WINDOW_MOUSEBUTTONUP;
+            break;
+        }
+
+        Application::PostMouseEvent(nEvent, pFocus->GetWindow(), &aEvent);
+    }
+}
+
+extern "C"
 void lo_pan(int deltaX, int deltaY)
 {
     SalFrame *pFocus = IosSalInstance::getInstance()->getFocusFrame();


More information about the Libreoffice-commits mailing list