32#include "layermanager.h"
33#include "timecontrols.h"
34#include "timelinecells.h"
41void TimeLine::initUI()
43 Q_ASSERT(editor() !=
nullptr);
49 mLayerList =
new TimeLineCells(
this, editor(), TIMELINE_CELL_TYPE::Layers);
50 mTracks =
new TimeLineCells(
this, editor(), TIMELINE_CELL_TYPE::Tracks);
75 addLayerButton->
setIcon(
QIcon(
":icons/themes/playful/timeline/layer-add.svg"));
79 mLayerDeleteButton->
setIcon(
QIcon(
":icons/themes/playful/timeline/layer-remove.svg"));
83 duplicateLayerButton->
setIcon(
QIcon(
":icons/themes/playful/timeline/layer-duplicate.svg"));
88 layerButtons->
addWidget(mLayerDeleteButton);
89 layerButtons->
addWidget(duplicateLayerButton);
94 leftToolBarLayout->
addWidget(layerButtons);
95 leftToolBar->
setLayout(leftToolBarLayout);
97 QAction* newBitmapLayerAct =
new QAction(
QIcon(
":icons/themes/playful/timeline/cell-bitmap.svg"),
tr(
"New Bitmap Layer"),
this);
98 QAction* newVectorLayerAct =
new QAction(
QIcon(
":icons/themes/playful/timeline/cell-vector.svg"),
tr(
"New Vector Layer"),
this);
99 QAction* newSoundLayerAct =
new QAction(
QIcon(
":icons/themes/playful/timeline/cell-sound.svg"),
tr(
"New Sound Layer"),
this);
100 QAction* newCameraLayerAct =
new QAction(
QIcon(
":icons/themes/playful/timeline/cell-camera.svg"),
tr(
"New Camera Layer"),
this);
102 QMenu* layerMenu =
new QMenu(
tr(
"Layer",
"Timeline add-layer menu"),
this);
107 addLayerButton->
setMenu(layerMenu);
111 leftLayout->
addWidget(leftToolBar, 0, 0);
125 addKeyButton->
setIcon(
QIcon(
":icons/themes/playful/timeline/frame-add.svg"));
129 removeKeyButton->
setIcon(
QIcon(
":icons/themes/playful/timeline/frame-remove.svg"));
133 duplicateKeyButton->
setIcon(
QIcon(
":icons/themes/playful/timeline/frame-duplicate.svg"));
142 zoomSlider->
setValue(mTracks->getFrameSize());
148 timelineButtons->
addWidget(addKeyButton);
149 timelineButtons->
addWidget(removeKeyButton);
150 timelineButtons->
addWidget(duplicateKeyButton);
159 mTimeControls->setEditor(editor());
160 mTimeControls->initUI();
164 rightToolBarLayout->
addWidget(timelineButtons);
166 rightToolBarLayout->
addWidget(mTimeControls);
169 rightToolBar->
setLayout(rightToolBarLayout);
172 rightLayout->
addWidget(rightToolBar, 0, 0);
209 connect(mTimeControls, &TimeControls::soundToggled,
this, &TimeLine::soundClick);
210 connect(mTimeControls, &TimeControls::fpsChanged,
this, &TimeLine::fpsChanged);
211 connect(mTimeControls, &TimeControls::fpsChanged,
this, &TimeLine::updateLength);
212 connect(mTimeControls, &TimeControls::playButtonTriggered,
this, &TimeLine::playButtonTriggered);
214 connect(mTimeControls, &TimeControls::fpsChanged, mTimeControls, &TimeControls::setFps);
215 connect(
this, &TimeLine::fpsChanged, mTimeControls, &TimeControls::setFps);
223 connect(mLayerList, &TimeLineCells::mouseMovedY, mLayerList, &TimeLineCells::setMouseMoveY);
224 connect(mLayerList, &TimeLineCells::mouseMovedY, mTracks, &TimeLineCells::setMouseMoveY);
225 connect(mTracks, &TimeLineCells::lengthChanged,
this, &TimeLine::updateLength);
226 connect(mTracks, &TimeLineCells::selectionChanged,
this, &TimeLine::selectionChanged);
227 connect(mTracks, &TimeLineCells::insertNewKeyFrame,
this, &TimeLine::insertKeyClick);
234 connect(layer, &LayerManager::layerCountChanged,
this, &TimeLine::updateLayerNumber);
235 connect(layer, &LayerManager::currentLayerChanged,
this, &TimeLine::onLayerChanged);
236 mNumLayers = layer->count();
241void TimeLine::updateUI()
246void TimeLine::updateUICached()
258 int currentLength = mTracks->getFrameLength();
259 if(frame > (currentLength * 0.75))
261 int newLength =
static_cast<int>(std::max(frame, currentLength) * 1.5);
263 if (newLength > 9999)
266 mTracks->setFrameLength(newLength);
288void TimeLine::updateFrame(
int frameNumber)
293 mTracks->updateFrame(mLastUpdatedFrame);
294 mTracks->updateFrame(frameNumber);
296 mLastUpdatedFrame = frameNumber;
299void TimeLine::updateLayerView()
301 int pageDisplay = (mTracks->
height() - mTracks->getOffsetY()) / mTracks->getLayerHeight();
304 mVScrollbar->
setMaximum(qMax(0, mNumLayers - pageDisplay));
308void TimeLine::updateLayerNumber(
int numberOfLayers)
310 mNumLayers = numberOfLayers;
314void TimeLine::updateLength()
316 int frameLength = mTracks->getFrameLength();
317 mHScrollbar->
setMaximum(qMax(0, frameLength - mTracks->
width() / mTracks->getFrameSize()));
318 mTimeControls->updateLength(frameLength);
322void TimeLine::updateContent()
324 mLayerList->updateContent();
325 mTracks->updateContent();
329void TimeLine::setLoop(
bool loop)
331 mTimeControls->setLoop(loop);
334void TimeLine::setPlaying(
bool isPlaying)
337 mTimeControls->updatePlayState();
340void TimeLine::setRangeState(
bool range)
342 mTimeControls->setRangeState(range);
345int TimeLine::getRangeLower()
347 return mTimeControls->getRangeLower();
350int TimeLine::getRangeUpper()
352 return mTimeControls->getRangeUpper();
355void TimeLine::onObjectLoaded()
357 mTimeControls->updateUI();
358 updateLayerNumber(editor()->layers()->count());
361void TimeLine::onLayerChanged()
363 mLayerDeleteButton->
setEnabled(editor()->layers()->canDeleteLayer(editor()->currentLayerIndex()));
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)