m_selectedKeyframe(0),
m_keyframeFactor(1),
m_fps(fps)
+#if QT_VERSION >= 0x040600
+ , m_closeAnimation(NULL)
+#endif
{
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
#if QT_VERSION >= 0x040600
#endif
}
+AbstractClipItem::~AbstractClipItem()
+{
+#if QT_VERSION >= 0x040600
+ if (m_closeAnimation) delete m_closeAnimation;
+#endif
+}
+
+void AbstractClipItem::closeAnimation()
+{
+#if QT_VERSION >= 0x040600
+ if (m_closeAnimation) return;
+ setEnabled(false);
+ m_closeAnimation = new QPropertyAnimation(this, "rect");
+ connect(m_closeAnimation, SIGNAL(finished()), this, SLOT(deleteLater()));
+ m_closeAnimation->setDuration(200);
+ QRectF r = rect();
+ QRectF r2 = r;
+ r2.setLeft(r.left() + r.width() / 2);
+ r2.setTop(r.top() + r.height() / 2);
+ r2.setWidth(1);
+ r2.setHeight(1);
+ m_closeAnimation->setStartValue(r);
+ m_closeAnimation->setEndValue(r2);
+ m_closeAnimation->setEasingCurve(QEasingCurve::InQuad);
+ m_closeAnimation->start();
+#endif
+}
+
ItemInfo AbstractClipItem::info() const
{
ItemInfo info = m_info;
return info;
}
+int AbstractClipItem::defaultZValue() const
+{
+ return 2;
+}
+
GenTime AbstractClipItem::endPos() const
{
return m_info.startPos + m_info.cropDuration;
if (type() == AVWIDGET) {
m_info.cropStart += durationDiff;
}
+
m_info.cropDuration = m_info.cropDuration - durationDiff;
setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
moveBy(durationDiff.frames(m_fps), 0);
- //setPos(m_startPos.frames(m_fps), pos().y());
- if ((int) scenePos().x() != posx) {
+
+ if (m_info.startPos != GenTime(posx, m_fps)) {
//kDebug()<<"////// WARNING, DIFF IN XPOS: "<<pos().x()<<" == "<<m_startPos.frames(m_fps);
- GenTime diff = GenTime((int) pos().x() - posx, m_fps);
+ GenTime diff = m_info.startPos - GenTime((int) posx, m_fps);
if (type() == AVWIDGET) {
m_info.cropStart += diff;
if (durationDiff > GenTime()) {
QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect);
for (int i = 0; i < collisionList.size(); ++i) {
+ if (!collisionList.at(i)->isEnabled()) continue;
QGraphicsItem *item = collisionList.at(i);
if (item->type() == type() && item->pos().x() > pos().x()) {
- /*kDebug() << "///////// COLLISION DETECTED!!!!!!!!!";
+ kDebug() << "///////// COLLISION DETECTED!!!!!!!!!";
kDebug() << "///////// CURRENT: " << startPos().frames(25) << "x" << endPos().frames(25) << ", RECT: " << rect() << "-" << pos();
- kDebug() << "///////// COLLISION: " << ((AbstractClipItem *)item)->startPos().frames(25) << "x" << ((AbstractClipItem *)item)->endPos().frames(25) << ", RECT: " << ((AbstractClipItem *)item)->rect() << "-" << item->pos();*/
- GenTime diff = ((AbstractClipItem *)item)->startPos() - GenTime(1, m_fps) - startPos();
+ kDebug() << "///////// COLLISION: " << ((AbstractClipItem *)item)->startPos().frames(25) << "x" << ((AbstractClipItem *)item)->endPos().frames(25) << ", RECT: " << ((AbstractClipItem *)item)->rect() << "-" << item->pos();
+ GenTime diff = ((AbstractClipItem *)item)->startPos() - startPos();
m_info.cropDuration = diff;
setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
break;
void AbstractClipItem::drawKeyFrames(QPainter *painter, QRectF /*exposedRect*/)
{
- if (m_keyframes.count() < 2) return;
+ if (m_keyframes.count() < 1) return;
QRectF br = rect();
double maxw = br.width() / cropDuration().frames(m_fps);
double maxh = br.height() / 100.0 * m_keyframeFactor;
y1 = br.bottom() - i.value() * maxh;
QLineF l2;
while (i != m_keyframes.constEnd()) {
- if (i.key() == m_selectedKeyframe) color = QColor(Qt::red);
+ if (i.key() == m_editedKeyframe) color = QColor(Qt::red);
else color = QColor(Qt::blue);
++i;
- if (i == m_keyframes.constEnd()) break;
- x2 = br.x() + maxw * (i.key() - cropStart().frames(m_fps));
- y2 = br.bottom() - i.value() * maxh;
+ if (i == m_keyframes.constEnd() && m_keyframes.count() != 1) {
+ break;
+ }
+ if (m_keyframes.count() == 1) {
+ x2 = br.right();
+ y2 = y1;
+ } else {
+ x2 = br.x() + maxw * (i.key() - cropStart().frames(m_fps));
+ y2 = br.bottom() - i.value() * maxh;
+ }
QLineF l(x1, y1, x2, y2);
l2 = painter->matrix().map(l);
painter->drawLine(l2);
const QRectF br = sceneBoundingRect();
double maxw = br.width() / cropDuration().frames(m_fps);
double maxh = br.height() / 100.0 * m_keyframeFactor;
- if (m_keyframes.count() > 1) {
+ if (m_keyframes.count() > 0) {
QMap<int, int>::const_iterator i = m_keyframes.constBegin();
double x1;
double y1;
update(br.x() + maxw *(m_selectedKeyframe - cropStart().frames(m_fps)) - 3, br.bottom() - m_keyframes[m_selectedKeyframe] * maxh - 3, 12, 12);
}
-int AbstractClipItem::selectedKeyFramePos() const
+int AbstractClipItem::editedKeyFramePos() const
{
return m_editedKeyframe;
}
+double AbstractClipItem::editedKeyFrameValue() const
+{
+ return m_keyframes.value(m_editedKeyframe);
+}
+
+int AbstractClipItem::selectedKeyFramePos() const
+{
+ return m_selectedKeyframe;
+}
+
double AbstractClipItem::selectedKeyFrameValue() const
{
- return m_keyframes[m_editedKeyframe];
+ return m_keyframes.value(m_selectedKeyframe);
}
void AbstractClipItem::updateKeyFramePos(const GenTime pos, const double value)
{
- if (!m_keyframes.contains(m_selectedKeyframe)) return;
+ if (!m_keyframes.contains(m_editedKeyframe)) return;
int newpos = (int) pos.frames(m_fps);
int start = cropStart().frames(m_fps);
int end = (cropStart() + cropDuration()).frames(m_fps) - 1;
newpos = qMax(newpos, start);
newpos = qMin(newpos, end);
- if (value < -50 && m_selectedKeyframe != start && m_selectedKeyframe != end) {
- // remove kexframe if it is dragged outside
- m_keyframes.remove(m_selectedKeyframe);
- m_selectedKeyframe = -1;
- update();
- return;
- }
- if (value > 150 && m_selectedKeyframe != start && m_selectedKeyframe != end) {
- // remove kexframe if it is dragged outside
- m_keyframes.remove(m_selectedKeyframe);
- m_selectedKeyframe = -1;
- update();
- return;
- }
+
double newval = qMax(value, 0.0);
newval = qMin(newval, 100.0);
newval = newval / m_keyframeFactor;
- if (m_selectedKeyframe != newpos) m_keyframes.remove(m_selectedKeyframe);
+ if (m_editedKeyframe != newpos) m_keyframes.remove(m_editedKeyframe);
m_keyframes[newpos] = (int) newval;
- m_selectedKeyframe = newpos;
+ m_editedKeyframe = newpos;
update();
}
return m_keyframeFactor;
}
-void AbstractClipItem::addKeyFrame(const GenTime pos, const double value)
+int AbstractClipItem::addKeyFrame(const GenTime pos, const double value)
{
QRectF br = sceneBoundingRect();
double maxh = 100.0 / br.height() / m_keyframeFactor;
m_keyframes[newpos] = newval;
m_selectedKeyframe = newpos;
update();
+ return newval;
}
bool AbstractClipItem::hasKeyFrames() const