|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/keyframenavigator.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/styleselection.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheet.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshcolumn.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tstageobjectkeyframe.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/stageobjectutil.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tpixelutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamcontainer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tspectrumparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttonecurveparam.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qpainter></qpainter>
|
|
Toshihiro Shimizu |
890ddd |
#include <qpixmap></qpixmap>
|
|
Toshihiro Shimizu |
890ddd |
#include <qicon></qicon>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef WIN32
|
|
Toshihiro Shimizu |
890ddd |
#pragma warning(disable : 4251)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
40cabe |
#include <memory></memory>
|
|
Campbell Barton |
40cabe |
|
|
Toshihiro Shimizu |
890ddd |
#include <qaction></qaction>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmouseevent></qmouseevent>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace std;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// KeyframeNavigator
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
KeyframeNavigator::KeyframeNavigator(QWidget *parent, TFrameHandle *frameHandle)
|
|
Toshihiro Shimizu |
890ddd |
: QToolBar(parent), m_frameHandle(frameHandle)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setLayoutDirection(Qt::LeftToRight);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
setIconSize(QSize(15, 23));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
setObjectName("keyFrameNavigator");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QIcon previewActIcon = createQIconPNG("prevkey");
|
|
Toshihiro Shimizu |
890ddd |
previewActIcon.addFile(QString(":Resources/prevkey_disabled.png"), QSize(), QIcon::Disabled);
|
|
Toshihiro Shimizu |
890ddd |
m_actPreviewKey = new QAction(previewActIcon, tr("Previous Key"), this);
|
|
Toshihiro Shimizu |
890ddd |
connect(m_actPreviewKey, SIGNAL(triggered()), SLOT(togglePrevKeyAct()));
|
|
Toshihiro Shimizu |
890ddd |
addAction(m_actPreviewKey);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_actKeyNo = new QAction(createQIconPNG("key_no"), tr("Set Key"), this);
|
|
Toshihiro Shimizu |
890ddd |
connect(m_actKeyNo, SIGNAL(triggered()), SLOT(toggleKeyAct()));
|
|
Toshihiro Shimizu |
890ddd |
addAction(m_actKeyNo);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_actKeyPartial = new QAction(createQIconPNG("key_partial"), tr("Set Key"), this);
|
|
Toshihiro Shimizu |
890ddd |
connect(m_actKeyPartial, SIGNAL(triggered()), SLOT(toggleKeyAct()));
|
|
Toshihiro Shimizu |
890ddd |
addAction(m_actKeyPartial);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_actKeyTotal = new QAction(createQIconPNG("key_total"), tr("Set Key"), this);
|
|
Toshihiro Shimizu |
890ddd |
connect(m_actKeyTotal, SIGNAL(triggered()), SLOT(toggleKeyAct()));
|
|
Toshihiro Shimizu |
890ddd |
addAction(m_actKeyTotal);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QIcon nextActIcon = createQIconPNG("nextkey");
|
|
Toshihiro Shimizu |
890ddd |
nextActIcon.addFile(QString(":Resources/nextkey_disabled.png"), QSize(), QIcon::Disabled);
|
|
Toshihiro Shimizu |
890ddd |
m_actNextKey = new QAction(nextActIcon, tr("Next Key"), this);
|
|
Toshihiro Shimizu |
890ddd |
connect(m_actNextKey, SIGNAL(triggered()), SLOT(toggleNextKeyAct()));
|
|
Toshihiro Shimizu |
890ddd |
addAction(m_actNextKey);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void KeyframeNavigator::update()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// Prev button
|
|
Toshihiro Shimizu |
890ddd |
if (hasPrev())
|
|
Toshihiro Shimizu |
890ddd |
m_actPreviewKey->setDisabled(false);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
m_actPreviewKey->setDisabled(true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool isFullKey = isFullKeyframe();
|
|
Toshihiro Shimizu |
890ddd |
bool isKey = isKeyframe();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (isKey && !isFullKey) {
|
|
Toshihiro Shimizu |
890ddd |
m_actKeyNo->setVisible(false);
|
|
Toshihiro Shimizu |
890ddd |
m_actKeyTotal->setVisible(false);
|
|
Toshihiro Shimizu |
890ddd |
m_actKeyPartial->setVisible(true);
|
|
Toshihiro Shimizu |
890ddd |
m_actKeyPartial->setDisabled(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (isFullKey) {
|
|
Toshihiro Shimizu |
890ddd |
m_actKeyNo->setVisible(false);
|
|
Toshihiro Shimizu |
890ddd |
m_actKeyPartial->setVisible(false);
|
|
Toshihiro Shimizu |
890ddd |
m_actKeyTotal->setVisible(true);
|
|
Toshihiro Shimizu |
890ddd |
m_actKeyTotal->setDisabled(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (!isKey && !isFullKey) {
|
|
Toshihiro Shimizu |
890ddd |
m_actKeyPartial->setVisible(false);
|
|
Toshihiro Shimizu |
890ddd |
m_actKeyTotal->setVisible(false);
|
|
Toshihiro Shimizu |
890ddd |
m_actKeyNo->setVisible(true);
|
|
Toshihiro Shimizu |
890ddd |
m_actKeyNo->setDisabled(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Next button
|
|
Toshihiro Shimizu |
890ddd |
if (hasNext())
|
|
Toshihiro Shimizu |
890ddd |
m_actNextKey->setDisabled(false);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
m_actNextKey->setDisabled(true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void KeyframeNavigator::showEvent(QShowEvent *e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
update();
|
|
Toshihiro Shimizu |
890ddd |
if (!m_frameHandle)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
connect(m_frameHandle, SIGNAL(frameSwitched()), this, SLOT(update()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void KeyframeNavigator::hideEvent(QHideEvent *e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_frameHandle)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
disconnect(m_frameHandle);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// ViewerKeyframeNavigator
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TStageObject *ViewerKeyframeNavigator::getStageObject() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_xsheetHandle || !m_objectHandle)
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TStageObjectId objectId = m_objectHandle->getObjectId();
|
|
Toshihiro Shimizu |
890ddd |
TXsheet *xsh = m_xsheetHandle->getXsheet();
|
|
Toshihiro Shimizu |
890ddd |
//Se e' una colonna sound non posso settare chiavi
|
|
Toshihiro Shimizu |
890ddd |
if (objectId.isColumn()) {
|
|
Toshihiro Shimizu |
890ddd |
TXshColumn *column = xsh->getColumn(objectId.getIndex());
|
|
Toshihiro Shimizu |
890ddd |
if (column && column->getSoundColumn())
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return xsh->getStageObject(objectId);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool ViewerKeyframeNavigator::hasNext() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TStageObject *pegbar = getStageObject();
|
|
Toshihiro Shimizu |
890ddd |
if (!pegbar)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
int r0, r1;
|
|
Toshihiro Shimizu |
890ddd |
pegbar->getKeyframeRange(r0, r1);
|
|
Toshihiro Shimizu |
890ddd |
return r0 <= r1 && getCurrentFrame() < r1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool ViewerKeyframeNavigator::hasPrev() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TStageObject *pegbar = getStageObject();
|
|
Toshihiro Shimizu |
890ddd |
if (!pegbar)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
int r0, r1;
|
|
Toshihiro Shimizu |
890ddd |
pegbar->getKeyframeRange(r0, r1);
|
|
Toshihiro Shimizu |
890ddd |
return r0 <= r1 && getCurrentFrame() > r0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool ViewerKeyframeNavigator::hasKeyframes() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TStageObject *pegbar = getStageObject();
|
|
Toshihiro Shimizu |
890ddd |
if (!pegbar)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
int r0, r1;
|
|
Toshihiro Shimizu |
890ddd |
pegbar->getKeyframeRange(r0, r1);
|
|
Toshihiro Shimizu |
890ddd |
return r0 <= r1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool ViewerKeyframeNavigator::isKeyframe() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TStageObject *pegbar = getStageObject();
|
|
Toshihiro Shimizu |
890ddd |
if (!pegbar)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
return pegbar->isKeyframe(getCurrentFrame());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool ViewerKeyframeNavigator::isFullKeyframe() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TStageObject *pegbar = getStageObject();
|
|
Toshihiro Shimizu |
890ddd |
if (!pegbar)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
return pegbar->isFullKeyframe(getCurrentFrame());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ViewerKeyframeNavigator::toggle()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TStageObject *pegbar = getStageObject();
|
|
Toshihiro Shimizu |
890ddd |
if (!pegbar)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
int frame = getCurrentFrame();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (pegbar->isFullKeyframe(frame)) {
|
|
Toshihiro Shimizu |
890ddd |
TStageObject::Keyframe key = pegbar->getKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
pegbar->removeKeyframeWithoutUndo(frame);
|
|
Toshihiro Shimizu |
890ddd |
UndoRemoveKeyFrame *undo = new UndoRemoveKeyFrame(pegbar->getId(), frame, key, m_xsheetHandle);
|
|
Toshihiro Shimizu |
890ddd |
undo->setObjectHandle(m_objectHandle);
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(undo);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
UndoSetKeyFrame *undo = new UndoSetKeyFrame(pegbar->getId(), frame, m_xsheetHandle);
|
|
Toshihiro Shimizu |
890ddd |
pegbar->setKeyframeWithoutUndo(frame);
|
|
Toshihiro Shimizu |
890ddd |
undo->setObjectHandle(m_objectHandle);
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(undo);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_objectHandle->notifyObjectIdChanged(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ViewerKeyframeNavigator::goNext()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TStageObject *pegbar = getStageObject();
|
|
Toshihiro Shimizu |
890ddd |
if (!pegbar)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
int frame = getCurrentFrame();
|
|
Toshihiro Shimizu |
890ddd |
TStageObject::KeyframeMap keyframes;
|
|
Toshihiro Shimizu |
890ddd |
pegbar->getKeyframes(keyframes);
|
|
Toshihiro Shimizu |
890ddd |
TStageObject::KeyframeMap::iterator it;
|
|
Toshihiro Shimizu |
890ddd |
for (it = keyframes.begin(); it != keyframes.end(); ++it)
|
|
Toshihiro Shimizu |
890ddd |
if (it->first > frame) {
|
|
Toshihiro Shimizu |
890ddd |
setCurrentFrame(it->first);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ViewerKeyframeNavigator::goPrev()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TStageObject *pegbar = getStageObject();
|
|
Toshihiro Shimizu |
890ddd |
if (!pegbar)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
int frame = getCurrentFrame();
|
|
Toshihiro Shimizu |
890ddd |
TStageObject::KeyframeMap keyframes;
|
|
Toshihiro Shimizu |
890ddd |
pegbar->getKeyframes(keyframes);
|
|
Toshihiro Shimizu |
890ddd |
TStageObject::KeyframeMap::reverse_iterator it;
|
|
Toshihiro Shimizu |
890ddd |
for (it = keyframes.rbegin(); it != keyframes.rend(); ++it)
|
|
Toshihiro Shimizu |
890ddd |
if (it->first < frame) {
|
|
Toshihiro Shimizu |
890ddd |
setCurrentFrame(it->first);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ViewerKeyframeNavigator::showEvent(QShowEvent *e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_objectHandle)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
connect(m_objectHandle, SIGNAL(objectSwitched()), this, SLOT(update()));
|
|
Toshihiro Shimizu |
890ddd |
connect(m_objectHandle, SIGNAL(objectChanged(bool)), this, SLOT(update()));
|
|
Toshihiro Shimizu |
890ddd |
KeyframeNavigator::showEvent(e);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ViewerKeyframeNavigator::hideEvent(QHideEvent *e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_objectHandle)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
disconnect(m_objectHandle);
|
|
Toshihiro Shimizu |
890ddd |
KeyframeNavigator::hideEvent(e);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class UndoPaletteSetKeyFrame : public TUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int m_frame;
|
|
Toshihiro Shimizu |
890ddd |
int m_styleId;
|
|
Toshihiro Shimizu |
890ddd |
TPaletteHandle *m_paletteHandle;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
UndoPaletteSetKeyFrame(int styleId, int frame, TPaletteHandle *paletteHandle)
|
|
Toshihiro Shimizu |
890ddd |
: m_frame(frame), m_styleId(styleId), m_paletteHandle(paletteHandle)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void undo() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setKeyFrame();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void redo() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setKeyFrame();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int getSize() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return sizeof(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
void setKeyFrame() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = m_paletteHandle->getPalette();
|
|
Toshihiro Shimizu |
890ddd |
if (palette->isKeyframe(m_styleId, m_frame))
|
|
Toshihiro Shimizu |
890ddd |
palette->clearKeyframe(m_styleId, m_frame);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
palette->setKeyframe(m_styleId, m_frame);
|
|
Toshihiro Shimizu |
890ddd |
m_paletteHandle->notifyPaletteChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
} //namespace
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// PaletteKeyframeNavigator
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool PaletteKeyframeNavigator::hasNext() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = getPalette();
|
|
Toshihiro Shimizu |
890ddd |
if (!palette)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
int styleId = getStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
int frame = getCurrentFrame();
|
|
Toshihiro Shimizu |
890ddd |
int n = palette->getKeyframeCount(styleId);
|
|
Toshihiro Shimizu |
890ddd |
for (int i = n - 1; i >= 0; i--) {
|
|
Toshihiro Shimizu |
890ddd |
int f = palette->getKeyframe(styleId, i);
|
|
Toshihiro Shimizu |
890ddd |
if (f > frame)
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
else if (f <= frame)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool PaletteKeyframeNavigator::hasPrev() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = getPalette();
|
|
Toshihiro Shimizu |
890ddd |
if (!palette)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
int styleId = getStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
int frame = getCurrentFrame();
|
|
Toshihiro Shimizu |
890ddd |
int n = palette->getKeyframeCount(styleId);
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < n; i++) {
|
|
Toshihiro Shimizu |
890ddd |
int f = palette->getKeyframe(styleId, i);
|
|
Toshihiro Shimizu |
890ddd |
if (f < frame)
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
else if (f >= frame)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool PaletteKeyframeNavigator::hasKeyframes() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = getPalette();
|
|
Toshihiro Shimizu |
890ddd |
if (!palette)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
return palette->getKeyframeCount(getStyleIndex()) > 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool PaletteKeyframeNavigator::isKeyframe() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = getPalette();
|
|
Toshihiro Shimizu |
890ddd |
if (!palette)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
int frame = getCurrentFrame();
|
|
Toshihiro Shimizu |
890ddd |
return palette->isKeyframe(getStyleIndex(), frame);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaletteKeyframeNavigator::toggle()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = getPalette();
|
|
Toshihiro Shimizu |
890ddd |
if (!palette)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int styleId = getStyleIndex(),
|
|
Toshihiro Shimizu |
890ddd |
frame = getCurrentFrame();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::auto_ptr<undopalettesetkeyframe> undo(new UndoPaletteSetKeyFrame(styleId, frame, m_paletteHandle));</undopalettesetkeyframe>
|
|
Toshihiro Shimizu |
890ddd |
undo->redo();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TUndoManager::manager()->add(undo.release());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaletteKeyframeNavigator::goNext()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = getPalette();
|
|
Toshihiro Shimizu |
890ddd |
if (!palette)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
int styleId = getStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
int frame = getCurrentFrame();
|
|
Toshihiro Shimizu |
890ddd |
int n = palette->getKeyframeCount(styleId);
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < n; i++) {
|
|
Toshihiro Shimizu |
890ddd |
int f = palette->getKeyframe(styleId, i);
|
|
Toshihiro Shimizu |
890ddd |
if (f > frame) {
|
|
Toshihiro Shimizu |
890ddd |
setCurrentFrame(f);
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaletteKeyframeNavigator::goPrev()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPalette *palette = getPalette();
|
|
Toshihiro Shimizu |
890ddd |
if (!palette)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
int styleId = getStyleIndex();
|
|
Toshihiro Shimizu |
890ddd |
int frame = getCurrentFrame();
|
|
Toshihiro Shimizu |
890ddd |
int n = palette->getKeyframeCount(styleId);
|
|
Toshihiro Shimizu |
890ddd |
for (int i = n - 1; i >= 0; i--) {
|
|
Toshihiro Shimizu |
890ddd |
int f = palette->getKeyframe(styleId, i);
|
|
Toshihiro Shimizu |
890ddd |
if (f < frame) {
|
|
Toshihiro Shimizu |
890ddd |
setCurrentFrame(f);
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaletteKeyframeNavigator::showEvent(QShowEvent *e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_paletteHandle)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
connect(m_paletteHandle, SIGNAL(paletteSwitched()), this, SLOT(update()));
|
|
Toshihiro Shimizu |
890ddd |
connect(m_paletteHandle, SIGNAL(paletteChanged()), this, SLOT(update()));
|
|
Toshihiro Shimizu |
890ddd |
connect(m_paletteHandle, SIGNAL(colorStyleSwitched()), this, SLOT(update()));
|
|
Toshihiro Shimizu |
890ddd |
KeyframeNavigator::showEvent(e);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaletteKeyframeNavigator::hideEvent(QHideEvent *e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_paletteHandle)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
disconnect(m_paletteHandle);
|
|
Toshihiro Shimizu |
890ddd |
KeyframeNavigator::hideEvent(e);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!Se non c'e' un keyframe successivo ritorna frame
|
|
Toshihiro Shimizu |
890ddd |
int getNextKeyframe(TFxP fx, int frame)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!fx)
|
|
Toshihiro Shimizu |
890ddd |
return frame;
|
|
Toshihiro Shimizu |
890ddd |
int targetFrame = frame;
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < fx->getParams()->getParamCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TParamP param = fx->getParams()->getParam(i);
|
|
Toshihiro Shimizu |
890ddd |
int j = param->getNextKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
if (j < 0)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
int f = (int)param->keyframeIndexToFrame(j);
|
|
Toshihiro Shimizu |
890ddd |
if (targetFrame == frame || f < targetFrame)
|
|
Toshihiro Shimizu |
890ddd |
targetFrame = f;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return targetFrame;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!Se non c'e' un keyframe precedente ritorna frame
|
|
Toshihiro Shimizu |
890ddd |
int getPrevKeyframe(TFxP fx, int frame)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!fx)
|
|
Toshihiro Shimizu |
890ddd |
return frame;
|
|
Toshihiro Shimizu |
890ddd |
int targetFrame = frame;
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < fx->getParams()->getParamCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TParamP param = fx->getParams()->getParam(i);
|
|
Toshihiro Shimizu |
890ddd |
int j = param->getPrevKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
if (j < 0)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
int f = (int)param->keyframeIndexToFrame(j);
|
|
Toshihiro Shimizu |
890ddd |
if (targetFrame == frame || f > targetFrame)
|
|
Toshihiro Shimizu |
890ddd |
targetFrame = f;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return targetFrame;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setKeyframe(TFxP fx, int frame, bool on)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (fx)
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < fx->getParams()->getParamCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TParamP param = fx->getParams()->getParam(i);
|
|
Toshihiro Shimizu |
890ddd |
if (TDoubleParamP dp = param) {
|
|
Toshihiro Shimizu |
890ddd |
if (on)
|
|
Toshihiro Shimizu |
890ddd |
dp->setValue(frame, dp->getValue(frame));
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
dp->deleteKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
} //anonymous namespace
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// FxKeyframeNavigator
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool FxKeyframeNavigator::hasNext() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = getFx();
|
|
Toshihiro Shimizu |
890ddd |
if (!fx)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
return getNextKeyframe(fx, getCurrentFrame()) > getCurrentFrame();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool FxKeyframeNavigator::hasPrev() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = getFx();
|
|
Toshihiro Shimizu |
890ddd |
if (!fx)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
return getPrevKeyframe(fx, getCurrentFrame()) < getCurrentFrame();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool FxKeyframeNavigator::hasKeyframes() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = getFx();
|
|
Toshihiro Shimizu |
890ddd |
if (!fx)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < fx->getParams()->getParamCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TParamP param = fx->getParams()->getParam(i);
|
|
Toshihiro Shimizu |
890ddd |
if (param->hasKeyframes())
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool FxKeyframeNavigator::isKeyframe() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = getFx();
|
|
Toshihiro Shimizu |
890ddd |
if (!fx)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < fx->getParams()->getParamCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TParamP param = fx->getParams()->getParam(i);
|
|
Toshihiro Shimizu |
890ddd |
if (param->isKeyframe(getCurrentFrame()))
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool FxKeyframeNavigator::isFullKeyframe() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = getFx();
|
|
Toshihiro Shimizu |
890ddd |
if (!fx)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
int keyFrameCount = 0;
|
|
Toshihiro Shimizu |
890ddd |
int animatableParamCount = 0;
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < fx->getParams()->getParamCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TParamP param = fx->getParams()->getParam(i);
|
|
Toshihiro Shimizu |
890ddd |
if (param->isAnimatable()) {
|
|
Toshihiro Shimizu |
890ddd |
animatableParamCount++;
|
|
Toshihiro Shimizu |
890ddd |
if (param->isKeyframe(getCurrentFrame()))
|
|
Toshihiro Shimizu |
890ddd |
keyFrameCount++;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return animatableParamCount > 0 && keyFrameCount == animatableParamCount;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxKeyframeNavigator::toggle()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = getFx();
|
|
Toshihiro Shimizu |
890ddd |
if (!fx)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
int i, paramCount = fx->getParams()->getParamCount();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// determino in quale caso ci troviamo:
|
|
Toshihiro Shimizu |
890ddd |
// il frame corrente non e' keyframe di nessun parametro (isKeyframe=false),
|
|
Toshihiro Shimizu |
890ddd |
// di qualche parametro o di tutti i parametri (isFullKeyframe=true)
|
|
Toshihiro Shimizu |
890ddd |
bool isFullKeyframe = true;
|
|
Toshihiro Shimizu |
890ddd |
bool isKeyframe = false;
|
|
Toshihiro Shimizu |
890ddd |
int frame = getCurrentFrame();
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < paramCount; i++) {
|
|
Toshihiro Shimizu |
890ddd |
TParamP param = fx->getParams()->getParam(i);
|
|
Toshihiro Shimizu |
890ddd |
if (!param->isAnimatable())
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
if (param->isKeyframe(frame))
|
|
Toshihiro Shimizu |
890ddd |
isKeyframe = true;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
isFullKeyframe = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (!isKeyframe)
|
|
Toshihiro Shimizu |
890ddd |
isFullKeyframe = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// modifico lo stato: nokeyframe->full, full->no, partial->full
|
|
Toshihiro Shimizu |
890ddd |
bool on = !isKeyframe || isKeyframe && !isFullKeyframe;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < fx->getParams()->getParamCount(); i++) { // TODO. spostare questo codice in TParam
|
|
Toshihiro Shimizu |
890ddd |
TParamP param = fx->getParams()->getParam(i);
|
|
Toshihiro Shimizu |
890ddd |
if (TDoubleParamP dp = param) {
|
|
Toshihiro Shimizu |
890ddd |
if (on)
|
|
Toshihiro Shimizu |
890ddd |
dp->setValue(frame, dp->getValue(frame));
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
dp->deleteKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
} else if (TRangeParamP rp = param) {
|
|
Toshihiro Shimizu |
890ddd |
if (on)
|
|
Toshihiro Shimizu |
890ddd |
rp->setValue(frame, rp->getValue(frame));
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
rp->deleteKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
} else if (TPointParamP pp = param) {
|
|
Toshihiro Shimizu |
890ddd |
if (on)
|
|
Toshihiro Shimizu |
890ddd |
pp->setValue(frame, pp->getValue(frame));
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
pp->deleteKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
} else if (TPixelParamP pip = param) {
|
|
Toshihiro Shimizu |
890ddd |
if (on)
|
|
Toshihiro Shimizu |
890ddd |
pip->setValue(frame, pip->getValue(frame));
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
pip->deleteKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
} else if (TSpectrumParamP sp = param) {
|
|
Toshihiro Shimizu |
890ddd |
if (on)
|
|
Toshihiro Shimizu |
890ddd |
sp->setValue(frame, sp->getValue(frame), false);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
sp->deleteKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
} else if (TToneCurveParamP tcp = param) {
|
|
Toshihiro Shimizu |
890ddd |
if (on)
|
|
Toshihiro Shimizu |
890ddd |
tcp->setValue(frame, tcp->getValue(frame), false);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
tcp->deleteKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_fxHandle->notifyFxChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxKeyframeNavigator::goNext()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = getFx();
|
|
Toshihiro Shimizu |
890ddd |
if (!fx)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
int frame = getNextKeyframe(fx, getCurrentFrame());
|
|
Toshihiro Shimizu |
890ddd |
if (frame > getCurrentFrame()) {
|
|
Toshihiro Shimizu |
890ddd |
setCurrentFrame(frame);
|
|
Toshihiro Shimizu |
890ddd |
// m_fxHandle->notifyFxChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxKeyframeNavigator::goPrev()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = getFx();
|
|
Toshihiro Shimizu |
890ddd |
if (!fx)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
int frame = getPrevKeyframe(fx, getCurrentFrame());
|
|
Toshihiro Shimizu |
890ddd |
if (frame < getCurrentFrame()) {
|
|
Toshihiro Shimizu |
890ddd |
setCurrentFrame(frame);
|
|
Toshihiro Shimizu |
890ddd |
// m_fxHandle->notifyFxChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxKeyframeNavigator::showEvent(QShowEvent *e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_fxHandle)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
connect(m_fxHandle, SIGNAL(fxSwitched()), this, SLOT(update()));
|
|
Toshihiro Shimizu |
890ddd |
connect(m_fxHandle, SIGNAL(fxChanged()), this, SLOT(update()));
|
|
Toshihiro Shimizu |
890ddd |
KeyframeNavigator::showEvent(e);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FxKeyframeNavigator::hideEvent(QHideEvent *e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_fxHandle)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
disconnect(m_fxHandle);
|
|
Toshihiro Shimizu |
890ddd |
KeyframeNavigator::hideEvent(e);
|
|
Toshihiro Shimizu |
890ddd |
}
|