diff --git a/app/app.pro b/app/app.pro index 3923eea35a..e798529727 100644 --- a/app/app.pro +++ b/app/app.pro @@ -75,7 +75,6 @@ HEADERS += \ src/predefinedsetmodel.h \ src/pegbaralignmentdialog.h \ src/shortcutfilter.h \ - src/timeline2.h \ src/actioncommands.h \ src/preferencesdialog.h \ src/filespage.h \ @@ -84,10 +83,16 @@ HEADERS += \ src/timelinepage.h \ src/toolspage.h \ src/preview.h \ + src/basedockwidget.h \ src/colorbox.h \ src/colorinspector.h \ src/colorpalettewidget.h \ src/colorwheel.h \ + src/timeline.h \ + src/timelinecells.h \ + src/timecontrols.h \ + src/cameracontextmenu.h \ + src/camerapropertiesdialog.h \ src/filedialog.h \ src/pencil2d.h \ src/exportmoviedialog.h \ @@ -123,7 +128,6 @@ SOURCES += \ src/predefinedsetmodel.cpp \ src/pegbaralignmentdialog.cpp \ src/shortcutfilter.cpp \ - src/timeline2.cpp \ src/actioncommands.cpp \ src/preferencesdialog.cpp \ src/filespage.cpp \ @@ -132,10 +136,16 @@ SOURCES += \ src/timelinepage.cpp \ src/toolspage.cpp \ src/preview.cpp \ + src/basedockwidget.cpp \ src/colorbox.cpp \ src/colorinspector.cpp \ src/colorpalettewidget.cpp \ src/colorwheel.cpp \ + src/timeline.cpp \ + src/timelinecells.cpp \ + src/timecontrols.cpp \ + src/cameracontextmenu.cpp \ + src/camerapropertiesdialog.cpp \ src/filedialog.cpp \ src/pencil2d.cpp \ src/exportmoviedialog.cpp \ @@ -162,6 +172,7 @@ SOURCES += \ FORMS += \ ui/cameraoptionswidget.ui \ + ui/camerapropertiesdialog.ui \ ui/importimageseqpreview.ui \ ui/importlayersdialog.ui \ ui/importpositiondialog.ui \ @@ -170,7 +181,6 @@ FORMS += \ ui/onionskin.ui \ ui/pegbaralignmentdialog.ui \ ui/repositionframesdialog.ui \ - ui/timeline2.ui \ ui/shortcutspage.ui \ ui/colorinspector.ui \ ui/colorpalette.ui \ diff --git a/app/src/actioncommands.cpp b/app/src/actioncommands.cpp index 173628e354..1eba2595f2 100644 --- a/app/src/actioncommands.cpp +++ b/app/src/actioncommands.cpp @@ -742,6 +742,7 @@ void ActionCommands::duplicateKey() layer->addKeyFrame(nextEmptyFrame, dupKey); mEditor->scrubTo(nextEmptyFrame); + emit mEditor->frameModified(nextEmptyFrame); if (layer->type() == Layer::SOUND) { diff --git a/core_lib/src/interface/basedockwidget.cpp b/app/src/basedockwidget.cpp similarity index 100% rename from core_lib/src/interface/basedockwidget.cpp rename to app/src/basedockwidget.cpp diff --git a/core_lib/src/interface/basedockwidget.h b/app/src/basedockwidget.h similarity index 100% rename from core_lib/src/interface/basedockwidget.h rename to app/src/basedockwidget.h diff --git a/core_lib/src/interface/cameracontextmenu.cpp b/app/src/cameracontextmenu.cpp similarity index 100% rename from core_lib/src/interface/cameracontextmenu.cpp rename to app/src/cameracontextmenu.cpp diff --git a/core_lib/src/interface/cameracontextmenu.h b/app/src/cameracontextmenu.h similarity index 100% rename from core_lib/src/interface/cameracontextmenu.h rename to app/src/cameracontextmenu.h diff --git a/core_lib/src/interface/camerapropertiesdialog.cpp b/app/src/camerapropertiesdialog.cpp similarity index 100% rename from core_lib/src/interface/camerapropertiesdialog.cpp rename to app/src/camerapropertiesdialog.cpp diff --git a/core_lib/src/interface/camerapropertiesdialog.h b/app/src/camerapropertiesdialog.h similarity index 100% rename from core_lib/src/interface/camerapropertiesdialog.h rename to app/src/camerapropertiesdialog.h diff --git a/app/src/mainwindow2.cpp b/app/src/mainwindow2.cpp index adcec627ca..aef3fd73ae 100644 --- a/app/src/mainwindow2.cpp +++ b/app/src/mainwindow2.cpp @@ -68,7 +68,6 @@ GNU General Public License for more details. #include "repositionframesdialog.h" //#include "preview.h" -//#include "timeline2.h" #include "errordialog.h" #include "filedialog.h" #include "importimageseqdialog.h" @@ -171,12 +170,6 @@ void MainWindow2::createDockWidgets() mToolBox = new ToolBoxWidget(this); mToolBox->setObjectName("ToolBox"); - /* - mTimeline2 = new Timeline2; - mTimeline2->setObjectName( "Timeline2" ); - mDockWidgets.append( mTimeline2 ); - */ - mDockWidgets << mTimeLine << mColorBox @@ -197,7 +190,6 @@ void MainWindow2::createDockWidgets() pWidget->setEditor(mEditor); pWidget->initUI(); - pWidget->show(); qDebug() << "Init Dock widget: " << pWidget->objectName(); } @@ -229,8 +221,9 @@ void MainWindow2::createDockWidgets() for (BaseDockWidget* w : mDockWidgets) { - w->updateUI(); w->setFloating(false); + w->show(); + w->updateUI(); } } @@ -1495,7 +1488,6 @@ void MainWindow2::makeConnections(Editor* pEditor, TimeLine* pTimeline) connect(mEditor->select(), &SelectionManager::selectionChanged, this, &MainWindow2::updateCopyCutPasteEnabled); connect(pEditor->layers(), &LayerManager::currentLayerChanged, pTimeline, &TimeLine::updateUI); - connect(pEditor->layers(), &LayerManager::layerCountChanged, pTimeline, &TimeLine::updateUI); connect(pEditor->layers(), &LayerManager::animationLengthChanged, pTimeline, &TimeLine::extendLength); connect(pEditor->sound(), &SoundManager::soundClipDurationChanged, pTimeline, &TimeLine::updateUI); @@ -1504,6 +1496,7 @@ void MainWindow2::makeConnections(Editor* pEditor, TimeLine* pTimeline) connect(pEditor, &Editor::objectLoaded, pTimeline, &TimeLine::onObjectLoaded); connect(pEditor, &Editor::updateTimeLine, pTimeline, &TimeLine::updateUI); + connect(pEditor, &Editor::updateTimeLineCached, pTimeline, &TimeLine::updateUICached); connect(pEditor->layers(), &LayerManager::currentLayerChanged, this, &MainWindow2::updateLayerMenu); connect(pEditor->layers(), &LayerManager::currentLayerChanged, mToolOptions, &ToolOptionWidget::updateUI); diff --git a/app/src/mainwindow2.h b/app/src/mainwindow2.h index 178c437d5d..a9f9f7a0cb 100644 --- a/app/src/mainwindow2.h +++ b/app/src/mainwindow2.h @@ -39,7 +39,6 @@ class PreviewWidget; class ColorBox; class ColorInspector; class RecentFileMenu; -class Timeline2; class ActionCommands; class ImportImageSeqDialog; class BackupElement; @@ -158,7 +157,6 @@ private slots: ColorPaletteWidget* mColorPalette = nullptr; ToolOptionWidget* mToolOptions = nullptr; ToolBoxWidget* mToolBox = nullptr; - //Timeline2* mTimeline2 = nullptr; RecentFileMenu* mRecentFileMenu = nullptr; PreferencesDialog* mPrefDialog = nullptr; //PreviewWidget* mPreview = nullptr; diff --git a/core_lib/src/interface/timecontrols.cpp b/app/src/timecontrols.cpp similarity index 97% rename from core_lib/src/interface/timecontrols.cpp rename to app/src/timecontrols.cpp index 69de9375e2..8a224c3ace 100644 --- a/core_lib/src/interface/timecontrols.cpp +++ b/app/src/timecontrols.cpp @@ -308,16 +308,8 @@ void TimeControls::loopEndValueChanged(int i) void TimeControls::updateSoundScrubIcon(bool soundScrubEnabled) { - if (soundScrubEnabled) - { - mEditor->playback()->setSoundScrubActive(true); - mEditor->preference()->set(SETTING::SOUND_SCRUB_ACTIVE, true); - } - else - { - mEditor->playback()->setSoundScrubActive(false); - mEditor->preference()->set(SETTING::SOUND_SCRUB_ACTIVE, false); - } + mEditor->playback()->setSoundScrubActive(soundScrubEnabled); + mEditor->preference()->set(SETTING::SOUND_SCRUB_ACTIVE, soundScrubEnabled); } void TimeControls::noTimecodeText() diff --git a/core_lib/src/interface/timecontrols.h b/app/src/timecontrols.h similarity index 100% rename from core_lib/src/interface/timecontrols.h rename to app/src/timecontrols.h diff --git a/core_lib/src/interface/timeline.cpp b/app/src/timeline.cpp similarity index 98% rename from core_lib/src/interface/timeline.cpp rename to app/src/timeline.cpp index bddf09ddec..63aa1e37f8 100644 --- a/core_lib/src/interface/timeline.cpp +++ b/app/src/timeline.cpp @@ -28,7 +28,6 @@ GNU General Public License for more details. #include #include -#include "layer.h" #include "editor.h" #include "layermanager.h" #include "timecontrols.h" @@ -246,15 +245,10 @@ void TimeLine::updateUI() updateContent(); } -int TimeLine::getLength() +void TimeLine::updateUICached() { - return mTracks->getFrameLength(); -} - -void TimeLine::setLength(int frame) -{ - mTracks->setFrameLength(frame); - updateLength(); + mLayerList->update(); + mTracks->update(); } /** Extends the timeline frame length if necessary @@ -310,7 +304,6 @@ void TimeLine::updateLayerView() mVScrollbar->setMinimum(0); mVScrollbar->setMaximum(qMax(0, mNumLayers - pageDisplay)); - update(); updateContent(); } @@ -322,7 +315,7 @@ void TimeLine::updateLayerNumber(int numberOfLayers) void TimeLine::updateLength() { - int frameLength = getLength(); + int frameLength = mTracks->getFrameLength(); mHScrollbar->setMaximum(qMax(0, frameLength - mTracks->width() / mTracks->getFrameSize())); mTimeControls->updateLength(frameLength); updateContent(); diff --git a/core_lib/src/interface/timeline.h b/app/src/timeline.h similarity index 97% rename from core_lib/src/interface/timeline.h rename to app/src/timeline.h index a14da69f02..f5f0191772 100644 --- a/core_lib/src/interface/timeline.h +++ b/app/src/timeline.h @@ -36,6 +36,7 @@ class TimeLine : public BaseDockWidget void initUI() override; void updateUI() override; + void updateUICached(); void updateFrame( int frameNumber ); void updateLayerNumber( int number ); @@ -46,8 +47,6 @@ class TimeLine : public BaseDockWidget void setRangeState( bool range ); void setPlaying( bool isPlaying ); - int getLength(); - void setLength(int frame); void extendLength(int frame); int getRangeLower(); diff --git a/app/src/timeline2.cpp b/app/src/timeline2.cpp deleted file mode 100644 index f11e36c639..0000000000 --- a/app/src/timeline2.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - -Pencil2D - Traditional Animation Software -Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon -Copyright (C) 2012-2020 Matthew Chiawen Chang - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -*/ -#include "timeline2.h" -#include "ui_timeline2.h" - -Timeline2::Timeline2(QWidget *parent) : BaseDockWidget(parent) -{ - ui = new Ui::Timeline2; - ui->setupUi(this); -} - -Timeline2::~Timeline2() -{ - delete ui; -} - -void Timeline2::initUI() -{ - -} - -void Timeline2::updateUI() -{ - -} diff --git a/app/src/timeline2.h b/app/src/timeline2.h deleted file mode 100644 index 343bc26e17..0000000000 --- a/app/src/timeline2.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - -Pencil2D - Traditional Animation Software -Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon -Copyright (C) 2012-2020 Matthew Chiawen Chang - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -*/ -#ifndef TIMELINE2_H -#define TIMELINE2_H - -#include "basedockwidget.h" - - -namespace Ui { -class Timeline2; -} - - -class Timeline2 : public BaseDockWidget -{ - Q_OBJECT - -public: - explicit Timeline2(QWidget* parent = nullptr); - ~Timeline2() override; - - void initUI() override; - void updateUI() override; - -private: - Ui::Timeline2* ui; -}; - -#endif // TIMELINE2_H diff --git a/core_lib/src/interface/timelinecells.cpp b/app/src/timelinecells.cpp similarity index 91% rename from core_lib/src/interface/timelinecells.cpp rename to app/src/timelinecells.cpp index bd2c7661dc..a37a6400a4 100644 --- a/core_lib/src/interface/timelinecells.cpp +++ b/app/src/timelinecells.cpp @@ -22,7 +22,6 @@ GNU General Public License for more details. #include #include #include -#include #include "camerapropertiesdialog.h" #include "editor.h" @@ -166,7 +165,7 @@ void TimeLineCells::updateFrame(int frameNumber) void TimeLineCells::updateContent() { - drawContent(); + mRedrawContent = true; update(); } @@ -192,14 +191,14 @@ void TimeLineCells::showCameraMenu(QPoint pos) CameraContextMenu menu(frameNumber, static_cast(curLayer)); - menu.connect(&menu, &CameraContextMenu::aboutToHide, [=] { + menu.connect(&menu, &CameraContextMenu::aboutToHide, this, [=] { mHighlightFrameEnabled = false; mHighlightedFrame = -1; update(); KeyFrame* key = curLayer->getKeyFrameAt(frameNumber); if (key->isModified()) { - mEditor->frameModified(frameNumber); + emit mEditor->frameModified(frameNumber); } }); @@ -211,8 +210,6 @@ void TimeLineCells::showCameraMenu(QPoint pos) void TimeLineCells::drawContent() { - const QPalette palette = QApplication::palette(); - if (mCache == nullptr) { mCache = new QPixmap(size()); @@ -225,22 +222,17 @@ void TimeLineCells::drawContent() QPainter painter(mCache); - const Object* object = mEditor->object(); - - Q_ASSERT(object != nullptr); - - const Layer* currentLayer = mEditor->layers()->currentLayer(); - if (currentLayer == nullptr) return; - // grey background of the view + const QPalette palette = QApplication::palette(); painter.setPen(Qt::NoPen); painter.setBrush(palette.color(QPalette::Base)); painter.drawRect(QRect(0, 0, width(), height())); const int widgetWidth = width(); - const int layerHeight = mLayerHeight; - // --- draw layers of the current object + // Draw non-current layers + const Object* object = mEditor->object(); + Q_ASSERT(object != nullptr); for (int i = 0; i < object->getLayerCount(); i++) { if (i == mEditor->layers()->currentLayerIndex()) @@ -257,18 +249,20 @@ void TimeLineCells::drawContent() case TIMELINE_CELL_TYPE::Tracks: paintTrack(painter, layeri, mOffsetX, layerY, widgetWidth - mOffsetX, - layerHeight, false, mFrameSize); + mLayerHeight, false, mFrameSize); break; case TIMELINE_CELL_TYPE::Layers: paintLabel(painter, layeri, 0, layerY, widgetWidth - 1, - layerHeight, false, mEditor->layerVisibility()); + mLayerHeight, false, mEditor->layerVisibility()); break; } } } + // Draw current layer + const Layer* currentLayer = mEditor->layers()->currentLayer(); if (didDetachLayer()) { int layerYMouseMove = getLayerY(mEditor->layers()->currentLayerIndex()) + mMouseMoveY; @@ -276,14 +270,14 @@ void TimeLineCells::drawContent() { paintTrack(painter, currentLayer, mOffsetX, layerYMouseMove, - widgetWidth - mOffsetX, layerHeight, + widgetWidth - mOffsetX, mLayerHeight, true, mFrameSize); } else if (mType == TIMELINE_CELL_TYPE::Layers) { paintLabel(painter, currentLayer, 0, layerYMouseMove, - widgetWidth - 1, layerHeight, true, mEditor->layerVisibility()); + widgetWidth - 1, mLayerHeight, true, mEditor->layerVisibility()); paintLayerGutter(painter); } @@ -297,7 +291,7 @@ void TimeLineCells::drawContent() mOffsetX, getLayerY(mEditor->layers()->currentLayerIndex()), widgetWidth - mOffsetX, - layerHeight, + mLayerHeight, true, mFrameSize); } @@ -308,7 +302,7 @@ void TimeLineCells::drawContent() 0, getLayerY(mEditor->layers()->currentLayerIndex()), widgetWidth - 1, - layerHeight, + mLayerHeight, true, mEditor->layerVisibility()); } @@ -349,21 +343,11 @@ void TimeLineCells::drawContent() { paintTicks(painter, palette); - const auto object = mEditor->object(); for (int i = 0; i < object->getLayerCount(); i++) { paintSelectedFrames(painter, object->getLayer(i), i); } - - if (mHighlightFrameEnabled && !mMovingFrames && mLayerPosMoveY == mEditor->currentLayerIndex()) { - - // This is terrible but well... - int recTop = getLayerY(mLayerPosMoveY) + 1; - int standardWidth = mFrameSize - 2; - int recHeight = layerHeight - 4; - - paintHighlightedFrame(painter, mHighlightedFrame, recTop, standardWidth, recHeight); - } } + mRedrawContent = false; } void TimeLineCells::paintTicks(QPainter& painter, const QPalette& palette) const @@ -473,11 +457,7 @@ void TimeLineCells::paintFrames(QPainter& painter, QColor trackCol, const Layer* } // Paint the frame border - if (selected && framePos == mEditor->currentFrame()) { - painter.setPen(Qt::white); - } else { - painter.setPen(QPen(QBrush(QColor(40, 40, 40)), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - } + painter.setPen(QPen(QBrush(QColor(40, 40, 40)), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); // Paint the frame contents if (selected) @@ -495,10 +475,15 @@ void TimeLineCells::paintFrames(QPainter& painter, QColor trackCol, const Layer* painter.drawRect(recLeft, recTop, recWidth, recHeight); } }); +} - if (!mMovingFrames && selected && mLayerPosMoveY != -1 && mLayerPosMoveY == mEditor->currentLayerIndex()) { - paintFrameCursorOnCurrentLayer(painter, recTop, standardWidth, recHeight); - } +void TimeLineCells::paintCurrentFrameBorder(QPainter &painter, int recLeft, int recTop, int recWidth, int recHeight) const +{ + painter.save(); + painter.setBrush(Qt::NoBrush); + painter.setPen(Qt::white); + painter.drawRect(recLeft, recTop, recWidth, recHeight); + painter.restore(); } void TimeLineCells::paintFrameCursorOnCurrentLayer(QPainter &painter, int recTop, int recWidth, int recHeight) const @@ -527,7 +512,7 @@ void TimeLineCells::paintHighlightedFrame(QPainter& painter, int framePos, int r painter.setPen(palette.color(QPalette::WindowText)); // Draw a rect slighly smaller than the frame - painter.drawRect(recLeft+1, recTop+1, recWidth-2, recHeight-2); + painter.drawRect(recLeft+1, recTop+1, recWidth-1, recHeight-1); painter.restore(); } @@ -721,16 +706,11 @@ void TimeLineCells::paintOnionSkin(QPainter& painter) const void TimeLineCells::paintEvent(QPaintEvent*) { - Object* object = mEditor->object(); - Layer* layer = mEditor->layers()->currentLayer(); - - Q_ASSUME(object != nullptr && layer != nullptr); - const QPalette palette = QApplication::palette(); QPainter painter(this); bool isPlaying = mEditor->playback()->isPlaying(); - if ((!isPlaying && !mTimeLine->scrubbing) || mCache == nullptr) + if (mCache == nullptr || mRedrawContent || trackScrubber()) { drawContent(); } @@ -741,27 +721,44 @@ void TimeLineCells::paintEvent(QPaintEvent*) if (mType == TIMELINE_CELL_TYPE::Tracks) { + if (!isPlaying) { + paintOnionSkin(painter); + } - if (mPrevFrame != mEditor->currentFrame() || mEditor->playback()->isPlaying()) + int currentFrame = mEditor->currentFrame(); + Layer* currentLayer = mEditor->layers()->currentLayer(); + KeyFrame* keyFrame = currentLayer->getKeyFrameWhichCovers(currentFrame); + if (keyFrame != nullptr && !keyFrame->isSelected()) { - mPrevFrame = mEditor->currentFrame(); - trackScrubber(); + int recWidth = keyFrame->length() == 1 ? mFrameSize - 2 : mFrameSize * keyFrame->length(); + int recLeft = getFrameX(keyFrame->pos()) - (mFrameSize - 2); + paintCurrentFrameBorder(painter, recLeft, getLayerY(mEditor->currentLayerIndex()) + 1, recWidth, mLayerHeight - 4); } - if (!isPlaying) { - paintOnionSkin(painter); + if (!mMovingFrames && mLayerPosMoveY != -1 && mLayerPosMoveY == mEditor->currentLayerIndex()) + { + // This is terrible but well... + int recTop = getLayerY(mLayerPosMoveY) + 1; + int standardWidth = mFrameSize - 2; + int recHeight = mLayerHeight - 4; + + if (mHighlightFrameEnabled) + { + paintHighlightedFrame(painter, mHighlightedFrame, recTop, standardWidth, recHeight); + } + paintFrameCursorOnCurrentLayer(painter, recTop, standardWidth, recHeight); } // --- draw the position of the current frame - if (mEditor->currentFrame() > mFrameOffset) + if (currentFrame > mFrameOffset) { QColor scrubColor = palette.color(QPalette::Highlight); scrubColor.setAlpha(160); painter.setBrush(scrubColor); painter.setPen(Qt::NoPen); - int currentFrameStartX = getFrameX(mEditor->currentFrame() - 1) + 1; - int currentFrameEndX = getFrameX(mEditor->currentFrame()); + int currentFrameStartX = getFrameX(currentFrame - 1) + 1; + int currentFrameEndX = getFrameX(currentFrame); QRect scrubRect; scrubRect.setTopLeft(QPoint(currentFrameStartX, 0)); scrubRect.setBottomRight(QPoint(currentFrameEndX, height())); @@ -771,7 +768,7 @@ void TimeLineCells::paintEvent(QPaintEvent*) } painter.save(); - bool mouseUnderScrubber = mEditor->currentFrame() == mFramePosMoveX; + bool mouseUnderScrubber = currentFrame == mFramePosMoveX; if (mouseUnderScrubber) { QRect smallScrub = QRect(QPoint(currentFrameStartX, 0), QPoint(currentFrameEndX,19)); QPen pen = scrubColor; @@ -784,9 +781,9 @@ void TimeLineCells::paintEvent(QPaintEvent*) painter.restore(); painter.setPen(palette.color(QPalette::HighlightedText)); - int incr = (mEditor->currentFrame() < 10) ? 4 : 0; + int incr = (currentFrame < 10) ? 4 : 0; painter.drawText(QPoint(currentFrameStartX + incr, 15), - QString::number(mEditor->currentFrame())); + QString::number(currentFrame)); } } } @@ -886,7 +883,7 @@ void TimeLineCells::mousePressEvent(QMouseEvent* event) { Layer *previousLayer = mEditor->object()->getLayer(previousLayerNumber); previousLayer->deselectAll(); - mEditor->selectedFramesChanged(); + emit mEditor->selectedFramesChanged(); mEditor->layers()->setCurrentLayer(layerNumber); } @@ -900,7 +897,7 @@ void TimeLineCells::mousePressEvent(QMouseEvent* event) mCanMoveFrame = true; currentLayer->selectAllFramesAfter(frameNumber); - mEditor->selectedFramesChanged(); + emit mEditor->selectedFramesChanged(); } // Check if we are clicking on a non selected frame else if (!currentLayer->isFrameSelected(frameNumber)) @@ -1036,32 +1033,29 @@ void TimeLineCells::mouseMoveEvent(QMouseEvent* event) currentLayer->extendSelectionTo(mFramePosMoveX); } mLastFrameNumber = mFramePosMoveX; + updateContent(); } } + update(); } } } - mTimeLine->update(); } void TimeLineCells::mouseReleaseEvent(QMouseEvent* event) { if (event->button() != primaryButton) return; - primaryButton = Qt::NoButton; - mEndY = mStartY; - mTimeLine->scrubbing = false; - int frameNumber = getFrameNumber(event->pos().x()); if (frameNumber < 1) frameNumber = 1; int layerNumber = getLayerNumber(event->pos().y()); - if (mCurrentLayerNumber != -1 && mType == TIMELINE_CELL_TYPE::Tracks && primaryButton != Qt::MidButton) + if (mType == TIMELINE_CELL_TYPE::Tracks && mCurrentLayerNumber != -1 && primaryButton != Qt::MidButton) { // We should affect the current layer based on what's selected, not where the mouse currently is. Layer* currentLayer = mEditor->layers()->getLayer(mCurrentLayerNumber); - Q_ASSERT(currentLayer); + if (mMovingFrames) { int posUnderCursor = getFrameNumber(mMousePressX); @@ -1070,7 +1064,8 @@ void TimeLineCells::mouseReleaseEvent(QMouseEvent* event) currentLayer->moveSelectedFrames(offset); mEditor->layers()->notifyAnimationLengthChanged(); - mEditor->framesModified(); + emit mEditor->framesModified(); + updateContent(); } else if (!mTimeLine->scrubbing && !mMovingFrames && !mClickSelecting && !mBoxSelecting) { @@ -1079,7 +1074,8 @@ void TimeLineCells::mouseReleaseEvent(QMouseEvent* event) // Add/remove from already selected currentLayer->toggleFrameSelected(frameNumber, multipleSelection); - mEditor->selectedFramesChanged(); + emit mEditor->selectedFramesChanged(); + updateContent(); } } if (mType == TIMELINE_CELL_TYPE::Layers && layerNumber != mStartLayerNumber && mStartLayerNumber != -1 && layerNumber != -1) @@ -1101,9 +1097,14 @@ void TimeLineCells::mouseReleaseEvent(QMouseEvent* event) } } - emit mouseMovedY(0); - mTimeLine->updateContent(); + if (mType == TIMELINE_CELL_TYPE::Layers && event->button() == Qt::LeftButton) + { + emit mouseMovedY(0); + } + primaryButton = Qt::NoButton; + mEndY = mStartY; + mTimeLine->scrubbing = false; mMovingFrames = false; } @@ -1195,32 +1196,36 @@ void TimeLineCells::editLayerName(Layer* layer) const void TimeLineCells::hScrollChange(int x) { mFrameOffset = x; - update(); + updateContent(); } void TimeLineCells::vScrollChange(int x) { mLayerOffset = x; - update(); + updateContent(); } void TimeLineCells::setMouseMoveY(int x) { mMouseMoveY = x; - if (x == 0) - { - update(); - } + updateContent(); } -void TimeLineCells::trackScrubber() +bool TimeLineCells::trackScrubber() { + if (mType != TIMELINE_CELL_TYPE::Tracks || + (mPrevFrame == mEditor->currentFrame() && !mEditor->playback()->isPlaying())) + { + return false; + } + mPrevFrame = mEditor->currentFrame(); + if (mEditor->currentFrame() <= mFrameOffset) { // Move the timeline back if the scrubber is offscreen to the left mFrameOffset = mEditor->currentFrame() - 1; emit offsetChanged(mFrameOffset); - mTimeLine->updateContent(); + return true; } else if (width() < (mEditor->currentFrame() - mFrameOffset + 1) * mFrameSize) { @@ -1230,8 +1235,9 @@ void TimeLineCells::trackScrubber() else mFrameOffset = mEditor->currentFrame() - width() / mFrameSize; emit offsetChanged(mFrameOffset); - mTimeLine->updateContent(); + return true; } + return false; } void TimeLineCells::onDidLeaveWidget() diff --git a/core_lib/src/interface/timelinecells.h b/app/src/timelinecells.h similarity index 95% rename from core_lib/src/interface/timelinecells.h rename to app/src/timelinecells.h index b8a91aa172..33d5d929cb 100644 --- a/core_lib/src/interface/timelinecells.h +++ b/app/src/timelinecells.h @@ -57,7 +57,7 @@ class TimeLineCells : public QWidget void setFrameLength(int n) { mFrameLength = n; } void setFrameSize(int size); - void clearCache() { delete mCache; mCache = new QPixmap( size() ); } + void clearCache() { delete mCache; mCache = nullptr; } bool didDetachLayer() const; @@ -98,13 +98,14 @@ private slots: void onDidLeaveWidget(); - void trackScrubber(); + bool trackScrubber(); void drawContent(); void paintTicks(QPainter& painter, const QPalette& palette) const; void paintOnionSkin(QPainter& painter) const; void paintLayerGutter(QPainter& painter) const; void paintTrack(QPainter& painter, const Layer* layer, int x, int y, int width, int height, bool selected, int frameSize) const; void paintFrames(QPainter& painter, QColor trackCol, const Layer* layer, int y, int height, bool selected, int frameSize) const; + void paintCurrentFrameBorder(QPainter& painter, int recLeft, int recTop, int recWidth, int recHeight) const; void paintFrameCursorOnCurrentLayer(QPainter& painter, int recTop, int recWidth, int recHeight) const; void paintSelectedFrames(QPainter& painter, const Layer* layer, const int layerIndex) const; void paintLabel(QPainter& painter, const Layer* layer, int x, int y, int height, int width, bool selected, LayerVisibility layerVisibility) const; @@ -122,6 +123,7 @@ private slots: TIMELINE_CELL_TYPE mType; QPixmap* mCache = nullptr; + bool mRedrawContent = false; bool mDrawFrameNumber = true; bool mbShortScrub = false; int mFrameLength = 1; diff --git a/core_lib/ui/camerapropertiesdialog.ui b/app/ui/camerapropertiesdialog.ui similarity index 100% rename from core_lib/ui/camerapropertiesdialog.ui rename to app/ui/camerapropertiesdialog.ui diff --git a/app/ui/timeline2.ui b/app/ui/timeline2.ui deleted file mode 100644 index f01d9bf279..0000000000 --- a/app/ui/timeline2.ui +++ /dev/null @@ -1,97 +0,0 @@ - - - Timeline2 - - - - 0 - 0 - 629 - 250 - - - - Timeline - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 35 - - - - - 5 - - - 5 - - - 5 - - - 5 - - - - - Layers - - - - - - - background-color: qlineargradient(spread:pad, x1:0.187818, y1:0.949, x2:0.0851364, y2:0.278, stop:0 rgba(216, 216, 216, 255), stop:1 rgba(250, 250, 250, 255)); - -border:1px solid #555555; - -border-radius:5px; - - - ... - - - - - - - background-color: qlineargradient(spread:pad, x1:0.187818, y1:0.949, x2:0.0851364, y2:0.278, stop:0 rgba(216, 216, 216, 255), stop:1 rgba(250, 250, 250, 255)); - -border:1px solid #555555; - -border-radius:5px; - - - ... - - - - - - - - - - - - - - - diff --git a/core_lib/core_lib.pro b/core_lib/core_lib.pro index 649a43423b..95d2d9609d 100644 --- a/core_lib/core_lib.pro +++ b/core_lib/core_lib.pro @@ -41,16 +41,10 @@ HEADERS += \ src/graphics/vector/vectorselection.h \ src/graphics/vector/vertexref.h \ src/interface/backupelement.h \ - src/interface/cameracontextmenu.h \ - src/interface/camerapropertiesdialog.h \ src/interface/editor.h \ src/interface/flowlayout.h \ src/interface/recentfilemenu.h \ src/interface/scribblearea.h \ - src/interface/timecontrols.h \ - src/interface/timeline.h \ - src/interface/timelinecells.h \ - src/interface/basedockwidget.h \ src/interface/backgroundwidget.h \ src/managers/basemanager.h \ src/managers/overlaymanager.h \ @@ -130,16 +124,10 @@ SOURCES += src/graphics/bitmap/bitmapimage.cpp \ src/graphics/vector/vectorselection.cpp \ src/graphics/vector/vertexref.cpp \ src/interface/backupelement.cpp \ - src/interface/cameracontextmenu.cpp \ - src/interface/camerapropertiesdialog.cpp \ src/interface/editor.cpp \ src/interface/flowlayout.cpp \ src/interface/recentfilemenu.cpp \ src/interface/scribblearea.cpp \ - src/interface/timecontrols.cpp \ - src/interface/timeline.cpp \ - src/interface/timelinecells.cpp \ - src/interface/basedockwidget.cpp \ src/interface/backgroundwidget.cpp \ src/managers/basemanager.cpp \ src/managers/overlaymanager.cpp \ @@ -199,9 +187,6 @@ SOURCES += src/graphics/bitmap/bitmapimage.cpp \ src/activeframepool.cpp \ src/selectionpainter.cpp -FORMS += \ - ui/camerapropertiesdialog.ui - win32 { INCLUDEPATH += src/external/win32 SOURCES += src/external/win32/win32.cpp diff --git a/core_lib/src/interface/editor.cpp b/core_lib/src/interface/editor.cpp index 3ca5e4b945..3e7b3630e6 100644 --- a/core_lib/src/interface/editor.cpp +++ b/core_lib/src/interface/editor.cpp @@ -47,8 +47,6 @@ GNU General Public License for more details. #include "clipboardmanager.h" #include "scribblearea.h" -#include "timeline.h" -#include "util.h" Editor::Editor(QObject* parent) : QObject(parent) { @@ -139,7 +137,7 @@ void Editor::settingUpdated(SETTING setting) break; case SETTING::ONION_TYPE: mScribbleArea->onOnionSkinTypeChanged(); - emit updateTimeLine(); + emit updateTimeLineCached(); break; case SETTING::FRAME_POOL_SIZE: mObject->setActiveFramePoolSize(mPreferenceManager->getInt(SETTING::FRAME_POOL_SIZE)); @@ -1104,7 +1102,7 @@ void Editor::scrubTo(int frame) // Will remove all Timeline related code in Editor class. if (mPlaybackManager && !mPlaybackManager->isPlaying()) { - emit updateTimeLine(); // needs to update the timeline to update onion skin positions + emit updateTimeLineCached(); // needs to update the timeline to update onion skin positions } mObject->updateActiveFrames(frame); } diff --git a/core_lib/src/interface/editor.h b/core_lib/src/interface/editor.h index 09d05b37fc..2b517bdfb4 100644 --- a/core_lib/src/interface/editor.h +++ b/core_lib/src/interface/editor.h @@ -135,6 +135,7 @@ class Editor : public QObject void selectedFramesChanged(); void updateTimeLine() const; + void updateTimeLineCached(); void updateLayerCount(); void updateBackup(); diff --git a/core_lib/src/structure/layer.cpp b/core_lib/src/structure/layer.cpp index 14a7f000a7..68133ba944 100644 --- a/core_lib/src/structure/layer.cpp +++ b/core_lib/src/structure/layer.cpp @@ -23,7 +23,6 @@ GNU General Public License for more details. #include #include "keyframe.h" #include "object.h" -#include "timelinecells.h" // Used to sort the selected frames list bool sortAsc(int left, int right)