|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/functionkeyframenavigator.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzQt includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/framenavigator.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tframehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/doubleparamcmd.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzBase includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tdoubleparam.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qpushbutton></qpushbutton>
|
|
Toshihiro Shimizu |
890ddd |
#include <qboxlayout></qboxlayout>
|
|
Toshihiro Shimizu |
890ddd |
#include <qtoolbutton></qtoolbutton>
|
|
Toshihiro Shimizu |
890ddd |
#include <qlabel></qlabel>
|
|
Toshihiro Shimizu |
890ddd |
#include <qaction></qaction>
|
|
Toshihiro Shimizu |
890ddd |
#include <qintvalidator></qintvalidator>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FunctionKeyframeNavigator::FunctionKeyframeNavigator(QWidget *parent)
|
|
Shinya Kitaoka |
120a6e |
: KeyframeNavigator(parent) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FunctionKeyframeNavigator::setCurve(TDoubleParam *curve) {
|
|
Shinya Kitaoka |
120a6e |
if (m_curve.getPointer() == curve) return;
|
|
Shinya Kitaoka |
120a6e |
m_curve = curve;
|
|
Shinya Kitaoka |
120a6e |
if (isVisible()) update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool FunctionKeyframeNavigator::hasNext() const {
|
|
Shinya Kitaoka |
120a6e |
return m_curve && m_curve->getNextKeyframe(getCurrentFrame()) >= 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool FunctionKeyframeNavigator::hasPrev() const {
|
|
Shinya Kitaoka |
120a6e |
return m_curve && m_curve->getPrevKeyframe(getCurrentFrame()) >= 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool FunctionKeyframeNavigator::hasKeyframes() const {
|
|
Shinya Kitaoka |
120a6e |
return m_curve && m_curve->hasKeyframes();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool FunctionKeyframeNavigator::isKeyframe() const {
|
|
Shinya Kitaoka |
120a6e |
return m_curve && m_curve->isKeyframe(getCurrentFrame());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FunctionKeyframeNavigator::toggle() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_curve) return;
|
|
Shinya Kitaoka |
120a6e |
int frame = getCurrentFrame();
|
|
Shinya Kitaoka |
120a6e |
double value = m_curve->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
if (m_curve->isKeyframe(frame))
|
|
Shinya Kitaoka |
120a6e |
KeyframeSetter::removeKeyframeAt(m_curve.getPointer(), frame);
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
KeyframeSetter setter(m_curve.getPointer());
|
|
Shinya Kitaoka |
120a6e |
setter.createKeyframe(frame);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FunctionKeyframeNavigator::goNext() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_curve) return;
|
|
Shinya Kitaoka |
120a6e |
int k = m_curve->getNextKeyframe(getCurrentFrame());
|
|
Shinya Kitaoka |
120a6e |
if (k < 0) return;
|
|
Shinya Kitaoka |
120a6e |
setCurrentFrame(m_curve->keyframeIndexToFrame(k));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FunctionKeyframeNavigator::goPrev() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_curve) return;
|
|
Shinya Kitaoka |
120a6e |
int k = m_curve->getPrevKeyframe(getCurrentFrame());
|
|
Shinya Kitaoka |
120a6e |
if (k < 0) return;
|
|
Shinya Kitaoka |
120a6e |
setCurrentFrame(m_curve->keyframeIndexToFrame(k));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FunctionKeyframeNavigator::showEvent(QShowEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
KeyframeNavigator::showEvent(e);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void FunctionKeyframeNavigator::hideEvent(QHideEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
KeyframeNavigator::hideEvent(e);
|
|
Toshihiro Shimizu |
890ddd |
}
|