summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-03-25 09:14:24 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-03-30 09:23:46 +0200
commitbaa0ef26dcec464dd8eec1adc629676a0a6f6e10 (patch)
tree19dc0f82316d4ae6474ef135b79aded1d914cec2 /libreofficekit
parente41e571072a105b9871d7f1014775bba0b2587c7 (diff)
lokdocview: sync graphic move behavior with Android
Android behavior is: if there is a graphic selection, then drag inside the shape is a move. lokdocivew behavior was: drag on the border of a graphic selection is a move, but inside, it's just a pair of clicks. Since commit 658534d36f87f9ab03d862e57b04ea268b73ccab (SdrMarkView tiled rendering: suppress handles during text edit, 2015-03-19), we can depend on the availability of the handles to decide if we want to move the shape or do text editing, so do the same in lokdocview as well. Change-Id: I2b105089e9acbbda75568622d4f2b1adecfe08f1
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx62
1 files changed, 17 insertions, 45 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 35b23a208265..f0ac06f5309b 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -221,38 +221,24 @@ gboolean lcl_signalMotion(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKD
g_info("lcl_signalMotion: dragging the graphic selection");
return FALSE;
}
- return FALSE;
-}
-/// Is pClick on the border of pDocView->m_aGraphicSelection?
-bool lcl_isOnBorders(LOKDocView* pDocView, GdkPoint* pClick)
-{
- // Handles are on the corners / edges of the shape:
- // Let aSelection be the bounding box of all handles (a bit larger than the graphic selection).
- int nHandleWidth = pixelToTwip(pDocView->m_pImpl->m_aGraphicHandleRects[0].width) / pDocView->m_pImpl->m_fZoom;
- int nHandleHeight = pixelToTwip(pDocView->m_pImpl->m_aGraphicHandleRects[0].height) / pDocView->m_pImpl->m_fZoom;
- GdkRectangle aSelection;
- aSelection.x = pDocView->m_pImpl->m_aGraphicSelection.x - nHandleWidth / 2;
- aSelection.y = pDocView->m_pImpl->m_aGraphicSelection.y - nHandleHeight / 2;
- aSelection.width = pDocView->m_pImpl->m_aGraphicSelection.width + nHandleWidth;
- aSelection.height = pDocView->m_pImpl->m_aGraphicSelection.height + nHandleHeight;
- GdkRegion* pSelection = gdk_region_rectangle(&aSelection);
-
- // Let aInsideBorder be the shape without the handles (a bit smaller than the graphic selection).
- GdkRectangle aInsideBorder;
- aInsideBorder.x = pDocView->m_pImpl->m_aGraphicSelection.x + nHandleWidth / 2;
- aInsideBorder.y = pDocView->m_pImpl->m_aGraphicSelection.y + nHandleHeight / 2;
- aInsideBorder.width = pDocView->m_pImpl->m_aGraphicSelection.width - nHandleWidth;
- aInsideBorder.height = pDocView->m_pImpl->m_aGraphicSelection.height - nHandleHeight;
- GdkRegion* pInsideBorder = gdk_region_rectangle(&aInsideBorder);
-
- // Did we click on the border?
- gdk_region_subtract(pSelection, pInsideBorder);
- bool bRet = gdk_region_point_in(pSelection, pClick->x, pClick->y);
-
- gdk_region_destroy(pInsideBorder);
- gdk_region_destroy(pSelection);
- return bRet;
+ GdkRectangle aMotionInTwipsInTwips;
+ aMotionInTwipsInTwips.x = pixelToTwip(pEvent->x) / pDocView->m_pImpl->m_fZoom;
+ aMotionInTwipsInTwips.y = pixelToTwip(pEvent->y) / pDocView->m_pImpl->m_fZoom;
+ aMotionInTwipsInTwips.width = 1;
+ aMotionInTwipsInTwips.height = 1;
+ if (gdk_rectangle_intersect(&aMotionInTwipsInTwips, &pDocView->m_pImpl->m_aGraphicSelection, 0))
+ {
+ g_info("lcl_signalMotion: start of drag graphic selection");
+ pDocView->m_pImpl->m_bInDragGraphicSelection = true;
+ pDocView->m_pImpl->m_pDocument->pClass->setGraphicSelection(
+ pDocView->m_pImpl->m_pDocument, LOK_SETGRAPHICSELECTION_START,
+ pixelToTwip(pEvent->x) / pDocView->m_pImpl->m_fZoom,
+ pixelToTwip(pEvent->y) / pDocView->m_pImpl->m_fZoom);
+ return FALSE;
+ }
+
+ return FALSE;
}
/// Receives a button press event.
@@ -347,20 +333,6 @@ gboolean lcl_signalButton(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKD
return FALSE;
}
}
-
- GdkPoint aClickInTwips;
- aClickInTwips.x = pixelToTwip(pEvent->x) / pDocView->m_pImpl->m_fZoom;
- aClickInTwips.y = pixelToTwip(pEvent->y) / pDocView->m_pImpl->m_fZoom;
- if (lcl_isOnBorders(pDocView, &aClickInTwips))
- {
- g_info("lcl_signalButton: start of drag graphic selection");
- pDocView->m_pImpl->m_bInDragGraphicSelection = true;
- pDocView->m_pImpl->m_pDocument->pClass->setGraphicSelection(
- pDocView->m_pImpl->m_pDocument, LOK_SETGRAPHICSELECTION_START,
- pixelToTwip(pEvent->x) / pDocView->m_pImpl->m_fZoom,
- pixelToTwip(pEvent->y) / pDocView->m_pImpl->m_fZoom);
- return FALSE;
- }
}
}