1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ANIMATEDPRIMITIVE2D_HXX
21 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ANIMATEDPRIMITIVE2D_HXX
23 #include <drawinglayer/drawinglayerdllapi.h>
25 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
26 #include <basegfx/matrix/b2dhommatrix.hxx>
27 #include <basegfx/matrix/b2dhommatrixtools.hxx>
31 namespace drawinglayer
{ namespace animation
{
37 namespace drawinglayer
41 /** AnimatedSwitchPrimitive2D class
43 This is the basic class for simple, animated primitives. The basic idea
44 is to have an animation definition (AnimationEntry) who's basic
45 functionality is to return a state value for any given animation time in
46 the range of [0.0 .. 1.0]. Depending on the state, the decomposition
47 calculates an index, which of the members of the child vector is to
50 An example: For blinking, the Child vector should exist of two entries;
51 for values of [0.0 .. 0.5] the first, else the last entry will be used.
52 This mechanism is not limited to two entries, though.
54 class DRAWINGLAYER_DLLPUBLIC AnimatedSwitchPrimitive2D
: public GroupPrimitive2D
58 The animation definition which allows translation of a point in time
59 to an animation state [0.0 .. 1.0]. This member contains a cloned
60 definition and is owned by this implementation.
62 animation::AnimationEntry
* mpAnimationEntry
;
65 /** flag if this is a text or graphic animation. Necessary since SdrViews need to differentiate
66 between both types if they are on/off
68 bool mbIsTextAnimation
: 1;
72 AnimatedSwitchPrimitive2D(
73 const animation::AnimationEntry
& rAnimationEntry
,
74 const Primitive2DSequence
& rChildren
,
75 bool bIsTextAnimation
);
77 /// destructor - needed due to mpAnimationEntry
78 virtual ~AnimatedSwitchPrimitive2D();
81 const animation::AnimationEntry
& getAnimationEntry() const { return *mpAnimationEntry
; }
82 bool isTextAnimation() const { return mbIsTextAnimation
; }
83 bool isGraphicAnimation() const { return !isTextAnimation(); }
86 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const SAL_OVERRIDE
;
89 DeclPrimitive2DIDBlock()
91 /** Override getDecomposition() here since the decompose
92 depends on the point in time, so the default implementation is
93 not useful here, it needs to be handled locally
95 virtual Primitive2DSequence
get2DDecomposition(const geometry::ViewInformation2D
& rViewInformation
) const SAL_OVERRIDE
;
97 } // end of namespace primitive2d
98 } // end of namespace drawinglayer
102 namespace drawinglayer
104 namespace primitive2d
106 /** AnimatedBlinkPrimitive2D class
108 Basically the same mechanism as in AnimatedSwitchPrimitive2D, but the
109 decomposition is specialized in delivering the children in the
110 range [0.0.. 0.5] and an empty sequence else
112 class DRAWINGLAYER_DLLPUBLIC AnimatedBlinkPrimitive2D
: public AnimatedSwitchPrimitive2D
117 AnimatedBlinkPrimitive2D(
118 const animation::AnimationEntry
& rAnimationEntry
,
119 const Primitive2DSequence
& rChildren
,
120 bool bIsTextAnimation
);
122 /// create local decomposition
123 virtual Primitive2DSequence
get2DDecomposition(const geometry::ViewInformation2D
& rViewInformation
) const SAL_OVERRIDE
;
125 /// provide unique ID
126 DeclPrimitive2DIDBlock()
128 } // end of namespace primitive2d
129 } // end of namespace drawinglayer
133 namespace drawinglayer
135 namespace primitive2d
137 /** AnimatedInterpolatePrimitive2D class
139 Specialized on multi-step animations based on matrix transformations. The
140 Child sequelce will be embedded in a matrix transformation. That transformation
141 will be linearly combined from the decomposed values and the animation value
142 to allow a smooth animation.
144 class DRAWINGLAYER_DLLPUBLIC AnimatedInterpolatePrimitive2D
: public AnimatedSwitchPrimitive2D
147 /// the transformations
148 std::vector
< basegfx::tools::B2DHomMatrixBufferedDecompose
> maMatrixStack
;
153 AnimatedInterpolatePrimitive2D(
154 const std::vector
< basegfx::B2DHomMatrix
>& rmMatrixStack
,
155 const animation::AnimationEntry
& rAnimationEntry
,
156 const Primitive2DSequence
& rChildren
,
157 bool bIsTextAnimation
);
159 /// create local decomposition
160 virtual Primitive2DSequence
get2DDecomposition(const geometry::ViewInformation2D
& rViewInformation
) const SAL_OVERRIDE
;
162 /// provide unique ID
163 DeclPrimitive2DIDBlock()
165 } // end of namespace primitive2d
166 } // end of namespace drawinglayer
170 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ANIMATEDPRIMITIVE2D_HXX
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */