summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-07-01 18:05:43 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-01 17:20:17 +0000
commit3ebfc5b95559a9bcb2fc0508b51fd00e8eb20260 (patch)
tree1dc7b603d93ab73d05a2e2c720972ac2ed926b8a /libreofficekit
parenta2c09913d87127230cfc6944dc7454088f966165 (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>
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx43
1 files changed, 39 insertions, 4 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 502ae5dbead5..8bf889ff9f79 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:
@@ -1108,6 +1113,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")
@@ -1271,7 +1295,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;
@@ -1325,7 +1350,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);
}
@@ -1586,7 +1611,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))