diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-02-09 14:22:01 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-02-16 09:20:45 +0100 |
commit | 5dee910234067175b8be2fe5a6ea93dd0fdc8de9 (patch) | |
tree | 7eb0b4bc0afcf5c9a94334f9c34ad0de0949976c | |
parent | 3d9b364b567a9046ac4530297c7e922ae9bf0596 (diff) |
lokdocview: when have a cursor but no selection, show the middle handle
Change-Id: I1497bd73303a0445f06f3302aa5b8a537243bfeb
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c index a7cf3ec91f17..351c7ccd7fd3 100644 --- a/libreofficekit/source/gtk/lokdocview.c +++ b/libreofficekit/source/gtk/lokdocview.c @@ -24,6 +24,9 @@ #define g_info(...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, __VA_ARGS__) #endif +// Cursor bitmaps from the Android app. +#define CURSOR_HANDLE_DIR "android/experimental/LOAndroid3/res/drawable/" + static void lok_docview_class_init( LOKDocViewClass* pClass ); static void lok_docview_init( LOKDocView* pDocView ); static float pixelToTwip(float nInput); @@ -204,6 +207,32 @@ static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpoint twipToPixel(pDocView->m_aVisibleCursor.width), twipToPixel(pDocView->m_aVisibleCursor.height)); cairo_fill(pCairo); + + } + + if (!lcl_isEmptyRectangle(&pDocView->m_aVisibleCursor) && !pDocView->m_pTextSelectionRectangles) + { + // Have a cursor, but no selection: we need the middle handle. + GdkPoint aCursorBottom; + cairo_surface_t* pSurface; + int nHandleWidth, nHandleHeight; + double fHandleScale; + + pSurface = cairo_image_surface_create_from_png(CURSOR_HANDLE_DIR "handle_middle.png"); + nHandleWidth = cairo_image_surface_get_width(pSurface); + nHandleHeight = cairo_image_surface_get_height(pSurface); + // We want to scale down the handle, so that its height is the same as the cursor caret. + fHandleScale = twipToPixel(pDocView->m_aVisibleCursor.height) / nHandleHeight; + // We want the top center of the handle bitmap to be at the bottom center of the cursor rectangle. + aCursorBottom.x = twipToPixel(pDocView->m_aVisibleCursor.x) + twipToPixel(pDocView->m_aVisibleCursor.width) / 2 - (nHandleWidth * fHandleScale) / 2; + aCursorBottom.y = twipToPixel(pDocView->m_aVisibleCursor.y) + twipToPixel(pDocView->m_aVisibleCursor.height); + cairo_save(pCairo); + cairo_translate(pCairo, aCursorBottom.x, aCursorBottom.y); + cairo_scale(pCairo, fHandleScale, fHandleScale); + cairo_set_source_surface(pCairo, pSurface, 0, 0); + cairo_paint(pCairo); + cairo_surface_destroy(pSurface); + cairo_restore(pCairo); } if (pDocView->m_pTextSelectionRectangles) |