- while (roundingX > br.width() / 2) {
- roundingX = roundingX / 2;
- roundingY = roundingY / 2;
- }
- int br_endx = (int)(br.x() + br .width() - offset);
- int br_startx = (int)(br.x() + offset);
- int br_starty = (int)(br.y());
- int br_halfy = (int)(br.y() + br.height() / 2 - offset);
- int br_endy = (int)(br.y() + br.height());
-
- roundRectPathUpper.moveTo(br_endx , br_halfy);
- roundRectPathUpper.arcTo(br_endx - roundingX , br_starty , roundingX, roundingY, 0.0, 90.0);
- roundRectPathUpper.lineTo(br_startx + roundingX , br_starty);
- roundRectPathUpper.arcTo(br_startx , br_starty , roundingX, roundingY, 90.0, 90.0);
- roundRectPathUpper.lineTo(br_startx , br_halfy);
-
- return roundRectPathUpper;
-}
-
-QPainterPath AbstractClipItem::lowerRectPart(QRectF br) {
- QPainterPath roundRectPathLower;
- double roundingY = 20;
- double roundingX = 20;
- double offset = 1;
-
- int br_endx = (int)(br.x() + br .width() - offset);
- int br_startx = (int)(br.x() + offset);
- int br_starty = (int)(br.y());
- int br_halfy = (int)(br.y() + br.height() / 2 - offset);
- int br_endy = (int)(br.y() + br.height() - 1);
-
- while (roundingX > br.width() / 2) {
- roundingX = roundingX / 2;
- roundingY = roundingY / 2;
- }
- roundRectPathLower.moveTo(br_startx, br_halfy);
- roundRectPathLower.arcTo(br_startx , br_endy - roundingY , roundingX, roundingY, 180.0, 90.0);
- roundRectPathLower.lineTo(br_endx - roundingX , br_endy);
- roundRectPathLower.arcTo(br_endx - roundingX , br_endy - roundingY, roundingX, roundingY, 270.0, 90.0);
- roundRectPathLower.lineTo(br_endx , br_halfy);
- return roundRectPathLower;
+void AbstractClipItem::updateKeyFramePos(const GenTime pos, const double value)
+{
+ 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);
+
+ double newval = qMax(value, 0.0);
+ newval = qMin(newval, 100.0);
+ newval = newval / m_keyframeFactor;
+ if (m_editedKeyframe != newpos) m_keyframes.remove(m_editedKeyframe);
+ m_keyframes[newpos] = (int) newval;
+ m_editedKeyframe = newpos;
+ update();
+}
+
+double AbstractClipItem::keyFrameFactor() const
+{
+ return m_keyframeFactor;
+}
+
+int AbstractClipItem::addKeyFrame(const GenTime pos, const double value)
+{
+ QRectF br = sceneBoundingRect();
+ double maxh = 100.0 / br.height() / m_keyframeFactor;
+ int newval = (br.bottom() - value) * maxh;
+ //kDebug() << "Rect: " << br << "/ SCENE: " << sceneBoundingRect() << ", VALUE: " << value << ", MAX: " << maxh << ", NEWVAL: " << newval;
+ int newpos = (int) pos.frames(m_fps) ;
+ m_keyframes[newpos] = newval;
+ m_selectedKeyframe = newpos;
+ update();
+ return newval;
+}
+
+bool AbstractClipItem::hasKeyFrames() const
+{
+ return !m_keyframes.isEmpty();