18#include "timelinecells.h"
20#include <QApplication>
21#include <QResizeEvent>
22#include <QInputDialog>
24#include <QRegularExpression>
27#include "camerapropertiesdialog.h"
30#include "layermanager.h"
31#include "viewmanager.h"
33#include "playbackmanager.h"
34#include "preferencemanager.h"
37#include "cameracontextmenu.h"
39TimeLineCells::TimeLineCells(
TimeLine* parent,
Editor* editor, TIMELINE_CELL_TYPE type) :
QWidget(parent)
43 mPrefs = editor->preference();
46 mFrameLength = mPrefs->getInt(SETTING::TIMELINE_SIZE);
47 mFontSize = mPrefs->getInt(SETTING::LABEL_FONT_SIZE);
48 mFrameSize = mPrefs->getInt(SETTING::FRAME_SIZE);
49 mbShortScrub = mPrefs->isOn(SETTING::SHORT_SCRUB);
50 mDrawFrameNumber = mPrefs->isOn(SETTING::DRAW_LABEL);
52 setMinimumSize(500, 4 * mLayerHeight);
55 setMouseTracking(
true);
57 connect(mPrefs, &PreferenceManager::optionChanged,
this, &TimeLineCells::loadSetting);
60TimeLineCells::~TimeLineCells()
65void TimeLineCells::loadSetting(SETTING setting)
69 case SETTING::TIMELINE_SIZE:
70 mFrameLength = mPrefs->getInt(SETTING::TIMELINE_SIZE);
71 mTimeLine->updateLength();
73 case SETTING::LABEL_FONT_SIZE:
74 mFontSize = mPrefs->getInt(SETTING::LABEL_FONT_SIZE);
76 case SETTING::FRAME_SIZE:
77 mFrameSize = mPrefs->getInt(SETTING::FRAME_SIZE);
78 mTimeLine->updateLength();
80 case SETTING::SHORT_SCRUB:
81 mbShortScrub = mPrefs->isOn(SETTING::SHORT_SCRUB);
83 case SETTING::DRAW_LABEL:
84 mDrawFrameNumber = mPrefs->isOn(SETTING::DRAW_LABEL);
93int TimeLineCells::getFrameNumber(
int x)
const
95 return mFrameOffset + 1 + (
x - mOffsetX) / mFrameSize;
98int TimeLineCells::getFrameX(
int frameNumber)
const
100 return mOffsetX + (frameNumber - mFrameOffset) * mFrameSize;
103void TimeLineCells::setFrameSize(
int size)
106 mPrefs->set(SETTING::FRAME_SIZE, mFrameSize);
110int TimeLineCells::getLayerNumber(
int y)
const
112 int layerNumber = mLayerOffset + (
y - mOffsetY) / mLayerHeight;
114 int totalLayerCount = mEditor->object()->getLayerCount();
118 if (layerNumber <= totalLayerCount)
119 layerNumber = (totalLayerCount - 1) - layerNumber;
128 if (layerNumber >= totalLayerCount)
130 layerNumber = totalLayerCount;
135 if (layerNumber < -1)
142int TimeLineCells::getInbetweenLayerNumber(
int y)
const {
143 int layerNumber = getLayerNumber(
y);
145 if(layerNumber != mFromLayer) {
146 if(mMouseMoveY > 0 &&
y < getLayerY(layerNumber) + mLayerHeight / 2) {
149 else if(mMouseMoveY < 0 && y > getLayerY(layerNumber) + mLayerHeight / 2) {
156int TimeLineCells::getLayerY(
int layerNumber)
const
158 return mOffsetY + (mEditor->object()->getLayerCount() - 1 - layerNumber - mLayerOffset)*mLayerHeight;
161void TimeLineCells::updateFrame(
int frameNumber)
163 int x = getFrameX(frameNumber);
167void TimeLineCells::updateContent()
169 mRedrawContent =
true;
173bool TimeLineCells::didDetachLayer()
const {
174 return abs(mMouseMoveY) > mLayerDetachThreshold;
177void TimeLineCells::showCameraMenu(
QPoint pos)
179 int frameNumber = getFrameNumber(
pos.x());
181 const Layer* curLayer = mEditor->layers()->currentLayer();
185 if (curLayer->type() != Layer::CAMERA || !curLayer->keyExists(frameNumber))
190 mHighlightFrameEnabled =
true;
191 mHighlightedFrame = frameNumber;
196 mHighlightFrameEnabled =
false;
197 mHighlightedFrame = -1;
200 KeyFrame* key = curLayer->getKeyFrameAt(frameNumber);
201 if (key->isModified()) {
212void TimeLineCells::drawContent()
214 if (mCache ==
nullptr)
232 const int widgetWidth =
width();
235 const Object*
object = mEditor->object();
236 Q_ASSERT(
object !=
nullptr);
237 for (
int i = 0; i <
object->getLayerCount(); i++)
239 if (i == mEditor->layers()->currentLayerIndex())
243 const Layer* layeri =
object->getLayer(i);
245 if (layeri !=
nullptr)
247 const int layerY = getLayerY(i);
250 case TIMELINE_CELL_TYPE::Tracks:
251 paintTrack(painter, layeri, mOffsetX,
252 layerY, widgetWidth - mOffsetX,
253 mLayerHeight,
false, mFrameSize);
256 case TIMELINE_CELL_TYPE::Layers:
257 paintLabel(painter, layeri, 0,
258 layerY, widgetWidth - 1,
259 mLayerHeight,
false, mEditor->layerVisibility());
266 const Layer* currentLayer = mEditor->layers()->currentLayer();
267 if (didDetachLayer())
269 int layerYMouseMove = getLayerY(mEditor->layers()->currentLayerIndex()) + mMouseMoveY;
270 if (mType == TIMELINE_CELL_TYPE::Tracks)
272 paintTrack(painter, currentLayer,
273 mOffsetX, layerYMouseMove,
274 widgetWidth - mOffsetX, mLayerHeight,
277 else if (mType == TIMELINE_CELL_TYPE::Layers)
279 paintLabel(painter, currentLayer,
281 widgetWidth - 1, mLayerHeight,
true, mEditor->layerVisibility());
283 paintLayerGutter(painter);
288 if (mType == TIMELINE_CELL_TYPE::Tracks)
293 getLayerY(mEditor->layers()->currentLayerIndex()),
294 widgetWidth - mOffsetX,
299 else if (mType == TIMELINE_CELL_TYPE::Layers)
304 getLayerY(mEditor->layers()->currentLayerIndex()),
308 mEditor->layerVisibility());
315 painter.drawRect(
QRect(0, 0,
width() - 1, mOffsetY - 1));
319 painter.drawLine(0, mOffsetY - 2,
width() - 1, mOffsetY - 2);
321 if (mType == TIMELINE_CELL_TYPE::Layers)
325 if (mEditor->layerVisibility() == LayerVisibility::CURRENTONLY)
329 else if (mEditor->layerVisibility() == LayerVisibility::RELATED)
333 painter.setBrush(color);
335 else if (mEditor->layerVisibility() == LayerVisibility::ALL)
340 painter.drawEllipse(6, 4, 9, 9);
343 else if (mType == TIMELINE_CELL_TYPE::Tracks)
347 for (
int i = 0; i <
object->getLayerCount(); i++) {
348 paintSelectedFrames(painter, object->getLayer(i), i);
351 mRedrawContent =
false;
354void TimeLineCells::paintTicks(
QPainter& painter,
const QPalette& palette)
const
358 int fps = mEditor->playback()->fps();
359 for (
int i = mFrameOffset; i < mFrameOffset + (
width() - mOffsetX) / mFrameSize; i++)
362 const int lineX = getFrameX(i) + 1;
363 if (i + 1 >= mTimeLine->getRangeLower() && i < mTimeLine->getRangeUpper())
368 painter.
drawRect(lineX, 1, mFrameSize + 1, 2);
375 if (i % fps == 0 || i % fps == fps / 2)
377 painter.
drawLine(lineX, 1, lineX, 5);
381 painter.
drawLine(lineX, 1, lineX, 3);
383 if (i == 0 || i % fps == fps - 1)
385 int incr = (i < 9) ? 4 : 0;
391void TimeLineCells::paintTrack(
QPainter& painter,
const Layer* layer,
392 int x,
int y,
int width,
int height,
393 bool selected,
int frameSize)
const
398 if (layer->type() == Layer::BITMAP) col =
QColor(51, 155, 252);
399 if (layer->type() == Layer::VECTOR) col =
QColor(70, 205, 123);
400 if (layer->type() == Layer::SOUND) col =
QColor(255, 141, 112);
401 if (layer->type() == Layer::CAMERA) col =
QColor(253, 202, 92);
403 if (!layer->visible()) col.
setAlpha(64);
410 if (!layer->visible())
425 linearGrad.setColorAt(0,
QColor(255,255,255,150));
426 linearGrad.setColorAt(1,
QColor(0,0,0,0));
438void TimeLineCells::paintFrames(
QPainter& painter,
QColor trackCol,
const Layer* layer,
int y,
int height,
bool selected,
int frameSize)
const
445 int recHeight =
height - 4;
447 layer->foreachKeyFrame([&](
KeyFrame* key)
449 int framePos = key->pos();
450 int recWidth = standardWidth;
451 int recLeft = getFrameX(framePos) - recWidth;
453 if (key->length() > 1)
466 if (key->isSelected()) {
475 if (!key->isSelected()) {
476 painter.
drawRect(recLeft, recTop, recWidth, recHeight);
481void TimeLineCells::paintCurrentFrameBorder(
QPainter &painter,
int recLeft,
int recTop,
int recWidth,
int recHeight)
const
486 painter.
drawRect(recLeft, recTop, recWidth, recHeight);
490void TimeLineCells::paintFrameCursorOnCurrentLayer(
QPainter &painter,
int recTop,
int recWidth,
int recHeight)
const
492 int recLeft = getFrameX(mFramePosMoveX) - recWidth;
502 painter.
drawRect(recLeft, recTop, recWidth, recHeight);
506void TimeLineCells::paintHighlightedFrame(
QPainter& painter,
int framePos,
int recTop,
int recWidth,
int recHeight)
const
508 int recLeft = getFrameX(framePos) - recWidth;
516 painter.
drawRect(recLeft+1, recTop+1, recWidth-1, recHeight-1);
520void TimeLineCells::paintSelectedFrames(
QPainter& painter,
const Layer* layer,
const int layerIndex)
const
522 int mouseX = mMouseMoveX;
523 int posUnderCursor = getFrameNumber(mMousePressX);
524 int standardWidth = mFrameSize - 2;
525 int recWidth = standardWidth;
526 int recHeight = mLayerHeight - 4;
527 int recTop = getLayerY(layerIndex) + 1;
530 for (
int framePos : layer->getSelectedFramesByPos()) {
532 KeyFrame* key = layer->getKeyFrameAt(framePos);
533 if (key->length() > 1)
537 recWidth = mFrameSize * key->length();
543 int frameX = getFrameX(framePos);
545 int offset = (framePos - posUnderCursor) + mFrameOffset;
546 int newFrameX = getFrameX(getFrameNumber(getFrameX(offset)+mouseX)) - standardWidth;
548 painter.
drawRect(newFrameX, recTop-4, recWidth, recHeight);
551 int currentFrameX = frameX - standardWidth;
552 painter.
drawRect(currentFrameX, recTop, recWidth, recHeight);
558void TimeLineCells::paintLabel(
QPainter& painter,
const Layer* layer,
559 int x,
int y,
int width,
int height,
560 bool selected, LayerVisibility layerVisibility)
const
575 if (!layer->visible())
581 if ((layerVisibility == LayerVisibility::ALL) || selected)
585 else if (layerVisibility == LayerVisibility::CURRENTONLY)
589 else if (layerVisibility == LayerVisibility::RELATED)
608 if (layer->type() == Layer::BITMAP) painter.
drawPixmap(
QPoint(22,
y - 1),
QPixmap(
":icons/themes/playful/timeline/cell-bitmap.svg"));
609 if (layer->type() == Layer::VECTOR) painter.
drawPixmap(
QPoint(22,
y - 1),
QPixmap(
":icons/themes/playful/timeline/cell-vector.svg"));
610 if (layer->type() == Layer::SOUND) painter.
drawPixmap(
QPoint(22,
y - 1),
QPixmap(
":icons/themes/playful/timeline/cell-sound.svg"));
611 if (layer->type() == Layer::CAMERA) painter.
drawPixmap(
QPoint(22,
y - 1),
QPixmap(
":icons/themes/playful/timeline/cell-camera.svg"));
624void TimeLineCells::paintSelection(
QPainter& painter,
int x,
int y,
int width,
int height)
const
627 linearGrad.setColorAt(0,
QColor(0, 0, 0, 255));
628 linearGrad.setColorAt(1,
QColor(255, 255, 255, 0));
637void TimeLineCells::paintLayerGutter(
QPainter& painter)
const
640 if (mMouseMoveY > mLayerDetachThreshold)
642 painter.
drawRect(0, getLayerY(getInbetweenLayerNumber(mEndY))+mLayerHeight,
width(), 2);
646 painter.
drawRect(0, getLayerY(getInbetweenLayerNumber(mEndY)),
width(), 2);
650void TimeLineCells::paintOnionSkin(
QPainter& painter)
const
652 Layer* layer = mEditor->layers()->currentLayer();
653 if (layer ==
nullptr) {
return; }
655 int frameNumber = mEditor->currentFrame();
657 int prevOnionSkinCount = mEditor->preference()->getInt(SETTING::ONION_PREV_FRAMES_NUM);
658 int nextOnionSkinCount = mEditor->preference()->getInt(SETTING::ONION_NEXT_FRAMES_NUM);
660 bool isAbsolute = (mEditor->preference()->getString(SETTING::ONION_TYPE) ==
"absolute");
662 if (mEditor->preference()->isOn(SETTING::PREV_ONION) && prevOnionSkinCount > 0)
664 int onionFrameNumber = frameNumber;
667 onionFrameNumber = layer->getPreviousFrameNumber(onionFrameNumber+1,
true);
669 onionFrameNumber = layer->getPreviousFrameNumber(onionFrameNumber, isAbsolute);
670 int onionPosition = 0;
672 while (onionPosition < prevOnionSkinCount && onionFrameNumber > 0)
682 onionFrameNumber = layer->getPreviousFrameNumber(onionFrameNumber, isAbsolute);
687 if (mEditor->preference()->isOn(SETTING::NEXT_ONION) && nextOnionSkinCount > 0) {
689 int onionFrameNumber = layer->getNextFrameNumber(frameNumber, isAbsolute);
690 int onionPosition = 0;
692 while (onionPosition < nextOnionSkinCount && onionFrameNumber > 0)
702 onionFrameNumber = layer->getNextFrameNumber(onionFrameNumber, isAbsolute);
713 bool isPlaying = mEditor->playback()->isPlaying();
714 if (mCache ==
nullptr || mRedrawContent || trackScrubber())
723 if (mType == TIMELINE_CELL_TYPE::Tracks)
726 paintOnionSkin(painter);
729 int currentFrame = mEditor->currentFrame();
730 Layer* currentLayer = mEditor->layers()->currentLayer();
731 KeyFrame* keyFrame = currentLayer->getKeyFrameWhichCovers(currentFrame);
732 if (keyFrame !=
nullptr && !keyFrame->isSelected())
734 int recWidth = keyFrame->length() == 1 ? mFrameSize - 2 : mFrameSize * keyFrame->length();
735 int recLeft = getFrameX(keyFrame->pos()) - (mFrameSize - 2);
736 paintCurrentFrameBorder(painter, recLeft, getLayerY(mEditor->currentLayerIndex()) + 1, recWidth, mLayerHeight - 4);
739 if (!mMovingFrames && mLayerPosMoveY != -1 && mLayerPosMoveY == mEditor->currentLayerIndex())
742 int recTop = getLayerY(mLayerPosMoveY) + 1;
743 int standardWidth = mFrameSize - 2;
744 int recHeight = mLayerHeight - 4;
746 if (mHighlightFrameEnabled)
748 paintHighlightedFrame(painter, mHighlightedFrame, recTop, standardWidth, recHeight);
750 if (currentLayer->visible())
752 paintFrameCursorOnCurrentLayer(painter, recTop, standardWidth, recHeight);
757 if (currentFrame > mFrameOffset)
764 int currentFrameStartX = getFrameX(currentFrame - 1) + 1;
765 int currentFrameEndX = getFrameX(currentFrame);
775 bool mouseUnderScrubber = currentFrame == mFramePosMoveX;
776 if (mouseUnderScrubber) {
778 QPen pen = scrubColor;
788 int incr = (currentFrame < 10) ? 4 : 0;
800 emit lengthChanged(getFrameLength());
803bool TimeLineCells::event(
QEvent* event)
812void TimeLineCells::mousePressEvent(
QMouseEvent* event)
814 int frameNumber = getFrameNumber(event->
pos().
x());
815 int layerNumber = getLayerNumber(event->
pos().
y());
816 mCurrentLayerNumber = layerNumber;
818 mMousePressX =
event->pos().x();
819 mFromLayer = mToLayer = layerNumber;
821 mStartY =
event->pos().y();
822 mStartLayerNumber = layerNumber;
823 mEndY =
event->pos().y();
825 mStartFrameNumber = frameNumber;
826 mLastFrameNumber = mStartFrameNumber;
828 mCanMoveFrame =
false;
829 mMovingFrames =
false;
831 mCanBoxSelect =
false;
832 mBoxSelecting =
false;
834 mClickSelecting =
false;
836 primaryButton =
event->button();
840 case TIMELINE_CELL_TYPE::Layers:
841 if (layerNumber != -1 && layerNumber < mEditor->
object()->getLayerCount())
843 if (event->
pos().
x() < 15)
845 mEditor->switchVisibilityOfLayer(layerNumber);
847 else if (mEditor->currentLayerIndex() != layerNumber)
849 mEditor->layers()->setCurrentLayer(layerNumber);
850 mEditor->layers()->currentLayer()->deselectAll();
853 if (layerNumber == -1)
855 if (event->
pos().
x() < 15)
858 mEditor->increaseLayerVisibilityIndex();
860 mEditor->decreaseLayerVisibilityIndex();
865 case TIMELINE_CELL_TYPE::Tracks:
868 mLastFrameNumber = getFrameNumber(event->
pos().
x());
872 if (frameNumber == mEditor->currentFrame() && mStartY < 20)
874 if (mEditor->playback()->isPlaying())
876 mEditor->playback()->stop();
878 mTimeLine->scrubbing =
true;
882 if ((layerNumber != -1) && layerNumber < mEditor->
object()->getLayerCount())
884 int previousLayerNumber = mEditor->layers()->currentLayerIndex();
886 if (previousLayerNumber != layerNumber)
888 Layer *previousLayer = mEditor->object()->getLayer(previousLayerNumber);
889 previousLayer->deselectAll();
890 emit mEditor->selectedFramesChanged();
891 mEditor->layers()->setCurrentLayer(layerNumber);
894 Layer *currentLayer = mEditor->object()->getLayer(layerNumber);
900 mClickSelecting =
true;
901 mCanMoveFrame =
true;
903 currentLayer->selectAllFramesAfter(frameNumber);
904 emit mEditor->selectedFramesChanged();
907 else if (!currentLayer->isFrameSelected(frameNumber))
910 mCanBoxSelect =
true;
911 mClickSelecting =
true;
918 currentLayer->toggleFrameSelected(frameNumber,
true);
919 emit mEditor->selectedFramesChanged();
924 currentLayer->extendSelectionTo(frameNumber);
925 emit mEditor->selectedFramesChanged();
930 currentLayer->toggleFrameSelected(frameNumber,
false);
931 emit mEditor->selectedFramesChanged();
938 showCameraMenu(event->
pos());
947 showCameraMenu(event->
pos());
950 mCanMoveFrame =
true;
953 if (currentLayer->hasAnySelectedFrames()) {
954 emit selectionChanged();
957 mTimeLine->updateContent();
963 if (mEditor->playback()->isPlaying())
965 mEditor->playback()->stop();
967 if (mEditor->playback()->getSoundScrubActive() && mLastScrubFrame != frameNumber)
969 mEditor->playback()->playScrub(frameNumber);
970 mLastScrubFrame = frameNumber;
973 mEditor->scrubTo(frameNumber);
975 mTimeLine->scrubbing =
true;
976 qDebug(
"Scrub to %d frame", frameNumber);
985void TimeLineCells::mouseMoveEvent(
QMouseEvent* event)
987 mMouseMoveX =
event->pos().x();
988 mFramePosMoveX = getFrameNumber(mMouseMoveX);
989 mLayerPosMoveY = getLayerNumber(event->
pos().
y());
991 if (mType == TIMELINE_CELL_TYPE::Layers)
994 mEndY =
event->pos().y();
995 emit mouseMovedY(mEndY - mStartY);
998 else if (mType == TIMELINE_CELL_TYPE::Tracks)
1002 mFrameOffset = qMin(qMax(0, mFrameLength -
width() / getFrameSize()), qMax(0, mFrameOffset + mLastFrameNumber - mFramePosMoveX));
1004 emit offsetChanged(mFrameOffset);
1008 if (mTimeLine->scrubbing)
1010 if (mEditor->playback()->getSoundScrubActive() && mLastScrubFrame != mFramePosMoveX)
1012 mEditor->playback()->playScrub(mFramePosMoveX);
1013 mLastScrubFrame = mFramePosMoveX;
1015 mEditor->scrubTo(mFramePosMoveX);
1020 if (mStartLayerNumber != -1 && mStartLayerNumber < mEditor->
object()->getLayerCount())
1022 Layer *currentLayer = mEditor->object()->getLayer(mStartLayerNumber);
1025 if (mCanMoveFrame) {
1028 mMovingFrames =
true;
1030 else if (mCanBoxSelect)
1033 mBoxSelecting =
true;
1035 currentLayer->deselectAll();
1036 currentLayer->setFrameSelected(mStartFrameNumber,
true);
1037 currentLayer->extendSelectionTo(mFramePosMoveX);
1038 emit mEditor->selectedFramesChanged();
1040 mLastFrameNumber = mFramePosMoveX;
1050void TimeLineCells::mouseReleaseEvent(
QMouseEvent* event)
1052 if (event->
button() != primaryButton)
return;
1054 int frameNumber = getFrameNumber(event->
pos().
x());
1055 if (frameNumber < 1) frameNumber = 1;
1056 int layerNumber = getLayerNumber(event->
pos().
y());
1058 if (mType == TIMELINE_CELL_TYPE::Tracks && mCurrentLayerNumber != -1 && primaryButton !=
Qt::MiddleButton)
1061 Layer* currentLayer = mEditor->layers()->getLayer(mCurrentLayerNumber);
1062 Q_ASSERT(currentLayer);
1066 int posUnderCursor = getFrameNumber(mMousePressX);
1067 int offset = frameNumber - posUnderCursor;
1069 currentLayer->moveSelectedFrames(offset);
1075 else if (!mTimeLine->scrubbing && !mMovingFrames && !mClickSelecting && !mBoxSelecting)
1081 currentLayer->toggleFrameSelected(frameNumber, multipleSelection);
1082 emit mEditor->selectedFramesChanged();
1086 if (mType == TIMELINE_CELL_TYPE::Layers && !mScrollingVertically && layerNumber != mStartLayerNumber && mStartLayerNumber != -1 && layerNumber != -1)
1088 mToLayer = getInbetweenLayerNumber(event->
pos().
y());
1089 if (mToLayer != mFromLayer && mToLayer > -1 && mToLayer < mEditor->layers()->count())
1092 if (mToLayer < mFromLayer)
1094 for (
int i = mFromLayer - 1; i >= mToLayer; i--)
1095 mEditor->swapLayers(i, i + 1);
1099 for (
int i = mFromLayer + 1; i <= mToLayer; i++)
1100 mEditor->swapLayers(i, i - 1);
1107 emit mouseMovedY(0);
1112 mTimeLine->scrubbing =
false;
1113 mMovingFrames =
false;
1116void TimeLineCells::mouseDoubleClickEvent(
QMouseEvent* event)
1118 int frameNumber = getFrameNumber(event->
pos().
x());
1119 int layerNumber = getLayerNumber(event->
pos().
y());
1122 if (event->
pos().
y() < 20 && (mType != TIMELINE_CELL_TYPE::Layers || event->
pos().
x() >= 15))
1124 mPrefs->set(SETTING::SHORT_SCRUB, !mbShortScrub);
1128 Layer* layer = mEditor->object()->getLayer(layerNumber);
1131 if (mType == TIMELINE_CELL_TYPE::Tracks && (layerNumber != -1) && (frameNumber > 0) && layerNumber < mEditor->
object()->getLayerCount())
1133 if (!layer->keyExistsWhichCovers(frameNumber))
1135 mEditor->scrubTo(frameNumber);
1136 emit insertNewKeyFrame();
1141 layer->setFrameSelected(frameNumber,
true);
1143 else if (mType == TIMELINE_CELL_TYPE::Layers && event->
pos().
x() >= 15)
1145 editLayerProperties(layer);
1151void TimeLineCells::editLayerProperties(
Layer *layer)
const
1153 if (layer->type() != Layer::CAMERA)
1155 editLayerName(layer);
1159 auto cameraLayer =
dynamic_cast<LayerCamera*
>(layer);
1160 Q_ASSERT(cameraLayer);
1161 editLayerProperties(cameraLayer);
1164void TimeLineCells::editLayerProperties(
LayerCamera* cameraLayer)
const
1169 cameraLayer->getViewRect().
height());
1178 mEditor->layers()->renameLayer(cameraLayer, name);
1181 settings.setValue(SETTING_FIELD_W, dialog.getWidth());
1182 settings.setValue(SETTING_FIELD_H, dialog.getHeight());
1183 cameraLayer->setViewRect(
QRect(-dialog.getWidth() / 2, -dialog.getHeight() / 2, dialog.getWidth(), dialog.getHeight()));
1184 mEditor->view()->forceUpdateViewTransform();
1187void TimeLineCells::editLayerName(
Layer* layer)
const
1194 layer->name(), &ok);
1201 mEditor->layers()->renameLayer(layer, name);
1204void TimeLineCells::hScrollChange(
int x)
1210void TimeLineCells::vScrollChange(
int x)
1213 mScrollingVertically =
true;
1217void TimeLineCells::onScrollingVerticallyStopped()
1219 mScrollingVertically =
false;
1222void TimeLineCells::setMouseMoveY(
int x)
1228bool TimeLineCells::trackScrubber()
1230 if (mType != TIMELINE_CELL_TYPE::Tracks ||
1231 (mPrevFrame == mEditor->currentFrame() && !mEditor->playback()->isPlaying()))
1235 mPrevFrame = mEditor->currentFrame();
1237 if (mEditor->currentFrame() <= mFrameOffset)
1240 mFrameOffset = mEditor->currentFrame() - 1;
1241 emit offsetChanged(mFrameOffset);
1244 else if (
width() < (mEditor->currentFrame() - mFrameOffset + 1) * mFrameSize)
1247 if (mEditor->playback()->isPlaying())
1248 mFrameOffset = mFrameOffset + ((mEditor->currentFrame() - mFrameOffset) / 2);
1250 mFrameOffset = mEditor->currentFrame() -
width() / mFrameSize;
1251 emit offsetChanged(mFrameOffset);
1257void TimeLineCells::onDidLeaveWidget()
void framesModified()
This should be emitted after modifying multiple frames.
void frameModified(int frameNumber)
This should be emitted after modifying the frame content.
void notifyAnimationLengthChanged()
This should be emitted whenever the animation length frames, eg.
QEvent::Type type() const const
QString getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode mode, const QString &text, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints)
QString tr(const char *sourceText, const char *disambiguation, int n)
void drawEllipse(const QRectF &rectangle)
void drawLine(const QLineF &line)
void drawPixmap(const QRectF &target, const QPixmap &pixmap, const QRectF &source)
void drawRect(const QRectF &rectangle)
void drawText(const QPointF &position, const QString &text)
void setBrush(const QBrush &brush)
void setCompositionMode(QPainter::CompositionMode mode)
void setPen(const QColor &color)
void setRenderHint(QPainter::RenderHint hint, bool on)
bool isNull() const const
void setBottomRight(const QPoint &position)
void setTopLeft(const QPoint &position)
bool isEmpty() const const
QString number(int n, int base)
QString & replace(int position, int n, QChar after)