1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ANIMATEDPRIMITIVE2D_HXX 29 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ANIMATEDPRIMITIVE2D_HXX 30 31 #include <drawinglayer/drawinglayerdllapi.h> 32 #include <drawinglayer/primitive2d/groupprimitive2d.hxx> 33 #include <basegfx/matrix/b2dhommatrix.hxx> 34 #include <basegfx/matrix/b2dhommatrixtools.hxx> 35 36 ////////////////////////////////////////////////////////////////////////////// 37 // predefines 38 namespace drawinglayer { namespace animation { 39 class AnimationEntry; 40 }} 41 42 ////////////////////////////////////////////////////////////////////////////// 43 44 namespace drawinglayer 45 { 46 namespace primitive2d 47 { 48 /** AnimatedSwitchPrimitive2D class 49 50 This is the basic class for simple, animated primitives. The basic idea 51 is to have an animation definition (AnimationEntry) who's basic 52 functionality is to return a state value for any given animation time in 53 the range of [0.0 .. 1.0]. Depending on the state, the decomposition 54 calculates an index, which of the members of the child vector is to 55 be visualized. 56 57 An example: For blinking, the Child vector should exist of two entries; 58 for values of [0.0 .. 0.5] the first, else the last entry will be used. 59 This mechanism is not limited to two entries, though. 60 */ 61 class DRAWINGLAYER_DLLPUBLIC AnimatedSwitchPrimitive2D : public GroupPrimitive2D 62 { 63 private: 64 /** 65 The animation definition which allows translation of a point in time 66 to an animation state [0.0 .. 1.0]. This member contains a cloned 67 definition and is owned by this implementation. 68 */ 69 animation::AnimationEntry* mpAnimationEntry; 70 71 /// bitfield 72 /** flag if this is a text or graphic animation. Necessary since SdrViews need to differentiate 73 between both types if they are on/off 74 */ 75 unsigned mbIsTextAnimation : 1; 76 77 public: 78 /// constructor 79 AnimatedSwitchPrimitive2D( 80 const animation::AnimationEntry& rAnimationEntry, 81 const Primitive2DSequence& rChildren, 82 bool bIsTextAnimation); 83 84 /// destructor - needed due to mpAnimationEntry 85 virtual ~AnimatedSwitchPrimitive2D(); 86 87 /// data read access 88 const animation::AnimationEntry& getAnimationEntry() const { return *mpAnimationEntry; } 89 bool isTextAnimation() const { return mbIsTextAnimation; } 90 bool isGraphicAnimation() const { return !isTextAnimation(); } 91 92 /// compare operator 93 virtual bool operator==(const BasePrimitive2D& rPrimitive) const; 94 95 /// provide unique ID 96 DeclPrimitrive2DIDBlock() 97 98 /** The getDecomposition is overloaded here since the decompose is dependent of the point in time, 99 so the default implementation is nut useful here, it needs to be handled locally 100 */ 101 virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 102 }; 103 } // end of namespace primitive2d 104 } // end of namespace drawinglayer 105 106 ////////////////////////////////////////////////////////////////////////////// 107 108 namespace drawinglayer 109 { 110 namespace primitive2d 111 { 112 /** AnimatedBlinkPrimitive2D class 113 114 Basically the same mechanism as in AnimatedSwitchPrimitive2D, but the 115 decomposition is specialized in delivering the children in the 116 range [0.0.. 0.5] and an empty sequence else 117 */ 118 class DRAWINGLAYER_DLLPUBLIC AnimatedBlinkPrimitive2D : public AnimatedSwitchPrimitive2D 119 { 120 protected: 121 public: 122 /// constructor 123 AnimatedBlinkPrimitive2D( 124 const animation::AnimationEntry& rAnimationEntry, 125 const Primitive2DSequence& rChildren, 126 bool bIsTextAnimation); 127 128 /// create local decomposition 129 virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 130 131 /// provide unique ID 132 DeclPrimitrive2DIDBlock() 133 }; 134 } // end of namespace primitive2d 135 } // end of namespace drawinglayer 136 137 ////////////////////////////////////////////////////////////////////////////// 138 139 namespace drawinglayer 140 { 141 namespace primitive2d 142 { 143 /** AnimatedInterpolatePrimitive2D class 144 145 Specialized on multi-step animations based on matrix transformations. The 146 Child sequelce will be embedded in a matrix transformation. That transformation 147 will be linearly combined from the decomposed values and the animation value 148 to allow a smooth animation. 149 */ 150 class DRAWINGLAYER_DLLPUBLIC AnimatedInterpolatePrimitive2D : public AnimatedSwitchPrimitive2D 151 { 152 private: 153 /// the transformations 154 std::vector< basegfx::tools::B2DHomMatrixBufferedDecompose > maMatrixStack; 155 156 protected: 157 public: 158 /// constructor 159 AnimatedInterpolatePrimitive2D( 160 const std::vector< basegfx::B2DHomMatrix >& rmMatrixStack, 161 const animation::AnimationEntry& rAnimationEntry, 162 const Primitive2DSequence& rChildren, 163 bool bIsTextAnimation); 164 165 /// create local decomposition 166 virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 167 168 /// provide unique ID 169 DeclPrimitrive2DIDBlock() 170 }; 171 } // end of namespace primitive2d 172 } // end of namespace drawinglayer 173 174 ////////////////////////////////////////////////////////////////////////////// 175 176 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ANIMATEDPRIMITIVE2D_HXX 177 178 ////////////////////////////////////////////////////////////////////////////// 179 // eof 180