Kaydet (Commit) cca44fe2 authored tarafından Miklos Vajna's avatar Miklos Vajna

lokdocview: replace handle_graphic.png with manual drawing

If we draw a black graphic handle manually, then it's possible to color
it later, this isn't easy if a bitmap is painted.

Change-Id: Ib4456fd5155862d52e3ffa79ee49c7bfd16fb742
Reviewed-on: https://gerrit.libreoffice.org/26860Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst d77d8160
......@@ -13,7 +13,6 @@ $(eval $(call gb_Package_add_files,libreofficekit_selectionhandles,$(LIBO_SHARE_
handle_image_start.png \
handle_image_middle.png \
handle_image_end.png \
handle_graphic.png \
))
# vim: set noet sw=4 ts=4:
......@@ -131,8 +131,6 @@ struct LOKDocViewPrivateImpl
/// @name Graphic handles.
///@{
/// Bitmap of a graphic selection handle.
cairo_surface_t* m_pGraphicHandle;
/// Rectangle of a graphic selection handle, to know if the user clicked on it or not.
GdkRectangle m_aGraphicHandleRects[8];
/// If we are in the middle of a drag of a graphic selection handle.
......@@ -189,7 +187,6 @@ struct LOKDocViewPrivateImpl
m_pHandleEnd(nullptr),
m_aHandleEndRect({0, 0, 0, 0}),
m_bInDragEndHandle(false),
m_pGraphicHandle(nullptr),
m_nViewId(0),
m_nTileSizeTwips(0),
m_aVisibleArea({0, 0, 0, 0}),
......@@ -1270,20 +1267,16 @@ renderHandle(LOKDocView* pDocView,
rRectangle.height = nHandleHeight * fHandleScale;
}
/// Renders pHandle around an rSelection rectangle on pCairo.
/// Renders handles around an rSelection rectangle on pCairo.
static void
renderGraphicHandle(LOKDocView* pDocView,
cairo_t* pCairo,
const GdkRectangle& rSelection,
cairo_surface_t* pHandle)
const GdkRectangle& rSelection)
{
LOKDocViewPrivate& priv = getPrivate(pDocView);
int nHandleWidth, nHandleHeight;
int nHandleWidth = 9, nHandleHeight = 9;
GdkRectangle aSelection;
nHandleWidth = cairo_image_surface_get_width(pHandle);
nHandleHeight = cairo_image_surface_get_height(pHandle);
aSelection.x = twipToPixel(rSelection.x, priv->m_fZoom);
aSelection.y = twipToPixel(rSelection.y, priv->m_fZoom);
aSelection.width = twipToPixel(rSelection.width, priv->m_fZoom);
......@@ -1332,11 +1325,9 @@ renderGraphicHandle(LOKDocView* pDocView,
priv->m_aGraphicHandleRects[i].width = nHandleWidth;
priv->m_aGraphicHandleRects[i].height = nHandleHeight;
cairo_save (pCairo);
cairo_translate(pCairo, x, y);
cairo_set_source_surface(pCairo, pHandle, 0, 0);
cairo_paint(pCairo);
cairo_restore (pCairo);
cairo_set_source_rgb(pCairo, 0, 0, 0);
cairo_rectangle(pCairo, x, y, nHandleWidth, nHandleHeight);
cairo_fill(pCairo);
}
}
......@@ -1595,16 +1586,7 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
}
if (!isEmptyRectangle(priv->m_aGraphicSelection))
{
gchar* handleGraphicPath = g_strconcat (priv->m_aLOPath, CURSOR_HANDLE_DIR, "handle_graphic.png", nullptr);
if (!priv->m_pGraphicHandle)
{
priv->m_pGraphicHandle = cairo_image_surface_create_from_png(handleGraphicPath);
assert(cairo_surface_status(priv->m_pGraphicHandle) == CAIRO_STATUS_SUCCESS);
}
renderGraphicHandle(pDocView, pCairo, priv->m_aGraphicSelection, priv->m_pGraphicHandle);
g_free (handleGraphicPath);
}
renderGraphicHandle(pDocView, pCairo, priv->m_aGraphicSelection);
// Draw the cell cursor.
if (!isEmptyRectangle(priv->m_aCellCursor))
......@@ -3123,8 +3105,6 @@ lok_doc_view_reset_view(LOKDocView* pDocView)
memset(&priv->m_aHandleEndRect, 0, sizeof(priv->m_aHandleEndRect));
priv->m_bInDragEndHandle = false;
cairo_surface_destroy(priv->m_pGraphicHandle);
priv->m_pGraphicHandle = nullptr;
memset(&priv->m_aGraphicHandleRects, 0, sizeof(priv->m_aGraphicHandleRects));
memset(&priv->m_bInDragGraphicHandles, 0, sizeof(priv->m_bInDragGraphicHandles));
......
......@@ -19,8 +19,7 @@ Module gid_Module_Libreofficekit
Files = (
gid_File_Dat_HandleImageStart,
gid_File_Dat_HandleImageMiddle,
gid_File_Dat_HandleImageEnd,
gid_File_Dat_HandleGraphic);
gid_File_Dat_HandleImageEnd);
End
Directory gid_Dir_Share_Libreofficekit
......@@ -49,13 +48,6 @@ File gid_File_Dat_HandleImageEnd
Name = "handle_image_end.png";
Styles = (PACKED);
End
File gid_File_Dat_HandleGraphic
TXT_FILE_BODY;
Dir = gid_Dir_Share_Libreofficekit;
Name = "handle_graphic.png";
Styles = (PACKED);
End
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment