LibreOffice Module svx (master) 1
animationstate.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
26#include <comphelper/lok.hxx>
27
28
30{
31 double PrimitiveAnimation::getSmallestNextTime(double fCurrentTime)
32 {
33 double fRetval(0.0);
34
35 if(!maAnimatedPrimitives.empty())
36 {
37 const sal_Int32 nCount(maAnimatedPrimitives.size());
38
39 for(sal_Int32 a(0); a < nCount; a++)
40 {
43
44 const drawinglayer::animation::AnimationEntry& rAnimEntry = pCandidate->getAnimationEntry();
45 const double fNextTime(rAnimEntry.getNextEventTime(fCurrentTime));
46
47 if(!::basegfx::fTools::equalZero(fNextTime))
48 {
49 if(::basegfx::fTools::equalZero(fRetval))
50 {
51 fRetval = fNextTime;
52 }
53 else if(::basegfx::fTools::less(fNextTime, fRetval))
54 {
55 fRetval = fNextTime;
56 }
57 }
58 }
59 }
60
61 return fRetval;
62 }
63
65 {
66 const double fCurrentTime(mrVOContact.GetObjectContact().getPrimitiveAnimator().GetTime());
67 const double fNextTime(getSmallestNextTime(fCurrentTime));
68
69 // getSmallestNextTime will be zero when animation ended. If not zero, a next step
70 // exists
71 if(::basegfx::fTools::equalZero(fNextTime))
72 return;
73
74 // next time point exists, use it
75 sal_uInt32 nNextTime;
76
77 if(fNextTime >= double(0xffffff00))
78 {
79 // take care for very late points in time, e.g. when a text animation stops
80 // in a defined AnimationEntryFixed with endless (0xffffffff) duration
81 nNextTime = GetTime() + (1000 * 60 * 60); // one hour, works with vcl timers, 0xffffff00 was too much...
82 }
83 else
84 {
85 nNextTime = static_cast<sal_uInt32>(fNextTime);
86 }
87
88 // ensure step forward in integer timing, the floating step difference maybe smaller than 1.0. Use
89 // at least 25ms for next step
90 const sal_uInt32 nMinimumStepTime(static_cast<sal_uInt32>(fCurrentTime) + 25);
91
92 if(nNextTime <= nMinimumStepTime)
93 {
94 nNextTime = nMinimumStepTime;
95 }
96
97 // set time and reactivate by re-adding to the scheduler
98 SetTime(nNextTime);
100 }
101
103 : mrVOContact(rVOContact),
104 maAnimatedPrimitives(std::move(rAnimatedPrimitives))
105 {
107 // setup initially
109 }
110
112 {
113 // ensure that Event member is removed from PrimitiveAnimator
115 }
116
117 // execute event, from base class Event
118 void PrimitiveAnimation::Trigger(sal_uInt32 /*nTime*/)
119 {
120 // schedule a repaint of associated object
122
124 // re-setup
126 }
127
128} // end of namespace
129
130/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual double getNextEventTime(double fTime) const=0
const animation::AnimationEntry & getAnimationEntry() const
SAL_DLLPRIVATE sal_uInt32 GetTime() const
Definition: scheduler.hxx:43
void SetTime(sal_uInt32 nNew)
Definition: scheduler.cxx:39
sdr::contact::ViewObjectContact & mrVOContact
virtual void Trigger(sal_uInt32 nTime) override
drawinglayer::primitive2d::Primitive2DContainer maAnimatedPrimitives
PrimitiveAnimation(sdr::contact::ViewObjectContact &rVOContact, drawinglayer::primitive2d::Primitive2DContainer &&rAnimatedPrimitives)
double getSmallestNextTime(double fCurrentTime)
SAL_DLLPRIVATE sal_uInt32 GetTime() const
Definition: scheduler.hxx:74
SAL_DLLPRIVATE void RemoveEvent(Event *pOld)
Definition: scheduler.cxx:153
void InsertEvent(Event &rNew)
Definition: scheduler.cxx:144
sdr::animation::primitiveAnimator & getPrimitiveAnimator()
ObjectContact & GetObjectContact() const
int nCount
uno_Any a