From 5da6de552eaef7849e563d7b3c0ef8dc1a3d54ac Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Wed, 16 Jun 2010 17:58:45 +0200 Subject: [PATCH] renaissance1: #i107215# Fixed painting of page object backgrounds. Page numbers of selected pages are now painted darker. --- .../slidesorter/view/SlsPageObjectPainter.cxx | 76 +++++++++++-------- sd/source/ui/slidesorter/view/SlsTheme.cxx | 4 +- 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx index c96ccf0bec25..cb0312238523 100644 --- a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx +++ b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx @@ -325,9 +325,15 @@ void PageObjectPainter::PaintPageNumber ( // Determine the color of the page number. Color aPageNumberColor (mpTheme->GetColor(Theme::Color_PageNumberDefault)); - if (rpDescriptor->HasState(model::PageDescriptor::ST_MouseOver)) + if (rpDescriptor->HasState(model::PageDescriptor::ST_MouseOver) || + rpDescriptor->HasState(model::PageDescriptor::ST_Selected)) + { + // Page number is painted on background for hover or selection or + // both. Each of these background colors has a predefined luminance + // which is compatible with the PageNumberHover color. aPageNumberColor = Color(mpTheme->GetColor(Theme::Color_PageNumberHover)); - else if ( ! rpDescriptor->HasState(model::PageDescriptor::ST_Selected)) + } + else { const Color aBackgroundColor (mpTheme->GetColor(Theme::Color_Background)); const sal_Int32 nBackgroundLuminance (aBackgroundColor.GetLuminance()); @@ -337,9 +343,9 @@ void PageObjectPainter::PaintPageNumber ( aPageNumberColor = Color(mpTheme->GetColor(Theme::Color_PageNumberHighContrast)); else { - // Compare luminance of default page number color and background - // color. When the two are similar then use a darker (preferred) or - // brighter font color. + // Compare luminance of default page number color and background + // color. When the two are similar then use a darker + // (preferred) or brighter font color. const sal_Int32 nFontLuminance (aPageNumberColor.GetLuminance()); if (abs(nBackgroundLuminance - nFontLuminance) < 60) if (nBackgroundLuminance > nFontLuminance-30) @@ -474,40 +480,50 @@ Bitmap PageObjectPainter::CreateBackgroundBitmap( aBitmapDevice.SetOutputSizePixel(aSize); // Fill the background with the background color of the slide sorter. - aBitmapDevice.SetFillColor(mpTheme->GetColor(Theme::Color_Background)); - aBitmapDevice.SetLineColor(mpTheme->GetColor(Theme::Color_Background)); + const Color aBackgroundColor (mpTheme->GetColor(Theme::Color_Background)); + OSL_TRACE("filling background of page object bitmap with color %x", aBackgroundColor.GetColor()); + aBitmapDevice.SetFillColor(aBackgroundColor); + aBitmapDevice.SetLineColor(aBackgroundColor); aBitmapDevice.DrawRect(Rectangle(Point(0,0), aSize)); // Paint the slide area with a linear gradient that starts some pixels // below the top and ends some pixels above the bottom. - const sal_Int32 nHeight (aPageObjectBox.GetHeight()); - const sal_Int32 nDefaultConstantSize(nHeight/4); - const sal_Int32 nMinimalGradientSize(40); - const sal_Int32 nY1 ( - ::std::max( - 0, - ::std::min( - nDefaultConstantSize, - (nHeight - nMinimalGradientSize)/2))); - const sal_Int32 nY2 (nHeight-nY1); const Color aTopColor(mpTheme->GetGradientColor(eColorType, Theme::Fill1)); const Color aBottomColor(mpTheme->GetGradientColor(eColorType, Theme::Fill2)); - const sal_Int32 nTop (aPageObjectBox.Top()); - for (sal_Int32 nY=0; nY=nY2) - aBitmapDevice.SetLineColor(aBottomColor); - else + const sal_Int32 nHeight (aPageObjectBox.GetHeight()); + const sal_Int32 nDefaultConstantSize(nHeight/4); + const sal_Int32 nMinimalGradientSize(40); + const sal_Int32 nY1 ( + ::std::max( + 0, + ::std::min( + nDefaultConstantSize, + (nHeight - nMinimalGradientSize)/2))); + const sal_Int32 nY2 (nHeight-nY1); + const sal_Int32 nTop (aPageObjectBox.Top()); + for (sal_Int32 nY=0; nY=nY2) + aBitmapDevice.SetLineColor(aBottomColor); + else + { + Color aColor (aTopColor); + aColor.Merge(aBottomColor, 255 * (nY2-nY) / (nY2-nY1)); + aBitmapDevice.SetLineColor(aColor); + } + aBitmapDevice.DrawLine( + Point(aPageObjectBox.Left(), nY+nTop), + Point(aPageObjectBox.Right(), nY+nTop)); } - aBitmapDevice.DrawLine( - Point(aPageObjectBox.Left(), nY+nTop), - Point(aPageObjectBox.Right(), nY+nTop)); + } + else + { + aBitmapDevice.SetFillColor(aTopColor); + aBitmapDevice.DrawRect(aPageObjectBox); } // Paint the simple border and, for some backgrounds, the focus border. diff --git a/sd/source/ui/slidesorter/view/SlsTheme.cxx b/sd/source/ui/slidesorter/view/SlsTheme.cxx index 6baee70355de..d0143b2597bb 100644 --- a/sd/source/ui/slidesorter/view/SlsTheme.cxx +++ b/sd/source/ui/slidesorter/view/SlsTheme.cxx @@ -380,7 +380,9 @@ void Theme::SetGradient ( rGradient.mnSaturationOverride = nSaturationOverride; rGradient.mnBrightnessOverride = nBrightnessOverride; - const ColorData aColor (HGBAdapt(aBaseColor, nSaturationOverride, nBrightnessOverride)); + const ColorData aColor (nSaturationOverride>=0 || nBrightnessOverride>=0 + ? HGBAdapt(aBaseColor, nSaturationOverride, nBrightnessOverride) + : aBaseColor); rGradient.maFillColor1 = ChangeLuminance(aColor, nFillStartOffset); rGradient.maFillColor2 = ChangeLuminance(aColor, nFillEndOffset);