Kaydet (Commit) 965e72d6 authored tarafından Cédric Bosdonnat's avatar Cédric Bosdonnat

Page Break: show the page break right under the mouse

üst 6572e22d
...@@ -68,59 +68,22 @@ using namespace drawinglayer::primitive2d; ...@@ -68,59 +68,22 @@ using namespace drawinglayer::primitive2d;
namespace namespace
{ {
static B2DPolygon lcl_CreatePolygon( B2DRectangle aBounds, bool bMirror ) static B2DPolygon lcl_CreatePolygon( B2DRectangle aBounds )
{ {
B2DPolygon aRetval; B2DPolygon aRetval;
const double nRadius = 1; const double nRadius = 1;
const double nKappa((M_SQRT2 - 1.0) * 4.0 / 3.0); const double nKappa((M_SQRT2 - 1.0) * 4.0 / 3.0);
// Create the top left corner // Create the top right corner
{
B2DPoint aTLCorner = aBounds.getMinimum();
B2DPoint aStart( 0.0, nRadius );
B2DPoint aEnd( nRadius, 0.0 );
aRetval.append( aStart );
aRetval.appendBezierSegment(
interpolate( aStart, aTLCorner, nKappa ),
interpolate( aEnd, aTLCorner, nKappa ),
aEnd );
}
// Create the top right angle
{
B2DPoint aTMCorner( aBounds.getWidth() - ARROW_WIDTH, 0.0 );
B2DPoint aStart = aTMCorner + B2DVector( - nRadius, 0.0 );
B2DVector aEndVect( double( ARROW_WIDTH ), aBounds.getHeight() / 2.0 );
aEndVect.setLength( nRadius );
B2DPoint aEnd = aTMCorner + aEndVect;
aRetval.append( aStart );
aRetval.appendBezierSegment(
interpolate( aStart, aTMCorner, nKappa ),
interpolate( aEnd, aTMCorner, nKappa ),
aEnd );
}
// Create the right corner
{ {
B2DPoint aMRCorner( aBounds.getWidth(), aBounds.getHeight() / 2.0 ); B2DPoint aTMCorner( aBounds.getWidth(), 0.0 );
B2DVector aStartVect( double( - ARROW_WIDTH ), - aBounds.getHeight() / 2.0 ); aRetval.append( aTMCorner );
aStartVect.setLength( nRadius );
B2DPoint aStart = aMRCorner + aStartVect;
B2DVector aEndVect( double( - ARROW_WIDTH ), aBounds.getHeight() / 2.0 );
aEndVect.setLength( nRadius );
B2DPoint aEnd = aMRCorner + aEndVect;
aRetval.append( aStart );
aRetval.appendBezierSegment(
interpolate( aStart, aMRCorner, nKappa ),
interpolate( aEnd, aMRCorner, nKappa ),
aEnd );
} }
// Create the bottom right angle // Create the bottom right corner
{ {
B2DPoint aBMCorner( aBounds.getWidth() - ARROW_WIDTH, aBounds.getHeight() ); B2DPoint aBMCorner( aBounds.getWidth(), aBounds.getHeight() );
B2DVector aStartVect( double( ARROW_WIDTH ), - aBounds.getHeight() / 2.0 ); B2DVector aStartVect( 0.0, - nRadius );
aStartVect.setLength( nRadius );
B2DPoint aStart = aBMCorner + aStartVect; B2DPoint aStart = aBMCorner + aStartVect;
B2DPoint aEnd = aBMCorner + B2DVector( - nRadius, 0.0 ); B2DPoint aEnd = aBMCorner + B2DVector( - nRadius, 0.0 );
aRetval.append( aStart ); aRetval.append( aStart );
...@@ -142,13 +105,10 @@ namespace ...@@ -142,13 +105,10 @@ namespace
aEnd ); aEnd );
} }
aRetval.setClosed( true ); // Create the top left corner
if ( bMirror )
{ {
B2DHomMatrix bRotMatrix = createRotateAroundPoint( B2DPoint aTLCorner = aBounds.getMinimum();
aBounds.getCenterX(), aBounds.getCenterY(), M_PI ); aRetval.append( aTLCorner );
aRetval.transform( bRotMatrix );
} }
return aRetval; return aRetval;
...@@ -178,7 +138,12 @@ namespace ...@@ -178,7 +138,12 @@ namespace
m_pWin->Fade( false ); m_pWin->Fade( false );
} }
else if ( !m_pWin->IsVisible() ) else if ( !m_pWin->IsVisible() )
{
m_pWin->Fade( true ); m_pWin->Fade( true );
}
Point* pPtr = new Point( rMEvt.GetPosPixel() );
m_pWin->UpdatePosition( pPtr );
} }
void SwBreakDashedLine::MouseButtonDown( const MouseEvent& rMEvt ) void SwBreakDashedLine::MouseButtonDown( const MouseEvent& rMEvt )
...@@ -199,7 +164,8 @@ SwPageBreakWin::SwPageBreakWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm ) ...@@ -199,7 +164,8 @@ SwPageBreakWin::SwPageBreakWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm )
m_pLine( NULL ), m_pLine( NULL ),
m_bIsAppearing( false ), m_bIsAppearing( false ),
m_nFadeRate( 100 ), m_nFadeRate( 100 ),
m_bDestroyed( false ) m_bDestroyed( false ),
m_pMousePt( NULL )
{ {
// Use pixels for the rest of the drawing // Use pixels for the rest of the drawing
SetMapMode( MapMode ( MAP_PIXEL ) ); SetMapMode( MapMode ( MAP_PIXEL ) );
...@@ -224,6 +190,7 @@ SwPageBreakWin::~SwPageBreakWin( ) ...@@ -224,6 +190,7 @@ SwPageBreakWin::~SwPageBreakWin( )
delete m_pPopupMenu; delete m_pPopupMenu;
delete m_pLine; delete m_pLine;
delete m_pMousePt;
} }
void SwPageBreakWin::Paint( const Rectangle& ) void SwPageBreakWin::Paint( const Rectangle& )
...@@ -255,7 +222,7 @@ void SwPageBreakWin::Paint( const Rectangle& ) ...@@ -255,7 +222,7 @@ void SwPageBreakWin::Paint( const Rectangle& )
B2DRectangle aBRect( double( aRect.Left() ), double( aRect.Top( ) ), B2DRectangle aBRect( double( aRect.Left() ), double( aRect.Top( ) ),
double( aRect.Right() ), double( aRect.Bottom( ) ) ); double( aRect.Right() ), double( aRect.Bottom( ) ) );
bool bMirror = ( bShowOnRight && !bRtl ) || ( !bShowOnRight && bRtl ); bool bMirror = ( bShowOnRight && !bRtl ) || ( !bShowOnRight && bRtl );
B2DPolygon aPolygon = lcl_CreatePolygon( aBRect, bMirror ); B2DPolygon aPolygon = lcl_CreatePolygon( aBRect );
// Create the polygon primitives // Create the polygon primitives
aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D( aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D(
...@@ -401,7 +368,7 @@ void SwPageBreakWin::MouseMove( const MouseEvent& rMEvt ) ...@@ -401,7 +368,7 @@ void SwPageBreakWin::MouseMove( const MouseEvent& rMEvt )
if ( rMEvt.IsLeaveWindow() ) if ( rMEvt.IsLeaveWindow() )
{ {
// don't fade if we just move to the 'line', or the popup menu is open // don't fade if we just move to the 'line', or the popup menu is open
Point aEventPos( GetPosPixel() + rMEvt.GetPosPixel() ); Point aEventPos( rMEvt.GetPosPixel() + rMEvt.GetPosPixel() );
if ( !Contains( aEventPos ) && !PopupMenu::IsInExecute() ) if ( !Contains( aEventPos ) && !PopupMenu::IsInExecute() )
Fade( false ); Fade( false );
} }
...@@ -433,8 +400,16 @@ bool SwPageBreakWin::ShowOnRight( ) ...@@ -433,8 +400,16 @@ bool SwPageBreakWin::ShowOnRight( )
return bOnRight; return bOnRight;
} }
void SwPageBreakWin::UpdatePosition( ) void SwPageBreakWin::UpdatePosition( const Point* pEvtPt )
{ {
if ( pEvtPt != NULL )
{
if ( pEvtPt == m_pMousePt )
return;
delete m_pMousePt;
m_pMousePt = pEvtPt;
}
const SwPageFrm* pPageFrm = GetPageFrame(); const SwPageFrm* pPageFrm = GetPageFrame();
const SwFrm* pPrevPage = pPageFrm->GetPrev(); const SwFrm* pPrevPage = pPageFrm->GetPrev();
while ( pPrevPage && ( pPrevPage->Frm().Top( ) == pPageFrm->Frm().Top( ) ) ) while ( pPrevPage && ( pPrevPage->Frm().Top( ) == pPageFrm->Frm().Top( ) ) )
...@@ -471,18 +446,17 @@ void SwPageBreakWin::UpdatePosition( ) ...@@ -471,18 +446,17 @@ void SwPageBreakWin::UpdatePosition( )
long nLineLeft = std::max( nPgLeft, aVisArea.Left() ); long nLineLeft = std::max( nPgLeft, aVisArea.Left() );
long nLineRight = std::min( nPgRight, aVisArea.Right() ); long nLineRight = std::min( nPgRight, aVisArea.Right() );
long nBtnLeft = nPgLeft; long nBtnLeft = nLineLeft;
if ( ShowOnRight( ) ) if ( m_pMousePt )
{ {
long nRight = std::min( nPgRight + aBtnSize.getWidth() - ARROW_WIDTH / 2, aVisArea.Right() ); nBtnLeft = nLineLeft + m_pMousePt->X();
nBtnLeft = nRight - aBtnSize.getWidth(); if ( ( nBtnLeft + aBtnSize.getWidth() ) > nLineRight )
nBtnLeft = nLineRight - aBtnSize.getWidth();
} }
else
nBtnLeft = std::max( nPgLeft - aBtnSize.Width() + ARROW_WIDTH / 2, aVisArea.Left() );
// Set the button position // Set the button position
Point aBtnPos( nBtnLeft, nYLineOffset - aBtnSize.Height() / 2 ); Point aBtnPos( nBtnLeft, nYLineOffset + 1 );
SetPosSizePixel( aBtnPos, aBtnSize ); SetPosSizePixel( aBtnPos, aBtnSize );
// Set the line position // Set the line position
......
...@@ -48,6 +48,8 @@ class SwPageBreakWin : public MenuButton, public SwFrameControl ...@@ -48,6 +48,8 @@ class SwPageBreakWin : public MenuButton, public SwFrameControl
Timer m_aFadeTimer; Timer m_aFadeTimer;
bool m_bDestroyed; bool m_bDestroyed;
const Point* m_pMousePt;
public: public:
SwPageBreakWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm ); SwPageBreakWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm );
~SwPageBreakWin( ); ~SwPageBreakWin( );
...@@ -57,7 +59,7 @@ public: ...@@ -57,7 +59,7 @@ public:
virtual void MouseMove( const MouseEvent& rMEvt ); virtual void MouseMove( const MouseEvent& rMEvt );
virtual void Activate( ); virtual void Activate( );
void UpdatePosition( ); void UpdatePosition( const Point* pEvtPt = NULL );
virtual void ShowAll( bool bShow ); virtual void ShowAll( bool bShow );
virtual bool Contains( const Point &rDocPt ) const; virtual bool Contains( const Point &rDocPt ) const;
......
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