[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 3 commits - sw/source

Petr Mladek pmladek at kemper.freedesktop.org
Tue Jan 10 02:26:58 PST 2012


 sw/source/ui/docvw/HeaderFooterWin.cxx |   14 +++-
 sw/source/ui/docvw/PageBreakWin.cxx    |  108 ++++++---------------------------
 sw/source/ui/inc/HeaderFooterWin.hxx   |    1 
 sw/source/ui/inc/PageBreakWin.hxx      |    3 
 4 files changed, 37 insertions(+), 89 deletions(-)

New commits:
commit 1e0de54d88a79c99f0671f608f7de096cb721537
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Sat Jan 7 04:27:25 2012 +0100

    Page Breaks: IsLeaveWindow() is unreliable, we do not need it here.

diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx
index 0edeb61..ff5050b 100644
--- a/sw/source/ui/docvw/PageBreakWin.cxx
+++ b/sw/source/ui/docvw/PageBreakWin.cxx
@@ -83,17 +83,11 @@ namespace
 
     void SwBreakDashedLine::MouseMove( const MouseEvent& rMEvt )
     {
-        if ( rMEvt.IsLeaveWindow() )
-        {
-            // don't fade if we just move to the 'button'
-            Point aEventPos( GetPosPixel() + rMEvt.GetPosPixel() );
-            if ( !m_pWin->Contains( aEventPos ) )
-                m_pWin->Fade( false );
-        }
+        Point aEventPos( GetPosPixel() + rMEvt.GetPosPixel() );
+        if ( !m_pWin->Contains( aEventPos ) )
+            m_pWin->Fade( false );
         else if ( !m_pWin->IsVisible() )
-        {
             m_pWin->Fade( true );
-        }
 
         if ( !rMEvt.IsSynthetic() )
         {
@@ -309,13 +303,9 @@ void SwPageBreakWin::Select( )
 
 void SwPageBreakWin::MouseMove( const MouseEvent& rMEvt )
 {
-    if ( rMEvt.IsLeaveWindow() )
-    {
-        // don't fade if we just move to the 'line', or the popup menu is open
-        Point aEventPos( rMEvt.GetPosPixel() + rMEvt.GetPosPixel() );
-        if ( !Contains( aEventPos ) && !PopupMenu::IsInExecute() )
-            Fade( false );
-    }
+    Point aEventPos( rMEvt.GetPosPixel() + rMEvt.GetPosPixel() );
+    if ( !Contains( aEventPos ) && !PopupMenu::IsInExecute() )
+        Fade( false );
     else if ( !IsVisible() )
         Fade( true );
 }
commit a5f59c3802199f01dfbce70b01183d4d0166c2f2
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Sat Jan 7 04:16:44 2012 +0100

    Header/Footer, Page Breaks: Delay appearing by 500ms.
    
    The delay was a good idea, just the 1s was too long.

diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index ff7d50e..330c1ff 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -153,6 +153,7 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag
     m_pLine( NULL ),
     m_bIsAppearing( false ),
     m_nFadeRate( 100 ),
+    m_nDelayAppearing( 0 ),
     m_aFadeTimer( )
 {
     // Get the font and configure it
@@ -243,6 +244,9 @@ void SwHeaderFooterWin::ShowAll( bool bShow )
     if ( !PopupMenu::IsInExecute() )
     {
         m_bIsAppearing = bShow;
+        if ( bShow )
+            m_nDelayAppearing = 0;
+
         if ( m_aFadeTimer.IsActive( ) )
             m_aFadeTimer.Stop();
         m_aFadeTimer.Start( );
@@ -516,6 +520,14 @@ void SwHeaderFooterWin::Select( )
 
 IMPL_LINK( SwHeaderFooterWin, FadeHandler, Timer *, EMPTYARG )
 {
+    const int TICKS_BEFORE_WE_APPEAR = 10;
+    if ( m_bIsAppearing && m_nDelayAppearing < TICKS_BEFORE_WE_APPEAR )
+    {
+        ++m_nDelayAppearing;
+        m_aFadeTimer.Start();
+        return 0;
+    }
+
     if ( m_bIsAppearing && m_nFadeRate > 0 )
         m_nFadeRate -= 25;
     else if ( !m_bIsAppearing && m_nFadeRate < 100 )
@@ -535,7 +547,7 @@ IMPL_LINK( SwHeaderFooterWin, FadeHandler, Timer *, EMPTYARG )
         Invalidate();
 
     if ( IsVisible( ) && m_nFadeRate > 0 && m_nFadeRate < 100 )
-            m_aFadeTimer.Start();
+        m_aFadeTimer.Start();
 
     return 0;
 }
diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx
index 0617101..0edeb61 100644
--- a/sw/source/ui/docvw/PageBreakWin.cxx
+++ b/sw/source/ui/docvw/PageBreakWin.cxx
@@ -110,6 +110,7 @@ SwPageBreakWin::SwPageBreakWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm )
     m_pLine( NULL ),
     m_bIsAppearing( false ),
     m_nFadeRate( 100 ),
+    m_nDelayAppearing( 0 ),
     m_bDestroyed( false ),
     m_pMousePt( NULL )
 {
@@ -424,6 +425,9 @@ void SwPageBreakWin::SetReadonly( bool bReadonly )
 void SwPageBreakWin::Fade( bool bFadeIn )
 {
     m_bIsAppearing = bFadeIn;
+    if ( bFadeIn )
+        m_nDelayAppearing = 0;
+
     if ( !m_bDestroyed && m_aFadeTimer.IsActive( ) )
         m_aFadeTimer.Stop();
     if ( !m_bDestroyed )
@@ -439,6 +443,14 @@ IMPL_LINK( SwPageBreakWin, HideHandler, void *, EMPTYARG )
 
 IMPL_LINK( SwPageBreakWin, FadeHandler, Timer *, EMPTYARG )
 {
+    const int TICKS_BEFORE_WE_APPEAR = 10;
+    if ( m_bIsAppearing && m_nDelayAppearing < TICKS_BEFORE_WE_APPEAR )
+    {
+        ++m_nDelayAppearing;
+        m_aFadeTimer.Start();
+        return 0;
+    }
+
     if ( m_bIsAppearing && m_nFadeRate > 0 )
         m_nFadeRate -= 25;
     else if ( !m_bIsAppearing && m_nFadeRate < 100 )
diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx
index c895b53..6075bb3 100644
--- a/sw/source/ui/inc/HeaderFooterWin.hxx
+++ b/sw/source/ui/inc/HeaderFooterWin.hxx
@@ -46,6 +46,7 @@ class SwHeaderFooterWin : public MenuButton, public SwFrameControl
     Window*               m_pLine;
     bool                  m_bIsAppearing;
     int                   m_nFadeRate;
+    int                   m_nDelayAppearing; //< Before we show the control, let it transparent for a few timer ticks to avoid appearing with every mouse over.
     Timer                 m_aFadeTimer;
 
 public:
diff --git a/sw/source/ui/inc/PageBreakWin.hxx b/sw/source/ui/inc/PageBreakWin.hxx
index c782571..86c4623 100644
--- a/sw/source/ui/inc/PageBreakWin.hxx
+++ b/sw/source/ui/inc/PageBreakWin.hxx
@@ -45,6 +45,7 @@ class SwPageBreakWin : public MenuButton, public SwFrameControl
     Window*               m_pLine;
     bool                  m_bIsAppearing;
     int                   m_nFadeRate;
+    int                   m_nDelayAppearing; //< Before we show the control, let it transparent for a few timer ticks to avoid appearing with every mouse over.
     Timer                 m_aFadeTimer;
     bool                  m_bDestroyed;
 
commit d5143dba0fa2f6e47088a574cef1b6d626100841
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Sat Jan 7 03:32:58 2012 +0100

    Page Breaks: Vertically center the control.
    
    It is not necessary to draw it below the line when we draw it where the cursor
    stands; avoids disappearing when the user moves the cursor a bit up.

diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx
index f954b6e..0617101 100644
--- a/sw/source/ui/docvw/PageBreakWin.cxx
+++ b/sw/source/ui/docvw/PageBreakWin.cxx
@@ -68,52 +68,6 @@ using namespace drawinglayer::primitive2d;
 
 namespace
 {
-    static B2DPolygon lcl_CreatePolygon( B2DRectangle aBounds )
-    {
-        B2DPolygon aRetval;
-        const double nRadius = 1;
-        const double nKappa((M_SQRT2 - 1.0) * 4.0 / 3.0);
-
-        // Create the top right corner
-        {
-            B2DPoint aTMCorner( aBounds.getWidth(), 0.0 );
-            aRetval.append( aTMCorner );
-        }
-
-        // Create the bottom right corner
-        {
-            B2DPoint aBMCorner( aBounds.getWidth(), aBounds.getHeight() );
-            B2DVector aStartVect( 0.0, - nRadius );
-            B2DPoint aStart = aBMCorner + aStartVect;
-            B2DPoint aEnd = aBMCorner + B2DVector( - nRadius, 0.0 );
-            aRetval.append( aStart );
-            aRetval.appendBezierSegment(
-                    interpolate( aStart, aBMCorner, nKappa ),
-                    interpolate( aEnd, aBMCorner, nKappa ),
-                    aEnd );
-        }
-
-        // Create the bottom left corner
-        {
-            B2DPoint aBLCorner( aBounds.getMinX(), aBounds.getHeight() );
-            B2DPoint aStart( nRadius, aBounds.getHeight() );
-            B2DPoint aEnd( 0.0, aBounds.getHeight() - nRadius );
-            aRetval.append( aStart );
-            aRetval.appendBezierSegment(
-                    interpolate( aStart, aBLCorner, nKappa ),
-                    interpolate( aEnd, aBLCorner, nKappa ),
-                    aEnd );
-        }
-
-        // Create the top left corner
-        {
-            B2DPoint aTLCorner = aBounds.getMinimum();
-            aRetval.append( aTLCorner );
-        }
-
-        return aRetval;
-    }
-
     class SwBreakDashedLine : public SwDashedLine
     {
         private:
@@ -206,14 +160,12 @@ void SwPageBreakWin::Paint( const Rectangle& )
         aOtherColor = rSettings.GetDialogColor( ).getBColor();
     }
 
-    bool bShowOnRight = ShowOnRight( );
     bool bRtl = Application::GetSettings().GetLayoutRTL();
 
     Primitive2DSequence aSeq( 3 );
     B2DRectangle aBRect( double( aRect.Left() ), double( aRect.Top( ) ),
            double( aRect.Right() ), double( aRect.Bottom( ) ) );
-    bool bMirror = ( bShowOnRight && !bRtl ) || ( !bShowOnRight && bRtl );
-    B2DPolygon aPolygon = lcl_CreatePolygon( aBRect );
+    B2DPolygon aPolygon = createPolygonFromRect( aBRect, 3.0 / BUTTON_WIDTH, 3.0 / BUTTON_HEIGHT );
 
     // Create the polygon primitives
     aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D(
@@ -224,7 +176,7 @@ void SwPageBreakWin::Paint( const Rectangle& )
     // Create the primitive for the image
     Image aImg( SW_RES( IMG_PAGE_BREAK ) );
     double nImgOfstX = 3.0;
-    if ( bMirror )
+    if ( bRtl )
         nImgOfstX = aRect.Right() - aImg.GetSizePixel().Width() - 3.0;
     aSeq[2] = Primitive2DReference( new DiscreteBitmapPrimitive2D(
             aImg.GetBitmapEx(), B2DPoint( nImgOfstX, 1.0 ) ) );
@@ -235,7 +187,7 @@ void SwPageBreakWin::Paint( const Rectangle& )
         double nTop = double( aRect.getHeight() ) / 2.0;
         double nBottom = nTop + 4.0;
         double nLeft = aRect.getWidth( ) - ARROW_WIDTH - 6.0;
-        if ( bMirror )
+        if ( bRtl )
             nLeft = ARROW_WIDTH - 2.0;
         double nRight = nLeft + 8.0;
 
@@ -373,24 +325,6 @@ void SwPageBreakWin::Activate( )
     MenuButton::Activate();
 }
 
-bool SwPageBreakWin::ShowOnRight( )
-{
-    bool bOnRight = false;
-
-    // Handle the book mode / columns view case
-    const SwViewOption* pViewOpt = GetEditWin()->GetView().GetWrtShell().GetViewOptions();
-    bool bBookMode = pViewOpt->IsViewLayoutBookMode();
-
-    if ( bBookMode )
-        bOnRight = GetPageFrame()->SidebarPosition( ) == sw::sidebarwindows::SIDEBAR_RIGHT;
-
-    // Handle the RTL case
-    if ( !bBookMode && Application::GetSettings().GetLayoutRTL() )
-        bOnRight = !bOnRight;
-
-    return bOnRight;
-}
-
 void SwPageBreakWin::UpdatePosition( const Point* pEvtPt )
 {
     if ( pEvtPt != NULL )
@@ -450,7 +384,7 @@ void SwPageBreakWin::UpdatePosition( const Point* pEvtPt )
     }
 
     // Set the button position
-    Point aBtnPos( nBtnLeft, nYLineOffset + 1 );
+    Point aBtnPos( nBtnLeft, nYLineOffset - BUTTON_HEIGHT / 2 );
     SetPosSizePixel( aBtnPos, aBtnSize );
 
     // Set the line position
diff --git a/sw/source/ui/inc/PageBreakWin.hxx b/sw/source/ui/inc/PageBreakWin.hxx
index bd4eb64..c782571 100644
--- a/sw/source/ui/inc/PageBreakWin.hxx
+++ b/sw/source/ui/inc/PageBreakWin.hxx
@@ -71,8 +71,6 @@ public:
     void Fade( bool bFadeIn );
 
 private:
-    bool ShowOnRight();
-
     /// Hide the button (used when the popup menu is closed by clicking outside)
     DECL_LINK( HideHandler, void * );
     DECL_LINK( FadeHandler, Timer * );


More information about the Libreoffice-commits mailing list