diff options
author | Michael Meeks <michael.meeks@suse.com> | 2013-04-12 16:31:48 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-06-25 05:41:07 +0200 |
commit | 0036ced049d56557570b808f4c03df1127ca679e (patch) | |
tree | 14a4323d933d2716d36af1b07ae5e12aea9d4ca2 /sd | |
parent | 9af5c13851482e95ff17f7cf4a46a5660f8588af (diff) |
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
Diffstat (limited to 'sd')
7 files changed, 95 insertions, 140 deletions
diff --git a/sd/source/ui/slidesorter/inc/view/SlsPageObjectLayouter.hxx b/sd/source/ui/slidesorter/inc/view/SlsPageObjectLayouter.hxx index 729788e888be..dc92d007ec0e 100644 --- a/sd/source/ui/slidesorter/inc/view/SlsPageObjectLayouter.hxx +++ b/sd/source/ui/slidesorter/inc/view/SlsPageObjectLayouter.hxx @@ -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;} diff --git a/sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx b/sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx index 7d417daf3844..bb91270309fa 100644 --- a/sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx +++ b/sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx @@ -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, diff --git a/sd/source/ui/slidesorter/view/SlideSorterView.cxx b/sd/source/ui/slidesorter/view/SlideSorterView.cxx index d1d908459460..dd139f856c81 100644 --- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx +++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx @@ -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); diff --git a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx index eb5ceeb41d76..5860d341e6ca 100644 --- a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx +++ b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx @@ -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); diff --git a/sd/source/ui/slidesorter/view/SlsLayouter.cxx b/sd/source/ui/slidesorter/view/SlsLayouter.cxx index 48b94eeeb400..fca5a7ebbfea 100644 --- a/sd/source/ui/slidesorter/view/SlsLayouter.cxx +++ b/sd/source/ui/slidesorter/view/SlsLayouter.cxx @@ -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); } diff --git a/sd/source/ui/slidesorter/view/SlsPageObjectLayouter.cxx b/sd/source/ui/slidesorter/view/SlsPageObjectLayouter.cxx index a5f2b5a73fba..3bc173685a39 100644 --- a/sd/source/ui/slidesorter/view/SlsPageObjectLayouter.cxx +++ b/sd/source/ui/slidesorter/view/SlsPageObjectLayouter.cxx @@ -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) { diff --git a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx index 736c6dcfd486..6a7515c525ac 100644 --- a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx +++ b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx @@ -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; } -} - - - - -Bitmap& PageObjectPainter::GetBackground( - Bitmap& rBackground, - Theme::GradientColorType eType, - const OutputDevice& rReferenceDevice, - const bool bHasFocusBorder) -{ - if (rBackground.IsEmpty()) - rBackground = CreateBackgroundBitmap(rReferenceDevice, eType, bHasFocusBorder); - return rBackground; -} + const Rectangle aFocusSize (mpPageObjectLayouter->GetBoundingBox( + rpDescriptor, + PageObjectLayouter::FocusIndicator, + PageObjectLayouter::ModelCoordinateSystem)); - - -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, |