MythTV  master
gallerytransitions.h
Go to the documentation of this file.
1 
4 #ifndef GALLERYTRANSITIONS_H
5 #define GALLERYTRANSITIONS_H
6 
7 #include "galleryslide.h"
8 
9 
12  // First transition must be 0 and useable by all painters
20  kLastTransSentinel = 7 // Must be last
21 };
22 
23 
25 class Transition : public QObject
26 {
27  Q_OBJECT
28 public:
29  explicit Transition(const QString& name);
30  virtual ~Transition() = default;
31 
32  virtual void Start(Slide &from, Slide &to, bool forwards, float speed = 1.0);
33  virtual void SetSpeed(float) {}
34  virtual void Pulse(int interval) = 0;
35  virtual void Initialise() {}
36  virtual void Finalise() {}
37 
38 protected slots:
39  virtual void Finished();
40 
41 signals:
42  void finished();
43 
44 protected:
46  int m_duration {1000};
49  Slide *m_old {nullptr};
52  Slide *m_new {nullptr};
53  // Transitions play forwards or backwards. Symmetric transitions can
54  // define a one-way transition in terms of "prev" & "next" (as in
55  // position rather than time). The reverse transition can then be
56  // achieved by playing it backwards.
57  // When played forwards next replaces prev, ie. prev = old, next = new
58  // When played backwards prev replaces next, ie. prev = new, next = old
60  Slide *m_prev {nullptr};
62  Slide *m_next {nullptr};
63 };
64 
65 
66 typedef QMap<int, Transition*> TransitionMap;
67 
68 
70 class TransitionNone : public Transition
71 {
72 public:
73  TransitionNone() : Transition("None") {}
74  void Start(Slide &from, Slide &to,
75  bool forwards, float speed = 1.0) override; // Transition
76  void Pulse(int) override {} // Transition
77 };
78 
79 
82 {
83 public:
84  GroupTransition(GroupAnimation *animation, QString name);
85  virtual ~GroupTransition();
86  void Start(Slide &from, Slide &to,
87  bool forwards, float speed = 1.0) override; // Transition
88  void SetSpeed(float speed) override; // Transition
89  void Pulse(int interval) override; // Transition
90  void Initialise() override = 0; // Transition
91  void Finalise() override = 0; // Transition
92 
93 protected:
95 };
96 
97 
100 {
101 public:
103  Transition::tr("Blend")) {}
104  void Initialise() override; // GroupTransition
105  void Finalise() override; // GroupTransition
106 };
107 
108 
111 {
112 public:
114  Transition::tr("Twist")) {}
115  void Initialise() override; // GroupTransition
116  void Finalise() override; // GroupTransition
117 };
118 
119 
122 {
123 public:
125  Transition::tr("Slide")) {}
126  void Initialise() override; // GroupTransition
127  void Finalise() override; // GroupTransition
128 };
129 
130 
133 {
134 public:
136  Transition::tr("Zoom")) {}
137  void Initialise() override; // GroupTransition
138  void Finalise() override; // GroupTransition
139 };
140 
141 
144 {
145 public:
147  { setObjectName(Transition::tr("Spin")); }
148  void Initialise() override; // TransitionBlend
149  void Finalise() override; // TransitionBlend
150 };
151 
152 
155 {
156  Q_OBJECT
157 public:
158  explicit TransitionRandom(const QList<Transition*>& peers)
159  : Transition(Transition::tr("Random")), m_peers(peers) {}
160  void Start(Slide &from, Slide &to, bool forwards, float speed = 1.0) override; // Transition
161  void SetSpeed(float speed) override // Transition
162  { if (m_current) m_current->SetSpeed(speed); }
163  void Pulse(int interval) override // Transition
164  { if (m_current) m_current->Pulse(interval); }
165  void Initialise() override // Transition
166  { if (m_current) m_current->Initialise(); }
167  void Finalise() override // Transition
168  { if (m_current) m_current->Finalise(); }
169 
170 protected slots:
171  void Finished() override; // Transition
172 
173 protected:
175  QList<Transition*> m_peers;
177  Transition *m_current {nullptr};
178 };
179 
180 
183 {
184 public:
185  explicit TransitionRegistry(bool includeAnimations);
186  ~TransitionRegistry() { qDeleteAll(m_map); }
187  const TransitionMap GetAll() const { return m_map; }
188  Transition &Select(int setting);
189 
192 
193 private:
196 };
197 
198 
199 #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.
TransitionRandom(const QList< Transition * > &peers)
Switches images instantly with no effects.
virtual ~Transition()=default
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:127
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:109
void Finalise() override=0
ImageTransitionType
Available transitions.
virtual void SetSpeed(float)
Abstract class implementing sequential & parallel animations.
TransitionMap m_map
All possible transitions.
virtual void Initialise()
TransitionNone m_immediate
A transition that updates instantly.
GroupTransition(GroupAnimation *animation, QString name)
Create group transition.
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
const char * name
Definition: ParseText.cpp:328
virtual ~GroupTransition()
Destroy group transition.
void Finalise() override
Reset Slide transition.
QMap< int, Transition * > TransitionMap
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:155
Transition * m_current
Selected transition.
Base class of an animated transition that can be accelerated & reversed.
const TransitionMap GetAll() const
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.
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:91
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