diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-03-10 10:53:28 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-03-16 09:38:03 +0100 |
commit | b2355ed71d1cacff6a27749f66d1fe973105186f (patch) | |
tree | 786378032917d52c8469e54df93fe4b97a00b271 | |
parent | d440dd241249efbd3f7357e38b1da5b2dd69d242 (diff) |
lokdocview: implement move of images
It's the same as resizing, except that the action starts inside the
graphic selection, but not over any handles.
Change-Id: Ie2465fc4534d2d919ccb0f316874477f02a5d103
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKitGtk.h | 1 | ||||
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.c | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h index d83dbd28e804..a67c841fd340 100644 --- a/include/LibreOfficeKit/LibreOfficeKitGtk.h +++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h @@ -59,6 +59,7 @@ struct _LOKDocView /// Position and size of the selection end. GdkRectangle m_aTextSelectionEnd; GdkRectangle m_aGraphicSelection; + gboolean m_bInDragGraphicSelection; /// @name Start/middle/end handle. ///@{ diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c index 0d62a5f8c0c4..0862c8a4f15a 100644 --- a/libreofficekit/source/gtk/lokdocview.c +++ b/libreofficekit/source/gtk/lokdocview.c @@ -150,6 +150,17 @@ gboolean lcl_signalButton(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocVi return FALSE; } } + + if (pDocView->m_bInDragGraphicSelection) + { + g_info("lcl_signalButton: end of drag graphic selection"); + pDocView->m_bInDragGraphicSelection = FALSE; + pDocView->pDocument->pClass->setGraphicSelection( + pDocView->pDocument, LOK_SETGRAPHICSELECTION_END, + pixelToTwip(pEvent->x) / pDocView->fZoom, + pixelToTwip(pEvent->y) / pDocView->fZoom); + return FALSE; + } } if (pDocView->m_bEdit) @@ -162,6 +173,7 @@ gboolean lcl_signalButton(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocVi if (pEvent->type == GDK_BUTTON_PRESS) { int i; + GdkRectangle aClickInTwips; if (gdk_rectangle_intersect(&aClick, &pDocView->m_aHandleStartRect, NULL)) { @@ -195,6 +207,21 @@ gboolean lcl_signalButton(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocVi return FALSE; } } + + aClickInTwips.x = pixelToTwip(pEvent->x) / pDocView->fZoom; + aClickInTwips.y = pixelToTwip(pEvent->y) / pDocView->fZoom; + aClickInTwips.width = 1; + aClickInTwips.height = 1; + if (gdk_rectangle_intersect(&aClickInTwips, &pDocView->m_aGraphicSelection, NULL)) + { + g_info("lcl_signalButton: start of drag graphic selection"); + pDocView->m_bInDragGraphicSelection = TRUE; + pDocView->pDocument->pClass->setGraphicSelection( + pDocView->pDocument, LOK_SETGRAPHICSELECTION_START, + pixelToTwip(pEvent->x) / pDocView->fZoom, + pixelToTwip(pEvent->y) / pDocView->fZoom); + return FALSE; + } } } @@ -297,6 +324,7 @@ static void lok_docview_init( LOKDocView* pDocView ) memset(&pDocView->m_aTextSelectionStart, 0, sizeof(pDocView->m_aTextSelectionStart)); memset(&pDocView->m_aTextSelectionEnd, 0, sizeof(pDocView->m_aTextSelectionEnd)); memset(&pDocView->m_aGraphicSelection, 0, sizeof(pDocView->m_aGraphicSelection)); + pDocView->m_bInDragGraphicSelection = FALSE; // Start/middle/end handle. pDocView->m_pHandleStart = NULL; |