[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 3 commits - editeng/source libreofficekit/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Mar 12 09:30:13 PDT 2015


 editeng/source/editeng/editview.cxx      |    6 ++++
 editeng/source/editeng/impedit.cxx       |    9 ++++++
 libreofficekit/source/gtk/lokdocview.cxx |   40 ++++++++++++++++++++++++++-----
 3 files changed, 49 insertions(+), 6 deletions(-)

New commits:
commit c1d3a6fbf42b2023ec43206507963fdc8f6f47eb
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Mar 12 17:21:44 2015 +0100

    lokdocview: detect click on border vs click inside graphic selection
    
    Previously there were two cases when the user clicked inside a graphic
    selection:
    
    1) If the click started at a handle, it was a resize.
    2) Otherwise it was a move.
    
    Change 2) by requiring a click on the border for move, and otherwise
    interpreting the click as a normal one.  This makes it possible to edit
    shape text with a blinking cursor.
    
    Change-Id: Ifc063790cacb3da2684f6f72eaadd86323dd3aef

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 338b568..1f542b5 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -114,6 +114,37 @@ gboolean lcl_signalMotion(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKD
     return FALSE;
 }
 
+/// Is pClick on the border of pDocView->m_aGraphicSelection?
+bool lcl_isOnBorders(LOKDocView* pDocView, GdkPoint* pClick)
+{
+    // Handles are on the corners / edges of the shape:
+    // Let aSelection be the bounding box of all handles (a bit larger than the graphic selection).
+    int nHandleWidth = pixelToTwip(pDocView->m_aGraphicHandleRects[0].width) / pDocView->fZoom;
+    int nHandleHeight = pixelToTwip(pDocView->m_aGraphicHandleRects[0].height) / pDocView->fZoom;
+    GdkRectangle aSelection;
+    aSelection.x = pDocView->m_aGraphicSelection.x - nHandleWidth / 2;
+    aSelection.y = pDocView->m_aGraphicSelection.y - nHandleHeight / 2;
+    aSelection.width = pDocView->m_aGraphicSelection.width + nHandleWidth;
+    aSelection.height = pDocView->m_aGraphicSelection.height + nHandleHeight;
+    GdkRegion* pSelection = gdk_region_rectangle(&aSelection);
+
+    // Let aInsideBorder be the shape without the handles (a bit smaller than the graphic selection).
+    GdkRectangle aInsideBorder;
+    aInsideBorder.x = pDocView->m_aGraphicSelection.x + nHandleWidth / 2;
+    aInsideBorder.y = pDocView->m_aGraphicSelection.y + nHandleHeight / 2;
+    aInsideBorder.width = pDocView->m_aGraphicSelection.width - nHandleWidth;
+    aInsideBorder.height = pDocView->m_aGraphicSelection.height - nHandleHeight;
+    GdkRegion* pInsideBorder = gdk_region_rectangle(&aInsideBorder);
+
+    // Did we click on the border?
+    gdk_region_subtract(pSelection, pInsideBorder);
+    bool bRet = gdk_region_point_in(pSelection, pClick->x, pClick->y);
+
+    gdk_region_destroy(pInsideBorder);
+    gdk_region_destroy(pSelection);
+    return bRet;
+}
+
 /// Receives a button press event.
 gboolean lcl_signalButton(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKDocView* pDocView)
 {
@@ -174,8 +205,6 @@ gboolean lcl_signalButton(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKD
         aClick.height = 1;
         if (pEvent->type == GDK_BUTTON_PRESS)
         {
-            GdkRectangle aClickInTwips;
-
             if (gdk_rectangle_intersect(&aClick, &pDocView->m_aHandleStartRect, NULL))
             {
                 g_info("lcl_signalButton: start of drag start handle");
@@ -209,11 +238,10 @@ gboolean lcl_signalButton(GtkWidget* /*pEventBox*/, GdkEventButton* pEvent, LOKD
                 }
             }
 
+            GdkPoint aClickInTwips;
             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))
+            if (lcl_isOnBorders(pDocView, &aClickInTwips))
             {
                 g_info("lcl_signalButton: start of drag graphic selection");
                 pDocView->m_bInDragGraphicSelection = TRUE;
commit 0d102f8d28fd899b1dfede1bc43de78c1d9e351d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Mar 12 15:18:00 2015 +0100

    lokdocview: ensure that the cursor is at least 30 twips wide
    
    While Writer uses "0" for the "minimal width" case, editeng uses 2. We
    used to round up 0 to 30, do it for any value smaller than 30.
    
    Change-Id: Ib3cc7645b55881fc51f0729163cdea5eb9ca4f0a

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index e3fd1cb..338b568 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -519,7 +519,7 @@ static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* /*pEvent*/, gp
 
     if (pDocView->m_bEdit && pDocView->m_bCursorVisible && pDocView->m_bCursorOverlayVisible && !lcl_isEmptyRectangle(&pDocView->m_aVisibleCursor))
     {
-        if (pDocView->m_aVisibleCursor.width == 0)
+        if (pDocView->m_aVisibleCursor.width < 30)
             // Set a minimal width if it would be 0.
             pDocView->m_aVisibleCursor.width = 30;
 
commit cac14527fe4abb1e1d5bbe505ff15694e3a761b5
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Mar 12 15:16:50 2015 +0100

    editeng tiled rendering: emit callbacks necessary to have a blinking cursor
    
    Change-Id: I031827cbcb14242ede549ce6f65f809795075db5

diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 4db1892..684e7de 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -62,6 +62,7 @@
 #include <com/sun/star/lang/Locale.hpp>
 #include <linguistic/lngprops.hxx>
 #include <vcl/settings.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
 #include <com/sun/star/lang/XServiceInfo.hpp>
 
@@ -394,12 +395,17 @@ void EditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
         if ( !pImpEditView->DoAutoScroll() )
             bGotoCursor = false;
         pImpEditView->ShowCursor( bGotoCursor, bForceVisCursor );
+
+        if (pImpEditView->isTiledRendering())
+            pImpEditView->libreOfficeKitCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(true).getStr());
     }
 }
 
 void EditView::HideCursor()
 {
     pImpEditView->GetCursor()->Hide();
+    if (pImpEditView->isTiledRendering())
+        pImpEditView->libreOfficeKitCallback(LOK_CALLBACK_CURSOR_VISIBLE, OString::boolean(false).getStr());
 }
 
 Pair EditView::Scroll( long ndX, long ndY, sal_uInt8 nRangeCheck )
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 633593b..0c54e5e 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -45,6 +45,7 @@
 #include <svtools/transfer.hxx>
 #include <sot/exchange.hxx>
 #include <sot/formats.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -873,6 +874,14 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, sal_uInt16
 
         GetCursor()->SetSize( aCursorSz );
 
+        if (isTiledRendering())
+        {
+            const Point& rPos = GetCursor()->GetPos();
+            Rectangle aRect(rPos.getX(), rPos.getY(), rPos.getX() + GetCursor()->GetWidth(), rPos.getY() + GetCursor()->GetHeight());
+            OString sRect = aRect.toString();
+            libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
+        }
+
         unsigned char nCursorDir = CURSOR_DIRECTION_NONE;
         if ( IsInsertMode() && !aEditSelection.HasRange() && ( pEditEngine->pImpEditEngine->HasDifferentRTLLevels( aPaM.GetNode() ) ) )
         {


More information about the Libreoffice-commits mailing list