slide-sorter: re-factor to improve bbox calcuation

Always use a SlsPageDescriptor to calculate bbox, so we can
adapt it to merge slides attributes where possible.

Change-Id: Id71945bbbb9adb069654ab712e22ea79fea96c1f
This commit is contained in:
Michael Meeks 2013-04-12 16:31:48 +01:00 committed by Markus Mohrhard
parent 9af5c13851
commit 0036ced049
7 changed files with 95 additions and 140 deletions

View File

@ -98,18 +98,29 @@ public:
@param eCoodinateSystem
The bounding box can be returned in model and in pixel
(window) coordinates.
@param bIgnoreLocation
Return a position ignoring the slides' location, ie. as if
we were the first slide.
*/
Rectangle GetBoundingBox (
const model::SharedPageDescriptor& rpPageDescriptor,
const Part ePart,
const CoordinateSystem eCoordinateSystem);
const CoordinateSystem eCoordinateSystem,
bool bIgnoreLocation = false);
/// the size of the embedded preview: position independent
Size GetPreviewSize(const CoordinateSystem eCoordinateSystem);
/// the maximum size of each tile, also position independent
Size GetGridMaxSize(const CoordinateSystem eCoordinateSystem);
Image GetTransitionEffectIcon (void) const;
private:
Rectangle GetBoundingBox (
const Point& rPageObjectLocation,
const Part ePart,
const CoordinateSystem eCoordinateSystem);
Size GetSize (
const Part ePart,
const CoordinateSystem eCoordinateSystem);
Image GetTransitionEffectIcon (void) const { return maTransitionEffectIcon;}
Image GetCustomAnimationEffectIcon (void) const { return maCustomAnimationEffectIcon;}

View File

