]> git.sesse.net Git - kdenlive/commitdiff
- Fix resize start allowing to go further than duration = 0 (inverted the clip)
authorTill Theato <root@ttill.de>
Sat, 12 Jun 2010 17:40:50 +0000 (17:40 +0000)
committerTill Theato <root@ttill.de>
Sat, 12 Jun 2010 17:40:50 +0000 (17:40 +0000)
- cleanup

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

src/abstractclipitem.cpp
src/abstractclipitem.h
src/clipitem.cpp
src/gentime.cpp
src/gentime.h

index 2583962247bbd59c935ec56dbffbfbf019e26442..cf9c60c328043f70642463c8d3553094fe5122a8 100644 (file)
@@ -131,8 +131,7 @@ void AbstractClipItem::resizeStart(int posx, bool hasSizeLimit)
     if (durationDiff == GenTime()) return;
     //kDebug() << "-- RESCALE DIFF=" << durationDiff.frames(25) << ", CLIP: " << startPos().frames(25) << "-" << endPos().frames(25);
 
-    if (type() == AVWIDGET) {
-        if (hasSizeLimit && cropStart() + durationDiff < GenTime())
+    if (type() == AVWIDGET && hasSizeLimit && cropStart() + durationDiff < GenTime()) {
             durationDiff = GenTime() - cropStart();
     } else if (durationDiff >= cropDuration()) {
         return;
@@ -142,22 +141,21 @@ void AbstractClipItem::resizeStart(int posx, bool hasSizeLimit)
     //kDebug()<<"// DURATION DIFF: "<<durationDiff.frames(25)<<", POS: "<<pos().x();
     m_info.startPos += durationDiff;
 
-    if (type() == AVWIDGET) {
+    if (type() == AVWIDGET)
         m_info.cropStart += durationDiff;
-    }
 
-    m_info.cropDuration = m_info.cropDuration - durationDiff;
+    m_info.cropDuration -= durationDiff;
     setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
     moveBy(durationDiff.frames(m_fps), 0);
 
     if (m_info.startPos != GenTime(posx, m_fps)) {
         //kDebug()<<"//////  WARNING, DIFF IN XPOS: "<<pos().x()<<" == "<<m_startPos.frames(m_fps);
-        GenTime diff = m_info.startPos - GenTime((int) posx, m_fps);
+        GenTime diff = m_info.startPos - GenTime(posx, m_fps);
 
-        if (type() == AVWIDGET) {
+        if (type() == AVWIDGET)
             m_info.cropStart += diff;
-        }
-        m_info.cropDuration = m_info.cropDuration - diff;
+
+        m_info.cropDuration -= diff;
         setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
         //kDebug()<<"// NEW START: "<<m_startPos.frames(25)<<", NW DUR: "<<m_cropDuration.frames(25);
     }
index dde3adfddefd840329edc82fa6444d2129578e9a..f36c71f59aa8c0f4cd04b778e8310d0fc6620224 100644 (file)
@@ -69,7 +69,14 @@ public:
     virtual int track() const ;
     virtual GenTime cropStart() const ;
     virtual GenTime cropDuration() const ;
+
+    /** @brief Resizes the clip from the start.
+    * @param posx Absolute position of new in point
+    * @param hasSizeLimit (optional) Whether the clip has a maximum size */
     virtual void resizeStart(int posx, bool hasSizeLimit = true);
+
+    /** @brief Resizes the clip from the end.
+    * @param posx Absolute position of new out point */
     virtual void resizeEnd(int posx);
     virtual double fps() const;
     virtual void updateFps(double fps);
index ea08aa4bda937229eddee9bd6efd59087fcb2429..9fe3bf4fb182ed9e52a0cffb8121c906d85d2f34 100644 (file)
@@ -1151,7 +1151,7 @@ void ClipItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
 }
 */
 
-void ClipItem::resizeStart(int posx, bool)
+void ClipItem::resizeStart(int posx, bool /*size*/)
 {
     bool sizeLimit = false;
     if (clipType() != IMAGE && clipType() != COLOR && clipType() != TEXT) {
index 760d988885f0dc74b0b95e574fbfadbe861f3aef..d5ebab383d4429b5f6b8348c3c38b55ab71562b6 100644 (file)
 
 double GenTime::s_delta = 0.00001;
 
-/** Creates a time object, with a time of 0 seconds. */
 GenTime::GenTime()
 {
     m_time = 0.0;
 }
 
-/** Creates a time object, with time given in seconds. */
 GenTime::GenTime(double seconds)
 {
     m_time = seconds;
 }
 
-/** Creates a time object, by passing number of frames and how many frames per second */
 GenTime::GenTime(int frames, double framesPerSecond)
 {
     m_time = (double) frames / framesPerSecond;
 }
 
-/** Returns the time, in milliseconds */
+double GenTime::seconds() const
+{
+    return m_time;
+}
+
 double GenTime::ms() const
 {
     return m_time * 1000;
 }
 
-/** Returns the time in frames, after being given the number of frames per second */
 double GenTime::frames(double framesPerSecond) const
 {
     return floor(m_time * framesPerSecond + 0.5);
 }
 
-GenTime::~GenTime()
+GenTime& GenTime::roundNearestFrame(double framesPerSecond)
 {
-}
+    m_time = floor((m_time * framesPerSecond) + 0.5) / framesPerSecond;
+    return *this;
+}
\ No newline at end of file
index 6a4354b411115e463f2655be0ac5edd437abcc29..34f7bc59a2fc158bea78ab68a9303a2481928648 100644 (file)
 
 #include <cmath>
 
-/**Encapsulates a time, which can be set in various forms and outputted in various forms.
-  *@author Jason Wood
-  */
+/**
+ * @class GenTime
+ * @brief Encapsulates a time, which can be set in various forms and outputted in various forms.
+ * @author Jason Wood
+ */
 
 class GenTime
 {
 public:
-    /** Creates a time object, with a time of 0 seconds. */
+    /** @brief Creates a GenTime object, with a time of 0 seconds. */
     GenTime();
 
-    /** Creates a time object, with time given in seconds. */
+    /** @brief Creates a GenTime object, with time given in seconds. */
     explicit GenTime(double seconds);
 
-    /** Creates a time object, by passing number of frames and how many frames per second */
+    /** @brief Creates a GenTime object, by passing number of frames and how many frames per second. */
     GenTime(int frames, double framesPerSecond);
 
-    /** returns the time, in seconds */
-    double seconds() const {
-        return m_time;
-    }
-    /** Returns the time, in milliseconds */ double ms() const;
+    /** @brief Gets the time, in seconds. */
+    double seconds() const;
+
+    /** @brief Gets the time, in milliseconds */
+    double ms() const;
 
-    /** Returns the time in frames, after being given the number of frames per second */
+    /** @brief Gets the time in frames.
+    * @param framesPerSecond Number of frames per second */
     double frames(double framesPerSecond) const;
 
+    /** @brief Rounds the GenTime's value to the nearest frame.
+    * @param framesPerSecond Number of frames per second */
+    GenTime & roundNearestFrame(double framesPerSecond);
+
+
+    /*
+     * Operators.
+     */
+    
     GenTime & operator+=(GenTime op) {
         m_time += op.m_time;
         return *this;
     }
-    /** Adds two GenTimes */ GenTime operator+(GenTime op) const {
+
+    GenTime & operator-=(GenTime op) {
+        m_time -= op.m_time;
+        return *this;
+    }
+
+    /** @brief Adds two GenTimes. */
+    GenTime operator+(GenTime op) const {
         return GenTime(m_time + op.m_time);
     }
-    /** Subtracts one genTime from another */ GenTime operator-(GenTime op) const {
+
+    /** @brief Subtracts one genTime from another. */
+    GenTime operator-(GenTime op) const {
         return GenTime(m_time - op.m_time);
     }
-    /** Multiplies one GenTime by a double value, returning a GenTime */
+
+    /** @brief Multiplies one GenTime by a double value, returning a GenTime. */
     GenTime operator*(double op) const {
         return GenTime(m_time * op);
     }
-    /** Divides one GenTime by a double value, returning a GenTime */
+
+    /** @brief Divides one GenTime by a double value, returning a GenTime. */
     GenTime operator/(double op) const {
         return GenTime(m_time / op);
     }
-    /* Implementation of < operator; Works identically as with basic types. */
+
     bool operator<(GenTime op) const {
         return m_time + s_delta < op.m_time;
     }
-    /* Implementation of > operator; Works identically as with basic types. */
+
     bool operator>(GenTime op) const {
         return m_time > op.m_time + s_delta;
     }
-    /* Implementation of >= operator; Works identically as with basic types. */
+
     bool operator>=(GenTime op) const {
         return m_time + s_delta >= op.m_time;
     }
-    /* Implementation of <= operator; Works identically as with basic types. */
+
     bool operator<=(GenTime op) const {
         return m_time <= op.m_time + s_delta;
     }
-    /* Implementation of == operator; Works identically as with basic types. */
+
     bool operator==(GenTime op) const {
         return fabs(m_time - op.m_time) < s_delta;
     }
-    /* Implementation of != operator; Works identically as with basic types. */
+
     bool operator!=(GenTime op) const {
         return fabs(m_time - op.m_time) >= s_delta;
     }
-    /* Rounds the GenTIme's value to the nearest frame */
-    GenTime & roundNearestFrame(double framesPerSecond) {
-        m_time = floor((m_time * framesPerSecond) + 0.5) / framesPerSecond;
-        return *this;
-    }
 
-    ~GenTime();
-private:   // Private attributes
+private:
     /** Holds the time for this object. */
     double m_time;