diff options
author | Adrien Ollier <adr.ollier@hotmail.fr> | 2020-01-18 20:30:43 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-01-20 10:00:36 +0100 |
commit | ec1c08a68e45306d455b9df0432b8e915d74d124 (patch) | |
tree | 59279037c6f0667c7f444c4046bbd7436339a154 | |
parent | 4bceda79065e91d6410d05931bff0324a9cbc321 (diff) |
rewrite of Animation::Start using the STL
Change-Id: Ieca520db4e3ea754dd8574809e366db11c451c2d
Signed-off-by: Adrien Ollier <adr.ollier@hotmail.fr>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87031
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | vcl/source/animate/Animation.cxx | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx index e3fb37125af9..7326def3ba5d 100644 --- a/vcl/source/animate/Animation.cxx +++ b/vcl/source/animate/Animation.cxx @@ -169,28 +169,24 @@ bool Animation::Start(OutputDevice* pOut, const Point& rDestPt, const Size& rDes if ((pOut->GetOutDevType() == OUTDEV_WINDOW) && !mbLoopTerminated && (ANIMATION_TIMEOUT_ON_CLICK != maList[mnPos]->mnWait)) { - ImplAnimView* pView; - ImplAnimView* pMatch = nullptr; + bool differs = true; - for (size_t i = 0; i < maViewList.size(); ++i) + auto itAnimView = std::find_if( + maViewList.begin(), maViewList.end(), + [pOut, nExtraData](const std::unique_ptr<ImplAnimView>& pAnimView) -> bool { + return pAnimView->matches(pOut, nExtraData); + }); + + if (itAnimView != maViewList.end()) { - pView = maViewList[i].get(); - if (pView->matches(pOut, nExtraData)) + if ((*itAnimView)->getOutPos() == rDestPt + && (*itAnimView)->getOutSizePix() == pOut->LogicToPixel(rDestSz)) { - if (pView->getOutPos() == rDestPt - && pView->getOutSizePix() == pOut->LogicToPixel(rDestSz)) - { - pView->repaint(); - pMatch = pView; - } - else - { - maViewList.erase(maViewList.begin() + i); - pView = nullptr; - } - - break; + (*itAnimView)->repaint(); + differs = false; } + else + maViewList.erase(itAnimView); } if (maViewList.empty()) @@ -200,7 +196,7 @@ bool Animation::Start(OutputDevice* pOut, const Point& rDestPt, const Size& rDes mnPos = 0; } - if (!pMatch) + if (differs) maViewList.emplace_back( new ImplAnimView(this, pOut, rDestPt, rDestSz, nExtraData, pFirstFrameOutDev)); |