diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-01 18:05:43 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-21 10:21:34 +0200 |
commit | 2ca45663bf74e82fe508c2577613627741cf14f6 (patch) | |
tree | 5fb6fdaa4d21db1c4958ded2897701965b1c7850 /libreofficekit | |
parent | 606ad3c7961ced06a9c4278d64a7913090f03abe (diff) |
svx lok: add LOK_CALLBACK_GRAPHIC_VIEW_SELECTION
So a view can be aware where the graphic selections of other views are.
Change-Id: I0cc420cfe4bf3824fbfa1a58da889cac5e9a7b60
Reviewed-on: https://gerrit.libreoffice.org/26863
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
(cherry picked from commit 3ebfc5b95559a9bcb2fc0508b51fd00e8eb20260)
Diffstat (limited to 'libreofficekit')
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index a6fbe7871d9a..6c7c305b4062 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -101,9 +101,12 @@ struct LOKDocViewPrivateImpl /// Position and size of the selection end. GdkRectangle m_aTextSelectionEnd; GdkRectangle m_aGraphicSelection; + /// Position and size of the graphic view selections. The current view can only + /// see them, can't modify them. Key is the view id. + std::map<int, GdkRectangle> m_aGraphicViewSelections; GdkRectangle m_aCellCursor; /// Position and size of the cell view cursors. The current view can only - //see / them, can't modify them. Key is the view id. + /// see them, can't modify them. Key is the view id. std::map<int, GdkRectangle> m_aCellViewCursors; gboolean m_bInDragGraphicSelection; @@ -323,6 +326,8 @@ callbackTypeToString (int nType) return "LOK_CALLBACK_CURSOR_VISIBLE"; case LOK_CALLBACK_GRAPHIC_SELECTION: return "LOK_CALLBACK_GRAPHIC_SELECTION"; + case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION: + return "LOK_CALLBACK_GRAPHIC_VIEW_SELECTION"; case LOK_CALLBACK_CELL_CURSOR: return "LOK_CALLBACK_CELL_CURSOR"; case LOK_CALLBACK_HYPERLINK_CLICKED: @@ -1102,6 +1107,25 @@ callback (gpointer pData) gtk_widget_queue_draw(GTK_WIDGET(pDocView)); } break; + case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION: + { + std::stringstream aStream(pCallback->m_aPayload); + boost::property_tree::ptree aTree; + boost::property_tree::read_json(aStream, aTree); + int nViewId = aTree.get<int>("viewId"); + const std::string& rRectangle = aTree.get<std::string>("selection"); + if (rRectangle != "EMPTY") + priv->m_aGraphicViewSelections[nViewId] = payloadToRectangle(pDocView, rRectangle.c_str()); + else + { + auto it = priv->m_aGraphicViewSelections.find(nViewId); + if (it != priv->m_aGraphicViewSelections.end()) + priv->m_aGraphicViewSelections.erase(it); + } + gtk_widget_queue_draw(GTK_WIDGET(pDocView)); + break; + } + break; case LOK_CALLBACK_CELL_CURSOR: { if (pCallback->m_aPayload != "EMPTY") @@ -1265,7 +1289,8 @@ renderHandle(LOKDocView* pDocView, static void renderGraphicHandle(LOKDocView* pDocView, cairo_t* pCairo, - const GdkRectangle& rSelection) + const GdkRectangle& rSelection, + const GdkRGBA& rColor) { LOKDocViewPrivate& priv = getPrivate(pDocView); int nHandleWidth = 9, nHandleHeight = 9; @@ -1319,7 +1344,7 @@ renderGraphicHandle(LOKDocView* pDocView, priv->m_aGraphicHandleRects[i].width = nHandleWidth; priv->m_aGraphicHandleRects[i].height = nHandleHeight; - cairo_set_source_rgb(pCairo, 0, 0, 0); + cairo_set_source_rgb(pCairo, rColor.red, rColor.green, rColor.blue); cairo_rectangle(pCairo, x, y, nHandleWidth, nHandleHeight); cairo_fill(pCairo); } @@ -1580,7 +1605,17 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo) } if (!isEmptyRectangle(priv->m_aGraphicSelection)) - renderGraphicHandle(pDocView, pCairo, priv->m_aGraphicSelection); + { + GdkRGBA aBlack{0, 0, 0, 0}; + renderGraphicHandle(pDocView, pCairo, priv->m_aGraphicSelection, aBlack); + } + + // Graphic selections of other views. + for (std::pair<const int, GdkRectangle>& rPair : priv->m_aGraphicViewSelections) + { + const GdkRGBA& rDark = getDarkColor(rPair.first); + renderGraphicHandle(pDocView, pCairo, rPair.second, rDark); + } // Draw the cell cursor. if (!isEmptyRectangle(priv->m_aCellCursor)) |