renaissance1: #i107215# Fixed painting of page object backgrounds. Page numbers of selected pages are now painted darker.

This commit is contained in:
Andre Fischer 2010-06-16 17:58:45 +02:00
parent a72371004c
commit 5da6de552e
2 changed files with 49 additions and 31 deletions

View File

@ -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());
@ -338,8 +344,8 @@ void PageObjectPainter::PaintPageNumber (
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.
// 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,12 +480,18 @@ 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 Color aTopColor(mpTheme->GetGradientColor(eColorType, Theme::Fill1));
const Color aBottomColor(mpTheme->GetGradientColor(eColorType, Theme::Fill2));
if (aTopColor != aBottomColor)
{
const sal_Int32 nHeight (aPageObjectBox.GetHeight());
const sal_Int32 nDefaultConstantSize(nHeight/4);
const sal_Int32 nMinimalGradientSize(40);
@ -490,8 +502,6 @@ Bitmap PageObjectPainter::CreateBackgroundBitmap(
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<nHeight; ++nY)
{
@ -509,6 +519,12 @@ Bitmap PageObjectPainter::CreateBackgroundBitmap(
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.
if (bHasFocusBorder)

View File

@ -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);