LibreOffice Module slideshow (master) 1
continuouskeytimeactivitybase.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
20
22
24
25#include <tuple>
26
27namespace slideshow::internal
28{
31 maLerper( std::vector(rParms.maDiscreteTimes) )
32 {
33 ENSURE_OR_THROW( rParms.maDiscreteTimes.size() > 1,
34 "ContinuousKeyTimeActivityBase::ContinuousKeyTimeActivityBase(): key times vector must have two entries or more" );
35 ENSURE_OR_THROW( rParms.maDiscreteTimes.front() == 0.0,
36 "ContinuousKeyTimeActivityBase::ContinuousKeyTimeActivityBase(): key times vector first entry must be zero" );
37 ENSURE_OR_THROW( rParms.maDiscreteTimes.back() <= 1.0,
38 "ContinuousKeyTimeActivityBase::ContinuousKeyTimeActivityBase(): key times vector last entry must be less or equal 1" );
39 }
40
42 sal_uInt32 nRepeatCount ) const
43 {
44 // calc simple time from global time - sweep through the
45 // array multiple times for repeated animations (according to
46 // SMIL spec).
47 double fAlpha( calcAcceleratedTime( nSimpleTime ) );
48 std::ptrdiff_t nIndex;
49
50 std::tie(nIndex,fAlpha) = maLerper.lerp(fAlpha);
51
52 perform(
53 nIndex,
54 fAlpha,
55 nRepeatCount );
56 }
57}
58
59/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ResultType lerp(double fAlpha) const
double calcAcceleratedTime(double nT) const
Modify fractional time.
virtual bool perform() override
From Activity interface.
virtual void simplePerform(double nSimpleTime, sal_uInt32 nRepeatCount) const override
From SimpleContinuousActivityBase class.
#define ENSURE_OR_THROW(c, m)
sal_Int32 nIndex
Parameter struct for animation activities.
::std::vector< double > maDiscreteTimes
Key times, for discrete and key time activities.