Skip to content

Commit

Permalink
Timeline improvements (#531)
Browse files Browse the repository at this point in the history
* Fix timeline length display

* Fix timeline length behavior

* Add timeline sidescroll with shift

* Refactor QSettings init

* Added timeline middle mouse drag

* Update timeline on fps change

* Remove some unnecessary debug messages

* Fix non-native vertical scrolling behavior for the timeline

Don't forget to KISS!

* Fix timeline tracks not updating when layer dropped in place

* Scrubbing stops playback, other timeline ops function during playback

* Timeline start and end buttons use range when applicable

* Update loop check state when triggered in PlaybackManager

* Fix range option in Animation menu

* Change play button/menu item to stop while playing

* Highlight range in timeline
  • Loading branch information
scribblemaniac authored and chchwy committed Sep 10, 2016
1 parent 50c5ddb commit 5953dec
Show file tree
Hide file tree
Showing 33 changed files with 377 additions and 214 deletions.
28 changes: 23 additions & 5 deletions app/mainwindow2.cpp
Expand Up @@ -169,6 +169,9 @@ void MainWindow2::createDockWidgets()
<< mToolOptions
<< mToolBox;

mStartIcon = QIcon(":icons/controls/play.png");
mStopIcon = QIcon(":icons/controls/stop.png");

/*
mTimeline2 = new Timeline2;
mTimeline2->setObjectName( "Timeline2" );
Expand Down Expand Up @@ -290,7 +293,11 @@ void MainWindow2::createMenus()
connect( ui->actionLoop, &QAction::triggered, pPlaybackManager, &PlaybackManager::setLooping );
connect( ui->actionLoopControl, &QAction::triggered, pPlaybackManager, &PlaybackManager::enableRangedPlayback );
connect( pPlaybackManager, &PlaybackManager::loopStateChanged, ui->actionLoop, &QAction::setChecked );
connect( pPlaybackManager, &PlaybackManager::loopStateChanged, mTimeLine, &TimeLine::setLoop );
connect( pPlaybackManager, &PlaybackManager::rangedPlaybackStateChanged, ui->actionLoopControl, &QAction::setChecked );
connect( pPlaybackManager, &PlaybackManager::rangedPlaybackStateChanged, mTimeLine, &TimeLine::setRangeState );
connect( pPlaybackManager, &PlaybackManager::playStateChanged, mTimeLine, &TimeLine::setPlaying );
connect( pPlaybackManager, &PlaybackManager::playStateChanged, this, &MainWindow2::changePlayState );

connect(ui->actionAdd_Frame, &QAction::triggered, mEditor, &Editor::addNewKey );
connect(ui->actionRemove_Frame, &QAction::triggered, mEditor, &Editor::removeKey );
Expand Down Expand Up @@ -382,7 +389,6 @@ void MainWindow2::markTitleSaved()

void MainWindow2::updateTitleSaveState()
{
qDebug() << "updateTitleSaveState";
if( mEditor->currentBackup() == mBackupAtSave )
{
markTitleSaved();
Expand Down Expand Up @@ -617,7 +623,7 @@ bool MainWindow2::maybeSave()

void MainWindow2::importImage()
{
QSettings settings( "Pencil", "Pencil" );
QSettings settings( PENCIL2D, PENCIL2D );
QString initPath = settings.value( "lastImportPath", QDir::homePath() ).toString();

QString strFilePath = QFileDialog::getOpenFileName( this,
Expand Down Expand Up @@ -682,7 +688,7 @@ void MainWindow2::importImageSequence()

void MainWindow2::importMovie()
{
QSettings settings( "Pencil", "Pencil" );
QSettings settings( PENCIL2D, PENCIL2D );

QString initialPath = settings.value( "lastExportPath", QDir::homePath() ).toString();
QString filePath = QFileDialog::getOpenFileName( this,
Expand Down Expand Up @@ -1046,7 +1052,7 @@ void MainWindow2::undoActSetEnabled( void )

void MainWindow2::exportPalette()
{
QSettings settings( "Pencil", "Pencil" );
QSettings settings( PENCIL2D, PENCIL2D );
QString initialPath = settings.value( "lastPalettePath", QVariant( QDir::homePath() ) ).toString();
if ( initialPath.isEmpty() )
{
Expand All @@ -1062,7 +1068,7 @@ void MainWindow2::exportPalette()

void MainWindow2::importPalette()
{
QSettings settings( "Pencil", "Pencil" );
QSettings settings( PENCIL2D, PENCIL2D );
QString initialPath = settings.value( "lastPalettePath", QVariant( QDir::homePath() ) ).toString();
if ( initialPath.isEmpty() )
{
Expand Down Expand Up @@ -1205,3 +1211,15 @@ void MainWindow2::updateZoomLabel()
float zoom = mEditor->view()->scaling() * 100.f;
statusBar()->showMessage( QString( "Zoom: %0%1" ).arg( zoom, 0, 'f', 1 ).arg("%") );
}

void MainWindow2::changePlayState( bool isPlaying )
{
if( isPlaying ) {
ui->actionPlay->setText(tr("Stop"));
ui->actionPlay->setIcon(mStopIcon);
}
else {
ui->actionPlay->setText(tr("Play"));
ui->actionPlay->setIcon(mStartIcon);
}
}
4 changes: 4 additions & 0 deletions app/mainwindow2.h
Expand Up @@ -108,6 +108,8 @@ public slots:
void readSettings();
void writeSettings();

void changePlayState( bool isPlaying );

void makeConnections( Editor* );
void makeConnections( Editor*, ColorBox* );
void makeConnections( Editor*, ScribbleArea* );
Expand Down Expand Up @@ -145,6 +147,8 @@ public slots:
Ui::MainWindow2* ui = nullptr;
QList< BaseDockWidget* > mDockWidgets;
BackgroundWidget* mBackground;

QIcon mStartIcon, mStopIcon;
};

#endif // MAINWINDOW2_H
19 changes: 9 additions & 10 deletions app/preferencesdialog.cpp
Expand Up @@ -439,28 +439,27 @@ void GridPage::gridSizeChange(int value)

TimelinePage::TimelinePage(QWidget* parent) : QWidget(parent)
{
QSettings settings("Pencil","Pencil");
QSettings settings( PENCIL2D, PENCIL2D );

QVBoxLayout* lay = new QVBoxLayout();

QGroupBox* timeLineBox = new QGroupBox(tr("Timeline"));
mDrawLabel = new QCheckBox(tr("Draw timeline labels"));
mFontSize = new QSpinBox();
QLabel* frameSizeLabel = new QLabel(tr("Frame size in Pixels"));
mFrameSize = new QSpinBox(this);
QLabel* frameSizeLabel = new QLabel(tr("Frame size"));
mFrameSize = new QSlider(Qt::Horizontal, this);
QLabel* lengthSizeLabel = new QLabel(tr("Timeline size in Frames"));
mLengthSize = new QLineEdit(this);
mLengthSize->setInputMask("0009");
QIntValidator* lengthSizeValidator = new QIntValidator(this);
lengthSizeValidator->setBottom(2);
mLengthSize->setValidator( lengthSizeValidator );

mScrubBox = new QCheckBox(tr("Short scrub"));

mFontSize->setMinimum(4);
mFontSize->setMaximum(20);
mFrameSize->setMinimum(4);
mFrameSize->setMaximum(20);
mFontSize->setRange(4, 20);
mFrameSize->setRange(4, 20);

mFontSize->setFixedWidth(50);
mFrameSize->setFixedWidth(50);
mLengthSize->setFixedWidth(50);


Expand Down Expand Up @@ -569,7 +568,7 @@ void FilesPage::autosaveNumberChange(int number)

ToolsPage::ToolsPage(QWidget* parent) : QWidget(parent)
{
QSettings settings("Pencil","Pencil");
QSettings settings( PENCIL2D, PENCIL2D );

QVBoxLayout* lay = new QVBoxLayout();

Expand Down
2 changes: 1 addition & 1 deletion app/preferencesdialog.h
Expand Up @@ -149,7 +149,7 @@ public slots:
PreferenceManager* mManager = nullptr;
QCheckBox* mDrawLabel;
QSpinBox* mFontSize;
QSpinBox* mFrameSize;
QSlider* mFrameSize;
QLineEdit* mLengthSize;
QCheckBox* mScrubBox;
};
Expand Down
6 changes: 3 additions & 3 deletions app/shortcutspage.cpp
Expand Up @@ -70,7 +70,7 @@ void ShortcutsPage::keyCapLineEditTextChanged(QKeySequence keySeqence)
QString strCmdName = QString("Cmd%1").arg( actionItem->text() );
QString strKeySeq = keySeqence.toString( QKeySequence::PortableText );

QSettings setting("Pencil", "Pencil");
QSettings setting( PENCIL2D, PENCIL2D );
setting.beginGroup("shortcuts");

if (isKeySequenceExist(setting, strCmdName, keySeqence))
Expand Down Expand Up @@ -147,7 +147,7 @@ void ShortcutsPage::removeDuplicateKeySequence(QSettings* settings, QKeySequence
void ShortcutsPage::treeModelLoadShortcutsSetting()
{
// Load shortcuts from settings
QSettings settings("Pencil", "Pencil");
QSettings settings( PENCIL2D, PENCIL2D );
settings.beginGroup("shortcuts");

m_treeModel->clear(); // release all existing items.
Expand Down Expand Up @@ -194,7 +194,7 @@ void ShortcutsPage::clearButtonClicked()

QString strCmdName = QString("shortcuts/Cmd%1").arg( actionItem->text() );

QSettings setting("Pencil", "Pencil");
QSettings setting( PENCIL2D, PENCIL2D );
setting.setValue( strCmdName, "" );
setting.sync();

Expand Down
7 changes: 4 additions & 3 deletions app/ui/mainwindow2.ui
Expand Up @@ -30,7 +30,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>24</height>
<height>22</height>
</rect>
</property>
<property name="font">
Expand Down Expand Up @@ -820,10 +820,10 @@ background: #B6DBEA;
<bool>true</bool>
</property>
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>loopcontrol</string>
<string>Range</string>
</property>
</action>
<action name="actionToolsWidget">
Expand Down Expand Up @@ -898,6 +898,7 @@ background: #B6DBEA;
<resources>
<include location="../../pencil.qrc"/>
<include location="../resource/app.qrc"/>
<include location="../../pencil.qrc"/>
</resources>
<connections/>
</ui>
3 changes: 2 additions & 1 deletion core_lib/external/linux/linux.cpp
Expand Up @@ -25,6 +25,7 @@ GNU General Public License for more details.
#include "object.h"
#include "editor.h"
#include "layersound.h"
#include "pencildef.h"

#define MIN(a,b) ((a)>(b)?(b):(a))

Expand Down Expand Up @@ -269,7 +270,7 @@ void Editor::importMovie (QString filePath, int fps)
{

int i;
QSettings settings("Pencil","Pencil");
QSettings settings( PENCIL2D, PENCIL2D );

qDebug() << "-------IMPORT VIDEO------" << filePath;

Expand Down
3 changes: 2 additions & 1 deletion core_lib/external/macosx/macosx.cpp
Expand Up @@ -21,6 +21,7 @@ GNU General Public License for more details.
#include <QSysInfo>
#include "object.h"
#include "editor.h"
#include "pencildef.h"

#include <CoreFoundation/CoreFoundation.h>
#include <Carbon/Carbon.h>
Expand Down Expand Up @@ -122,7 +123,7 @@ void Editor::importMovie (QString filePath, int fps)
{

int i;
QSettings settings("Pencil","Pencil");
QSettings settings( PENCIL2D , PENCIL2D );

qDebug() << "-------IMPORT VIDEO------" << filePath;

Expand Down
2 changes: 1 addition & 1 deletion core_lib/external/win32/win32.cpp
Expand Up @@ -300,7 +300,7 @@ bool Object::exportMovie( ExportMovieParameters exportParams )
void Editor::importMovie( QString filePath, int fps )
{
int i;
QSettings settings( "Pencil", "Pencil" );
QSettings settings( PENCIL2D, PENCIL2D );

qDebug() << "-------IMPORT VIDEO------" << filePath;

Expand Down
3 changes: 1 addition & 2 deletions core_lib/interface/editor.cpp
Expand Up @@ -177,7 +177,6 @@ void Editor::settingUpdated(SETTING setting)

BackupElement* Editor::currentBackup()
{
qDebug() << mBackupIndex << mBackupList.length();
if ( mBackupIndex >= 0 )
{
return mBackupList[ mBackupIndex ];
Expand Down Expand Up @@ -622,7 +621,7 @@ QString Editor::workingDir() const
/*
bool Editor::exportMov()
{
QSettings settings( "Pencil", "Pencil" );
QSettings settings( PENCIL2D, PENCIL2D );
QString initialPath = settings.value( "lastExportPath", QVariant( QDir::homePath() ) ).toString();
if ( initialPath.isEmpty() ) initialPath = QDir::homePath() + "/untitled.avi";
// QString filePath = QFileDialog::getSaveFileName(this, tr("Export As"),initialPath);
Expand Down
6 changes: 3 additions & 3 deletions core_lib/interface/recentfilemenu.cpp
Expand Up @@ -32,7 +32,7 @@ void RecentFileMenu::setRecentFiles( QStringList filenames )

bool RecentFileMenu::loadFromDisk()
{
QSettings settings( "Pencil", "Pencil" );
QSettings settings( PENCIL2D, PENCIL2D );
QVariant _recent = settings.value( "RecentFiles" );
if ( _recent.isNull() )
{
Expand All @@ -45,7 +45,7 @@ bool RecentFileMenu::loadFromDisk()

bool RecentFileMenu::saveToDisk()
{
QSettings settings( "Pencil", "Pencil" );
QSettings settings( PENCIL2D, PENCIL2D );
settings.setValue( "RecentFiles", QVariant( mRecentFiles ) );
return true;
}
Expand Down Expand Up @@ -103,4 +103,4 @@ void RecentFileMenu::onRecentFileTriggered()
{
emit loadRecentFile( filePath );
}
}
}
1 change: 1 addition & 0 deletions core_lib/interface/recentfilemenu.h
Expand Up @@ -4,6 +4,7 @@
#include <QMenu>
#include <QMap>
#include <QStringList>
#include "pencildef.h"

class QAction;
class ListItemModel;
Expand Down

0 comments on commit 5953dec

Please sign in to comment.