diff options
author | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2011-10-12 02:01:03 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2011-10-12 02:04:57 +0200 |
commit | f7ffa5f14758fb49ca85b4cea7f705c2d438710e (patch) | |
tree | ec97cd33f4d310a973d260095b66161c02811447 | |
parent | 01e704121ace2d9c732fbf0fad0ef69cd3c39378 (diff) |
Header/Footer: Implemented fade in/out
-rw-r--r-- | sw/source/ui/docvw/HeaderFooterWin.cxx | 50 | ||||
-rw-r--r-- | sw/source/ui/docvw/PageBreakWin.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/inc/HeaderFooterWin.hxx | 6 |
3 files changed, 53 insertions, 5 deletions
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx index c536fe99039a..0c0aa00be06e 100644 --- a/sw/source/ui/docvw/HeaderFooterWin.cxx +++ b/sw/source/ui/docvw/HeaderFooterWin.cxx @@ -53,6 +53,7 @@ #include <drawinglayer/attribute/fillgradientattribute.hxx> #include <drawinglayer/attribute/fontattribute.hxx> #include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx> +#include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #include <drawinglayer/primitive2d/textlayoutdevice.hxx> @@ -149,7 +150,10 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag m_bIsHeader( bHeader ), m_bReadonly( false ), m_pPopupMenu( NULL ), - m_pLine( NULL ) + m_pLine( NULL ), + m_bIsAppearing( false ), + m_nFadeRate( 100 ), + m_aFadeTimer( ) { // Get the font and configure it Font aFont = GetSettings().GetStyleSettings().GetToolFont(); @@ -186,6 +190,9 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag aText = m_pPopupMenu->GetItemText( FN_HEADERFOOTER_DELETE ); m_pPopupMenu->SetItemText( FN_HEADERFOOTER_DELETE, aRewriter.Apply( aText ) ); SetPopupMenu( m_pPopupMenu ); + + m_aFadeTimer.SetTimeout( 500 ); + m_aFadeTimer.SetTimeoutHdl( LINK( this, SwHeaderFooterWin, FadeHandler ) ); } SwHeaderFooterWin::~SwHeaderFooterWin( ) @@ -229,8 +236,13 @@ void SwHeaderFooterWin::SetOffset( Point aOffset, long nXLineStart, long nXLineE void SwHeaderFooterWin::ShowAll( bool bShow ) { - Show( bShow ); - m_pLine->Show( bShow ); + if ( !PopupMenu::IsInExecute() ) + { + m_bIsAppearing = bShow; + if ( m_aFadeTimer.IsActive( ) ) + m_aFadeTimer.Stop(); + m_aFadeTimer.Start( ); + } } void SwHeaderFooterWin::Paint( const Rectangle& ) @@ -356,8 +368,12 @@ void SwHeaderFooterWin::Paint( const Rectangle& ) *this, aNewViewInfos ); // TODO Ghost it all if needed + Primitive2DSequence aGhostedSeq( 1 ); + double nFadeRate = double( m_nFadeRate ) / 100.0; + aGhostedSeq[0] = Primitive2DReference( new ModifiedColorPrimitive2D( + aSeq, BColorModifier( Color( COL_WHITE ).getBColor(), 1.0 - nFadeRate, BCOLORMODIFYMODE_INTERPOLATE ) ) ); - pProcessor->process( aSeq ); + pProcessor->process( aGhostedSeq ); } bool SwHeaderFooterWin::IsEmptyHeaderFooter( ) @@ -482,4 +498,30 @@ void SwHeaderFooterWin::Select( ) ExecuteCommand( GetCurItemId() ); } +IMPL_LINK( SwHeaderFooterWin, FadeHandler, Timer *, EMPTYARG ) +{ + if ( m_bIsAppearing && m_nFadeRate > 0 ) + m_nFadeRate -= 10; + else if ( !m_bIsAppearing && m_nFadeRate < 100 ) + m_nFadeRate += 10; + + if ( m_nFadeRate != 100 && !IsVisible() ) + { + Show( true ); + m_pLine->Show( true ); + } + else if ( m_nFadeRate == 100 && IsVisible( ) ) + { + Show( false ); + m_pLine->Show( false ); + } + else + Invalidate(); + + if ( IsVisible( ) && m_nFadeRate > 0 && m_nFadeRate < 100 ) + m_aFadeTimer.Start(); + + return 0; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx index 8e871e279a97..b48e450af0e7 100644 --- a/sw/source/ui/docvw/PageBreakWin.cxx +++ b/sw/source/ui/docvw/PageBreakWin.cxx @@ -376,7 +376,7 @@ void SwPageBreakWin::MouseMove( const MouseEvent& rMEvt ) void SwPageBreakWin::Activate( ) { - m_aFadeTimer.Stop(); + Fade( true ); MenuButton::Activate(); } diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx index 5ab8ef5041ee..247678ea75ae 100644 --- a/sw/source/ui/inc/HeaderFooterWin.hxx +++ b/sw/source/ui/inc/HeaderFooterWin.hxx @@ -44,6 +44,9 @@ class SwHeaderFooterWin : public MenuButton, public SwFrameControl bool m_bReadonly; PopupMenu* m_pPopupMenu; Window* m_pLine; + bool m_bIsAppearing; + int m_nFadeRate; + Timer m_aFadeTimer; public: SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm, bool bHeader ); @@ -64,6 +67,9 @@ public: void ExecuteCommand(sal_uInt16 nSlot); void SetReadonly( bool bReadonly ); + +private: + DECL_LINK( FadeHandler, Timer * ); }; #endif |