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