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/primitive2d/groupprimitive2d.hxx> 32 #include <basegfx/matrix/b2dhommatrix.hxx> 33 #include <basegfx/matrix/b2dhommatrixtools.hxx> 34 35 ////////////////////////////////////////////////////////////////////////////// 36 // predefines 37 namespace drawinglayer { namespace animation { 38 class AnimationEntry; 39 }} 40 41 ////////////////////////////////////////////////////////////////////////////// 42 43 namespace drawinglayer 44 { 45 namespace primitive2d 46 { 47 /** AnimatedSwitchPrimitive2D class 48 49 This is the basic class for simple, animated primitives. The basic idea 50 is to have an animation definition (AnimationEntry) who's basic 51 functionality is to return a state value for any given animation time in 52 the range of [0.0 .. 1.0]. Depending on the state, the decomposition 53 calculates an index, which of the members of the child vector is to 54 be visualized. 55 56 An example: For blinking, the Child vector should exist of two entries; 57 for values of [0.0 .. 0.5] the first, else the last entry will be used. 58 This mechanism is not limited to two entries, though. 59 */ 60 class AnimatedSwitchPrimitive2D : public GroupPrimitive2D 61 { 62 private: 63 /** 64 The animation definition which allows translation of a point in time 65 to an animation state [0.0 .. 1.0]. This member contains a cloned 66 definition and is owned by this implementation. 67 */ 68 animation::AnimationEntry* mpAnimationEntry; 69 70 /// bitfield 71 /** flag if this is a text or graphic animation. Necessary since SdrViews need to differentiate 72 between both types if they are on/off 73 */ 74 unsigned mbIsTextAnimation : 1; 75 76 public: 77 /// constructor 78 AnimatedSwitchPrimitive2D( 79 const animation::AnimationEntry& rAnimationEntry, 80 const Primitive2DSequence& rChildren, 81 bool bIsTextAnimation); 82 83 /// destructor - needed due to mpAnimationEntry 84 virtual ~AnimatedSwitchPrimitive2D(); 85 86 /// data read access 87 const animation::AnimationEntry& getAnimationEntry() const { return *mpAnimationEntry; } 88 bool isTextAnimation() const { return mbIsTextAnimation; } 89 bool isGraphicAnimation() const { return !isTextAnimation(); } 90 91 /// compare operator 92 virtual bool operator==(const BasePrimitive2D& rPrimitive) const; 93 94 /// provide unique ID 95 DeclPrimitrive2DIDBlock() 96 97 /** The getDecomposition is overloaded here since the decompose is dependent of the point in time, 98 so the default implementation is nut useful here, it needs to be handled locally 99 */ 100 virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 101 }; 102 } // end of namespace primitive2d 103 } // end of namespace drawinglayer 104 105 ////////////////////////////////////////////////////////////////////////////// 106 107 namespace drawinglayer 108 { 109 namespace primitive2d 110 { 111 /** AnimatedBlinkPrimitive2D class 112 113 Basically the same mechanism as in AnimatedSwitchPrimitive2D, but the 114 decomposition is specialized in delivering the children in the 115 range [0.0.. 0.5] and an empty sequence else 116 */ 117 class AnimatedBlinkPrimitive2D : public AnimatedSwitchPrimitive2D 118 { 119 protected: 120 public: 121 /// constructor 122 AnimatedBlinkPrimitive2D( 123 const animation::AnimationEntry& rAnimationEntry, 124 const Primitive2DSequence& rChildren, 125 bool bIsTextAnimation); 126 127 /// create local decomposition 128 virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 129 130 /// provide unique ID 131 DeclPrimitrive2DIDBlock() 132 }; 133 } // end of namespace primitive2d 134 } // end of namespace drawinglayer 135 136 ////////////////////////////////////////////////////////////////////////////// 137 138 namespace drawinglayer 139 { 140 namespace primitive2d 141 { 142 /** AnimatedInterpolatePrimitive2D class 143 144 Specialized on multi-step animations based on matrix transformations. The 145 Child sequelce will be embedded in a matrix transformation. That transformation 146 will be linearly combined from the decomposed values and the animation value 147 to allow a smooth animation. 148 */ 149 class AnimatedInterpolatePrimitive2D : public AnimatedSwitchPrimitive2D 150 { 151 private: 152 /// the transformations 153 std::vector< basegfx::tools::B2DHomMatrixBufferedDecompose > maMatrixStack; 154 155 protected: 156 public: 157 /// constructor 158 AnimatedInterpolatePrimitive2D( 159 const std::vector< basegfx::B2DHomMatrix >& rmMatrixStack, 160 const animation::AnimationEntry& rAnimationEntry, 161 const Primitive2DSequence& rChildren, 162 bool bIsTextAnimation); 163 164 /// create local decomposition 165 virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 166 167 /// provide unique ID 168 DeclPrimitrive2DIDBlock() 169 }; 170 } // end of namespace primitive2d 171 } // end of namespace drawinglayer 172 173 ////////////////////////////////////////////////////////////////////////////// 174 175 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ANIMATEDPRIMITIVE2D_HXX 176 177 ////////////////////////////////////////////////////////////////////////////// 178 // eof 179