diff options
author | Michael Meeks <michael.meeks@suse.com> | 2013-04-12 16:31:48 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-04-12 17:42:08 +0100 |
commit | fdb1e019e30a40d81754ddd4c6846d08b19c83fd (patch) | |
tree | a1c9e23249c2747c3ffde9fba273aed3c9b47af7 | |
parent | 482949bcfa4231540def562e7ba5315a0a18b4be (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
7 files changed, 98 insertions, 149 deletions
diff --git a/sd/source/ui/slidesorter/inc/view/SlsPageObjectLayouter.hxx b/sd/source/ui/slidesorter/inc/view/SlsPageObjectLayouter.hxx index 1c50da9871ce..16c7a2a15274 100644 --- a/sd/source/ui/slidesorter/inc/view/SlsPageObjectLayouter.hxx +++ b/sd/source/ui/slidesorter/inc/view/SlsPageObjectLayouter.hxx @@ -95,22 +95,30 @@ 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; - -private: SharedSdWindow mpWindow; Size maPageObjectSize; Rectangle maFocusIndicatorBoundingBox; diff --git a/sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx b/sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx index 67de31c2101c..6697de43a44b 100644 --- a/sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx +++ b/sd/source/ui/slidesorter/inc/view/SlsPageObjectPainter.hxx @@ -104,8 +104,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, @@ -116,6 +120,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 06e15d6c66ab..66b101562626 100644 --- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx +++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx @@ -421,9 +421,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, true); diff --git a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx index fc5248384358..6ad4c19a39a4 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 61105f7bc004..47bd74f269cc 100644 --- a/sd/source/ui/slidesorter/view/SlsLayouter.cxx +++ b/sd/source/ui/slidesorter/view/SlsLayouter.cxx @@ -552,7 +552,7 @@ Layouter::Implementation::~Implementation (void) -bool Layouter::Implementation::Rearrange ( +bool Layouter::Implementation::Rearrange ( const Size& rWindowSize, const Size& rPreviewModelSize, const sal_uInt32 nPageCount) @@ -595,8 +595,8 @@ bool Layouter::Implementation::Rearrange ( rPreviewModelSize, mpWindow, mnPageCount)); - maPageObjectSize = mpPageObjectLayouter->GetSize( - PageObjectLayouter::FocusIndicator, + + maPageObjectSize = mpPageObjectLayouter->GetGridMaxSize( PageObjectLayouter::WindowCoordinateSystem); CalculateMaxRowAndColumnCount(rWindowSize); @@ -874,17 +874,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 684061041c6a..f2934742ad27 100644 --- a/sd/source/ui/slidesorter/view/SlsPageObjectLayouter.cxx +++ b/sd/source/ui/slidesorter/view/SlsPageObjectLayouter.cxx @@ -152,22 +152,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, @@ -212,18 +209,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 b3c2b660b010..9cb53fa8a0a0 100644 --- a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx +++ b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx @@ -105,10 +105,9 @@ void PageObjectPainter::NotifyResize (const bool bForce) InvalidateBitmaps(); else { - const Size aSize (mpPageObjectLayouter->GetSize( - PageObjectLayouter::FocusIndicator, + const Size aSize (mpPageObjectLayouter->GetGridMaxSize( PageObjectLayouter::WindowCoordinateSystem)); - if ( maSize!=aSize) + if (maSize != aSize) { maSize = aSize; InvalidateBitmaps(); @@ -127,29 +126,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. @@ -319,12 +306,9 @@ void PageObjectPainter::PaintTransitionEffect ( } } - - - -Bitmap& PageObjectPainter::GetBackgroundForState ( - const model::SharedPageDescriptor& rpDescriptor, - const OutputDevice& rReferenceDevice) +void PageObjectPainter::PaintBackgroundDetail( + OutputDevice& rDevice, + const model::SharedPageDescriptor& rpDescriptor) { enum State { None = 0x00, Selected = 0x01, MouseOver = 0x02, Focused = 0x04 }; const int eState = @@ -332,98 +316,64 @@ 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: 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. @@ -445,47 +395,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, |