xref: /AOO41X/main/drawinglayer/inc/drawinglayer/primitive2d/animatedprimitive2d.hxx (revision 4f506f19cd544df9572ed8c88b6bdbc6c8f33210)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ANIMATEDPRIMITIVE2D_HXX
25 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ANIMATEDPRIMITIVE2D_HXX
26 
27 #include <drawinglayer/drawinglayerdllapi.h>
28 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
29 #include <basegfx/matrix/b2dhommatrix.hxx>
30 #include <basegfx/matrix/b2dhommatrixtools.hxx>
31 
32 //////////////////////////////////////////////////////////////////////////////
33 // predefines
34 namespace drawinglayer { namespace animation {
35     class AnimationEntry;
36 }}
37 
38 //////////////////////////////////////////////////////////////////////////////
39 
40 namespace drawinglayer
41 {
42     namespace primitive2d
43     {
44         /** AnimatedSwitchPrimitive2D class
45 
46             This is the basic class for simple, animated primitives. The basic idea
47             is to have an animation definition (AnimationEntry) who's basic
48             functionality is to return a state value for any given animation time in
49             the range of [0.0 .. 1.0]. Depending on the state, the decomposition
50             calculates an index, which of the members of the child vector is to
51             be visualized.
52 
53             An example: For blinking, the Child vector should exist of two entries;
54             for values of [0.0 .. 0.5] the first, else the last entry will be used.
55             This mechanism is not limited to two entries, though.
56          */
57         class DRAWINGLAYER_DLLPUBLIC AnimatedSwitchPrimitive2D : public GroupPrimitive2D
58         {
59         private:
60             /**
61                 The animation definition which allows translation of a point in time
62                 to an animation state [0.0 .. 1.0]. This member contains a cloned
63                 definition and is owned by this implementation.
64              */
65             animation::AnimationEntry*                      mpAnimationEntry;
66 
67             /// bitfield
68             /** flag if this is a text or graphic animation. Necessary since SdrViews need to differentiate
69                 between both types if they are on/off
70              */
71             unsigned                                        mbIsTextAnimation : 1;
72 
73         public:
74             /// constructor
75             AnimatedSwitchPrimitive2D(
76                 const animation::AnimationEntry& rAnimationEntry,
77                 const Primitive2DSequence& rChildren,
78                 bool bIsTextAnimation);
79 
80             /// destructor - needed due to mpAnimationEntry
81             virtual ~AnimatedSwitchPrimitive2D();
82 
83             /// data read access
getAnimationEntry() const84             const animation::AnimationEntry& getAnimationEntry() const { return *mpAnimationEntry; }
isTextAnimation() const85             bool isTextAnimation() const { return mbIsTextAnimation; }
isGraphicAnimation() const86             bool isGraphicAnimation() const { return !isTextAnimation(); }
87 
88             /// compare operator
89             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
90 
91             /// provide unique ID
92             DeclPrimitrive2DIDBlock()
93 
94             /** The getDecomposition is overloaded here since the decompose is dependent of the point in time,
95                 so the default implementation is nut useful here, it needs to be handled locally
96              */
97             virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
98         };
99     } // end of namespace primitive2d
100 } // end of namespace drawinglayer
101 
102 //////////////////////////////////////////////////////////////////////////////
103 
104 namespace drawinglayer
105 {
106     namespace primitive2d
107     {
108         /** AnimatedBlinkPrimitive2D class
109 
110             Basically the same mechanism as in AnimatedSwitchPrimitive2D, but the
111             decomposition is specialized in delivering the children in the
112             range [0.0.. 0.5] and an empty sequence else
113          */
114         class DRAWINGLAYER_DLLPUBLIC AnimatedBlinkPrimitive2D : public AnimatedSwitchPrimitive2D
115         {
116         protected:
117         public:
118             /// constructor
119             AnimatedBlinkPrimitive2D(
120                 const animation::AnimationEntry& rAnimationEntry,
121                 const Primitive2DSequence& rChildren,
122                 bool bIsTextAnimation);
123 
124             /// create local decomposition
125             virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
126 
127             /// provide unique ID
128             DeclPrimitrive2DIDBlock()
129         };
130     } // end of namespace primitive2d
131 } // end of namespace drawinglayer
132 
133 //////////////////////////////////////////////////////////////////////////////
134 
135 namespace drawinglayer
136 {
137     namespace primitive2d
138     {
139         /** AnimatedInterpolatePrimitive2D class
140 
141             Specialized on multi-step animations based on matrix transformations. The
142             Child sequelce will be embedded in a matrix transformation. That transformation
143             will be linearly combined from the decomposed values and the animation value
144             to allow a smooth animation.
145          */
146         class DRAWINGLAYER_DLLPUBLIC AnimatedInterpolatePrimitive2D : public AnimatedSwitchPrimitive2D
147         {
148         private:
149             /// the transformations
150             std::vector< basegfx::tools::B2DHomMatrixBufferedDecompose >        maMatrixStack;
151 
152         protected:
153         public:
154             /// constructor
155             AnimatedInterpolatePrimitive2D(
156                 const std::vector< basegfx::B2DHomMatrix >& rmMatrixStack,
157                 const animation::AnimationEntry& rAnimationEntry,
158                 const Primitive2DSequence& rChildren,
159                 bool bIsTextAnimation);
160 
161             /// create local decomposition
162             virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
163 
164             /// provide unique ID
165             DeclPrimitrive2DIDBlock()
166         };
167     } // end of namespace primitive2d
168 } // end of namespace drawinglayer
169 
170 //////////////////////////////////////////////////////////////////////////////
171 
172 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ANIMATEDPRIMITIVE2D_HXX
173 
174 //////////////////////////////////////////////////////////////////////////////
175 // eof
176