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
{
36 namespace drawinglayer
40 /** AnimatedSwitchPrimitive2D class
42 This is the basic class for simple, animated primitives. The basic idea
43 is to have an animation definition (AnimationEntry) who's basic
44 functionality is to return a state value for any given animation time in
45 the range of [0.0 .. 1.0]. Depending on the state, the decomposition
46 calculates an index, which of the members of the child vector is to
49 An example: For blinking, the Child vector should exist of two entries;
50 for values of [0.0 .. 0.5] the first, else the last entry will be used.
51 This mechanism is not limited to two entries, though.
53 class DRAWINGLAYER_DLLPUBLIC AnimatedSwitchPrimitive2D
: public GroupPrimitive2D
57 The animation definition which allows translation of a point in time
58 to an animation state [0.0 .. 1.0]. This member contains a cloned
59 definition and is owned by this implementation.
61 std::unique_ptr
<animation::AnimationEntry
> mpAnimationEntry
;
63 /** flag if this is a text or graphic animation. Necessary since SdrViews need to differentiate
64 between both types if they are on/off
66 bool mbIsTextAnimation
: 1;
69 /** write access right for classes deriving from this who want to do special
70 things (e.g. optimization, buffering).
71 Caution: This is an exception from the read-only, non-modifyable paradigm
72 for primitives, so special preparations may be needed. Usually should
73 only be used for initialization (e.g. in a derived constructor)
75 void setAnimationEntry(const animation::AnimationEntry
& rNew
);
79 AnimatedSwitchPrimitive2D(
80 const animation::AnimationEntry
& rAnimationEntry
,
81 const Primitive2DContainer
& rChildren
,
82 bool bIsTextAnimation
);
84 /// destructor - needed due to mpAnimationEntry
85 virtual ~AnimatedSwitchPrimitive2D() override
;
88 const animation::AnimationEntry
& getAnimationEntry() const { return *mpAnimationEntry
; }
89 bool isTextAnimation() const { return mbIsTextAnimation
; }
90 bool isGraphicAnimation() const { return !isTextAnimation(); }
93 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const override
;
96 DeclPrimitive2DIDBlock()
98 /** Override getDecomposition() here since the decompose
99 depends on the point in time, so the default implementation is
100 not useful here, it needs to be handled locally
102 virtual void get2DDecomposition(Primitive2DDecompositionVisitor
& rVisitor
, const geometry::ViewInformation2D
& rViewInformation
) const override
;
104 } // end of namespace primitive2d
105 } // end of namespace drawinglayer
108 namespace drawinglayer
110 namespace primitive2d
112 /** AnimatedBlinkPrimitive2D class
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
118 class DRAWINGLAYER_DLLPUBLIC AnimatedBlinkPrimitive2D
: public AnimatedSwitchPrimitive2D
123 AnimatedBlinkPrimitive2D(
124 const animation::AnimationEntry
& rAnimationEntry
,
125 const Primitive2DContainer
& rChildren
);
127 /// create local decomposition
128 virtual void get2DDecomposition(Primitive2DDecompositionVisitor
& rVisitor
, const geometry::ViewInformation2D
& rViewInformation
) const override
;
130 /// provide unique ID
131 DeclPrimitive2DIDBlock()
133 } // end of namespace primitive2d
134 } // end of namespace drawinglayer
137 namespace drawinglayer
139 namespace primitive2d
141 /** AnimatedInterpolatePrimitive2D class
143 Specialized on multi-step animations based on matrix transformations. The
144 Child sequence will be embedded in a matrix transformation. That transformation
145 will be linearly combined from the decomposed values and the animation value
146 to allow a smooth animation.
148 class DRAWINGLAYER_DLLPUBLIC AnimatedInterpolatePrimitive2D
: public AnimatedSwitchPrimitive2D
151 /// the transformations
152 std::vector
< basegfx::tools::B2DHomMatrixBufferedDecompose
> maMatrixStack
;
157 AnimatedInterpolatePrimitive2D(
158 const std::vector
< basegfx::B2DHomMatrix
>& rmMatrixStack
,
159 const animation::AnimationEntry
& rAnimationEntry
,
160 const Primitive2DContainer
& rChildren
);
162 /// create local decomposition
163 virtual void get2DDecomposition(Primitive2DDecompositionVisitor
& rVisitor
, const geometry::ViewInformation2D
& rViewInformation
) const override
;
165 /// provide unique ID
166 DeclPrimitive2DIDBlock()
168 } // end of namespace primitive2d
169 } // end of namespace drawinglayer
172 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_ANIMATEDPRIMITIVE2D_HXX
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */