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 
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(int interval) = 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  int m_duration {1000};
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(int /*interval*/) 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(int interval) 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(int interval) override // Transition
166  { if (m_current) m_current->Pulse(interval); }
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
void Start(Slide &from, Slide &to, bool forwards, float speed=1.0) override
Starts a random transition from a set of its peer transitions,.
Images blend whilst rotating.
Switches images instantly with no effects.
Transition(const QString &name)
void Initialise() override
Set up Blend transition.
unsigned int slots[4]
Definition: element.c:38
void Initialise() override
Set up Slide transition.
Slide * m_next
The image occurring later in the slideshow sequence.
Invokes random transitions.
void Initialise() override
Set up Zoom transition.
Transition & Select(int setting)
Returns the requested transition or an alternative if it is not suitable for the painter.
void SetSpeed(float speed) override
void Pulse(int) override
virtual void Pulse(int interval)=0
A group of animations to be played simultaneously.
Definition: galleryslide.h:128
GroupAnimation * m_animation
void finished()
Slide * m_prev
The image occurring earlier in the slideshow sequence.
int m_duration
Seconds transition will last.
A group of animations to be played sequentially.
Definition: galleryslide.h:110
GroupTransition(GroupAnimation *animation, const QString &name)
Create group transition.
void Finalise() override=0
ImageTransitionType
Available transitions.
virtual void SetSpeed(float)
TransitionRandom(QList< Transition * > peers)
Abstract class implementing sequential & parallel animations.
TransitionMap m_map
All possible transitions.
virtual void Initialise()
TransitionNone m_immediate
A transition that updates instantly.
~Transition() override=default
void Initialise() override=0
Slide * m_old
The image currently displayed, which will be replaced (whatever the transition direction)
Slide on from right, then off to left.
void Initialise() override
Set up Spin transition.
Defines specialised images used by the Gallery slideshow and the animation framework used by transfor...
void Start(Slide &from, Slide &to, bool forwards, float speed=1.0) override
Switch images.
Image twists into the next.
void Finalise() override
QMap< int, Transition * > TransitionMap
void Finalise() override
Reset Slide transition.
void SetSpeed(float speed) override
Change transition speed.
virtual void Finished()
Transition has completed.
Slide * m_new
The new image that will replace the current one (whatever the transition direction)
A specialised image for slideshows.
Definition: galleryslide.h:156
Transition * m_current
Selected transition.
Base class of an animated transition that can be accelerated & reversed.
void Initialise() override
Set up Twist transition.
QList< Transition * > m_peers
Set of distinct transitions.
virtual void Finalise()
virtual void Start(Slide &from, Slide &to, bool forwards, float speed=1.0)
Start base transition.
void Pulse(int interval) override
Image blends into the next by fading.
Zooms from right, then away to left.
void Finalise() override
Reset Blend transition.
TransitionRegistry(bool includeAnimations)
Constructor.
void Finalise() override
Reset Twist transition.
~GroupTransition() override
Destroy group transition.
TransitionMap GetAll() const
void Pulse(int interval) override
Update group transition.
void Finalise() override
Reset Zoom transition.
void Finalise() override
Reset Spin transition.
Manages transitions available to s psinter.
Abstract class for groups of animations.
Definition: galleryslide.h:90
void Start(Slide &from, Slide &to, bool forwards, float speed=1.0) override
Start group transition.
void Finished() override
Invoked when peer transition completes.
void Initialise() override