Radium Engine  1.5.20
Loading...
Searching...
No Matches
TimelineFrameSelector.hpp
1#pragma once
2#include <Gui/Timeline/Configurations.hpp>
3
4#include <QDoubleSpinBox>
5#include <QFrame>
6#include <QLabel>
7#include <QSpacerItem>
8#include <QToolButton>
9#include <set>
10
11#include <Core/CoreMacros.hpp>
12
13namespace Ui {
14class Timeline;
15}
16
17namespace Ra::Gui {
18
23class TimelineFrameSelector : public QFrame
24{
25 Q_OBJECT
26 public:
27 explicit TimelineFrameSelector( QWidget* parent = nullptr );
28 ~TimelineFrameSelector() override;
29
31 void setTimelineUi( Ui::Timeline* ui );
32
41 void onChangeStart( Scalar time, bool internal = true );
42
51 void onChangeEnd( Scalar time, bool internal = true );
52
61 void onChangeDuration( Scalar time, bool internal = true );
62
71 void onChangeCursor( Scalar time, bool internal = true );
72
73 public slots:
90 void onAddingKeyFrame( Scalar time = -1.0, bool internal = true );
91
99 void onDeletingKeyFrame( bool internal = true );
100
111 void onMoveKeyFrame( Scalar time0, Scalar time1, bool internal = true );
112
139 void onMoveKeyFrames( Scalar time, Scalar offset, bool internal = true );
140
144 void onClearKeyFrames();
145
146 signals:
153 void startChanged( Scalar time );
154
161 void endChanged( Scalar time );
162
167 void durationChanged( Scalar time );
168
175 void cursorChanged( Scalar time );
176
181 void keyFrameAdded( Scalar time );
182
189 void keyFrameDeleted( size_t i );
190
195 void keyFrameChanged( size_t i );
196
201 void keyFrameMoved( size_t i, Scalar time1 );
202
208 void keyFramesMoved( size_t first, Scalar offset );
209
210 private slots:
217 void onSlideLeftSlider( int deltaX );
218
225 void onSlideRightSlider( int deltaX );
226
231 void onSetCursorToStart();
232
237 void onSetCursorToEnd();
238
243 void onSetCursorToPreviousKeyFrame();
244
249 void onSetCursorToNextKeyFrame();
250
251 protected:
252 virtual void paintEvent( QPaintEvent* event ) override;
253
254 void mousePressEvent( QMouseEvent* event ) override;
255 void mouseMoveEvent( QMouseEvent* event ) override;
256 void mouseReleaseEvent( QMouseEvent* event ) override;
257
258 private:
260 void updateStartSpin();
261
263 void updateEndSpin();
264
266 void updateCursorSpin();
267
269 void updateDurationSpin();
270
272 void updateNbKeyFrameSpin();
273
279 Scalar nearestStep( Scalar time ) const;
280
286 void deleteZone( Scalar time, Scalar time2 );
287
291 void redrawPlayZone();
292
293 private:
295 Scalar m_start;
296
298 Scalar m_end;
299
301 Scalar m_cursor;
302
304 std::vector<Scalar> m_keyFrames;
305
307 bool m_mouseLeftClicked { false };
308
310 Scalar m_keyFrameFlash;
311
313 int m_updateKeyFrameFlash { 0 };
314
316 QTimer* m_timer { nullptr };
317
319 Ui::Timeline* m_timelineUI { nullptr };
320};
321
322} // namespace Ra::Gui
void onAddingKeyFrame(Scalar time=-1.0, bool internal=true)
void onMoveKeyFrame(Scalar time0, Scalar time1, bool internal=true)
void onChangeDuration(Scalar time, bool internal=true)
void onChangeCursor(Scalar time, bool internal=true)
void durationChanged(Scalar time)
void cursorChanged(Scalar time)
void keyFrameAdded(Scalar time)
void keyFrameMoved(size_t i, Scalar time1)
void onChangeStart(Scalar time, bool internal=true)
void endChanged(Scalar time)
void onMoveKeyFrames(Scalar time, Scalar offset, bool internal=true)
void keyFramesMoved(size_t first, Scalar offset)
void onDeletingKeyFrame(bool internal=true)
void onChangeEnd(Scalar time, bool internal=true)
void setTimelineUi(Ui::Timeline *ui)
Registers the Timeline's UI for update.
void startChanged(Scalar time)