tdf#154546 skip dispatch when presenter controller is not set
[LibreOffice.git] / include / drawinglayer / primitive2d / animatedprimitive2d.hxx
blob61ff4d33ef60a786d3cc04ac0bf308b31c3fa068
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <drawinglayer/drawinglayerdllapi.h>
24 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
25 #include <basegfx/matrix/b2dhommatrixtools.hxx>
26 #include <memory>
28 // predefines
29 namespace drawinglayer::animation
31 class AnimationEntry;
34 namespace basegfx
36 class B2DHomMatrix;
39 namespace drawinglayer::primitive2d
41 /** AnimatedSwitchPrimitive2D class
43 This is the basic class for simple, animated primitives. The basic idea
44 is to have an animation definition (AnimationEntry) who's basic
45 functionality is to return a state value for any given animation time in
46 the range of [0.0 .. 1.0]. Depending on the state, the decomposition
47 calculates an index, which of the members of the child vector is to
48 be visualized.
50 An example: For blinking, the Child vector should exist of two entries;
51 for values of [0.0 .. 0.5] the first, else the last entry will be used.
52 This mechanism is not limited to two entries, though.
54 class DRAWINGLAYER_DLLPUBLIC AnimatedSwitchPrimitive2D : public GroupPrimitive2D
56 private:
57 /**
58 The animation definition which allows translation of a point in time
59 to an animation state [0.0 .. 1.0]. This member contains a cloned
60 definition and is owned by this implementation.
62 std::unique_ptr<animation::AnimationEntry> mpAnimationEntry;
64 /** flag if this is a text or graphic animation. Necessary since SdrViews need to differentiate
65 between both types if they are on/off
67 bool mbIsTextAnimation : 1;
69 protected:
70 /** write access right for classes deriving from this who want to do special
71 things (e.g. optimization, buffering).
72 Caution: This is an exception from the read-only, non-modifiable paradigm
73 for primitives, so special preparations may be needed. Usually should
74 only be used for initialization (e.g. in a derived constructor)
76 void setAnimationEntry(const animation::AnimationEntry& rNew);
78 public:
79 /// constructor
80 AnimatedSwitchPrimitive2D(const animation::AnimationEntry& rAnimationEntry,
81 Primitive2DContainer&& aChildren, bool bIsTextAnimation);
83 /// destructor - needed due to mpAnimationEntry
84 virtual ~AnimatedSwitchPrimitive2D() override;
86 /// data read access
87 const animation::AnimationEntry& getAnimationEntry() const { return *mpAnimationEntry; }
88 bool isTextAnimation() const { return mbIsTextAnimation; }
89 bool isGraphicAnimation() const { return !isTextAnimation(); }
91 /// compare operator
92 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
94 /// provide unique ID
95 virtual sal_uInt32 getPrimitive2DID() const override;
97 /** Override getDecomposition() here since the decompose
98 depends on the point in time, so the default implementation is
99 not useful here, it needs to be handled locally
101 virtual void
102 get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor,
103 const geometry::ViewInformation2D& rViewInformation) const override;
106 /** AnimatedBlinkPrimitive2D class
108 Basically the same mechanism as in AnimatedSwitchPrimitive2D, but the
109 decomposition is specialized in delivering the children in the
110 range [0.0.. 0.5] and an empty sequence else
112 class DRAWINGLAYER_DLLPUBLIC AnimatedBlinkPrimitive2D final : public AnimatedSwitchPrimitive2D
114 public:
115 /// constructor
116 AnimatedBlinkPrimitive2D(const animation::AnimationEntry& rAnimationEntry,
117 Primitive2DContainer&& aChildren);
119 /// create local decomposition
120 virtual void
121 get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor,
122 const geometry::ViewInformation2D& rViewInformation) const override;
124 /// provide unique ID
125 virtual sal_uInt32 getPrimitive2DID() const override;
128 /** AnimatedInterpolatePrimitive2D class
130 Specialized on multi-step animations based on matrix transformations. The
131 Child sequence will be embedded in a matrix transformation. That transformation
132 will be linearly combined from the decomposed values and the animation value
133 to allow a smooth animation.
135 class DRAWINGLAYER_DLLPUBLIC AnimatedInterpolatePrimitive2D final : public AnimatedSwitchPrimitive2D
137 private:
138 /// the transformations
139 std::vector<basegfx::utils::B2DHomMatrixBufferedDecompose> maMatrixStack;
141 public:
142 /// constructor
143 AnimatedInterpolatePrimitive2D(const std::vector<basegfx::B2DHomMatrix>& rmMatrixStack,
144 const animation::AnimationEntry& rAnimationEntry,
145 Primitive2DContainer&& aChildren);
147 /// create local decomposition
148 virtual void
149 get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor,
150 const geometry::ViewInformation2D& rViewInformation) const override;
152 /// provide unique ID
153 virtual sal_uInt32 getPrimitive2DID() const override;
156 } // end of namespace drawinglayer::primitive2d
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */