sw/source/ui/docvw/HeaderFooterWin.cxx | 288 +++++++++++++++++++++++---------- sw/source/ui/docvw/PageBreakWin.cxx | 20 +- sw/source/ui/inc/HeaderFooterWin.hxx | 6 3 files changed, 223 insertions(+), 91 deletions(-)
New commits: commit f7ffa5f14758fb49ca85b4cea7f705c2d438710e Author: Cédric Bosdonnat <cedric.bosdon...@free.fr> Date: Wed Oct 12 02:01:03 2011 +0200 Header/Footer: Implemented fade in/out diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx index c536fe9..0c0aa00 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 8e871e2..b48e450 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 5ab8ef5..247678e 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 commit 01e704121ace2d9c732fbf0fad0ef69cd3c39378 Author: Cédric Bosdonnat <cedric.bosdon...@free.fr> Date: Wed Oct 12 00:24:17 2011 +0200 Page Break: Make the line control thicker to ease fade in/out diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx index ebcd215..8e871e2 100644 --- a/sw/source/ui/docvw/PageBreakWin.cxx +++ b/sw/source/ui/docvw/PageBreakWin.cxx @@ -455,8 +455,8 @@ void SwPageBreakWin::UpdatePosition( ) SetPosSizePixel( aBtnPos, aBtnSize ); // Set the line position - Point aLinePos( nLineLeft, nYLineOffset ); - Size aLineSize( nLineRight - nLineLeft, 5 ); + Point aLinePos( nLineLeft, nYLineOffset - 5 ); + Size aLineSize( nLineRight - nLineLeft, 10 ); m_pLine->SetPosSizePixel( aLinePos, aLineSize ); } commit 8398373c622d0f1c9088e0193b99474b5d4284a5 Author: Cédric Bosdonnat <cedric.bosdon...@free.fr> Date: Tue Oct 11 17:54:38 2011 +0200 Header/Footer: using the drawinglayer to paint the indicator First step before implementing Fade In/Out diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx index 770f1cd..c536fe9 100644 --- a/sw/source/ui/docvw/HeaderFooterWin.cxx +++ b/sw/source/ui/docvw/HeaderFooterWin.cxx @@ -45,11 +45,22 @@ #include <viewopt.hxx> #include <wrtsh.hxx> -#include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/color/bcolortools.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/range/b2drectangle.hxx> +#include <basegfx/vector/b2dsize.hxx> +#include <drawinglayer/attribute/fillgradientattribute.hxx> +#include <drawinglayer/attribute/fontattribute.hxx> +#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx> +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> +#include <drawinglayer/primitive2d/textlayoutdevice.hxx> +#include <drawinglayer/primitive2d/textprimitive2d.hxx> #include <editeng/boxitem.hxx> #include <svtools/svtdata.hxx> #include <svx/hdft.hxx> +#include <svx/sdr/contact/objectcontacttools.hxx> #include <vcl/decoview.hxx> #include <vcl/gradient.hxx> #include <vcl/menubtn.hxx> @@ -59,6 +70,11 @@ #define BOX_DISTANCE 10 #define BUTTON_WIDTH 18 +using namespace basegfx; +using namespace basegfx::tools; +using namespace drawinglayer; +using namespace drawinglayer::primitive2d; + namespace { basegfx::BColor lcl_GetFillColor( basegfx::BColor aLineColor ) @@ -81,59 +97,47 @@ namespace return basegfx::tools::hsl2rgb( aHslDark ); } - void lcl_DrawBackground( OutputDevice* pOut, const Rectangle& rRect, bool bHeader ) + B2DPolygon lcl_GetPolygon( const Rectangle& rRect, bool bHeader ) { - basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor(); + const double nRadius = 3; + const double nKappa((M_SQRT2 - 1.0) * 4.0 / 3.0); - const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); - if ( rSettings.GetHighContrastMode() ) - { - aLineColor = rSettings.GetDialogTextColor().getBColor(); - - pOut->SetFillColor( rSettings.GetDialogColor( ) ); - pOut->SetLineColor( rSettings.GetDialogTextColor( ) ); + B2DPolygon aPolygon; + aPolygon.append( B2DPoint( rRect.Left(), rRect.Top() ) ); - pOut->DrawRect( rRect ); - } - else { - // Colors - basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor ); - basegfx::BColor aLighterColor = lcl_GetLighterGradientColor( aFillColor ); - // Draw the background gradient - Gradient aGradient; - if ( bHeader ) - aGradient = Gradient( GRADIENT_LINEAR, - Color( aLighterColor ), Color( aFillColor ) ); - else - aGradient = Gradient( GRADIENT_LINEAR, - Color( aFillColor ), Color( aLighterColor ) ); - - pOut->DrawGradient( rRect, aGradient ); - - pOut->SetFillColor( Color ( aFillColor ) ); - pOut->SetLineColor( Color ( aFillColor ) ); + B2DPoint aCorner( rRect.Left(), rRect.Bottom() ); + B2DPoint aStart( rRect.Left(), rRect.Bottom() - nRadius ); + B2DPoint aEnd( rRect.Left() + nRadius, rRect.Bottom() ); + aPolygon.append( aStart ); + aPolygon.appendBezierSegment( + interpolate( aStart, aCorner, nKappa ), + interpolate( aEnd, aCorner, nKappa ), + aEnd ); } - // Draw the lines around the rect - pOut->SetLineColor( Color( aLineColor ) ); - basegfx::B2DPolygon aPolygon; - aPolygon.append( basegfx::B2DPoint( rRect.Left(), rRect.Top() ) ); - aPolygon.append( basegfx::B2DPoint( rRect.Left(), rRect.Bottom() ) ); - pOut->DrawPolyLine( aPolygon, 1.0 ); + { + B2DPoint aCorner( rRect.Right(), rRect.Bottom() ); + B2DPoint aStart( rRect.Right() - nRadius, rRect.Bottom() ); + B2DPoint aEnd( rRect.Right(), rRect.Bottom() - nRadius ); + aPolygon.append( aStart ); + aPolygon.appendBezierSegment( + interpolate( aStart, aCorner, nKappa ), + interpolate( aEnd, aCorner, nKappa ), + aEnd ); + } - aPolygon.clear(); - aPolygon.append( basegfx::B2DPoint( rRect.Right(), rRect.Top() ) ); - aPolygon.append( basegfx::B2DPoint( rRect.Right(), rRect.Bottom() ) ); - pOut->DrawPolyLine( aPolygon, 1.0 ); + aPolygon.append( B2DPoint( rRect.Right(), rRect.Top() ) ); - long nYLine = rRect.Bottom(); if ( !bHeader ) - nYLine = rRect.Top(); - aPolygon.clear(); - aPolygon.append( basegfx::B2DPoint( rRect.Left(), nYLine ) ); - aPolygon.append( basegfx::B2DPoint( rRect.Right(), nYLine ) ); - pOut->DrawPolyLine( aPolygon, 1.0 ); + { + B2DRectangle aBRect( rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom() ); + B2DHomMatrix aRotation = createRotateAroundPoint( + aBRect.getCenterX(), aBRect.getCenterY(), M_PI ); + aPolygon.transform( aRotation ); + } + + return aPolygon; } } @@ -164,6 +168,7 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag // Create the line control basegfx::BColor aColor = SwViewOption::GetHeaderFooterMarkColor().getBColor(); m_pLine = new SwDashedLine( GetEditWin(), aColor ); + m_pLine->SetZOrder( this, WINDOW_ZORDER_BEFOR ); // Create and set the PopupMenu m_pPopupMenu = new PopupMenu( SW_RES( MN_HEADERFOOTER_BUTTON ) ); @@ -231,47 +236,128 @@ void SwHeaderFooterWin::ShowAll( bool bShow ) void SwHeaderFooterWin::Paint( const Rectangle& ) { const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) ); - lcl_DrawBackground( this, aRect, m_bIsHeader ); + Primitive2DSequence aSeq( 3 ); - // Draw the text - Rectangle aTextRect; - GetTextBoundRect( aTextRect, String( m_sLabel ) ); - Point aTextPos = aTextRect.TopLeft() + Point( TEXT_PADDING, 0 ); + B2DPolygon aPolygon = lcl_GetPolygon( aRect, m_bIsHeader ); - const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + // Colors basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor(); - if ( rSettings.GetHighContrastMode( ) ) + basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor ); + basegfx::BColor aLighterColor = lcl_GetLighterGradientColor( aFillColor ); + + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + if ( rSettings.GetHighContrastMode() ) + { aLineColor = rSettings.GetDialogTextColor().getBColor(); - SetTextColor( Color( aLineColor ) ); - DrawText( aTextPos, String( m_sLabel ) ); - // Paint the symbol if not readonly button + aFillColor = rSettings.GetDialogColor( ).getBColor(); + aLineColor = rSettings.GetDialogTextColor( ).getBColor(); + + aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D( + B2DPolyPolygon( aPolygon ), aFillColor ) ); + } + else + { + B2DRectangle aGradientRect( aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom() ); + double nAngle = M_PI; + if ( m_bIsHeader ) + nAngle = 0; + attribute::FillGradientAttribute aFillAttrs( attribute::GRADIENTSTYLE_LINEAR, 0.0, 0.0, 0.0, nAngle, + aLighterColor, aFillColor, 10 ); + aSeq[0] = Primitive2DReference( new FillGradientPrimitive2D( + aGradientRect, aFillAttrs ) ); + } + + // Create the border lines primitive + aSeq[1] = Primitive2DReference( new PolygonHairlinePrimitive2D( + aPolygon, aLineColor ) ); + + // Create the text primitive + B2DVector aFontSize; + attribute::FontAttribute aFontAttr = primitive2d::getFontAttributeFromVclFont( + aFontSize, GetFont(), false, false ); + + Rectangle aTextRect; + GetTextBoundRect( aTextRect, String( m_sLabel ) ); + + FontMetric aFontMetric = GetFontMetric( GetFont() ); + double nTextOffsetY = aFontMetric.GetHeight() - aFontMetric.GetDescent() + TEXT_PADDING; + + Point aTextPos( TEXT_PADDING, nTextOffsetY ); + + basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix( + aFontSize.getX(), aFontSize.getY(), + double( aTextPos.X() ), double( aTextPos.Y() ) ) ); + + aSeq[2] = Primitive2DReference( new TextSimplePortionPrimitive2D( + aTextMatrix, + String( m_sLabel ), 0, m_sLabel.getLength(), + std::vector< double >( ), + aFontAttr, + com::sun::star::lang::Locale(), + aLineColor ) ); + + // Create the 'plus' or 'arrow' primitive if not readonly if ( !m_bReadonly ) { - Point aPicPos( aRect.getWidth() - BUTTON_WIDTH, 0 ); - Size aPicSize( BUTTON_WIDTH, aRect.getHeight() ); - Rectangle aSymbolRect( aPicPos, aPicSize ); - - // 25% distance to the left and right button border - const long nBorderDistanceLeftAndRight = ((aSymbolRect.GetWidth()*250)+500)/1000; - aSymbolRect.Left()+=nBorderDistanceLeftAndRight; - aSymbolRect.Right()-=nBorderDistanceLeftAndRight; - // 30% distance to the top button border - const long nBorderDistanceTop = ((aSymbolRect.GetHeight()*300)+500)/1000; - aSymbolRect.Top()+=nBorderDistanceTop; - // 25% distance to the bottom button border - const long nBorderDistanceBottom = ((aSymbolRect.GetHeight()*250)+500)/1000; - aSymbolRect.Bottom()-=nBorderDistanceBottom; - - SymbolType nSymbol = SYMBOL_SPIN_DOWN; + B2DRectangle aSignArea( B2DPoint( aRect.Right() - BUTTON_WIDTH, 0.0 ), + B2DSize( aRect.Right(), aRect.getHeight() ) ); + + B2DPolygon aSign; if ( IsEmptyHeaderFooter( ) ) - nSymbol = SYMBOL_PLUS; - DecorationView aDecoView( this ); - aDecoView.DrawSymbol( aSymbolRect, nSymbol, - ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() - ? Color( COL_WHITE ) - : Color( COL_BLACK ) ) ); + { + // Create the + polygon + double nLeft = aSignArea.getMinX() + TEXT_PADDING; + double nRight = aSignArea.getMaxX() - TEXT_PADDING; + double nHalfW = ( nRight - nLeft ) / 2.0; + + double nTop = aSignArea.getCenterY() - nHalfW; + double nBottom = aSignArea.getCenterY() + nHalfW; + + aSign.append( B2DPoint( nLeft, aSignArea.getCenterY() - 1.0 ) ); + aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, aSignArea.getCenterY() - 1.0 ) ); + aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, nTop ) ); + aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, nTop ) ); + aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, aSignArea.getCenterY() - 1.0 ) ); + aSign.append( B2DPoint( nRight, aSignArea.getCenterY() - 1.0 ) ); + aSign.append( B2DPoint( nRight, aSignArea.getCenterY() + 1.0 ) ); + aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, aSignArea.getCenterY() + 1.0 ) ); + aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, nBottom ) ); + aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, nBottom ) ); + aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, aSignArea.getCenterY() + 1.0 ) ); + aSign.append( B2DPoint( nLeft, aSignArea.getCenterY() + 1.0 ) ); + aSign.setClosed( true ); + } + else + { + // Create the v polygon + B2DPoint aLeft( aSignArea.getMinX() + TEXT_PADDING, aSignArea.getCenterY() ); + B2DPoint aRight( aSignArea.getMaxX() - TEXT_PADDING, aSignArea.getCenterY() ); + B2DPoint aBottom( ( aLeft.getX() + aRight.getX() ) / 2.0, aLeft.getY() + 4.0 ); + aSign.append( aLeft ); + aSign.append( aRight ); + aSign.append( aBottom ); + aSign.setClosed( true ); + } + + BColor aSignColor = Color( COL_BLACK ).getBColor( ); + if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) + aSignColor = Color( COL_WHITE ).getBColor( ); + + aSeq.realloc( aSeq.getLength() + 1 ); + aSeq[ aSeq.getLength() - 1 ] = Primitive2DReference( new PolyPolygonColorPrimitive2D( + B2DPolyPolygon( aSign ), aSignColor ) ); } + + // Create the processor and process the primitives + const drawinglayer::geometry::ViewInformation2D aNewViewInfos; + drawinglayer::processor2d::BaseProcessor2D * pProcessor = + sdr::contact::createBaseProcessor2DFromOutputDevice( + *this, aNewViewInfos ); + + // TODO Ghost it all if needed + + pProcessor->process( aSeq ); } bool SwHeaderFooterWin::IsEmptyHeaderFooter( ) diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx index f23b856..ebcd215 100644 --- a/sw/source/ui/docvw/PageBreakWin.cxx +++ b/sw/source/ui/docvw/PageBreakWin.cxx @@ -56,7 +56,6 @@ #include <editeng/brkitem.hxx> #include <sfx2/dispatch.hxx> #include <svx/sdr/contact/objectcontacttools.hxx> -#include <vcl/decoview.hxx> #include <vcl/svapp.hxx> #define BUTTON_WIDTH 30 @@ -250,13 +249,6 @@ void SwPageBreakWin::Paint( const Rectangle& ) aSeq[2] = Primitive2DReference( new DiscreteBitmapPrimitive2D( aImg.GetBitmapEx(), B2DPoint( nImgOfstX, 1.0 ) ) ); - // Create the processor and process the primitives - const drawinglayer::geometry::ViewInformation2D aNewViewInfos; - drawinglayer::processor2d::BaseProcessor2D * pProcessor = - sdr::contact::createBaseProcessor2DFromOutputDevice( - *this, aNewViewInfos ); - - // Paint the symbol if not readonly button if ( IsEnabled() ) { @@ -287,6 +279,12 @@ void SwPageBreakWin::Paint( const Rectangle& ) aGhostedSeq[0] = Primitive2DReference( new ModifiedColorPrimitive2D( aSeq, BColorModifier( Color( COL_WHITE ).getBColor(), 1.0 - nFadeRate, BCOLORMODIFYMODE_INTERPOLATE ) ) ); + // Create the processor and process the primitives + const drawinglayer::geometry::ViewInformation2D aNewViewInfos; + drawinglayer::processor2d::BaseProcessor2D * pProcessor = + sdr::contact::createBaseProcessor2DFromOutputDevice( + *this, aNewViewInfos ); + pProcessor->process( aGhostedSeq ); }
_______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits