summaryrefslogtreecommitdiff
path: root/sw/source/uibase/utlui
diff options
context:
space:
mode:
authorHossein <hossein@libreoffice.org>2023-06-14 23:55:06 +0200
committerHossein <hossein@libreoffice.org>2023-06-20 01:03:55 +0200
commitf9f7cfc080c3adb751ceca96be4ca5440de4a2b6 (patch)
treef45dcef9dffc8c68747c4bb4f299ce0795593ada /sw/source/uibase/utlui
parent71e5f7e43471cc479ea1e818c813170a389964e6 (diff)
tdf#122970 Fix direct cursor leaving screen trail
Previously, an old method using RasterOp::Xor rendering (see tdf#38844) was used to draw the extra triangle left or right of the mouse pointer in direct cursor mode. Now, instead of drawing it manually, we change the cursor type to somewhat similar pointer type. There is no perfect match for the previous mouse pointer shape, so now instead of left triangle, PointerStyle::AutoScrollW is used. Also instead of right triangle, PointerStyle::AutoScrollE is used. Change-Id: Iadb955f9fcee0978a190e0b8920186a2579f3a4b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153099 Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org>
Diffstat (limited to 'sw/source/uibase/utlui')
-rw-r--r--sw/source/uibase/utlui/shdwcrsr.cxx59
1 files changed, 9 insertions, 50 deletions
diff --git a/sw/source/uibase/utlui/shdwcrsr.cxx b/sw/source/uibase/utlui/shdwcrsr.cxx
index 4fea57d090d4..71c2b6ca4ba6 100644
--- a/sw/source/uibase/utlui/shdwcrsr.cxx
+++ b/sw/source/uibase/utlui/shdwcrsr.cxx
@@ -19,13 +19,14 @@
#include <com/sun/star/text/HoriOrientation.hpp>
#include <shdwcrsr.hxx>
+#include <vcl/ptrstyle.hxx>
using namespace ::com::sun::star;
SwShadowCursor::~SwShadowCursor()
{
if( USHRT_MAX != m_nOldMode )
- DrawCursor( m_aOldPt, m_nOldHeight, m_nOldMode );
+ DrawCursor( m_nOldMode);
}
void SwShadowCursor::SetPos( const Point& rPt, tools::Long nHeight, sal_uInt16 nMode )
@@ -35,63 +36,21 @@ void SwShadowCursor::SetPos( const Point& rPt, tools::Long nHeight, sal_uInt16 n
if( m_aOldPt != aPt || m_nOldHeight != nHeight || m_nOldMode != nMode )
{
if( USHRT_MAX != m_nOldMode )
- DrawCursor( m_aOldPt, m_nOldHeight, m_nOldMode );
+ DrawCursor( m_nOldMode);
- DrawCursor( aPt, nHeight, nMode );
+ DrawCursor( nMode);
m_nOldMode = nMode;
m_nOldHeight = nHeight;
m_aOldPt = aPt;
}
}
-void SwShadowCursor::DrawTri( const Point& rPt, tools::Long nHeight, bool bLeft )
+void SwShadowCursor::DrawCursor( sal_uInt16 nMode )
{
- tools::Long nLineDiff = nHeight / 2;
- tools::Long nLineDiffHalf = nLineDiff / 2;
-
- // Dot above
- Point aPt1( (bLeft ? rPt.X() - 3 : rPt.X() + 3),
- rPt.Y() + nLineDiffHalf );
- // Dot below
- Point aPt2( aPt1.X(), aPt1.Y() + nHeight - nLineDiff - 1 );
- tools::Long nDiff = bLeft ? -1 : 1;
- while( aPt1.Y() <= aPt2.Y() )
- {
- m_pWin->GetOutDev()->DrawLine( aPt1, aPt2 );
- aPt1.AdjustY( 1 );
- aPt2.AdjustY( -1 );
- aPt2.setX( aPt1.AdjustX(nDiff ) );
- }
-}
-
-void SwShadowCursor::DrawCursor( const Point& rPt, tools::Long nHeight, sal_uInt16 nMode )
-{
- nHeight = (((nHeight / 4)+1) * 4) + 1;
-
- m_pWin->GetOutDev()->Push();
-
- m_pWin->SetMapMode(MapMode(MapUnit::MapPixel));
- m_pWin->GetOutDev()->SetRasterOp( RasterOp::Xor );
-
- m_pWin->GetOutDev()->SetLineColor( Color( ColorTransparency, sal_uInt32(m_aCol) ^ sal_uInt32(COL_WHITE) ) );
-
- // 1. The Line:
- m_pWin->GetOutDev()->DrawLine( Point( rPt.X(), rPt.Y() + 1),
- Point( rPt.X(), rPt.Y() - 2 + nHeight ));
-
- // 2. The Triangle
- if( text::HoriOrientation::LEFT == nMode || text::HoriOrientation::CENTER == nMode ) // Arrow to the right
- DrawTri( rPt, nHeight, false );
- if( text::HoriOrientation::RIGHT == nMode || text::HoriOrientation::CENTER == nMode ) // Arrow to the left
- DrawTri( rPt, nHeight, true );
-
- m_pWin->GetOutDev()->Pop();
-}
-
-void SwShadowCursor::Paint()
-{
- if( USHRT_MAX != m_nOldMode )
- DrawCursor( m_aOldPt, m_nOldHeight, m_nOldMode );
+ if( text::HoriOrientation::LEFT == nMode ) // Arrow to the right
+ m_pWin->SetPointer(PointerStyle::AutoScrollE);
+ else // Arrow to the left
+ m_pWin->SetPointer(PointerStyle::AutoScrollW);
}
tools::Rectangle SwShadowCursor::GetRect() const