diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2020-01-04 22:37:31 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2020-01-06 14:27:36 +0100 |
commit | 39055f5e32fc0314353e95252ed54ae591881445 (patch) | |
tree | 6560054cd1c2227cbbfbab41a0d1d91449ad12a6 /sfx2 | |
parent | aacc5ed083b53a99719034ff3b87105741982609 (diff) |
sidebar: improve invalidation tracking for Panels.
Only emit an invalidation on panels that change position.
Ensure we invalidate the ScrollContainerWindow for updated separators.
Emit a single vcl::Region for an invalidation rather than per panel.
Change-Id: I5452791ac9a7d1a9b8604c7704d24641160c275b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86234
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/sidebar/Deck.cxx | 1 | ||||
-rw-r--r-- | sfx2/source/sidebar/DeckLayouter.cxx | 35 |
2 files changed, 32 insertions, 4 deletions
diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx index 074334c2e415..60ea6b71ebba 100644 --- a/sfx2/source/sidebar/Deck.cxx +++ b/sfx2/source/sidebar/Deck.cxx @@ -385,6 +385,7 @@ void Deck::ScrollContainerWindow::Paint(vcl::RenderContext& rRenderContext, cons void Deck::ScrollContainerWindow::SetSeparators (const ::std::vector<sal_Int32>& rSeparators) { maSeparators = rSeparators; + Invalidate(); } } } // end of namespace sfx2::sidebar diff --git a/sfx2/source/sidebar/DeckLayouter.cxx b/sfx2/source/sidebar/DeckLayouter.cxx index 33d6dc62f4b9..66f60f2ef03e 100644 --- a/sfx2/source/sidebar/DeckLayouter.cxx +++ b/sfx2/source/sidebar/DeckLayouter.cxx @@ -78,6 +78,8 @@ namespace { const sal_Int32 nHeightToDistribute, const sal_Int32 nContainerHeight, const bool bMinimumHeightIsBase); + bool MoveResizePixel(const VclPtr<vcl::Window> &pWindow, + const Point &rNewPos, const Size &rNewSize); sal_Int32 PlacePanels ( ::std::vector<LayoutItem>& rLayoutItems, const sal_Int32 nWidth, @@ -246,6 +248,17 @@ tools::Rectangle LayoutPanels ( return aBox; } +bool MoveResizePixel(const VclPtr<vcl::Window> &pWindow, + const Point &rNewPos, const Size &rNewSize) +{ + Point aCurPos = pWindow->GetPosPixel(); + Size aCurSize = pWindow->GetSizePixel(); + if (rNewPos == aCurPos && aCurSize == rNewSize) + return false; + pWindow->setPosSizePixel(rNewPos.X(), rNewPos.Y(), rNewSize.Width(), rNewSize.Height()); + return true; +} + sal_Int32 PlacePanels ( ::std::vector<LayoutItem>& rLayoutItems, const sal_Int32 nWidth, @@ -256,6 +269,8 @@ sal_Int32 PlacePanels ( const sal_Int32 nDeckSeparatorHeight (Theme::GetInteger(Theme::Int_DeckSeparatorHeight)); sal_Int32 nY (0); + vcl::Region aInvalidRegions; + // Assign heights and places. for(::std::vector<LayoutItem>::const_iterator iItem(rLayoutItems.begin()), iEnd(rLayoutItems.end()); @@ -268,8 +283,11 @@ sal_Int32 PlacePanels ( Panel& rPanel (*iItem->mpPanel); // Separator above the panel title bar. - aSeparators.push_back(nY); - nY += nDeckSeparatorHeight; + if (!rPanel.IsLurking()) + { + aSeparators.push_back(nY); + nY += nDeckSeparatorHeight; + } // Place the title bar. VclPtr<PanelTitleBar> pTitleBar = rPanel.GetTitleBar(); @@ -313,8 +331,15 @@ sal_Int32 PlacePanels ( } // Place the panel. - rPanel.setPosSizePixel(0, nY, nWidth, nPanelHeight); - rPanel.Invalidate(); + Point aNewPos(0, nY); + Size aNewSize(nWidth, nPanelHeight); + + // Only invalidate if we moved + if (MoveResizePixel(&rPanel, aNewPos, aNewSize)) + { + tools::Rectangle aRect(aNewPos, aNewSize); + aInvalidRegions.Union(rPanel.PixelToLogic(aRect)); + } nY += nPanelHeight; } @@ -338,6 +363,8 @@ sal_Int32 PlacePanels ( if (pScrollContainerWindow != nullptr) pScrollContainerWindow->SetSeparators(aSeparators); + rScrollContainer.Invalidate(aInvalidRegions); + return nY; } |