MythTV  master
gallerytransitions.h
Go to the documentation of this file.
1 
4 #ifndef GALLERYTRANSITIONS_H
5 #define GALLERYTRANSITIONS_H
6 
7 #include <utility>
8 
9 // MythTV headers
10 #include "galleryslide.h"
11 
12 
14 enum ImageTransitionType : std::uint8_t {
15  // First transition must be 0 and useable by all painters
23  kLastTransSentinel = 7 // Must be last
24 };
25 
26 
28 class Transition : public QObject
29 {
30  Q_OBJECT
31 public:
32  explicit Transition(const QString& name);
33  ~Transition() override = default;
34 
35  virtual void Start(Slide &from, Slide &to, bool forwards, float speed = 1.0);
36  virtual void SetSpeed(float /*speed*/) {}
37  virtual void Pulse() = 0;
38  virtual void Initialise() {}
39  virtual void Finalise() {}
40 
41 protected slots:
42  virtual void Finished();
43 
44 signals:
45  void finished();
46 
47 protected:
49  std::chrono::milliseconds m_duration {1s};
52  Slide *m_old {nullptr};
55  Slide *m_new {nullptr};
56  // Transitions play forwards or backwards. Symmetric transitions can
57  // define a one-way transition in terms of "prev" & "next" (as in
58  // position rather than time). The reverse transition can then be
59  // achieved by playing it backwards.
60  // When played forwards next replaces prev, ie. prev = old, next = new
61  // When played backwards prev replaces next, ie. prev = new, next = old
63  Slide *m_prev {nullptr};
65  Slide *m_next {nullptr};
66 };
67 
68 
69 using TransitionMap = QMap<int, Transition*>;
70 
71 
73 class TransitionNone : public Transition
74 {
75 public:
76  TransitionNone() : Transition("None") {}
77  void Start(Slide &from, Slide &to,
78  bool forwards, float speed = 1.0) override; // Transition
79  void Pulse() override {} // Transition
80 };
81 
82 
85 {
86 public:
87  GroupTransition(GroupAnimation *animation, const QString& name);
88  ~GroupTransition() override;
89  void Start(Slide &from, Slide &to,
90  bool forwards, float speed = 1.0) override; // Transition
91  void SetSpeed(float speed) override; // Transition
92  void Pulse() override; // Transition
93  void Initialise() override = 0; // Transition
94  void Finalise() override = 0; // Transition
95 
96 protected:
98 };
99 
100 
103 {
104 public:
106  Transition::tr("Blend")) {}
107  void Initialise() override; // GroupTransition
108  void Finalise() override; // GroupTransition
109 };
110 
111 
114 {
115 public:
117  Transition::tr("Twist")) {}
118  void Initialise() override; // GroupTransition
119  void Finalise() override; // GroupTransition
120 };
121 
122 
125 {
126 public:
128  Transition::tr("Slide")) {}
129  void Initialise() override; // GroupTransition
130  void Finalise() override; // GroupTransition
131 };
132 
133 
136 {
137 public:
139  Transition::tr("Zoom")) {}
140  void Initialise() override; // GroupTransition
141  void Finalise() override; // GroupTransition
142 };
143 
144 
147 {
148 public:
149  TransitionSpin() { setObjectName(Transition::tr("Spin")); }
150  void Initialise() override; // TransitionBlend
151  void Finalise() override; // TransitionBlend
152 };
153 
154 
157 {
158  Q_OBJECT
159 public:
160  explicit TransitionRandom(QList<Transition*> peers)
161  : Transition(Transition::tr("Random")), m_peers(std::move(peers)) {}
162  void Start(Slide &from, Slide &to, bool forwards, float speed = 1.0) override; // Transition
163  void SetSpeed(float speed) override // Transition
164  { if (m_current) m_current->SetSpeed(speed); }
165  void Pulse() override // Transition
166  { if (m_current) m_current->Pulse(); }
167  void Initialise() override // Transition
168  { if (m_current) m_current->Initialise(); }
169  void Finalise() override // Transition
170  { if (m_current) m_current->Finalise(); }
171 
172 protected slots:
173  void Finished() override; // Transition
174 
175 protected:
177  QList<Transition*> m_peers;
179  Transition *m_current {nullptr};
180 };
181 
182 
185 {
186 public:
187  explicit TransitionRegistry(bool includeAnimations);
188  ~TransitionRegistry() { qDeleteAll(m_map); }
189  TransitionMap GetAll() const { return m_map; }
190  Transition &Select(int setting);
191 
194 
195 private:
198 };
199 
200 
201 #endif // GALLERYTRANSITIONS_H
Slide
A specialised image for slideshows.
Definition: galleryslide.h:156
Transition::~Transition
~Transition() override=default
Transition::Finished
virtual void Finished()
Transition has completed.
Definition: gallerytransitions.cpp:106
ImageTransitionType
ImageTransitionType
Available transitions.
Definition: gallerytransitions.h:14
TransitionTwist::Initialise
void Initialise() override
Set up Twist transition.
Definition: gallerytransitions.cpp:235
kRandomTransition
@ kRandomTransition
Definition: gallerytransitions.h:17
GroupTransition::GroupTransition
GroupTransition(GroupAnimation *animation, const QString &name)
Create group transition.
Definition: gallerytransitions.cpp:144
TransitionRandom::m_current
Transition * m_current
Selected transition.
Definition: gallerytransitions.h:179
TransitionZoom::Finalise
void Finalise() override
Reset Zoom transition.
Definition: gallerytransitions.cpp:332
TransitionMap
QMap< int, Transition * > TransitionMap
Definition: gallerytransitions.h:69
TransitionTwist::TransitionTwist
TransitionTwist()
Definition: gallerytransitions.h:116
kNoTransition
@ kNoTransition
Definition: gallerytransitions.h:16
TransitionRandom::Finalise
void Finalise() override
Definition: gallerytransitions.h:169
TransitionRandom::m_peers
QList< Transition * > m_peers
Set of distinct transitions.
Definition: gallerytransitions.h:177
kSlideTransition
@ kSlideTransition
Definition: gallerytransitions.h:20
TransitionSpin::Finalise
void Finalise() override
Reset Spin transition.
Definition: gallerytransitions.cpp:387
Transition::Finalise
virtual void Finalise()
Definition: gallerytransitions.h:39
GroupTransition
Abstract class implementing sequential & parallel animations.
Definition: gallerytransitions.h:84
Transition::m_new
Slide * m_new
The new image that will replace the current one (whatever the transition direction)
Definition: gallerytransitions.h:55
Transition
Base class of an animated transition that can be accelerated & reversed.
Definition: gallerytransitions.h:28
TransitionSpin::TransitionSpin
TransitionSpin()
Definition: gallerytransitions.h:149
TransitionSlide::Initialise
void Initialise() override
Set up Slide transition.
Definition: gallerytransitions.cpp:265
GroupTransition::m_animation
GroupAnimation * m_animation
Definition: gallerytransitions.h:97
TransitionRandom::Initialise
void Initialise() override
Definition: gallerytransitions.h:167
TransitionBlend::Finalise
void Finalise() override
Reset Blend transition.
Definition: gallerytransitions.cpp:225
TransitionZoom
Zooms from right, then away to left.
Definition: gallerytransitions.h:135
TransitionZoom::TransitionZoom
TransitionZoom()
Definition: gallerytransitions.h:138
kSpinTransition
@ kSpinTransition
Definition: gallerytransitions.h:22
TransitionTwist::Finalise
void Finalise() override
Reset Twist transition.
Definition: gallerytransitions.cpp:255
Transition::Transition
Transition(const QString &name)
Definition: gallerytransitions.cpp:11
TransitionSlide::Finalise
void Finalise() override
Reset Slide transition.
Definition: gallerytransitions.cpp:288
GroupAnimation
Abstract class for groups of animations.
Definition: galleryslide.h:90
TransitionNone::Pulse
void Pulse() override
Definition: gallerytransitions.h:79
GroupTransition::~GroupTransition
~GroupTransition() override
Destroy group transition.
Definition: gallerytransitions.cpp:155
Transition::Start
virtual void Start(Slide &from, Slide &to, bool forwards, float speed=1.0)
Start base transition.
Definition: gallerytransitions.cpp:80
TransitionNone::Start
void Start(Slide &from, Slide &to, bool forwards, float speed=1.0) override
Switch images.
Definition: gallerytransitions.cpp:128
TransitionRandom::Finished
void Finished() override
Invoked when peer transition completes.
Definition: gallerytransitions.cpp:419
TransitionNone
Switches images instantly with no effects.
Definition: gallerytransitions.h:73
ParallelAnimation
A group of animations to be played simultaneously.
Definition: galleryslide.h:128
TransitionRandom
Invokes random transitions.
Definition: gallerytransitions.h:156
kBlendTransition
@ kBlendTransition
Definition: gallerytransitions.h:18
TransitionBlend::Initialise
void Initialise() override
Set up Blend transition.
Definition: gallerytransitions.cpp:205
TransitionSlide::TransitionSlide
TransitionSlide()
Definition: gallerytransitions.h:127
TransitionSpin
Images blend whilst rotating.
Definition: gallerytransitions.h:146
TransitionRandom::Start
void Start(Slide &from, Slide &to, bool forwards, float speed=1.0) override
Starts a random transition from a set of its peer transitions,.
Definition: gallerytransitions.cpp:405
kLastTransSentinel
@ kLastTransSentinel
Definition: gallerytransitions.h:23
GroupTransition::Pulse
void Pulse() override
Update group transition.
Definition: gallerytransitions.cpp:195
TransitionNone::TransitionNone
TransitionNone()
Definition: gallerytransitions.h:76
TransitionSlide
Slide on from right, then off to left.
Definition: gallerytransitions.h:124
Transition::m_duration
std::chrono::milliseconds m_duration
Seconds transition will last.
Definition: gallerytransitions.h:49
TransitionTwist
Image twists into the next.
Definition: gallerytransitions.h:113
TransitionBlend::TransitionBlend
TransitionBlend()
Definition: gallerytransitions.h:105
SequentialAnimation
A group of animations to be played sequentially.
Definition: galleryslide.h:110
GroupTransition::Initialise
void Initialise() override=0
TransitionRegistry
Manages transitions available to s psinter.
Definition: gallerytransitions.h:184
galleryslide.h
Defines specialised images used by the Gallery slideshow and the animation framework used by transfor...
TransitionRandom::TransitionRandom
TransitionRandom(QList< Transition * > peers)
Definition: gallerytransitions.h:160
Transition::m_next
Slide * m_next
The image occurring later in the slideshow sequence.
Definition: gallerytransitions.h:65
TransitionSpin::Initialise
void Initialise() override
Set up Spin transition.
Definition: gallerytransitions.cpp:343
TransitionRandom::SetSpeed
void SetSpeed(float speed) override
Definition: gallerytransitions.h:163
TransitionRegistry::m_immediate
TransitionNone m_immediate
A transition that updates instantly.
Definition: gallerytransitions.h:193
GroupTransition::Start
void Start(Slide &from, Slide &to, bool forwards, float speed=1.0) override
Start group transition.
Definition: gallerytransitions.cpp:169
TransitionRegistry::TransitionRegistry
TransitionRegistry(bool includeAnimations)
Constructor.
Definition: gallerytransitions.cpp:51
kTwistTransition
@ kTwistTransition
Definition: gallerytransitions.h:19
Transition::Pulse
virtual void Pulse()=0
Transition::SetSpeed
virtual void SetSpeed(float)
Definition: gallerytransitions.h:36
TransitionRegistry::Select
Transition & Select(int setting)
Returns the requested transition or an alternative if it is not suitable for the painter.
Definition: gallerytransitions.cpp:24
GroupTransition::SetSpeed
void SetSpeed(float speed) override
Change transition speed.
Definition: gallerytransitions.cpp:186
Transition::finished
void finished()
kZoomTransition
@ kZoomTransition
Definition: gallerytransitions.h:21
Transition::m_prev
Slide * m_prev
The image occurring earlier in the slideshow sequence.
Definition: gallerytransitions.h:63
TransitionRegistry::~TransitionRegistry
~TransitionRegistry()
Definition: gallerytransitions.h:188
Transition::m_old
Slide * m_old
The image currently displayed, which will be replaced (whatever the transition direction)
Definition: gallerytransitions.h:52
GroupTransition::Finalise
void Finalise() override=0
TransitionRegistry::GetAll
TransitionMap GetAll() const
Definition: gallerytransitions.h:189
TransitionZoom::Initialise
void Initialise() override
Set up Zoom transition.
Definition: gallerytransitions.cpp:298
TransitionRandom::Pulse
void Pulse() override
Definition: gallerytransitions.h:165
TransitionRegistry::m_map
TransitionMap m_map
All possible transitions.
Definition: gallerytransitions.h:197
TransitionBlend
Image blends into the next by fading.
Definition: gallerytransitions.h:102
Transition::Initialise
virtual void Initialise()
Definition: gallerytransitions.h:38