@ -108,8 +108,12 @@ private:
OutputDevice& rDevice,
const Theme::GradientColorType eColorType,
const Rectangle& rBox) const;
void PaintBackgroundDetail(
OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor);
#if 0
Bitmap& GetBackgroundForState (
const model::SharedPageDescriptor& rpDescriptor,
const OutputDevice& rTemplateDevice);
Bitmap& GetBackground(
Bitmap& rBackground,
@ -120,6 +124,7 @@ private:
const OutputDevice& rReferenceDevice,
const Theme::GradientColorType eType,
const bool bHasFocusBorder) const;
#endif
Bitmap CreateMarkedPreview(
const Size& rSize,
const Bitmap& rPreview,

View File

@ -477,9 +477,7 @@ void SlideSorterView::Layout ()
mpLayouter->GetPageObjectLayouter());
if (pPageObjectLayouter)
{
const Size aNewPreviewSize (mpLayouter->GetPageObjectLayouter()->GetSize(
PageObjectLayouter::Preview,
PageObjectLayouter::WindowCoordinateSystem));
const Size aNewPreviewSize (mpLayouter->GetPageObjectLayouter()->GetPreviewSize(PageObjectLayouter::WindowCoordinateSystem));
if (maPreviewSize != aNewPreviewSize && GetPreviewCache())
{
mpPreviewCache->ChangeSize(aNewPreviewSize, false);

View File

@ -129,8 +129,7 @@ void InsertionIndicatorOverlay::Create (
::boost::shared_ptr<view::PageObjectLayouter> pPageObjectLayouter (
rLayouter.GetPageObjectLayouter());
::boost::shared_ptr<view::Theme> pTheme (mrSlideSorter.GetTheme());
const Size aOriginalPreviewSize (pPageObjectLayouter->GetSize(
PageObjectLayouter::Preview,
const Size aOriginalPreviewSize (pPageObjectLayouter->GetPreviewSize(
PageObjectLayouter::WindowCoordinateSystem));
const double nPreviewScale (0.5);

View File

@ -549,7 +549,7 @@ Layouter::Implementation::~Implementation (void)
bool Layouter::Implementation::Rearrange (
bool Layouter::Implementation::Rearrange (
const Size& rWindowSize,
const Size& rPreviewModelSize,
const sal_uInt32 nPageCount)
@ -592,8 +592,8 @@ bool Layouter::Implementation::Rearrange (
rPreviewModelSize,
mpWindow,
mnPageCount));
maPageObjectSize = mpPageObjectLayouter->GetSize(
PageObjectLayouter::FocusIndicator,
maPageObjectSize = mpPageObjectLayouter->GetGridMaxSize(
PageObjectLayouter::WindowCoordinateSystem);
CalculateMaxRowAndColumnCount(rWindowSize);
@ -871,17 +871,14 @@ Rectangle Layouter::Implementation::GetInnerBoundingBox (
if ( ! pDescriptor)
return Rectangle();
const Point aLocation (pDescriptor->GetLocation(true));
PageObjectLayouter::Part ePart = PageObjectLayouter::Preview;
if (pDescriptor->HasState(model::PageDescriptor::ST_Selected))
return mpPageObjectLayouter->GetBoundingBox(
aLocation,
PageObjectLayouter::PageObject,
PageObjectLayouter::ModelCoordinateSystem);
else
return mpPageObjectLayouter->GetBoundingBox(
aLocation,
PageObjectLayouter::Preview,
PageObjectLayouter::ModelCoordinateSystem);
ePart = PageObjectLayouter::PageObject;
return mpPageObjectLayouter->GetBoundingBox(
pDescriptor, ePart,
PageObjectLayouter::ModelCoordinateSystem, true);
}

View File

@ -165,22 +165,19 @@ Rectangle PageObjectLayouter::CalculatePreviewBoundingBox (
nTop + nPreviewHeight);
}
Rectangle PageObjectLayouter::GetBoundingBox (
const model::SharedPageDescriptor& rpPageDescriptor,
const Part ePart,
const CoordinateSystem eCoordinateSystem)
const CoordinateSystem eCoordinateSystem,
bool bIgnoreLocation)
{
OSL_ASSERT(rpPageDescriptor);
Point aLocation (rpPageDescriptor ? rpPageDescriptor->GetLocation() : Point(0,0));
Point aLocation(0,0);
if (rpPageDescriptor)
aLocation = rpPageDescriptor->GetLocation( bIgnoreLocation );
return GetBoundingBox(aLocation, ePart, eCoordinateSystem);
}
Rectangle PageObjectLayouter::GetBoundingBox (
const Point& rPageObjectLocation,
const Part ePart,
@ -228,18 +225,18 @@ Rectangle PageObjectLayouter::GetBoundingBox (
aBoundingBox.BottomRight() + aLocation);
}
Size PageObjectLayouter::GetSize (
const Part ePart,
Size PageObjectLayouter::GetPreviewSize (
const CoordinateSystem eCoordinateSystem)
{
return GetBoundingBox(Point(0,0), ePart, eCoordinateSystem).GetSize();
return GetBoundingBox(Point(0,0), PageObjectLayouter::Preview,
eCoordinateSystem).GetSize();
}
Size PageObjectLayouter::GetGridMaxSize(const CoordinateSystem eCoordinateSystem)
{
return GetBoundingBox(Point(0,0), PageObjectLayouter::FocusIndicator,
eCoordinateSystem).GetSize();
}
Size PageObjectLayouter::GetPageNumberAreaSize (const int nPageCount)
{

View File

@ -121,10 +121,9 @@ void PageObjectPainter::NotifyResize (const bool bForce)
InvalidateBitmaps();
else if (UpdatePageObjectLayouter())
{
const Size aSize (mpPageObjectLayouter->GetSize(
PageObjectLayouter::FocusIndicator,
const Size aSize (mpPageObjectLayouter->GetGridMaxSize(
PageObjectLayouter::WindowCoordinateSystem));
if ( maSize!=aSize)
if (maSize != aSize)
{
maSize = aSize;
InvalidateBitmaps();
@ -147,29 +146,17 @@ void PageObjectPainter::InvalidateBitmaps (void)
maMouseOverSelectedAndFocusedBackground.SetEmpty();
}
void PageObjectPainter::SetTheme (const ::boost::shared_ptr<view::Theme>& rpTheme)
{
mpTheme = rpTheme;
NotifyResize(true);
}
void PageObjectPainter::PaintBackground (
OutputDevice& rDevice,
const model::SharedPageDescriptor& rpDescriptor)
{
const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
rpDescriptor,
PageObjectLayouter::FocusIndicator,
PageObjectLayouter::ModelCoordinateSystem));
const Bitmap& rBackground (GetBackgroundForState(rpDescriptor, rDevice));
rDevice.DrawBitmap(aBox.TopLeft(), rBackground);
PaintBackgroundDetail(rDevice, rpDescriptor);
// Fill the interior of the preview area with the default background
// color of the page.
@ -384,14 +371,15 @@ Bitmap& PageObjectPainter::GetBackgroundForState (
| (rpDescriptor->HasState(model::PageDescriptor::ST_MouseOver) ? MouseOver : None)
| (rpDescriptor->HasState(model::PageDescriptor::ST_Focused) ? Focused : None);
bool bHasFocusBorder;
Theme::GradientColorType eColorType;
switch (eState)
{
case MouseOver | Selected | Focused:
return GetBackground(
maMouseOverSelectedAndFocusedBackground,
Theme::Gradient_MouseOverSelectedAndFocusedPage,
rReferenceDevice,
true);
eColorType = Theme::Gradient_MouseOverSelectedAndFocusedPage;
bHasFocusBorder = true;
break;
case MouseOver | Selected:
return GetBackground(
@ -401,87 +389,52 @@ Bitmap& PageObjectPainter::GetBackgroundForState (
false);
case MouseOver:
return GetBackground(
maMouseOverBackground,
Theme::Gradient_MouseOverPage,
rReferenceDevice,
false);
eColorType = Theme::Gradient_MouseOverPage;
bHasFocusBorder = false;
break;
case MouseOver | Focused:
return GetBackground(
maMouseOverFocusedBackground,
Theme::Gradient_MouseOverPage,
rReferenceDevice,
true);
eColorType = Theme::Gradient_MouseOverPage;
bHasFocusBorder = true;
break;
case Selected | Focused:
return GetBackground(
maFocusedSelectionBackground,
Theme::Gradient_SelectedAndFocusedPage,
rReferenceDevice,
true);
eColorType = Theme::Gradient_SelectedAndFocusedPage;
bHasFocusBorder = true;
break;
case Selected:
return GetBackground(
maSelectionBackground,
Theme::Gradient_SelectedPage,
rReferenceDevice,
false);
eColorType = Theme::Gradient_SelectedPage;
bHasFocusBorder = false;
break;
case Focused:
return GetBackground(
maFocusedBackground,
Theme::Gradient_FocusedPage,
rReferenceDevice,
true);
eColorType = Theme::Gradient_FocusedPage;
bHasFocusBorder = true;
break;
case None:
default:
return GetBackground(
maNormalBackground,
Theme::Gradient_NormalPage,
rReferenceDevice,
false);
eColorType = Theme::Gradient_NormalPage;
bHasFocusBorder = false;
break;
}
}
const Rectangle aFocusSize (mpPageObjectLayouter->GetBoundingBox(
rpDescriptor,
PageObjectLayouter::FocusIndicator,
PageObjectLayouter::ModelCoordinateSystem));
Bitmap& PageObjectPainter::GetBackground(
Bitmap& rBackground,
Theme::GradientColorType eType,
const OutputDevice& rReferenceDevice,
const bool bHasFocusBorder)
{
if (rBackground.IsEmpty())
rBackground = CreateBackgroundBitmap(rReferenceDevice, eType, bHasFocusBorder);
return rBackground;
}
Bitmap PageObjectPainter::CreateBackgroundBitmap(
const OutputDevice& rReferenceDevice,
const Theme::GradientColorType eColorType,
const bool bHasFocusBorder) const
{
const Size aSize (mpPageObjectLayouter->GetSize(
PageObjectLayouter::FocusIndicator,
PageObjectLayouter::WindowCoordinateSystem));
const Rectangle aPageObjectBox (mpPageObjectLayouter->GetBoundingBox(
Point(0,0),
PageObjectLayouter::PageObject,
PageObjectLayouter::ModelCoordinateSystem));
VirtualDevice aBitmapDevice (rReferenceDevice);
aBitmapDevice.SetOutputSizePixel(aSize);
rpDescriptor,
PageObjectLayouter::PageObject,
PageObjectLayouter::ModelCoordinateSystem));
// Fill the background with the background color of the slide sorter.
const Color aBackgroundColor (mpTheme->GetColor(Theme::Color_Background));
aBitmapDevice.SetFillColor(aBackgroundColor);
aBitmapDevice.SetLineColor(aBackgroundColor);
aBitmapDevice.DrawRect(Rectangle(Point(0,0), aSize));
rDevice.SetFillColor(aBackgroundColor);
rDevice.SetLineColor(aBackgroundColor);
rDevice.DrawRect(aFocusSize);
// Paint the slide area with a linear gradient that starts some pixels
// below the top and ends some pixels above the bottom.
@ -503,47 +456,42 @@ Bitmap PageObjectPainter::CreateBackgroundBitmap(
for (sal_Int32 nY=0; nY<nHeight; ++nY)
{
if (nY<=nY1)
aBitmapDevice.SetLineColor(aTopColor);
rDevice.SetLineColor(aTopColor);
else if (nY>=nY2)
aBitmapDevice.SetLineColor(aBottomColor);
rDevice.SetLineColor(aBottomColor);
else
{
Color aColor (aTopColor);
aColor.Merge(aBottomColor, 255 * (nY2-nY) / (nY2-nY1));
aBitmapDevice.SetLineColor(aColor);
rDevice.SetLineColor(aColor);
}
aBitmapDevice.DrawLine(
rDevice.DrawLine(
Point(aPageObjectBox.Left(), nY+nTop),
Point(aPageObjectBox.Right(), nY+nTop));
}
}
else
{
aBitmapDevice.SetFillColor(aTopColor);
aBitmapDevice.DrawRect(aPageObjectBox);
rDevice.SetFillColor(aTopColor);
rDevice.DrawRect(aPageObjectBox);
}
// Paint the simple border and, for some backgrounds, the focus border.
if (bHasFocusBorder)
mpFocusBorderPainter->PaintFrame(aBitmapDevice, aPageObjectBox);
mpFocusBorderPainter->PaintFrame(rDevice, aPageObjectBox);
else
PaintBorder(aBitmapDevice, eColorType, aPageObjectBox);
PaintBorder(rDevice, eColorType, aPageObjectBox);
// Get bounding box of the preview around which a shadow is painted.
// Compensate for the border around the preview.
const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
Point(0,0),
PageObjectLayouter::Preview,
PageObjectLayouter::ModelCoordinateSystem));
rpDescriptor,
PageObjectLayouter::Preview,
PageObjectLayouter::ModelCoordinateSystem));
Rectangle aFrameBox (aBox.Left()-1,aBox.Top()-1,aBox.Right()+1,aBox.Bottom()+1);
mpShadowPainter->PaintFrame(aBitmapDevice, aFrameBox);
return aBitmapDevice.GetBitmap (Point(0,0),aSize);
mpShadowPainter->PaintFrame(rDevice, aFrameBox);
}
void PageObjectPainter::PaintBorder (
OutputDevice& rDevice,
const Theme::GradientColorType eColorType,