33#include "layermanager.h"
34#include "timecontrols.h"
35#include "timelinecells.h"
42void TimeLine::initUI()
44 Q_ASSERT(editor() !=
nullptr);
50 mLayerList =
new TimeLineCells(
this, editor(), TIMELINE_CELL_TYPE::Layers);
51 mTracks =
new TimeLineCells(
this, editor(), TIMELINE_CELL_TYPE::Tracks);
76 addLayerButton->
setIcon(
QIcon(
":icons/themes/playful/timeline/layer-add.svg"));
80 mLayerDeleteButton->
setIcon(
QIcon(
":icons/themes/playful/timeline/layer-remove.svg"));
84 duplicateLayerButton->
setIcon(
QIcon(
":icons/themes/playful/timeline/layer-duplicate.svg"));
89 layerButtons->
addWidget(mLayerDeleteButton);
90 layerButtons->
addWidget(duplicateLayerButton);
95 leftToolBarLayout->
addWidget(layerButtons);
96 leftToolBar->
setLayout(leftToolBarLayout);
98 QAction* newBitmapLayerAct =
new QAction(
QIcon(
":icons/themes/playful/timeline/cell-bitmap.svg"),
tr(
"New Bitmap Layer"),
this);
99 QAction* newVectorLayerAct =
new QAction(
QIcon(
":icons/themes/playful/timeline/cell-vector.svg"),
tr(
"New Vector Layer"),
this);
100 QAction* newSoundLayerAct =
new QAction(
QIcon(
":icons/themes/playful/timeline/cell-sound.svg"),
tr(
"New Sound Layer"),
this);
101 QAction* newCameraLayerAct =
new QAction(
QIcon(
":icons/themes/playful/timeline/cell-camera.svg"),
tr(
"New Camera Layer"),
this);
103 QMenu* layerMenu =
new QMenu(
tr(
"Layer",
"Timeline add-layer menu"),
this);
108 addLayerButton->
setMenu(layerMenu);
112 leftLayout->
addWidget(leftToolBar, 0, 0);
126 addKeyButton->
setIcon(
QIcon(
":icons/themes/playful/timeline/frame-add.svg"));
130 removeKeyButton->
setIcon(
QIcon(
":icons/themes/playful/timeline/frame-remove.svg"));
134 duplicateKeyButton->
setIcon(
QIcon(
":icons/themes/playful/timeline/frame-duplicate.svg"));
143 zoomSlider->
setValue(mTracks->getFrameSize());
149 timelineButtons->
addWidget(addKeyButton);
150 timelineButtons->
addWidget(removeKeyButton);
151 timelineButtons->
addWidget(duplicateKeyButton);
160 mTimeControls->setEditor(editor());
161 mTimeControls->initUI();
165 rightToolBarLayout->
addWidget(timelineButtons);
167 rightToolBarLayout->
addWidget(mTimeControls);
170 rightToolBar->
setLayout(rightToolBarLayout);
173 rightLayout->
addWidget(rightToolBar, 0, 0);
195 mScrollingStoppedTimer =
new QTimer();
205 connect(mScrollingStoppedTimer, &
QTimer::timeout, mLayerList, &TimeLineCells::onScrollingVerticallyStopped);
215 connect(mTimeControls, &TimeControls::soundToggled,
this, &TimeLine::soundClick);
216 connect(mTimeControls, &TimeControls::fpsChanged,
this, &TimeLine::fpsChanged);
217 connect(mTimeControls, &TimeControls::fpsChanged,
this, &TimeLine::updateLength);
218 connect(mTimeControls, &TimeControls::playButtonTriggered,
this, &TimeLine::playButtonTriggered);
220 connect(mTimeControls, &TimeControls::fpsChanged, mTimeControls, &TimeControls::setFps);
221 connect(
this, &TimeLine::fpsChanged, mTimeControls, &TimeControls::setFps);
229 connect(mLayerList, &TimeLineCells::mouseMovedY, mLayerList, &TimeLineCells::setMouseMoveY);
230 connect(mLayerList, &TimeLineCells::mouseMovedY, mTracks, &TimeLineCells::setMouseMoveY);
231 connect(mTracks, &TimeLineCells::lengthChanged,
this, &TimeLine::updateLength);
232 connect(mTracks, &TimeLineCells::selectionChanged,
this, &TimeLine::selectionChanged);
233 connect(mTracks, &TimeLineCells::insertNewKeyFrame,
this, &TimeLine::insertKeyClick);
240 connect(layer, &LayerManager::layerCountChanged,
this, &TimeLine::updateLayerNumber);
241 connect(layer, &LayerManager::currentLayerChanged,
this, &TimeLine::onCurrentLayerChanged);
242 mNumLayers = layer->count();
247void TimeLine::updateUI()
252void TimeLine::updateUICached()
264 int currentLength = mTracks->getFrameLength();
265 if(frame > (currentLength * 0.75))
267 int newLength =
static_cast<int>(std::max(frame, currentLength) * 1.5);
269 if (newLength > 9999)
272 mTracks->setFrameLength(newLength);
294void TimeLine::onScrollbarValueChanged()
297 mScrollingStoppedTimer->
start(150);
300void TimeLine::updateFrame(
int frameNumber)
305 mTracks->updateFrame(mLastUpdatedFrame);
306 mTracks->updateFrame(frameNumber);
308 mLastUpdatedFrame = frameNumber;
311void TimeLine::updateLayerView()
313 int pageDisplay = (mTracks->
height() - mTracks->getOffsetY()) / mTracks->getLayerHeight();
316 mVScrollbar->
setMaximum(qMax(0, mNumLayers - pageDisplay));
320void TimeLine::updateLayerNumber(
int numberOfLayers)
322 mNumLayers = numberOfLayers;
326void TimeLine::updateLength()
328 int frameLength = mTracks->getFrameLength();
329 mHScrollbar->
setMaximum(qMax(0, frameLength - mTracks->
width() / mTracks->getFrameSize()));
330 mTimeControls->updateLength(frameLength);
334void TimeLine::updateContent()
336 mLayerList->updateContent();
337 mTracks->updateContent();
341void TimeLine::setLoop(
bool loop)
343 mTimeControls->setLoop(loop);
346void TimeLine::setPlaying(
bool isPlaying)
349 mTimeControls->updatePlayState();
352void TimeLine::setRangeState(
bool range)
354 mTimeControls->setRangeState(range);
357int TimeLine::getRangeLower()
359 return mTimeControls->getRangeLower();
362int TimeLine::getRangeUpper()
364 return mTimeControls->getRangeUpper();
367void TimeLine::onObjectLoaded()
369 mTimeControls->updateUI();
370 updateLayerNumber(editor()->layers()->count());
373void TimeLine::onCurrentLayerChanged()
375 updateVerticalScrollbarPosition();
376 mLayerDeleteButton->
setEnabled(editor()->layers()->canDeleteLayer(editor()->currentLayerIndex()));
379void TimeLine::updateVerticalScrollbarPosition()
382 int idx = mNumLayers - editor()->currentLayerIndex() - 1;
void framesModified()
This should be emitted after modifying multiple frames.
void frameModified(int frameNumber)
This should be emitted after modifying the frame content.
void scrubbed(int frameNumber)
This should be emitted after scrubbing.
void extendLength(int frame)
Extends the timeline frame length if necessary.
void setOrientation(Qt::Orientation)
void setRange(int min, int max)
void valueChanged(int value)
void triggered(bool checked)
void setSpacing(int spacing)
void setSpacing(int spacing)
bool setAlignment(QWidget *w, Qt::Alignment alignment)
void setContentsMargins(int left, int top, int right, int bottom)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString tr(const char *sourceText, const char *disambiguation, int n)
void setSizes(const QList< int > &list)
void splitterMoved(int pos, int index)
void setSingleShot(bool singleShot)