summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2013-10-22 23:30:26 +0300
committerTor Lillqvist <tml@collabora.com>2013-10-23 00:19:20 +0300
commit54ef5bd641ef5c6938b591697115d63af381ebc3 (patch)
tree714690adf71ad9cd358352da0de70eaf28e0d8fd /ios
parent025bd0fab4cd8e4f90c362ec03b51c23e0a55655 (diff)
More work on selection handling in iOS
Got the selection start and end handle dragging working... The trick was not to call SwWrtShell::SetCursor(), but SwCrsrShell::SetCrsr(). Sounds easy but took a lot of guessing and experimentation to figure out. Anyway, now it does what I had expected it to do a few das ago already. There are glitches, especially in corner cases like if you move the start handle past the end handle or vice versa. more Change-Id: Id6c1d99a4052531789bccf0d48165cfb41b89cfe 9b94c0dd55b04a7b6b3c40654562a9c51fa9b450
Diffstat (limited to 'ios')
-rw-r--r--ios/experimental/LibreOffice/LibreOffice/View.m48
1 files changed, 18 insertions, 30 deletions
diff --git a/ios/experimental/LibreOffice/LibreOffice/View.m b/ios/experimental/LibreOffice/LibreOffice/View.m
index cb96e48507e3..3a9b35bdbdd4 100644
--- a/ios/experimental/LibreOffice/LibreOffice/View.m
+++ b/ios/experimental/LibreOffice/LibreOffice/View.m
@@ -154,71 +154,59 @@
- (void)panGesture:(UIPanGestureRecognizer *)gestureRecognizer
{
+ const int N = self.selectionRectangleCount;
+
static enum { NONE, TOPLEFT, BOTTOMRIGHT } draggedHandle = NONE;
- static CGFloat previousX, previousY;
+ static CGPoint previous;
+ static CGPoint dragOffset;
CGPoint location = [gestureRecognizer locationInView:self];
CGPoint translation = [gestureRecognizer translationInView:self];
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
- previousX = previousY = 0;
+ previous = CGPointMake(0, 0);
}
CGPoint delta;
- delta.x = translation.x - previousX;
- delta.y = translation.y - previousY;
+ delta.x = translation.x - previous.x;
+ delta.y = translation.y - previous.y;
// NSLog(@"location: (%f,%f) , drag: (%f,%f)", location.x, location.y, delta.x, delta.y);
- previousX = translation.x;
- previousY = translation.y;
+ previous = translation;
if (gestureRecognizer.state == UIGestureRecognizerStateBegan &&
gestureRecognizer.numberOfTouches == 1) {
if (CGRectContainsPoint([self topLeftResizeHandle], location)) {
NSLog(@"===> dragging TOPLEFT handle");
draggedHandle = TOPLEFT;
+ dragOffset.x = location.x - self.selectionRectangles[0].origin.x;
+ dragOffset.y = location.y - self.selectionRectangles[0].origin.y;
} else if (CGRectContainsPoint([self bottomRightResizeHandle], location)) {
NSLog(@"===> dragging BOTTOMRIGHT handle");
draggedHandle = BOTTOMRIGHT;
+ dragOffset.x = location.x - self.selectionRectangles[N-1].origin.x;
+ dragOffset.y = location.y - self.selectionRectangles[N-1].origin.y;
}
}
if (draggedHandle == TOPLEFT) {
- const int N = self.selectionRectangleCount;
- CGPoint old = self.selectionRectangles[0].origin;
+ touch_lo_selection_start_move(self.documentHandle,
+ location.x - dragOffset.x, location.y - dragOffset.y);
- self.selectionRectangles[0].origin = location;
- self.selectionRectangles[0].size.width -= (location.x - old.x);
- self.selectionRectangles[0].size.height -= (location.y - old.y);
-
-#if 0
- touch_lo_selection_attempt_resize(self.documentHandle,
- self.selectionRectangles,
- self.selectionRectangleCount);
-#else
- touch_lo_tap((self.selectionRectangles[0].origin.x + self.selectionRectangles[N-1].origin.x) / 2,
- (self.selectionRectangles[0].origin.y + self.selectionRectangles[N-1].origin.y) / 2);
-
- touch_lo_mouse(self.selectionRectangles[0].origin.x,
- self.selectionRectangles[0].origin.y,
- DOWN, NONE);
- touch_lo_mouse(self.selectionRectangles[N-1].origin.x +
- self.selectionRectangles[N-1].size.width,
- self.selectionRectangles[N-1].origin.y +
- self.selectionRectangles[N-1].size.height,
- UP, NONE);
-#endif
if (gestureRecognizer.state == UIGestureRecognizerStateEnded)
draggedHandle = NONE;
+
return;
} else if (draggedHandle == BOTTOMRIGHT) {
- touch_lo_selection_end_move(self.documentHandle, location.x, location.y);
+ touch_lo_selection_end_move(self.documentHandle,
+ location.x - dragOffset.x, location.y - dragOffset.y);
if (gestureRecognizer.state == UIGestureRecognizerStateEnded)
draggedHandle = NONE;
+
return;
}