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

Header/Footer: display improvements

Changed the following:
 + Draw a gradient in the separator tabs background
 + Draw a solid line under the dotted one to have a contrast for some page
   background colors.
üst d670cdcf
...@@ -3279,31 +3279,48 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr ...@@ -3279,31 +3279,48 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
const SwPageFrm* pPageFrm, double nLineY ) const SwPageFrm* pPageFrm, double nLineY )
{ {
// Adjust the Y-coordinate of the line to the header/footer box // Adjust the Y-coordinate of the line to the header/footer box
drawinglayer::primitive2d::Primitive2DSequence aSeq( 1 ); drawinglayer::primitive2d::Primitive2DSequence aSeq( 2 );
basegfx::B2DPoint aLeft ( pPageFrm->Frm().Left(), nLineY ); basegfx::B2DPoint aLeft ( pPageFrm->Frm().Left(), nLineY );
basegfx::B2DPoint aRight( pPageFrm->Frm().Right(), nLineY ); basegfx::B2DPoint aRight( pPageFrm->Frm().Right(), nLineY );
basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor(); basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
// Get a color for the contrast
basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aLineColor );
double nLuminance = aHslLine.getZ() * 2.5;
if ( nLuminance == 0 )
nLuminance = 0.5;
else if ( nLuminance >= 1.0 )
nLuminance = aHslLine.getZ() * 0.4;
aHslLine.setZ( nLuminance );
const basegfx::BColor aOtherColor = basegfx::tools::hsl2rgb( aHslLine );
// Compute the plain line
basegfx::B2DPolygon aLinePolygon;
aLinePolygon.append( aLeft );
aLinePolygon.append( aRight );
drawinglayer::primitive2d::PolygonHairlinePrimitive2D * pPlainLine =
new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
aLinePolygon, aOtherColor );
aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pPlainLine );
// Dashed line in twips // Dashed line in twips
std::vector< double > aStrokePattern; std::vector< double > aStrokePattern;
aStrokePattern.push_back( 40 ); aStrokePattern.push_back( 40 );
aStrokePattern.push_back( 40 ); aStrokePattern.push_back( 40 );
// Compute the dashed line primitive // Compute the dashed line primitive
basegfx::B2DPolygon aLinePolygon;
aLinePolygon.append( aLeft );
aLinePolygon.append( aRight );
drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine = drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine =
new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D ( new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D (
basegfx::B2DPolyPolygon( aLinePolygon ), basegfx::B2DPolyPolygon( aLinePolygon ),
drawinglayer::attribute::LineAttribute( aLineColor ), drawinglayer::attribute::LineAttribute( aLineColor ),
drawinglayer::attribute::StrokeAttribute( aStrokePattern ) ); drawinglayer::attribute::StrokeAttribute( aStrokePattern ) );
aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pLine ); aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( pLine );
return aSeq; return aSeq;
} }
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include <editeng/ulspitem.hxx> #include <editeng/ulspitem.hxx>
#include <svtools/svtdata.hxx> #include <svtools/svtdata.hxx>
#include <vcl/decoview.hxx> #include <vcl/decoview.hxx>
#include <vcl/gradient.hxx>
#include <vcl/menubtn.hxx> #include <vcl/menubtn.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
...@@ -69,16 +70,35 @@ namespace ...@@ -69,16 +70,35 @@ namespace
return basegfx::tools::hsl2rgb( aHslLine ); return basegfx::tools::hsl2rgb( aHslLine );
} }
basegfx::BColor lcl_GetLighterGradientColor( basegfx::BColor aDarkColor )
{
basegfx::BColor aHslDark = basegfx::tools::rgb2hsl( aDarkColor );
double nLuminance = aHslDark.getZ() * 255 + 20;
aHslDark.setZ( nLuminance / 255.0 );
return basegfx::tools::hsl2rgb( aHslDark );
}
void lcl_DrawBackground( OutputDevice* pOut, const Rectangle& rRect, bool bHeader ) void lcl_DrawBackground( OutputDevice* pOut, const Rectangle& rRect, bool bHeader )
{ {
// Colors // Colors
basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor(); basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor ); 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 );
// Draw the background rect
pOut->SetFillColor( Color ( aFillColor ) ); pOut->SetFillColor( Color ( aFillColor ) );
pOut->SetLineColor( Color ( aFillColor ) ); pOut->SetLineColor( Color ( aFillColor ) );
pOut->DrawRect( rRect );
// Draw the lines around the rect // Draw the lines around the rect
pOut->SetLineColor( Color( aLineColor ) ); pOut->SetLineColor( Color( aLineColor ) );
......
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