parent
baa9c0d8fb
commit
1cc5c4c01f
6 changed files with 153 additions and 26 deletions
|
@ -85,6 +85,7 @@ public:
|
|||
signals:
|
||||
void nextFrame(int fps); // Must be connect with Qt::BlockingQueuedConnection
|
||||
// connection type.
|
||||
void playbackAborted();
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -331,6 +332,7 @@ signals:
|
|||
|
||||
void playStateChanged(bool isPlaying);
|
||||
void sliderReleased();
|
||||
void changeSceneFps(int);
|
||||
|
||||
private:
|
||||
UINT m_customizeMask;
|
||||
|
@ -347,9 +349,10 @@ private:
|
|||
ToolBarContainer *m_playToolBarContainer;
|
||||
QFrame *m_frameSliderFrame;
|
||||
|
||||
QLabel *m_fpsLabel;
|
||||
QLabel *m_fpsLabel, *m_timeLabel;
|
||||
QScrollBar *m_fpsSlider;
|
||||
DVGui::IntLineEdit *m_fpsField;
|
||||
QColor m_fpsFieldColor = QColor(1, 1, 1);
|
||||
QAction *m_fpsFieldAction;
|
||||
QAction *m_fpsLabelAction;
|
||||
QAction *m_fpsSliderAction;
|
||||
|
@ -394,6 +397,7 @@ private:
|
|||
void createPlayToolBar(QWidget *customWidget);
|
||||
DVGui::IntLineEdit *m_editCurrFrame;
|
||||
FlipSlider *m_currFrameSlider;
|
||||
void updateCurrentTime();
|
||||
|
||||
void doButtonPressed(UINT button);
|
||||
static void pressLinkedConsoleButton(UINT button, FlipConsole *skipIt);
|
||||
|
@ -419,6 +423,7 @@ protected slots:
|
|||
void onButtonPressed(int button);
|
||||
void incrementCurrentFrame(int delta);
|
||||
void onNextFrame(int fps);
|
||||
void setFpsFieldColors();
|
||||
void onCustomizeButtonPressed(QAction *);
|
||||
bool drawBlanks(int from, int to);
|
||||
void onSliderRelease();
|
||||
|
@ -427,6 +432,8 @@ protected slots:
|
|||
|
||||
public slots:
|
||||
void onPreferenceChanged(const QString &);
|
||||
void resetToSceneFps();
|
||||
void setSceneFpsToCurrent();
|
||||
|
||||
private:
|
||||
friend class PlaybackExecutor;
|
||||
|
|
|
@ -118,6 +118,10 @@ public:
|
|||
|
||||
void setLineEditBackgroundColor(QColor color);
|
||||
|
||||
signals:
|
||||
void controlClickEvent();
|
||||
void controlAltClickEvent();
|
||||
|
||||
protected:
|
||||
/*! If focus is lost and current text value is out of range emit signal
|
||||
\b editingFinished.*/
|
||||
|
|
|
@ -149,6 +149,8 @@ SceneViewerPanel::SceneViewerPanel(QWidget *parent, Qt::WFlags flags)
|
|||
ret = ret &&
|
||||
connect(m_flipConsole, SIGNAL(playStateChanged(bool)),
|
||||
TApp::instance()->getCurrentFrame(), SLOT(setPlaying(bool)));
|
||||
ret = ret && connect(m_flipConsole, SIGNAL(changeSceneFps(int)), this,
|
||||
SLOT(changeSceneFps(int)));
|
||||
ret = ret && connect(m_flipConsole, SIGNAL(playStateChanged(bool)), this,
|
||||
SLOT(onPlayingStatusChanged(bool)));
|
||||
ret = ret &&
|
||||
|
@ -178,15 +180,15 @@ SceneViewerPanel::SceneViewerPanel(QWidget *parent, Qt::WFlags flags)
|
|||
->getOutputProperties()
|
||||
->getFrameRate());
|
||||
|
||||
UINT mask;
|
||||
mask = mask | eShowVcr;
|
||||
mask = mask | eShowFramerate;
|
||||
mask = mask | eShowViewerControls;
|
||||
mask = mask | eShowSound;
|
||||
mask = mask | eShowCustom;
|
||||
mask = mask & ~eShowSave;
|
||||
mask = mask & ~eShowLocator;
|
||||
mask = mask & ~eShowHisto;
|
||||
UINT mask = 0;
|
||||
mask = mask | eShowVcr;
|
||||
mask = mask | eShowFramerate;
|
||||
mask = mask | eShowViewerControls;
|
||||
mask = mask | eShowSound;
|
||||
mask = mask | eShowCustom;
|
||||
mask = mask & ~eShowSave;
|
||||
mask = mask & ~eShowLocator;
|
||||
mask = mask & ~eShowHisto;
|
||||
m_flipConsole->setCustomizemask(mask);
|
||||
|
||||
updateFrameRange(), updateFrameMarkers();
|
||||
|
@ -850,6 +852,27 @@ void SceneViewerPanel::setFlipVButtonChecked(bool checked) {
|
|||
m_flipConsole->setChecked(FlipConsole::eFlipVertical, checked);
|
||||
}
|
||||
|
||||
void SceneViewerPanel::changeSceneFps(int value) {
|
||||
double oldFps = TApp::instance()
|
||||
->getCurrentScene()
|
||||
->getScene()
|
||||
->getProperties()
|
||||
->getOutputProperties()
|
||||
->getFrameRate();
|
||||
|
||||
if ((double)value == oldFps) return;
|
||||
TApp::instance()
|
||||
->getCurrentScene()
|
||||
->getScene()
|
||||
->getProperties()
|
||||
->getOutputProperties()
|
||||
->setFrameRate(value);
|
||||
TApp::instance()->getCurrentScene()->getScene()->updateSoundColumnFrameRate();
|
||||
TApp::instance()->getCurrentScene()->notifySceneChanged();
|
||||
TApp::instance()->getCurrentXsheet()->getXsheet()->updateFrameCount();
|
||||
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void SceneViewerPanel::setVisiblePartsFlag(UINT flag) {
|
||||
|
@ -857,24 +880,28 @@ void SceneViewerPanel::setVisiblePartsFlag(UINT flag) {
|
|||
updateShowHide();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// SaveLoadQSettings
|
||||
void SceneViewerPanel::save(QSettings &settings) const {
|
||||
settings.setValue("visibleParts", m_visiblePartsFlag);
|
||||
settings.setValue("consoleParts", m_flipConsole->getCustomizeMask());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void SceneViewerPanel::load(QSettings &settings) {
|
||||
m_visiblePartsFlag = settings.value("visibleParts", CVPARTS_ALL).toUInt();
|
||||
updateShowHide();
|
||||
UINT mask;
|
||||
mask = mask | eShowVcr;
|
||||
mask = mask | eShowFramerate;
|
||||
mask = mask | eShowViewerControls;
|
||||
mask = mask | eShowSound;
|
||||
mask = mask | eShowCustom;
|
||||
mask = mask & ~eShowSave;
|
||||
mask = mask & ~eShowLocator;
|
||||
mask = mask & ~eShowHisto;
|
||||
UINT mask = 0;
|
||||
mask = mask | eShowVcr;
|
||||
mask = mask | eShowFramerate;
|
||||
mask = mask | eShowViewerControls;
|
||||
mask = mask | eShowSound;
|
||||
mask = mask | eShowCustom;
|
||||
mask = mask & ~eShowSave;
|
||||
mask = mask & ~eShowLocator;
|
||||
mask = mask & ~eShowHisto;
|
||||
m_flipConsole->setCustomizemask(
|
||||
settings.value("consoleParts", mask).toUInt());
|
||||
}
|
||||
|
|
|
@ -104,6 +104,7 @@ public slots:
|
|||
void onButtonPressed(FlipConsole::EGadget button);
|
||||
void setFlipHButtonChecked(bool checked);
|
||||
void setFlipVButtonChecked(bool checked);
|
||||
void changeSceneFps(int value);
|
||||
|
||||
protected slots:
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "toonzqt/dvscrollwidget.h"
|
||||
#include "toonzqt/gutil.h"
|
||||
#include "toonzqt/flipconsoleowner.h"
|
||||
#include "toonzqt/dvdialog.h"
|
||||
|
||||
// TnzLib includes
|
||||
#include "toonz/preferences.h"
|
||||
|
@ -256,6 +257,7 @@ void PlaybackExecutor::run() {
|
|||
}
|
||||
|
||||
m_abort = false;
|
||||
emit(playbackAborted());
|
||||
}
|
||||
|
||||
//==========================================================================================
|
||||
|
@ -464,6 +466,7 @@ FlipConsole::FlipConsole(QVBoxLayout *mainLayout, std::vector<int> gadgetsMask,
|
|||
, m_playToolBar(0)
|
||||
, m_colorFilterGroup(0)
|
||||
, m_fpsLabel(0)
|
||||
, m_timeLabel(0)
|
||||
, m_consoleOwner(consoleOwner)
|
||||
, m_enableBlankFrameButton(0) {
|
||||
if (m_customizeId != "SceneViewerConsole") {
|
||||
|
@ -512,6 +515,12 @@ FlipConsole::FlipConsole(QVBoxLayout *mainLayout, std::vector<int> gadgetsMask,
|
|||
|
||||
bool ret = connect(&m_playbackExecutor, SIGNAL(nextFrame(int)), this,
|
||||
SLOT(onNextFrame(int)), Qt::BlockingQueuedConnection);
|
||||
ret = ret && connect(&m_playbackExecutor, SIGNAL(playbackAborted()), this,
|
||||
SLOT(setFpsFieldColors()));
|
||||
ret = ret && connect(m_fpsField, SIGNAL(controlClickEvent()), this,
|
||||
SLOT(resetToSceneFps()));
|
||||
ret = ret && connect(m_fpsField, SIGNAL(controlAltClickEvent()), this,
|
||||
SLOT(setSceneFpsToCurrent()));
|
||||
|
||||
assert(ret);
|
||||
|
||||
|
@ -798,6 +807,22 @@ void FlipConsole::onNextFrame(int fps) {
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void FlipConsole::setFpsFieldColors() {
|
||||
if (m_fpsField) {
|
||||
if (m_fpsField->getValue() == m_sceneFps) {
|
||||
m_fpsField->setLineEditBackgroundColor(Qt::transparent);
|
||||
m_fpsField->setToolTip("");
|
||||
} else {
|
||||
m_fpsField->setLineEditBackgroundColor(QColor(255, 69, 0));
|
||||
m_fpsField->setToolTip(
|
||||
tr("This value is different than the scene framerate.\n"
|
||||
"Control click to reset."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void FlipConsole::playNextFrame() {
|
||||
int from = m_from, to = m_to;
|
||||
if (m_markerFrom <= m_markerTo) from = m_markerFrom, to = m_markerTo;
|
||||
|
@ -823,6 +848,7 @@ void FlipConsole::playNextFrame() {
|
|||
|
||||
m_currFrameSlider->setValue(m_currentFrame);
|
||||
m_editCurrFrame->setText(QString::number(m_currentFrame));
|
||||
updateCurrentTime();
|
||||
m_settings.m_blankColor = TPixel::Transparent;
|
||||
m_settings.m_recomputeIfNeeded = true;
|
||||
m_consoleOwner->onDrawFrame(m_currentFrame, m_settings);
|
||||
|
@ -844,6 +870,7 @@ void FlipConsole::setFrameRate(int val, bool forceUpdate) {
|
|||
setCurrentFPS(val);
|
||||
}
|
||||
m_sceneFps = val;
|
||||
setFpsFieldColors();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -855,6 +882,23 @@ void FlipConsole::setCurrentFPS(bool dragging) {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FlipConsole::resetToSceneFps() {
|
||||
setCurrentFPS(m_sceneFps);
|
||||
m_fpsSlider->setValue(m_sceneFps);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FlipConsole::setSceneFpsToCurrent() {
|
||||
if (m_fps == abs(m_fps) && m_fps != m_sceneFps) {
|
||||
emit(changeSceneFps(m_fps));
|
||||
} else if (m_fps != abs(m_fps)) {
|
||||
DVGui::warning(tr("Cannot set the scene fps to a negative value."));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FlipConsole::setCurrentFPS(int val) {
|
||||
if (m_fps == val) return;
|
||||
|
||||
|
@ -866,7 +910,9 @@ void FlipConsole::setCurrentFPS(int val) {
|
|||
m_reverse = (val < 0);
|
||||
|
||||
if (m_fpsLabel) m_fpsLabel->setText(tr(" FPS "));
|
||||
if (m_fpsField) m_fpsField->setLineEditBackgroundColor(Qt::transparent);
|
||||
if (m_fpsField) {
|
||||
setFpsFieldColors();
|
||||
}
|
||||
|
||||
m_playbackExecutor.resetFps(m_fps);
|
||||
}
|
||||
|
@ -1585,7 +1631,9 @@ void FlipConsole::doButtonPressed(UINT button) {
|
|||
if ((m_fps == 0 || m_framesCount == 0) && m_playbackExecutor.isRunning()) {
|
||||
doButtonPressed(ePause);
|
||||
if (m_fpsLabel) m_fpsLabel->setText(tr(" FPS ") + QString::number(m_fps));
|
||||
if (m_fpsField) m_fpsField->setLineEditBackgroundColor(Qt::transparent);
|
||||
if (m_fpsField) {
|
||||
setFpsFieldColors();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (m_fpsLabel) m_fpsLabel->setText(tr(" FPS ") + "/");
|
||||
|
@ -1645,7 +1693,9 @@ void FlipConsole::doButtonPressed(UINT button) {
|
|||
m_consoleOwner->onDrawFrame(m_currentFrame, m_settings);
|
||||
}
|
||||
if (m_fpsLabel) m_fpsLabel->setText(tr(" FPS "));
|
||||
if (m_fpsField) m_fpsField->setLineEditBackgroundColor(Qt::transparent);
|
||||
if (m_fpsField) {
|
||||
setFpsFieldColors();
|
||||
}
|
||||
// setChecked(ePlay, false);
|
||||
// setChecked(eLoop, false);
|
||||
connect(m_editCurrFrame, SIGNAL(editingFinished()), this,
|
||||
|
@ -1756,7 +1806,7 @@ void FlipConsole::doButtonPressed(UINT button) {
|
|||
|
||||
m_currFrameSlider->setValue(m_currentFrame);
|
||||
m_editCurrFrame->setText(QString::number(m_currentFrame));
|
||||
|
||||
updateCurrentTime();
|
||||
m_consoleOwner->onDrawFrame(m_currentFrame, m_settings);
|
||||
}
|
||||
|
||||
|
@ -1775,6 +1825,11 @@ QFrame *FlipConsole::createFrameSlider() {
|
|||
m_currFrameSlider->setRange(0, 0);
|
||||
m_currFrameSlider->setValue(0);
|
||||
|
||||
m_timeLabel = new QLabel(QString("00:00:00"), frameSliderFrame);
|
||||
m_timeLabel->setFixedWidth(m_fpsLabel->fontMetrics().width("00:00:00"));
|
||||
m_timeLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
m_timeLabel->setStyleSheet("padding: 0px; margin: 0px;");
|
||||
|
||||
if (m_drawBlanksEnabled) {
|
||||
m_enableBlankFrameButton = new QPushButton(this);
|
||||
m_enableBlankFrameButton->setCheckable(true);
|
||||
|
@ -1790,6 +1845,7 @@ QFrame *FlipConsole::createFrameSlider() {
|
|||
frameSliderLayout->setSpacing(5);
|
||||
frameSliderLayout->setMargin(2);
|
||||
{
|
||||
frameSliderLayout->addWidget(m_timeLabel, 0);
|
||||
frameSliderLayout->addWidget(m_editCurrFrame, 0);
|
||||
frameSliderLayout->addWidget(m_currFrameSlider, 1);
|
||||
if (m_drawBlanksEnabled)
|
||||
|
@ -1903,16 +1959,21 @@ void FlipConsole::OnSetCurrentFrame() {
|
|||
if (m_step > 1) {
|
||||
newFrame -= ((newFrame - m_from) % m_step);
|
||||
m_editCurrFrame->setText(QString::number(newFrame));
|
||||
updateCurrentTime();
|
||||
}
|
||||
|
||||
int i, deltaFrame = newFrame - m_currentFrame;
|
||||
|
||||
if (m_framesCount == 0) m_editCurrFrame->setText(QString::number(1));
|
||||
if (m_framesCount == 0) {
|
||||
m_editCurrFrame->setText(QString::number(1));
|
||||
updateCurrentTime();
|
||||
}
|
||||
|
||||
if (m_framesCount == 0 || newFrame == m_currentFrame || newFrame == 0) return;
|
||||
|
||||
if (newFrame > m_to) {
|
||||
m_editCurrFrame->setText(QString::number(m_currentFrame));
|
||||
updateCurrentTime();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1958,6 +2019,7 @@ void FlipConsole::OnSetCurrentFrame(int index) {
|
|||
|
||||
assert(m_currentFrame <= m_to);
|
||||
m_editCurrFrame->setText(QString::number(m_currentFrame));
|
||||
updateCurrentTime();
|
||||
|
||||
m_consoleOwner->onDrawFrame(m_currentFrame, m_settings);
|
||||
|
||||
|
@ -1980,6 +2042,21 @@ void FlipConsole::setCurrentFrame(int frame, bool forceResetting) {
|
|||
|
||||
m_editCurrFrame->setValue(m_currentFrame);
|
||||
m_currFrameSlider->setValue(m_currentFrame);
|
||||
updateCurrentTime();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
void FlipConsole::updateCurrentTime() {
|
||||
int seconds = (int)((double)(m_currentFrame) / m_sceneFps);
|
||||
int frames = (m_currentFrame) % (int)m_sceneFps;
|
||||
int minutes = seconds / 60;
|
||||
int realSeconds = minutes > 0 ? seconds % minutes : seconds;
|
||||
QString strMinutes = QString("%1").arg(minutes, 2, 10, QChar('0'));
|
||||
QString strSeconds = QString("%1").arg(realSeconds, 2, 10, QChar('0'));
|
||||
QString strFrames = QString("%1").arg(frames, 2, 10, QChar('0'));
|
||||
QString time = strMinutes + ":" + strSeconds + ":" + strFrames;
|
||||
m_timeLabel->setText(time);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
@ -238,6 +238,17 @@ void IntLineEdit::mouseMoveEvent(QMouseEvent *e) {
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
void IntLineEdit::mouseReleaseEvent(QMouseEvent *e) {
|
||||
if (e->modifiers() & Qt::ControlModifier &&
|
||||
e->modifiers() & Qt::AltModifier) {
|
||||
emit(controlAltClickEvent());
|
||||
clearFocus();
|
||||
return;
|
||||
} else if (e->modifiers() & Qt::ControlModifier) {
|
||||
emit(controlClickEvent());
|
||||
clearFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((e->buttons() == Qt::NoButton && m_mouseDragEditing)) {
|
||||
m_mouseDragEditing = false;
|
||||
clearFocus();
|
||||
|
@ -284,7 +295,7 @@ IntField::IntField(QWidget *parent, bool isMaxRangeLimited, bool isRollerHide)
|
|||
m_slider = new QSlider(Qt::Horizontal, this);
|
||||
ret = ret && connect(m_slider, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(onSliderChanged(int)));
|
||||
ret = ret && connect(m_slider, SIGNAL(sliderReleased()), this,
|
||||
ret = ret && connect(m_slider, SIGNAL(sliderReleased()), this,
|
||||
SLOT(onSliderReleased()));
|
||||
|
||||
ret = ret && connect(m_lineEdit, SIGNAL(editingFinished()), this,
|
||||
|
@ -392,7 +403,7 @@ int IntField::pos2value(int x) const {
|
|||
else if (posRatio <= 0.9)
|
||||
t = -0.26 + 0.4 * posRatio;
|
||||
else
|
||||
t = -8.0 + 9.0 * posRatio;
|
||||
t = -8.0 + 9.0 * posRatio;
|
||||
double sliderVal = (double)m_slider->minimum() + rangeSize * t;
|
||||
return (int)round(sliderVal * pow(0.1, NonLinearSliderPrecision));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue