]> git.sesse.net Git - kdenlive/commitdiff
Try to correctly fix issue resize start issue:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 6 May 2010 09:48:39 +0000 (09:48 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 6 May 2010 09:48:39 +0000 (09:48 +0000)
http://kdenlive.org/mantis/view.php?id=1575

svn path=/trunk/kdenlive/; revision=4413

src/abstractclipitem.cpp
src/abstractclipitem.h
src/clipitem.cpp
src/clipitem.h
src/renderer.cpp

index a0f860f0351bc5ba0b6367000b50aac44c3a5ece..5cfcc36fb34aea469fc05560a0fff62ad9d6e18d 100644 (file)
@@ -124,14 +124,15 @@ void AbstractClipItem::updateRectGeometry()
     setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
 }
 
-void AbstractClipItem::resizeStart(int posx)
+void AbstractClipItem::resizeStart(int posx, bool hasSizeLimit)
 {
     GenTime durationDiff = GenTime(posx, m_fps) - m_info.startPos;
     if (durationDiff == GenTime()) return;
     //kDebug() << "-- RESCALE DIFF=" << durationDiff.frames(25) << ", CLIP: " << startPos().frames(25) << "-" << endPos().frames(25);
 
-    if (type() == AVWIDGET && cropStart() + durationDiff < GenTime()) {
-        durationDiff = GenTime() - cropStart();
+    if (type() == AVWIDGET) {
+       if (hasSizeLimit && cropStart() + durationDiff < GenTime())
+           durationDiff = GenTime() - cropStart();
     } else if (durationDiff >= cropDuration()) {
         return;
         if (cropDuration() > GenTime(3, m_fps)) durationDiff = GenTime(3, m_fps);
index 38efede3af277f09cb5b36449bf1eb210b41d1df..dde3adfddefd840329edc82fa6444d2129578e9a 100644 (file)
@@ -69,7 +69,7 @@ public:
     virtual int track() const ;
     virtual GenTime cropStart() const ;
     virtual GenTime cropDuration() const ;
-    virtual void resizeStart(int posx);
+    virtual void resizeStart(int posx, bool hasSizeLimit = true);
     virtual void resizeEnd(int posx);
     virtual double fps() const;
     virtual void updateFps(double fps);
index 463ffed5c91f964f692c9120ae3f88b3cb4250df..39df20878d6c91fe8abe2427999786cd678dcc1e 100644 (file)
@@ -653,6 +653,16 @@ QDomElement ClipItem::xml() const
     return xml;
 }
 
+QDomElement ClipItem::itemXml() const
+{
+    QDomElement xml = m_clip->toXML();
+    if (m_speed != 1.0) xml.setAttribute("speed", m_speed);
+    if (m_strobe > 1) xml.setAttribute("strobe", m_strobe);
+    if (m_audioOnly) xml.setAttribute("audio_only", 1);
+    else if (m_videoOnly) xml.setAttribute("video_only", 1);
+    return xml;
+}
+
 int ClipItem::clipType() const
 {
     return m_clipType;
@@ -1140,23 +1150,18 @@ void ClipItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
 }
 */
 
-void ClipItem::resizeStart(int posx)
+void ClipItem::resizeStart(int posx, bool)
 {
-    const int min = (startPos() - cropStart()).frames(m_fps);
-    if (posx < min) {
-        if (clipType() == IMAGE || clipType() == COLOR || clipType() == TEXT) {
-            GenTime oldPos = startPos();
-            moveBy(-1 * (oldPos - GenTime(posx, m_fps)).frames(m_fps), 0);
-            const int newPos = (endPos() + (oldPos - startPos())).frames(m_fps);
-            AbstractClipItem::resizeEnd(newPos);
-        }
-        posx = min;
+    bool sizeLimit = false;
+    if (clipType() != IMAGE && clipType() != COLOR && clipType() != TEXT) {
+       const int min = (startPos() - cropStart()).frames(m_fps);
+       if (posx < min) posx = min;
+       sizeLimit = true;
     }
-    
-    
+
     if (posx == startPos().frames(m_fps)) return;
     const int previous = cropStart().frames(m_fps);
-    AbstractClipItem::resizeStart(posx);
+    AbstractClipItem::resizeStart(posx, sizeLimit);
 
     // set speed independant info
     m_speedIndependantInfo = m_info;
index 8b1c3f06392157f0367b26d3332f6f5a40b6afb1..a4a19c1799673b09efcd60022d9663857081a6b6 100644 (file)
@@ -47,7 +47,7 @@ public:
                        const QStyleOptionGraphicsItem *option,
                        QWidget *);
     virtual int type() const;
-    void resizeStart(int posx);
+    void resizeStart(int posx, bool size = true);
     void resizeEnd(int posx);
     OPERATIONTYPE operationMode(QPointF pos);
     const QString clipProducer() const;
@@ -56,6 +56,7 @@ public:
     QString clipName() const;
     void setClipName(const QString &name);
     QDomElement xml() const;
+    QDomElement itemXml() const;
     ClipItem *clone(ItemInfo info) const;
     const EffectsList effectList() const;
     void setFadeOut(int pos);
@@ -145,6 +146,7 @@ private:
 
     QPixmap m_startPix;
     QPixmap m_endPix;
+    
     bool m_hasThumbs;
     QTimer m_startThumbTimer;
     QTimer m_endThumbTimer;
index ad5793da9478d645a083bb564cab4fab14023494..247e91337857755812bb2dc5baec34861522c5a4 100644 (file)
@@ -2750,17 +2750,15 @@ bool Render::mltResizeClipStart(ItemInfo info, GenTime diff)
     }
     mlt_service_lock(service.get_service());
     int clipIndex = trackPlaylist.get_clip_index_at(info.startPos.frames(m_fps));
-    Mlt::Producer *clip = trackPlaylist.get_clip(clipIndex);
-    if (clip == NULL) {
+    if (trackPlaylist.is_blank(clipIndex)) {
         kDebug() << "////////  ERROR RSIZING NULL CLIP!!!!!!!!!!!";
         mlt_service_unlock(service.get_service());
         return false;
     }
-    int previousStart = clip->get_in();
-    delete clip;
+    int previousStart = trackPlaylist.clip_start(clipIndex);
     int previousDuration = trackPlaylist.clip_length(clipIndex) - 1;
     m_isBlocked = true;
-    kDebug() << "RESIZE, old start: " << previousStart << ", PREV DUR: " << previousDuration << ", DIFF: " << moveFrame;
+    kDebug() << "RESIZE, old start: " << previousStart + moveFrame<<", "<<previousStart + previousDuration;
     trackPlaylist.resize_clip(clipIndex, previousStart + moveFrame, previousStart + previousDuration);
     if (moveFrame > 0) trackPlaylist.insert_blank(clipIndex, moveFrame - 1);
     else {